@pie-lib/graphing-solution-set 4.1.0-beta.7 → 5.0.0-next.35

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 (332) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +20 -0
  2. package/dist/autosize-input.d.ts +10 -0
  3. package/dist/autosize-input.js +66 -0
  4. package/dist/axis/arrow.d.ts +13 -0
  5. package/dist/axis/arrow.js +34 -0
  6. package/dist/axis/axes.d.ts +132 -0
  7. package/dist/axis/axes.js +214 -0
  8. package/dist/axis/index.d.ts +10 -0
  9. package/dist/bg.d.ts +51 -0
  10. package/dist/bg.js +44 -0
  11. package/dist/container/actions.d.ts +15 -0
  12. package/dist/container/actions.js +7 -0
  13. package/dist/container/index.d.ts +58 -0
  14. package/dist/container/index.js +48 -0
  15. package/dist/container/marks.d.ts +10 -0
  16. package/dist/container/marks.js +11 -0
  17. package/dist/container/middleware.d.ts +10 -0
  18. package/dist/container/middleware.js +4 -0
  19. package/dist/container/reducer.d.ts +14 -0
  20. package/dist/container/reducer.js +7 -0
  21. package/dist/coordinates-label.d.ts +50 -0
  22. package/dist/coordinates-label.js +46 -0
  23. package/dist/graph-with-controls.d.ts +85 -0
  24. package/dist/graph-with-controls.js +155 -0
  25. package/dist/graph.d.ts +119 -0
  26. package/dist/graph.js +221 -0
  27. package/dist/grid-setup.d.ts +27 -0
  28. package/dist/grid-setup.js +307 -0
  29. package/dist/grid.d.ts +43 -0
  30. package/dist/grid.js +59 -0
  31. package/dist/index.d.ts +14 -0
  32. package/dist/index.js +6 -0
  33. package/dist/labels.d.ts +73 -0
  34. package/dist/labels.js +134 -0
  35. package/dist/mark-label.d.ts +50 -0
  36. package/dist/mark-label.js +84 -0
  37. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Axis.js +67 -0
  38. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +66 -0
  39. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Ticks.js +39 -0
  40. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
  41. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
  42. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +13 -0
  43. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
  44. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
  45. package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickPosition.js +14 -0
  46. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/Grid.js +43 -0
  47. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridColumns.js +46 -0
  48. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridRows.js +46 -0
  49. package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
  50. package/dist/node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modules/@visx/group/esm/Group.js +17 -0
  51. package/dist/node_modules/.bun/@visx_point@4.0.0/node_modules/@visx/point/esm/Point.js +20 -0
  52. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
  53. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/getTicks.js +7 -0
  54. package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
  55. package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Line.js +27 -0
  56. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/Text.js +27 -0
  57. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/hooks/useText.js +68 -0
  58. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/getStringWidth.js +19 -0
  59. package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/memoize.js +13 -0
  60. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
  61. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
  62. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
  63. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  64. package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
  65. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
  66. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
  67. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
  68. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
  69. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
  70. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
  71. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
  72. package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
  73. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
  74. package/dist/toggle-bar.d.ts +40 -0
  75. package/dist/tool-menu.d.ts +21 -0
  76. package/dist/tool-menu.js +188 -0
  77. package/dist/tools/index.d.ts +17 -0
  78. package/dist/tools/index.js +12 -0
  79. package/dist/tools/line/component.d.ts +113 -0
  80. package/dist/tools/line/component.js +58 -0
  81. package/dist/tools/line/index.d.ts +13 -0
  82. package/dist/tools/line/index.js +6 -0
  83. package/dist/tools/polygon/component.d.ts +117 -0
  84. package/dist/tools/polygon/component.js +194 -0
  85. package/dist/tools/polygon/index.d.ts +19 -0
  86. package/dist/tools/polygon/index.js +55 -0
  87. package/dist/tools/polygon/line.d.ts +125 -0
  88. package/dist/tools/polygon/polygon.d.ts +122 -0
  89. package/dist/tools/polygon/polygon.js +62 -0
  90. package/dist/tools/shared/arrow-head.d.ts +43 -0
  91. package/dist/tools/shared/arrow-head.js +37 -0
  92. package/dist/tools/shared/line/index.d.ts +240 -0
  93. package/dist/tools/shared/line/index.js +320 -0
  94. package/dist/tools/shared/line/line-path.d.ts +57 -0
  95. package/dist/tools/shared/line/with-root-edge.d.ts +143 -0
  96. package/dist/tools/shared/point/arrow-point.d.ts +57 -0
  97. package/dist/tools/shared/point/arrow-point.js +47 -0
  98. package/dist/tools/shared/point/arrow.d.ts +46 -0
  99. package/dist/tools/shared/point/arrow.js +36 -0
  100. package/dist/tools/shared/point/base-point.d.ts +50 -0
  101. package/dist/tools/shared/point/base-point.js +88 -0
  102. package/dist/tools/shared/point/index.d.ts +217 -0
  103. package/dist/tools/shared/point/index.js +51 -0
  104. package/dist/tools/shared/styles.d.ts +24 -0
  105. package/dist/tools/shared/styles.js +17 -0
  106. package/dist/tools/shared/types.d.ts +15 -0
  107. package/dist/tools/shared/types.js +10 -0
  108. package/dist/undo-redo.d.ts +20 -0
  109. package/dist/undo-redo.js +33 -0
  110. package/dist/use-debounce.d.ts +9 -0
  111. package/dist/use-debounce.js +13 -0
  112. package/dist/utils.d.ts +58 -0
  113. package/dist/utils.js +72 -0
  114. package/package.json +52 -42
  115. package/CHANGELOG.json +0 -1
  116. package/CHANGELOG.md +0 -449
  117. package/lib/__tests__/bg.test.js +0 -282
  118. package/lib/__tests__/bg.test.js.map +0 -1
  119. package/lib/__tests__/coordinates-label.test.js +0 -276
  120. package/lib/__tests__/coordinates-label.test.js.map +0 -1
  121. package/lib/__tests__/graph-with-controls.test.js +0 -256
  122. package/lib/__tests__/graph-with-controls.test.js.map +0 -1
  123. package/lib/__tests__/graph.test.js +0 -113
  124. package/lib/__tests__/graph.test.js.map +0 -1
  125. package/lib/__tests__/grid-setup.test.js +0 -729
  126. package/lib/__tests__/grid-setup.test.js.map +0 -1
  127. package/lib/__tests__/grid.test.js +0 -29
  128. package/lib/__tests__/grid.test.js.map +0 -1
  129. package/lib/__tests__/labels.test.js +0 -45
  130. package/lib/__tests__/labels.test.js.map +0 -1
  131. package/lib/__tests__/mark-label.test.js +0 -133
  132. package/lib/__tests__/mark-label.test.js.map +0 -1
  133. package/lib/__tests__/toggle-bar.test.js +0 -146
  134. package/lib/__tests__/toggle-bar.test.js.map +0 -1
  135. package/lib/__tests__/tool-menu.test.js +0 -540
  136. package/lib/__tests__/tool-menu.test.js.map +0 -1
  137. package/lib/__tests__/undo-redo.test.js +0 -31
  138. package/lib/__tests__/undo-redo.test.js.map +0 -1
  139. package/lib/__tests__/use-debounce.test.js +0 -24
  140. package/lib/__tests__/use-debounce.test.js.map +0 -1
  141. package/lib/__tests__/utils.js +0 -70
  142. package/lib/__tests__/utils.js.map +0 -1
  143. package/lib/__tests__/utils.test.js +0 -123
  144. package/lib/__tests__/utils.test.js.map +0 -1
  145. package/lib/axis/__tests__/arrow.test.js +0 -60
  146. package/lib/axis/__tests__/arrow.test.js.map +0 -1
  147. package/lib/axis/__tests__/axes.test.js +0 -160
  148. package/lib/axis/__tests__/axes.test.js.map +0 -1
  149. package/lib/axis/arrow.js +0 -79
  150. package/lib/axis/arrow.js.map +0 -1
  151. package/lib/axis/axes.js +0 -327
  152. package/lib/axis/axes.js.map +0 -1
  153. package/lib/axis/index.js +0 -21
  154. package/lib/axis/index.js.map +0 -1
  155. package/lib/bg.js +0 -114
  156. package/lib/bg.js.map +0 -1
  157. package/lib/container/__tests__/actions.test.js +0 -108
  158. package/lib/container/__tests__/actions.test.js.map +0 -1
  159. package/lib/container/__tests__/index.test.js +0 -346
  160. package/lib/container/__tests__/index.test.js.map +0 -1
  161. package/lib/container/__tests__/marks.test.js +0 -259
  162. package/lib/container/__tests__/marks.test.js.map +0 -1
  163. package/lib/container/__tests__/middleware.test.js +0 -244
  164. package/lib/container/__tests__/middleware.test.js.map +0 -1
  165. package/lib/container/__tests__/reducer.test.js +0 -450
  166. package/lib/container/__tests__/reducer.test.js.map +0 -1
  167. package/lib/container/actions.js +0 -18
  168. package/lib/container/actions.js.map +0 -1
  169. package/lib/container/index.js +0 -129
  170. package/lib/container/index.js.map +0 -1
  171. package/lib/container/marks.js +0 -22
  172. package/lib/container/marks.js.map +0 -1
  173. package/lib/container/middleware.js +0 -19
  174. package/lib/container/middleware.js.map +0 -1
  175. package/lib/container/reducer.js +0 -18
  176. package/lib/container/reducer.js.map +0 -1
  177. package/lib/coordinates-label.js +0 -77
  178. package/lib/coordinates-label.js.map +0 -1
  179. package/lib/graph-with-controls.js +0 -297
  180. package/lib/graph-with-controls.js.map +0 -1
  181. package/lib/graph.js +0 -353
  182. package/lib/graph.js.map +0 -1
  183. package/lib/grid-setup.js +0 -414
  184. package/lib/grid-setup.js.map +0 -1
  185. package/lib/grid.js +0 -131
  186. package/lib/grid.js.map +0 -1
  187. package/lib/index.js +0 -40
  188. package/lib/index.js.map +0 -1
  189. package/lib/labels.js +0 -199
  190. package/lib/labels.js.map +0 -1
  191. package/lib/mark-label.js +0 -159
  192. package/lib/mark-label.js.map +0 -1
  193. package/lib/toggle-bar.js +0 -248
  194. package/lib/toggle-bar.js.map +0 -1
  195. package/lib/tool-menu.js +0 -218
  196. package/lib/tool-menu.js.map +0 -1
  197. package/lib/tools/index.js +0 -24
  198. package/lib/tools/index.js.map +0 -1
  199. package/lib/tools/line/__tests__/component.test.js +0 -45
  200. package/lib/tools/line/__tests__/component.test.js.map +0 -1
  201. package/lib/tools/line/component.js +0 -92
  202. package/lib/tools/line/component.js.map +0 -1
  203. package/lib/tools/line/index.js +0 -11
  204. package/lib/tools/line/index.js.map +0 -1
  205. package/lib/tools/polygon/__tests__/component.test.js +0 -501
  206. package/lib/tools/polygon/__tests__/component.test.js.map +0 -1
  207. package/lib/tools/polygon/__tests__/index.test.js +0 -92
  208. package/lib/tools/polygon/__tests__/index.test.js.map +0 -1
  209. package/lib/tools/polygon/__tests__/line.test.js +0 -30
  210. package/lib/tools/polygon/__tests__/line.test.js.map +0 -1
  211. package/lib/tools/polygon/__tests__/polygon.test.js +0 -61
  212. package/lib/tools/polygon/__tests__/polygon.test.js.map +0 -1
  213. package/lib/tools/polygon/component.js +0 -358
  214. package/lib/tools/polygon/component.js.map +0 -1
  215. package/lib/tools/polygon/index.js +0 -89
  216. package/lib/tools/polygon/index.js.map +0 -1
  217. package/lib/tools/polygon/line.js +0 -114
  218. package/lib/tools/polygon/line.js.map +0 -1
  219. package/lib/tools/polygon/polygon.js +0 -128
  220. package/lib/tools/polygon/polygon.js.map +0 -1
  221. package/lib/tools/shared/__tests__/arrow-head.test.js +0 -45
  222. package/lib/tools/shared/__tests__/arrow-head.test.js.map +0 -1
  223. package/lib/tools/shared/arrow-head.js +0 -62
  224. package/lib/tools/shared/arrow-head.js.map +0 -1
  225. package/lib/tools/shared/line/__tests__/index.test.js +0 -725
  226. package/lib/tools/shared/line/__tests__/index.test.js.map +0 -1
  227. package/lib/tools/shared/line/__tests__/line-path.test.js +0 -64
  228. package/lib/tools/shared/line/__tests__/line-path.test.js.map +0 -1
  229. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +0 -618
  230. package/lib/tools/shared/line/__tests__/with-root-edge.test.js.map +0 -1
  231. package/lib/tools/shared/line/index.js +0 -539
  232. package/lib/tools/shared/line/index.js.map +0 -1
  233. package/lib/tools/shared/line/line-path.js +0 -121
  234. package/lib/tools/shared/line/line-path.js.map +0 -1
  235. package/lib/tools/shared/line/with-root-edge.js +0 -121
  236. package/lib/tools/shared/line/with-root-edge.js.map +0 -1
  237. package/lib/tools/shared/point/__tests__/arrow-point.test.js +0 -127
  238. package/lib/tools/shared/point/__tests__/arrow-point.test.js.map +0 -1
  239. package/lib/tools/shared/point/__tests__/arrow.test.js +0 -619
  240. package/lib/tools/shared/point/__tests__/arrow.test.js.map +0 -1
  241. package/lib/tools/shared/point/__tests__/base-point.test.js +0 -122
  242. package/lib/tools/shared/point/__tests__/base-point.test.js.map +0 -1
  243. package/lib/tools/shared/point/arrow-point.js +0 -86
  244. package/lib/tools/shared/point/arrow-point.js.map +0 -1
  245. package/lib/tools/shared/point/arrow.js +0 -70
  246. package/lib/tools/shared/point/arrow.js.map +0 -1
  247. package/lib/tools/shared/point/base-point.js +0 -137
  248. package/lib/tools/shared/point/base-point.js.map +0 -1
  249. package/lib/tools/shared/point/index.js +0 -80
  250. package/lib/tools/shared/point/index.js.map +0 -1
  251. package/lib/tools/shared/styles.js +0 -26
  252. package/lib/tools/shared/styles.js.map +0 -1
  253. package/lib/tools/shared/types.js +0 -15
  254. package/lib/tools/shared/types.js.map +0 -1
  255. package/lib/undo-redo.js +0 -67
  256. package/lib/undo-redo.js.map +0 -1
  257. package/lib/use-debounce.js +0 -25
  258. package/lib/use-debounce.js.map +0 -1
  259. package/lib/utils.js +0 -235
  260. package/lib/utils.js.map +0 -1
  261. package/src/__tests__/bg.test.jsx +0 -250
  262. package/src/__tests__/coordinates-label.test.jsx +0 -243
  263. package/src/__tests__/graph-with-controls.test.jsx +0 -184
  264. package/src/__tests__/graph.test.jsx +0 -93
  265. package/src/__tests__/grid-setup.test.jsx +0 -645
  266. package/src/__tests__/grid.test.jsx +0 -23
  267. package/src/__tests__/labels.test.jsx +0 -41
  268. package/src/__tests__/mark-label.test.jsx +0 -66
  269. package/src/__tests__/toggle-bar.test.jsx +0 -106
  270. package/src/__tests__/tool-menu.test.jsx +0 -453
  271. package/src/__tests__/undo-redo.test.jsx +0 -26
  272. package/src/__tests__/use-debounce.test.js +0 -21
  273. package/src/__tests__/utils.js +0 -41
  274. package/src/__tests__/utils.test.js +0 -105
  275. package/src/axis/__tests__/arrow.test.jsx +0 -43
  276. package/src/axis/__tests__/axes.test.jsx +0 -182
  277. package/src/axis/arrow.jsx +0 -57
  278. package/src/axis/axes.jsx +0 -284
  279. package/src/axis/index.js +0 -3
  280. package/src/bg.jsx +0 -96
  281. package/src/container/__tests__/actions.test.js +0 -105
  282. package/src/container/__tests__/index.test.jsx +0 -227
  283. package/src/container/__tests__/marks.test.js +0 -172
  284. package/src/container/__tests__/middleware.test.js +0 -235
  285. package/src/container/__tests__/reducer.test.js +0 -324
  286. package/src/container/actions.js +0 -8
  287. package/src/container/index.jsx +0 -93
  288. package/src/container/marks.js +0 -14
  289. package/src/container/middleware.js +0 -7
  290. package/src/container/reducer.js +0 -5
  291. package/src/coordinates-label.jsx +0 -62
  292. package/src/graph-with-controls.jsx +0 -242
  293. package/src/graph.jsx +0 -333
  294. package/src/grid-setup.jsx +0 -432
  295. package/src/grid.jsx +0 -133
  296. package/src/index.js +0 -7
  297. package/src/labels.jsx +0 -173
  298. package/src/mark-label.jsx +0 -125
  299. package/src/toggle-bar.jsx +0 -221
  300. package/src/tool-menu.jsx +0 -235
  301. package/src/tools/index.js +0 -8
  302. package/src/tools/line/__tests__/component.test.jsx +0 -37
  303. package/src/tools/line/component.jsx +0 -77
  304. package/src/tools/line/index.js +0 -4
  305. package/src/tools/polygon/__tests__/component.test.jsx +0 -487
  306. package/src/tools/polygon/__tests__/index.test.js +0 -65
  307. package/src/tools/polygon/__tests__/line.test.jsx +0 -23
  308. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -44
  309. package/src/tools/polygon/component.jsx +0 -324
  310. package/src/tools/polygon/index.js +0 -52
  311. package/src/tools/polygon/line.jsx +0 -80
  312. package/src/tools/polygon/polygon.jsx +0 -93
  313. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -33
  314. package/src/tools/shared/arrow-head.jsx +0 -46
  315. package/src/tools/shared/line/__tests__/index.test.jsx +0 -553
  316. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -56
  317. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -488
  318. package/src/tools/shared/line/index.jsx +0 -471
  319. package/src/tools/shared/line/line-path.jsx +0 -85
  320. package/src/tools/shared/line/with-root-edge.jsx +0 -97
  321. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  322. package/src/tools/shared/point/__tests__/arrow.test.jsx +0 -469
  323. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  324. package/src/tools/shared/point/arrow-point.jsx +0 -60
  325. package/src/tools/shared/point/arrow.jsx +0 -40
  326. package/src/tools/shared/point/base-point.jsx +0 -113
  327. package/src/tools/shared/point/index.jsx +0 -58
  328. package/src/tools/shared/styles.js +0 -20
  329. package/src/tools/shared/types.js +0 -8
  330. package/src/undo-redo.jsx +0 -37
  331. package/src/use-debounce.js +0 -13
  332. package/src/utils.js +0 -230
@@ -1,66 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { coordinates, MarkLabel, position } from '../mark-label';
4
- import { graphProps as getGraphProps } from './utils';
5
-
6
- describe('MarkLabel', () => {
7
- let onChange = jest.fn();
8
- let inputRef = jest.fn();
9
-
10
- const renderComponent = (extras) => {
11
- const defaults = {
12
- classes: {},
13
- className: 'className',
14
- onChange,
15
- inputRef,
16
- mark: { x: 1, y: 1 },
17
- graphProps: getGraphProps(0, 10, 0, 10),
18
- };
19
- const props = { ...defaults, ...extras };
20
- return render(<MarkLabel {...props} />);
21
- };
22
-
23
- describe('rendering', () => {
24
- it('renders without crashing', () => {
25
- const { container } = renderComponent();
26
- expect(container.firstChild).toBeInTheDocument();
27
- });
28
-
29
- it('renders with different mark position', () => {
30
- const { container } = renderComponent({ mark: { x: 10, y: 10 } });
31
- expect(container.firstChild).toBeInTheDocument();
32
- });
33
- });
34
- });
35
-
36
- describe('position', () => {
37
- const assertPosition = (mark, rect, expected) => {
38
- it(`${mark.x},${mark.y} + ${rect.width},${rect.height} => ${expected}`, () => {
39
- // we set range.min to a value because in pixels - the greater the Y the lower down on the screen.
40
- const graphProps = getGraphProps(0, 12, 12, 0);
41
- const result = position(graphProps, mark, rect);
42
- expect(result).toEqual(expected);
43
- });
44
- };
45
-
46
- assertPosition({ x: 0, y: 0 }, { width: 10, height: 10 }, 'top-left');
47
- assertPosition({ x: 0, y: 0 }, { width: 1, height: 1 }, 'bottom-right');
48
- assertPosition({ x: 0, y: 0 }, { width: 10, height: 0 }, 'bottom-left');
49
- assertPosition({ x: 0, y: 0 }, { width: 0, height: 10 }, 'top-right');
50
- });
51
-
52
- describe('coordinates', () => {
53
- const assertCoordinates = (mark, rect, pos, expected) => {
54
- it(`${mark.x}, ${mark.y} -> ${pos} = ${expected.left}, ${expected.top}`, () => {
55
- const result = coordinates(getGraphProps(), mark, rect, pos);
56
- expect(result).toEqual(expected);
57
- });
58
- };
59
- assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'top-left', { left: -10, top: -10 });
60
- assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'bottom-left', { left: -10, top: 10 });
61
- assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'top-right', { left: 10, top: -10 });
62
- assertCoordinates({ x: 0, y: 0 }, { width: 0, height: 0 }, 'bottom-right', {
63
- left: 10,
64
- top: 10,
65
- });
66
- });
@@ -1,106 +0,0 @@
1
- import { render, screen } from '@pie-lib/test-utils';
2
- import userEvent from '@testing-library/user-event';
3
- import React from 'react';
4
-
5
- import { ToggleBar } from '../toggle-bar';
6
-
7
- // Mock DragProvider to avoid @dnd-kit React version conflicts
8
- jest.mock('@pie-lib/drag', () => ({
9
- DragProvider: ({ children }) => <div data-testid="drag-provider">{children}</div>,
10
- }));
11
-
12
- // Mock @dnd-kit/core hooks to avoid DndContext requirement
13
- jest.mock('@dnd-kit/core', () => ({
14
- useDraggable: jest.fn(() => ({
15
- attributes: {
16
- role: 'button',
17
- tabIndex: 0,
18
- },
19
- listeners: {
20
- onPointerDown: jest.fn(),
21
- },
22
- setNodeRef: jest.fn(),
23
- transform: null,
24
- transition: null,
25
- isDragging: false,
26
- })),
27
- useDroppable: jest.fn(() => ({
28
- setNodeRef: jest.fn(),
29
- isOver: false,
30
- active: null,
31
- })),
32
- }));
33
-
34
- // Mock @dnd-kit/utilities for CSS transform
35
- jest.mock('@dnd-kit/utilities', () => ({
36
- CSS: {
37
- Transform: {
38
- toString: jest.fn((transform) => (transform ? 'translate3d(0, 0, 0)' : '')),
39
- },
40
- },
41
- }));
42
-
43
- // Mock @dnd-kit/sortable for arrayMove
44
- jest.mock('@dnd-kit/sortable', () => ({
45
- arrayMove: jest.fn((array, from, to) => {
46
- const newArray = [...array];
47
- const [removed] = newArray.splice(from, 1);
48
- newArray.splice(to, 0, removed);
49
- return newArray;
50
- }),
51
- }));
52
-
53
- // Mock Translator to return the key as-is for testing
54
- jest.mock('@pie-lib/translator', () => ({
55
- translator: {
56
- t: (key) => {
57
- // Extract tool name from key like "graphing.point" -> "point"
58
- const parts = key.split('.');
59
- return parts[parts.length - 1];
60
- },
61
- },
62
- }));
63
-
64
- describe('ToggleBar', () => {
65
- let onChange = jest.fn();
66
-
67
- beforeEach(() => {
68
- onChange.mockClear();
69
- });
70
-
71
- const renderComponent = (extras) => {
72
- const defaults = {
73
- className: 'className',
74
- onChange,
75
- options: ['line', 'polygon'],
76
- language: 'en',
77
- };
78
- const props = { ...defaults, ...extras };
79
- return render(<ToggleBar {...props} />);
80
- };
81
-
82
- describe('rendering', () => {
83
- it('renders without crashing', () => {
84
- const { container } = renderComponent();
85
- expect(container.firstChild).toBeInTheDocument();
86
- });
87
-
88
- it('renders tool buttons for valid tools', () => {
89
- renderComponent({ options: ['line', 'polygon'] });
90
- expect(screen.getByText(/line/i)).toBeInTheDocument();
91
- expect(screen.getByText(/polygon/i)).toBeInTheDocument();
92
- });
93
- });
94
-
95
- describe('interactions', () => {
96
- it('calls onChange when tool button is clicked', async () => {
97
- const user = userEvent.setup();
98
- renderComponent({ options: ['line', 'polygon'] });
99
-
100
- const lineButton = screen.getByText(/line/i).closest('button');
101
- await user.click(lineButton);
102
-
103
- expect(onChange).toHaveBeenCalledWith('line');
104
- });
105
- });
106
- });
@@ -1,453 +0,0 @@
1
- import { fireEvent, render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
-
4
- import ToolMenu from '../tool-menu';
5
-
6
- describe('ToolMenu', () => {
7
- let onChange;
8
- const tools = ['one', 'two'];
9
-
10
- beforeEach(() => {
11
- onChange = jest.fn();
12
- });
13
-
14
- const renderComponent = (extras) => {
15
- const defaults = {
16
- classes: {},
17
- className: 'className',
18
- onChange,
19
- currentTool: tools[0],
20
- tools,
21
- gssLineData: {
22
- selectedTool: 'lineA',
23
- numberOfLines: 2,
24
- lineA: { lineType: 'Solid' },
25
- lineB: { lineType: 'Solid' },
26
- },
27
- };
28
- const props = { ...defaults, ...extras };
29
- return render(<ToolMenu {...props} />);
30
- };
31
-
32
- describe('rendering', () => {
33
- it('renders without crashing', () => {
34
- const { container } = renderComponent();
35
- expect(container.firstChild).toBeInTheDocument();
36
- });
37
-
38
- it('renders Line A radio button', () => {
39
- const { getByText } = renderComponent();
40
- expect(getByText('Line A')).toBeInTheDocument();
41
- });
42
-
43
- it('renders Line B radio button when numberOfLines is 2', () => {
44
- const { getByText } = renderComponent();
45
- expect(getByText('Line B')).toBeInTheDocument();
46
- });
47
-
48
- it('does not render Line B radio button when numberOfLines is 1', () => {
49
- const { queryByText } = renderComponent({
50
- gssLineData: {
51
- selectedTool: 'lineA',
52
- numberOfLines: 1,
53
- lineA: { lineType: 'Solid' },
54
- lineB: { lineType: 'Solid' },
55
- },
56
- });
57
- expect(queryByText('Line B')).not.toBeInTheDocument();
58
- });
59
-
60
- it('renders Solution Set radio button', () => {
61
- const { getByText } = renderComponent();
62
- expect(getByText('Solution Set')).toBeInTheDocument();
63
- });
64
-
65
- it('renders Solid and Dashed buttons for Line A', () => {
66
- const { getAllByText } = renderComponent();
67
- const solidButtons = getAllByText(/Solid/);
68
- const dashedButtons = getAllByText(/Dashed/);
69
- expect(solidButtons.length).toBeGreaterThan(0);
70
- expect(dashedButtons.length).toBeGreaterThan(0);
71
- });
72
-
73
- it('shows checkmark on selected line type for Line A', () => {
74
- const { getAllByText } = renderComponent({
75
- gssLineData: {
76
- selectedTool: 'lineA',
77
- numberOfLines: 2,
78
- lineA: { lineType: 'Solid' },
79
- lineB: { lineType: 'Dashed' },
80
- },
81
- });
82
- const solidButtons = getAllByText(/✔ Solid/);
83
- expect(solidButtons.length).toBeGreaterThan(0);
84
- });
85
-
86
- it('disables all controls when disabled prop is true', () => {
87
- const { getAllByRole } = renderComponent({ disabled: true });
88
- const radios = getAllByRole('radio');
89
- const buttons = getAllByRole('button');
90
-
91
- radios.forEach((radio) => {
92
- expect(radio).toBeDisabled();
93
- });
94
-
95
- buttons.forEach((button) => {
96
- expect(button).toBeDisabled();
97
- });
98
- });
99
- });
100
-
101
- describe('onChangeRadioValue', () => {
102
- it('calls onChange with updated selectedTool when lineA radio is clicked', () => {
103
- const { getAllByRole } = renderComponent({
104
- gssLineData: {
105
- selectedTool: 'solutionSet',
106
- numberOfLines: 2,
107
- lineA: { lineType: 'Solid' },
108
- lineB: { lineType: 'Solid' },
109
- },
110
- });
111
-
112
- const radios = getAllByRole('radio');
113
- const lineARadio = radios.find((r) => r.value === 'lineA');
114
-
115
- fireEvent.click(lineARadio);
116
-
117
- expect(onChange).toHaveBeenCalledTimes(1);
118
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
119
- expect(updatedData.selectedTool).toBe('lineA');
120
- expect(oldSelectedTool).toBe('solutionSet');
121
- });
122
-
123
- it('calls onChange with updated selectedTool when lineB radio is clicked', () => {
124
- const { getAllByRole } = renderComponent({
125
- gssLineData: {
126
- selectedTool: 'lineA',
127
- numberOfLines: 2,
128
- lineA: { lineType: 'Solid' },
129
- lineB: { lineType: 'Solid' },
130
- },
131
- });
132
-
133
- const radios = getAllByRole('radio');
134
- const lineBRadio = radios.find((r) => r.value === 'lineB');
135
-
136
- fireEvent.click(lineBRadio);
137
-
138
- expect(onChange).toHaveBeenCalledTimes(1);
139
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
140
- expect(updatedData.selectedTool).toBe('lineB');
141
- expect(oldSelectedTool).toBe('lineA');
142
- });
143
-
144
- it('calls onChange with updated selectedTool when solutionSet radio is clicked', () => {
145
- const { getAllByRole } = renderComponent({
146
- gssLineData: {
147
- selectedTool: 'lineA',
148
- numberOfLines: 2,
149
- lineA: { lineType: 'Solid' },
150
- lineB: { lineType: 'Solid' },
151
- },
152
- });
153
-
154
- const radios = getAllByRole('radio');
155
- const solutionSetRadio = radios.find((r) => r.value === 'solutionSet');
156
-
157
- fireEvent.click(solutionSetRadio);
158
-
159
- expect(onChange).toHaveBeenCalledTimes(1);
160
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
161
- expect(updatedData.selectedTool).toBe('solutionSet');
162
- expect(oldSelectedTool).toBe('lineA');
163
- });
164
-
165
- it('preserves other gssLineData properties when changing selectedTool', () => {
166
- const { getAllByRole } = renderComponent({
167
- gssLineData: {
168
- selectedTool: 'lineA',
169
- numberOfLines: 2,
170
- lineA: { lineType: 'Dashed' },
171
- lineB: { lineType: 'Solid' },
172
- },
173
- });
174
-
175
- const radios = getAllByRole('radio');
176
- const lineBRadio = radios.find((r) => r.value === 'lineB');
177
-
178
- fireEvent.click(lineBRadio);
179
-
180
- const [updatedData] = onChange.mock.calls[0];
181
- expect(updatedData.lineA.lineType).toBe('Dashed');
182
- expect(updatedData.lineB.lineType).toBe('Solid');
183
- expect(updatedData.numberOfLines).toBe(2);
184
- });
185
-
186
- it('does not call onChange when disabled', () => {
187
- const { getAllByRole } = renderComponent({
188
- disabled: true,
189
- gssLineData: {
190
- selectedTool: 'lineA',
191
- numberOfLines: 2,
192
- lineA: { lineType: 'Solid' },
193
- lineB: { lineType: 'Solid' },
194
- },
195
- });
196
-
197
- const radios = getAllByRole('radio');
198
- const lineBRadio = radios.find((r) => r.value === 'lineB');
199
-
200
- // Disabled radios should not fire change events
201
- expect(lineBRadio).toBeDisabled();
202
- });
203
- });
204
-
205
- describe('lineTypeChange', () => {
206
- it('calls onChange with updated lineType for Line A when Solid button is clicked', () => {
207
- const { getAllByText } = renderComponent({
208
- gssLineData: {
209
- selectedTool: 'lineA',
210
- numberOfLines: 2,
211
- lineA: { lineType: 'Dashed' },
212
- lineB: { lineType: 'Solid' },
213
- },
214
- });
215
-
216
- const solidButtons = getAllByText(/Solid/);
217
- // First solid button should be for Line A
218
- fireEvent.click(solidButtons[0]);
219
-
220
- expect(onChange).toHaveBeenCalledTimes(1);
221
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
222
- expect(updatedData.lineA.lineType).toBe('Solid');
223
- expect(oldSelectedTool).toBe('lineA');
224
- });
225
-
226
- it('calls onChange with updated lineType for Line A when Dashed button is clicked', () => {
227
- const { getAllByText } = renderComponent({
228
- gssLineData: {
229
- selectedTool: 'lineA',
230
- numberOfLines: 2,
231
- lineA: { lineType: 'Solid' },
232
- lineB: { lineType: 'Solid' },
233
- },
234
- });
235
-
236
- const dashedButtons = getAllByText(/Dashed/);
237
- // First dashed button should be for Line A
238
- fireEvent.click(dashedButtons[0]);
239
-
240
- expect(onChange).toHaveBeenCalledTimes(1);
241
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
242
- expect(updatedData.lineA.lineType).toBe('Dashed');
243
- expect(oldSelectedTool).toBe('lineA');
244
- });
245
-
246
- it('calls onChange with updated lineType for Line B when Solid button is clicked', () => {
247
- const { getAllByText } = renderComponent({
248
- gssLineData: {
249
- selectedTool: 'lineB',
250
- numberOfLines: 2,
251
- lineA: { lineType: 'Solid' },
252
- lineB: { lineType: 'Dashed' },
253
- },
254
- });
255
-
256
- const solidButtons = getAllByText(/Solid/);
257
- // Second solid button should be for Line B
258
- fireEvent.click(solidButtons[1]);
259
-
260
- expect(onChange).toHaveBeenCalledTimes(1);
261
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
262
- expect(updatedData.lineB.lineType).toBe('Solid');
263
- expect(oldSelectedTool).toBe('lineB');
264
- });
265
-
266
- it('calls onChange with updated lineType for Line B when Dashed button is clicked', () => {
267
- const { getAllByText } = renderComponent({
268
- gssLineData: {
269
- selectedTool: 'lineB',
270
- numberOfLines: 2,
271
- lineA: { lineType: 'Solid' },
272
- lineB: { lineType: 'Solid' },
273
- },
274
- });
275
-
276
- const dashedButtons = getAllByText(/Dashed/);
277
- // Second dashed button should be for Line B
278
- fireEvent.click(dashedButtons[1]);
279
-
280
- expect(onChange).toHaveBeenCalledTimes(1);
281
- const [updatedData, oldSelectedTool] = onChange.mock.calls[0];
282
- expect(updatedData.lineB.lineType).toBe('Dashed');
283
- expect(oldSelectedTool).toBe('lineB');
284
- });
285
-
286
- it('preserves other line properties when changing Line A lineType', () => {
287
- const { getAllByText } = renderComponent({
288
- gssLineData: {
289
- selectedTool: 'lineA',
290
- numberOfLines: 2,
291
- lineA: { lineType: 'Solid' },
292
- lineB: { lineType: 'Dashed' },
293
- },
294
- });
295
-
296
- const dashedButtons = getAllByText(/Dashed/);
297
- fireEvent.click(dashedButtons[0]);
298
-
299
- const [updatedData] = onChange.mock.calls[0];
300
- expect(updatedData.lineA.lineType).toBe('Dashed');
301
- expect(updatedData.lineB.lineType).toBe('Dashed');
302
- expect(updatedData.selectedTool).toBe('lineA');
303
- expect(updatedData.numberOfLines).toBe(2);
304
- });
305
-
306
- it('preserves other line properties when changing Line B lineType', () => {
307
- const { getAllByText } = renderComponent({
308
- gssLineData: {
309
- selectedTool: 'lineB',
310
- numberOfLines: 2,
311
- lineA: { lineType: 'Dashed' },
312
- lineB: { lineType: 'Solid' },
313
- },
314
- });
315
-
316
- const dashedButtons = getAllByText(/Dashed/);
317
- fireEvent.click(dashedButtons[1]);
318
-
319
- const [updatedData] = onChange.mock.calls[0];
320
- expect(updatedData.lineA.lineType).toBe('Dashed');
321
- expect(updatedData.lineB.lineType).toBe('Dashed');
322
- expect(updatedData.selectedTool).toBe('lineB');
323
- expect(updatedData.numberOfLines).toBe(2);
324
- });
325
-
326
- it('handles multiple line type changes correctly', () => {
327
- const { getAllByText } = renderComponent({
328
- gssLineData: {
329
- selectedTool: 'lineA',
330
- numberOfLines: 2,
331
- lineA: { lineType: 'Solid' },
332
- lineB: { lineType: 'Solid' },
333
- },
334
- });
335
-
336
- // Change Line A to Dashed
337
- let dashedButtons = getAllByText(/Dashed/);
338
- fireEvent.click(dashedButtons[0]);
339
-
340
- expect(onChange).toHaveBeenCalledTimes(1);
341
- let [updatedData] = onChange.mock.calls[0];
342
- expect(updatedData.lineA.lineType).toBe('Dashed');
343
-
344
- // Change Line B to Dashed
345
- dashedButtons = getAllByText(/Dashed/);
346
- fireEvent.click(dashedButtons[1]);
347
-
348
- expect(onChange).toHaveBeenCalledTimes(2);
349
- [updatedData] = onChange.mock.calls[1];
350
- expect(updatedData.lineB.lineType).toBe('Dashed');
351
- });
352
-
353
- it('does not call onChange when line type button is disabled', () => {
354
- const { getAllByRole } = renderComponent({
355
- disabled: true,
356
- gssLineData: {
357
- selectedTool: 'lineA',
358
- numberOfLines: 2,
359
- lineA: { lineType: 'Solid' },
360
- lineB: { lineType: 'Solid' },
361
- },
362
- });
363
-
364
- const buttons = getAllByRole('button');
365
-
366
- buttons.forEach((button) => {
367
- expect(button).toBeDisabled();
368
- });
369
- });
370
-
371
- it('maintains correct state when clicking same line type that is already selected', () => {
372
- const { getAllByText } = renderComponent({
373
- gssLineData: {
374
- selectedTool: 'lineA',
375
- numberOfLines: 2,
376
- lineA: { lineType: 'Solid' },
377
- lineB: { lineType: 'Solid' },
378
- },
379
- });
380
-
381
- const solidButtons = getAllByText(/Solid/);
382
- fireEvent.click(solidButtons[0]); // Click Solid when already Solid
383
-
384
- expect(onChange).toHaveBeenCalledTimes(1);
385
- const [updatedData] = onChange.mock.calls[0];
386
- expect(updatedData.lineA.lineType).toBe('Solid');
387
- });
388
- });
389
-
390
- describe('integration tests', () => {
391
- it('allows switching selected tool and changing line type in sequence', () => {
392
- const { getAllByRole, getAllByText } = renderComponent({
393
- gssLineData: {
394
- selectedTool: 'lineA',
395
- numberOfLines: 2,
396
- lineA: { lineType: 'Solid' },
397
- lineB: { lineType: 'Solid' },
398
- },
399
- });
400
-
401
- // Switch to Line B
402
- const radios = getAllByRole('radio');
403
- const lineBRadio = radios.find((r) => r.value === 'lineB');
404
- fireEvent.click(lineBRadio);
405
-
406
- expect(onChange).toHaveBeenCalledTimes(1);
407
- let [updatedData] = onChange.mock.calls[0];
408
- expect(updatedData.selectedTool).toBe('lineB');
409
-
410
- // Change Line B to Dashed
411
- const dashedButtons = getAllByText(/Dashed/);
412
- fireEvent.click(dashedButtons[1]);
413
-
414
- expect(onChange).toHaveBeenCalledTimes(2);
415
- [updatedData] = onChange.mock.calls[1];
416
- expect(updatedData.lineB.lineType).toBe('Dashed');
417
- });
418
-
419
- it('handles complete workflow of switching between all tools and changing line types', () => {
420
- const { getAllByRole, getAllByText } = renderComponent({
421
- gssLineData: {
422
- selectedTool: 'lineA',
423
- numberOfLines: 2,
424
- lineA: { lineType: 'Solid' },
425
- lineB: { lineType: 'Solid' },
426
- },
427
- });
428
-
429
- // Change Line A to Dashed
430
- let dashedButtons = getAllByText(/Dashed/);
431
- fireEvent.click(dashedButtons[0]);
432
- expect(onChange.mock.calls[0][0].lineA.lineType).toBe('Dashed');
433
-
434
- // Switch to Line B
435
- const radios = getAllByRole('radio');
436
- const lineBRadio = radios.find((r) => r.value === 'lineB');
437
- fireEvent.click(lineBRadio);
438
- expect(onChange.mock.calls[1][0].selectedTool).toBe('lineB');
439
-
440
- // Change Line B to Dashed
441
- dashedButtons = getAllByText(/Dashed/);
442
- fireEvent.click(dashedButtons[1]);
443
- expect(onChange.mock.calls[2][0].lineB.lineType).toBe('Dashed');
444
-
445
- // Switch to Solution Set
446
- const solutionSetRadio = radios.find((r) => r.value === 'solutionSet');
447
- fireEvent.click(solutionSetRadio);
448
- expect(onChange.mock.calls[3][0].selectedTool).toBe('solutionSet');
449
-
450
- expect(onChange).toHaveBeenCalledTimes(4);
451
- });
452
- });
453
- });
@@ -1,26 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import UndoRedo from '../undo-redo';
4
-
5
- describe('UndoRedo', () => {
6
- let onUndo = jest.fn();
7
- let onRedo = jest.fn();
8
- let onReset = jest.fn();
9
-
10
- const renderComponent = (extras) => {
11
- const defaults = {
12
- onUndo,
13
- onRedo,
14
- onReset,
15
- };
16
- const props = { ...defaults, ...extras };
17
- return render(<UndoRedo {...props} />);
18
- };
19
-
20
- describe('rendering', () => {
21
- it('renders without crashing', () => {
22
- const { container } = renderComponent();
23
- expect(container.firstChild).toBeInTheDocument();
24
- });
25
- });
26
- });
@@ -1,21 +0,0 @@
1
- import { useState } from 'react';
2
- import { useDebounce } from '../use-debounce';
3
-
4
- jest.useFakeTimers();
5
-
6
- jest.mock('react', () => ({
7
- useState: jest.fn(),
8
- useEffect: jest.fn((fn, deps) => fn()),
9
- }));
10
-
11
- describe('useDebounce', () => {
12
- it('..', () => {
13
- const debouncedValue = null;
14
- const setDebouncedValue = jest.fn();
15
-
16
- useState.mockReturnValue([debouncedValue, setDebouncedValue]);
17
- useDebounce('foo', 1000);
18
- jest.runAllTimers();
19
- expect(setDebouncedValue).toHaveBeenCalledWith('foo');
20
- });
21
- });