@pie-lib/graphing 4.0.5-next.30 → 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.
- package/CHANGELOG.json +1 -0
- package/CHANGELOG.md +1469 -0
- package/LICENSE.md +5 -0
- package/lib/axis/arrow.js +79 -0
- package/lib/axis/arrow.js.map +1 -0
- package/lib/axis/axes.js +329 -0
- package/lib/axis/axes.js.map +1 -0
- package/lib/axis/index.js +21 -0
- package/lib/axis/index.js.map +1 -0
- package/lib/bg.js +114 -0
- package/lib/bg.js.map +1 -0
- package/lib/container/actions.js +18 -0
- package/lib/container/actions.js.map +1 -0
- package/lib/container/index.js +127 -0
- package/lib/container/index.js.map +1 -0
- package/lib/container/marks.js +22 -0
- package/lib/container/marks.js.map +1 -0
- package/lib/container/middleware.js +19 -0
- package/lib/container/middleware.js.map +1 -0
- package/lib/container/reducer.js +18 -0
- package/lib/container/reducer.js.map +1 -0
- package/lib/coordinates-label.js +79 -0
- package/lib/coordinates-label.js.map +1 -0
- package/lib/graph-with-controls.js +294 -0
- package/lib/graph-with-controls.js.map +1 -0
- package/lib/graph.js +327 -0
- package/lib/graph.js.map +1 -0
- package/lib/grid-setup.js +414 -0
- package/lib/grid-setup.js.map +1 -0
- package/lib/grid.js +131 -0
- package/lib/grid.js.map +1 -0
- package/lib/index.js +47 -0
- package/lib/index.js.map +1 -0
- package/lib/key-legend.js +201 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/label-svg-icon.js +50 -0
- package/lib/label-svg-icon.js.map +1 -0
- package/lib/labels.js +243 -0
- package/lib/labels.js.map +1 -0
- package/lib/mark-label.js +285 -0
- package/lib/mark-label.js.map +1 -0
- package/lib/toggle-bar.js +252 -0
- package/lib/toggle-bar.js.map +1 -0
- package/lib/tool-menu.js +78 -0
- package/lib/tool-menu.js.map +1 -0
- package/lib/tools/absolute/component.js +29 -0
- package/lib/tools/absolute/component.js.map +1 -0
- package/lib/tools/absolute/index.js +50 -0
- package/lib/tools/absolute/index.js.map +1 -0
- package/lib/tools/circle/bg-circle.js +123 -0
- package/lib/tools/circle/bg-circle.js.map +1 -0
- package/lib/tools/circle/component.js +321 -0
- package/lib/tools/circle/component.js.map +1 -0
- package/lib/tools/circle/index.js +41 -0
- package/lib/tools/circle/index.js.map +1 -0
- package/lib/tools/exponential/component.js +28 -0
- package/lib/tools/exponential/component.js.map +1 -0
- package/lib/tools/exponential/index.js +56 -0
- package/lib/tools/exponential/index.js.map +1 -0
- package/lib/tools/index.js +86 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/tools/line/component.js +97 -0
- package/lib/tools/line/component.js.map +1 -0
- package/lib/tools/line/index.js +11 -0
- package/lib/tools/line/index.js.map +1 -0
- package/lib/tools/parabola/component.js +28 -0
- package/lib/tools/parabola/component.js.map +1 -0
- package/lib/tools/parabola/index.js +50 -0
- package/lib/tools/parabola/index.js.map +1 -0
- package/lib/tools/point/component.js +148 -0
- package/lib/tools/point/component.js.map +1 -0
- package/lib/tools/point/index.js +24 -0
- package/lib/tools/point/index.js.map +1 -0
- package/lib/tools/polygon/component.js +437 -0
- package/lib/tools/polygon/component.js.map +1 -0
- package/lib/tools/polygon/index.js +89 -0
- package/lib/tools/polygon/index.js.map +1 -0
- package/lib/tools/polygon/line.js +112 -0
- package/lib/tools/polygon/line.js.map +1 -0
- package/lib/tools/polygon/polygon.js +130 -0
- package/lib/tools/polygon/polygon.js.map +1 -0
- package/lib/tools/ray/component.js +95 -0
- package/lib/tools/ray/component.js.map +1 -0
- package/lib/tools/ray/index.js +11 -0
- package/lib/tools/ray/index.js.map +1 -0
- package/lib/tools/segment/component.js +71 -0
- package/lib/tools/segment/component.js.map +1 -0
- package/lib/tools/segment/index.js +11 -0
- package/lib/tools/segment/index.js.map +1 -0
- package/lib/tools/shared/arrow-head.js +111 -0
- package/lib/tools/shared/arrow-head.js.map +1 -0
- package/lib/tools/shared/icons/CorrectSVG.js +40 -0
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -0
- package/lib/tools/shared/icons/IncorrectSVG.js +40 -0
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -0
- package/lib/tools/shared/icons/MissingSVG.js +39 -0
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -0
- package/lib/tools/shared/line/index.js +550 -0
- package/lib/tools/shared/line/index.js.map +1 -0
- package/lib/tools/shared/line/line-path.js +118 -0
- package/lib/tools/shared/line/line-path.js.map +1 -0
- package/lib/tools/shared/line/with-root-edge.js +121 -0
- package/lib/tools/shared/line/with-root-edge.js.map +1 -0
- package/lib/tools/shared/point/arrow-point.js +72 -0
- package/lib/tools/shared/point/arrow-point.js.map +1 -0
- package/lib/tools/shared/point/arrow.js +67 -0
- package/lib/tools/shared/point/arrow.js.map +1 -0
- package/lib/tools/shared/point/base-point.js +157 -0
- package/lib/tools/shared/point/base-point.js.map +1 -0
- package/lib/tools/shared/point/index.js +68 -0
- package/lib/tools/shared/point/index.js.map +1 -0
- package/lib/tools/shared/styles.js +33 -0
- package/lib/tools/shared/styles.js.map +1 -0
- package/lib/tools/shared/types.js +16 -0
- package/lib/tools/shared/types.js.map +1 -0
- package/lib/tools/sine/component.js +40 -0
- package/lib/tools/sine/component.js.map +1 -0
- package/lib/tools/sine/index.js +50 -0
- package/lib/tools/sine/index.js.map +1 -0
- package/lib/tools/vector/component.js +68 -0
- package/lib/tools/vector/component.js.map +1 -0
- package/lib/tools/vector/index.js +11 -0
- package/lib/tools/vector/index.js.map +1 -0
- package/lib/undo-redo.js +86 -0
- package/lib/undo-redo.js.map +1 -0
- package/lib/use-debounce.js +25 -0
- package/lib/use-debounce.js.map +1 -0
- package/lib/utils.js +229 -0
- package/lib/utils.js.map +1 -0
- package/package.json +33 -45
- package/src/__tests__/bg.test.jsx +250 -0
- package/src/__tests__/coordinates-label.test.jsx +243 -0
- package/src/__tests__/graph-with-controls.test.jsx +198 -0
- package/src/__tests__/graph.test.jsx +721 -0
- package/src/__tests__/grid-setup.test.jsx +645 -0
- package/src/__tests__/grid.test.jsx +22 -0
- package/src/__tests__/key-legend.test.jsx +260 -0
- package/src/__tests__/label-svg-icon.test.jsx +278 -0
- package/src/__tests__/labels.test.jsx +55 -0
- package/src/__tests__/mark-label.test.jsx +63 -0
- package/src/__tests__/toggle-bar.test.jsx +146 -0
- package/src/__tests__/tool-menu.test.jsx +115 -0
- package/src/__tests__/undo-redo.test.jsx +24 -0
- package/src/__tests__/use-debounce.test.js +21 -0
- package/src/__tests__/utils.js +41 -0
- package/src/__tests__/utils.test.js +105 -0
- package/src/axis/__tests__/arrow.test.jsx +38 -0
- package/src/axis/__tests__/axes.test.jsx +216 -0
- package/src/axis/arrow.jsx +57 -0
- package/src/axis/axes.jsx +285 -0
- package/src/axis/index.js +3 -0
- package/src/bg.jsx +96 -0
- package/src/container/__tests__/actions.test.js +105 -0
- package/src/container/__tests__/index.test.jsx +319 -0
- package/src/container/__tests__/marks.test.js +172 -0
- package/src/container/__tests__/middleware.test.js +235 -0
- package/src/container/__tests__/reducer.test.js +324 -0
- package/src/container/actions.js +8 -0
- package/src/container/index.jsx +91 -0
- package/src/container/marks.js +14 -0
- package/src/container/middleware.js +7 -0
- package/src/container/reducer.js +5 -0
- package/src/coordinates-label.jsx +63 -0
- package/src/graph-with-controls.jsx +239 -0
- package/src/graph.jsx +303 -0
- package/src/grid-setup.jsx +432 -0
- package/src/grid.jsx +133 -0
- package/src/index.js +7 -0
- package/src/key-legend.jsx +142 -0
- package/src/label-svg-icon.jsx +39 -0
- package/src/labels.jsx +207 -0
- package/src/mark-label.jsx +244 -0
- package/src/toggle-bar.jsx +224 -0
- package/src/tool-menu.jsx +49 -0
- package/src/tools/absolute/__tests__/component.test.jsx +53 -0
- package/src/tools/absolute/component.jsx +23 -0
- package/src/tools/absolute/index.js +31 -0
- package/src/tools/circle/__tests__/bg-circle.test.jsx +26 -0
- package/src/tools/circle/__tests__/component.test.jsx +494 -0
- package/src/tools/circle/__tests__/index.test.js +480 -0
- package/src/tools/circle/bg-circle.jsx +81 -0
- package/src/tools/circle/component.jsx +264 -0
- package/src/tools/circle/index.js +25 -0
- package/src/tools/exponential/__tests__/component.test.jsx +53 -0
- package/src/tools/exponential/__tests__/index.test.js +729 -0
- package/src/tools/exponential/component.jsx +23 -0
- package/src/tools/exponential/index.js +39 -0
- package/src/tools/index.js +48 -0
- package/src/tools/line/__tests__/component.test.jsx +37 -0
- package/src/tools/line/component.jsx +93 -0
- package/src/tools/line/index.js +4 -0
- package/src/tools/parabola/__tests__/component.test.jsx +48 -0
- package/src/tools/parabola/__tests__/index.test.js +470 -0
- package/src/tools/parabola/component.jsx +23 -0
- package/src/tools/parabola/index.js +31 -0
- package/src/tools/point/__tests__/component.test.jsx +349 -0
- package/src/tools/point/__tests__/index.test.js +241 -0
- package/src/tools/point/component.jsx +126 -0
- package/src/tools/point/index.js +11 -0
- package/src/tools/polygon/__tests__/component.test.jsx +471 -0
- package/src/tools/polygon/__tests__/index.test.js +294 -0
- package/src/tools/polygon/__tests__/line.test.jsx +35 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +61 -0
- package/src/tools/polygon/component.jsx +409 -0
- package/src/tools/polygon/index.js +52 -0
- package/src/tools/polygon/line.jsx +74 -0
- package/src/tools/polygon/polygon.jsx +110 -0
- package/src/tools/ray/__tests__/component.test.jsx +29 -0
- package/src/tools/ray/component.jsx +92 -0
- package/src/tools/ray/index.js +4 -0
- package/src/tools/segment/__tests__/component.test.jsx +28 -0
- package/src/tools/segment/component.jsx +65 -0
- package/src/tools/segment/index.js +4 -0
- package/src/tools/shared/__tests__/arrow-head.test.jsx +31 -0
- package/src/tools/shared/arrow-head.jsx +102 -0
- package/src/tools/shared/icons/CorrectSVG.jsx +32 -0
- package/src/tools/shared/icons/IncorrectSVG.jsx +30 -0
- package/src/tools/shared/icons/MissingSVG.jsx +31 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +109 -0
- package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
- package/src/tools/shared/line/index.jsx +487 -0
- package/src/tools/shared/line/line-path.jsx +80 -0
- package/src/tools/shared/line/with-root-edge.jsx +97 -0
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +91 -0
- package/src/tools/shared/point/__tests__/base-point.test.jsx +87 -0
- package/src/tools/shared/point/arrow-point.jsx +46 -0
- package/src/tools/shared/point/arrow.jsx +37 -0
- package/src/tools/shared/point/base-point.jsx +121 -0
- package/src/tools/shared/point/index.jsx +54 -0
- package/src/tools/shared/styles.js +27 -0
- package/src/tools/shared/types.js +10 -0
- package/src/tools/sine/__tests__/component.test.jsx +51 -0
- package/src/tools/sine/component.jsx +32 -0
- package/src/tools/sine/index.js +33 -0
- package/src/tools/vector/__tests__/component.test.jsx +25 -0
- package/src/tools/vector/component.jsx +56 -0
- package/src/tools/vector/index.js +4 -0
- package/src/undo-redo.jsx +45 -0
- package/src/use-debounce.js +13 -0
- package/src/utils.js +224 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -23
- package/dist/autosize-input.d.ts +0 -10
- package/dist/autosize-input.js +0 -66
- package/dist/axis/arrow.d.ts +0 -13
- package/dist/axis/arrow.js +0 -34
- package/dist/axis/axes.d.ts +0 -132
- package/dist/axis/axes.js +0 -214
- package/dist/axis/index.d.ts +0 -10
- package/dist/bg.d.ts +0 -51
- package/dist/bg.js +0 -44
- package/dist/container/actions.d.ts +0 -15
- package/dist/container/actions.js +0 -7
- package/dist/container/index.d.ts +0 -58
- package/dist/container/index.js +0 -48
- package/dist/container/marks.d.ts +0 -10
- package/dist/container/marks.js +0 -11
- package/dist/container/middleware.d.ts +0 -10
- package/dist/container/middleware.js +0 -4
- package/dist/container/reducer.d.ts +0 -14
- package/dist/container/reducer.js +0 -7
- package/dist/coordinates-label.d.ts +0 -50
- package/dist/coordinates-label.js +0 -46
- package/dist/graph-with-controls.d.ts +0 -88
- package/dist/graph-with-controls.js +0 -154
- package/dist/graph.d.ts +0 -126
- package/dist/graph.js +0 -209
- package/dist/grid-setup.d.ts +0 -27
- package/dist/grid-setup.js +0 -307
- package/dist/grid.d.ts +0 -43
- package/dist/grid.js +0 -59
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -7
- package/dist/key-legend.d.ts +0 -21
- package/dist/key-legend.js +0 -231
- package/dist/label-svg-icon.d.ts +0 -18
- package/dist/label-svg-icon.js +0 -42
- package/dist/labels.d.ts +0 -37
- package/dist/labels.js +0 -152
- package/dist/mark-label.d.ts +0 -58
- package/dist/mark-label.js +0 -171
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +0 -101
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +0 -63
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +0 -44
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +0 -9
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +0 -14
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +0 -21
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +0 -16
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +0 -8
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +0 -15
- package/dist/node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js +0 -2
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +0 -6
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +0 -50
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +0 -18
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +0 -10
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +0 -47
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +0 -50
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +0 -9
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +0 -53
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +0 -57
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +0 -91
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +0 -21
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +0 -32
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -33
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +0 -32
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +0 -28
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +0 -10
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +0 -15
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +0 -8
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +0 -15
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +0 -19
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +0 -18
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +0 -19
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +0 -10
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +0 -20
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +0 -20
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +0 -37
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +0 -509
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +0 -108
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +0 -31
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +0 -45
- package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +0 -471
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +0 -49
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +0 -34
- package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +0 -185
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +0 -198
- 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
- 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
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +0 -10
- package/dist/toggle-bar.d.ts +0 -40
- package/dist/toggle-bar.js +0 -155
- package/dist/tool-menu.d.ts +0 -29
- package/dist/tool-menu.js +0 -41
- package/dist/tools/absolute/component.d.ts +0 -16
- package/dist/tools/absolute/component.js +0 -15
- package/dist/tools/absolute/index.d.ts +0 -20
- package/dist/tools/absolute/index.js +0 -32
- package/dist/tools/circle/bg-circle.d.ts +0 -116
- package/dist/tools/circle/bg-circle.js +0 -72
- package/dist/tools/circle/component.d.ts +0 -83
- package/dist/tools/circle/component.js +0 -195
- package/dist/tools/circle/index.d.ts +0 -20
- package/dist/tools/circle/index.js +0 -22
- package/dist/tools/exponential/component.d.ts +0 -16
- package/dist/tools/exponential/component.js +0 -14
- package/dist/tools/exponential/index.d.ts +0 -20
- package/dist/tools/exponential/index.js +0 -32
- package/dist/tools/index.d.ts +0 -27
- package/dist/tools/index.js +0 -55
- package/dist/tools/line/component.d.ts +0 -124
- package/dist/tools/line/component.js +0 -72
- package/dist/tools/line/index.d.ts +0 -13
- package/dist/tools/line/index.js +0 -6
- package/dist/tools/parabola/component.d.ts +0 -16
- package/dist/tools/parabola/component.js +0 -14
- package/dist/tools/parabola/index.d.ts +0 -20
- package/dist/tools/parabola/index.js +0 -32
- package/dist/tools/point/component.d.ts +0 -50
- package/dist/tools/point/component.js +0 -85
- package/dist/tools/point/index.d.ts +0 -15
- package/dist/tools/point/index.js +0 -13
- package/dist/tools/polygon/component.d.ts +0 -120
- package/dist/tools/polygon/component.js +0 -262
- package/dist/tools/polygon/index.d.ts +0 -19
- package/dist/tools/polygon/index.js +0 -55
- package/dist/tools/polygon/line.d.ts +0 -125
- package/dist/tools/polygon/line.js +0 -63
- package/dist/tools/polygon/polygon.d.ts +0 -122
- package/dist/tools/polygon/polygon.js +0 -74
- package/dist/tools/ray/component.d.ts +0 -101
- package/dist/tools/ray/component.js +0 -71
- package/dist/tools/ray/index.d.ts +0 -13
- package/dist/tools/ray/index.js +0 -6
- package/dist/tools/segment/component.d.ts +0 -100
- package/dist/tools/segment/component.js +0 -52
- package/dist/tools/segment/index.d.ts +0 -13
- package/dist/tools/segment/index.js +0 -6
- package/dist/tools/shared/arrow-head.d.ts +0 -51
- package/dist/tools/shared/arrow-head.js +0 -63
- package/dist/tools/shared/icons/CorrectSVG.d.ts +0 -26
- package/dist/tools/shared/icons/CorrectSVG.js +0 -29
- package/dist/tools/shared/icons/IncorrectSVG.d.ts +0 -26
- package/dist/tools/shared/icons/IncorrectSVG.js +0 -27
- package/dist/tools/shared/icons/MissingSVG.d.ts +0 -26
- package/dist/tools/shared/icons/MissingSVG.js +0 -28
- package/dist/tools/shared/line/index.d.ts +0 -245
- package/dist/tools/shared/line/index.js +0 -319
- package/dist/tools/shared/line/line-path.d.ts +0 -57
- package/dist/tools/shared/line/line-path.js +0 -71
- package/dist/tools/shared/line/with-root-edge.d.ts +0 -142
- package/dist/tools/shared/line/with-root-edge.js +0 -73
- package/dist/tools/shared/point/arrow-point.d.ts +0 -56
- package/dist/tools/shared/point/arrow-point.js +0 -41
- package/dist/tools/shared/point/arrow.d.ts +0 -45
- package/dist/tools/shared/point/arrow.js +0 -35
- package/dist/tools/shared/point/base-point.d.ts +0 -52
- package/dist/tools/shared/point/base-point.js +0 -103
- package/dist/tools/shared/point/index.d.ts +0 -216
- package/dist/tools/shared/point/index.js +0 -45
- package/dist/tools/shared/styles.d.ts +0 -29
- package/dist/tools/shared/styles.js +0 -20
- package/dist/tools/shared/types.d.ts +0 -21
- package/dist/tools/shared/types.js +0 -11
- package/dist/tools/sine/component.d.ts +0 -16
- package/dist/tools/sine/component.js +0 -22
- package/dist/tools/sine/index.d.ts +0 -20
- package/dist/tools/sine/index.js +0 -32
- package/dist/tools/vector/component.d.ts +0 -100
- package/dist/tools/vector/component.js +0 -44
- package/dist/tools/vector/index.d.ts +0 -13
- package/dist/tools/vector/index.js +0 -6
- package/dist/undo-redo.d.ts +0 -22
- package/dist/undo-redo.js +0 -47
- package/dist/use-debounce.d.ts +0 -9
- package/dist/use-debounce.js +0 -13
- package/dist/utils.d.ts +0 -61
- package/dist/utils.js +0 -75
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
jest.mock('@pie-lib/drag', () => ({
|
|
8
|
+
DragProvider: ({ children }) => <div data-testid="drag-provider">{children}</div>,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock('@dnd-kit/core', () => ({
|
|
12
|
+
useDraggable: jest.fn(() => ({
|
|
13
|
+
attributes: {
|
|
14
|
+
role: 'button',
|
|
15
|
+
tabIndex: 0,
|
|
16
|
+
},
|
|
17
|
+
listeners: {
|
|
18
|
+
onPointerDown: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
setNodeRef: jest.fn(),
|
|
21
|
+
transform: null,
|
|
22
|
+
transition: null,
|
|
23
|
+
isDragging: false,
|
|
24
|
+
})),
|
|
25
|
+
useDroppable: jest.fn(() => ({
|
|
26
|
+
setNodeRef: jest.fn(),
|
|
27
|
+
isOver: false,
|
|
28
|
+
active: null,
|
|
29
|
+
})),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
jest.mock('@dnd-kit/utilities', () => ({
|
|
33
|
+
CSS: {
|
|
34
|
+
Transform: {
|
|
35
|
+
toString: jest.fn((transform) => (transform ? 'translate3d(0, 0, 0)' : '')),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
jest.mock('@dnd-kit/sortable', () => ({
|
|
41
|
+
arrayMove: jest.fn((array, from, to) => {
|
|
42
|
+
const newArray = [...array];
|
|
43
|
+
const [removed] = newArray.splice(from, 1);
|
|
44
|
+
newArray.splice(to, 0, removed);
|
|
45
|
+
return newArray;
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
jest.mock('@pie-lib/translator', () => ({
|
|
50
|
+
translator: {
|
|
51
|
+
t: (key) => {
|
|
52
|
+
const parts = key.split('.');
|
|
53
|
+
return parts[parts.length - 1];
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
describe('ToggleBar', () => {
|
|
59
|
+
let onChange = jest.fn();
|
|
60
|
+
let onChangeToolsOrder = jest.fn();
|
|
61
|
+
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
onChange.mockClear();
|
|
64
|
+
onChangeToolsOrder.mockClear();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const renderComponent = (extras) => {
|
|
68
|
+
const defaults = {
|
|
69
|
+
className: 'className',
|
|
70
|
+
onChange,
|
|
71
|
+
onChangeToolsOrder,
|
|
72
|
+
options: ['point', 'line'],
|
|
73
|
+
language: 'en',
|
|
74
|
+
};
|
|
75
|
+
const props = { ...defaults, ...extras };
|
|
76
|
+
return render(<ToggleBar {...props} />);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
describe('rendering', () => {
|
|
80
|
+
it('renders without crashing', () => {
|
|
81
|
+
const { container } = renderComponent();
|
|
82
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renders tool buttons for valid tools', () => {
|
|
86
|
+
renderComponent({ options: ['point', 'line', 'circle'] });
|
|
87
|
+
expect(screen.getByText(/point/i)).toBeInTheDocument();
|
|
88
|
+
expect(screen.getByText(/line/i)).toBeInTheDocument();
|
|
89
|
+
expect(screen.getByText(/circle/i)).toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('does not render invalid tool options', () => {
|
|
93
|
+
renderComponent({ options: ['point', 'invalid-tool', 'line'] });
|
|
94
|
+
expect(screen.getByText(/point/i)).toBeInTheDocument();
|
|
95
|
+
expect(screen.getByText(/line/i)).toBeInTheDocument();
|
|
96
|
+
expect(screen.queryByText(/invalid-tool/i)).not.toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('highlights selected tool', () => {
|
|
100
|
+
const { container } = renderComponent({ selectedToolType: 'line' });
|
|
101
|
+
const selectedButton = screen.getByText(/line/i).closest('button');
|
|
102
|
+
expect(selectedButton).toHaveAttribute('value', 'line');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('interactions', () => {
|
|
107
|
+
it('calls onChange when tool button is clicked', async () => {
|
|
108
|
+
const user = userEvent.setup();
|
|
109
|
+
renderComponent({ options: ['point', 'line'] });
|
|
110
|
+
|
|
111
|
+
const pointButton = screen.getByText(/point/i).closest('button');
|
|
112
|
+
await user.click(pointButton);
|
|
113
|
+
|
|
114
|
+
expect(onChange).toHaveBeenCalledWith('point');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('calls onChange with selected tool type', async () => {
|
|
118
|
+
const user = userEvent.setup();
|
|
119
|
+
renderComponent({ options: ['point', 'line'], selectedToolType: 'point' });
|
|
120
|
+
|
|
121
|
+
const lineButton = screen.getByText(/line/i).closest('button');
|
|
122
|
+
await user.click(lineButton);
|
|
123
|
+
|
|
124
|
+
expect(onChange).toHaveBeenCalledWith('line');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('disables buttons when disabled prop is true', () => {
|
|
128
|
+
renderComponent({ disabled: true, options: ['point', 'line'] });
|
|
129
|
+
|
|
130
|
+
const pointButton = screen.getByText(/point/i).closest('button');
|
|
131
|
+
const lineButton = screen.getByText(/line/i).closest('button');
|
|
132
|
+
|
|
133
|
+
expect(pointButton).toBeDisabled();
|
|
134
|
+
expect(lineButton).toBeDisabled();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('does not call onChange when disabled', () => {
|
|
138
|
+
renderComponent({ disabled: true, options: ['point'] });
|
|
139
|
+
|
|
140
|
+
const pointButton = screen.getByText(/point/i).closest('button');
|
|
141
|
+
expect(pointButton).toBeDisabled();
|
|
142
|
+
// Note: Cannot test click on disabled button with pointer-events: none
|
|
143
|
+
// The disabled state is verified above
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
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 ToolMenu from '../tool-menu';
|
|
6
|
+
|
|
7
|
+
jest.mock('@pie-lib/drag', () => ({
|
|
8
|
+
DragProvider: ({ children }) => <div data-testid="drag-provider">{children}</div>,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock('@dnd-kit/core', () => ({
|
|
12
|
+
useDraggable: jest.fn(() => ({
|
|
13
|
+
attributes: {
|
|
14
|
+
role: 'button',
|
|
15
|
+
tabIndex: 0,
|
|
16
|
+
},
|
|
17
|
+
listeners: {
|
|
18
|
+
onPointerDown: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
setNodeRef: jest.fn(),
|
|
21
|
+
transform: null,
|
|
22
|
+
transition: null,
|
|
23
|
+
isDragging: false,
|
|
24
|
+
})),
|
|
25
|
+
useDroppable: jest.fn(() => ({
|
|
26
|
+
setNodeRef: jest.fn(),
|
|
27
|
+
isOver: false,
|
|
28
|
+
active: null,
|
|
29
|
+
})),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
jest.mock('@dnd-kit/utilities', () => ({
|
|
33
|
+
CSS: {
|
|
34
|
+
Transform: {
|
|
35
|
+
toString: jest.fn((transform) => (transform ? 'translate3d(0, 0, 0)' : '')),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
jest.mock('@dnd-kit/sortable', () => ({
|
|
41
|
+
arrayMove: jest.fn((array, from, to) => {
|
|
42
|
+
const newArray = [...array];
|
|
43
|
+
const [removed] = newArray.splice(from, 1);
|
|
44
|
+
newArray.splice(to, 0, removed);
|
|
45
|
+
return newArray;
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
describe('ToolMenu', () => {
|
|
50
|
+
let onChange = jest.fn();
|
|
51
|
+
let onChangeTools = jest.fn();
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
onChange.mockClear();
|
|
55
|
+
onChangeTools.mockClear();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const renderComponent = (extras) => {
|
|
59
|
+
const defaults = {
|
|
60
|
+
className: 'className',
|
|
61
|
+
onChange,
|
|
62
|
+
onChangeTools,
|
|
63
|
+
currentToolType: 'point',
|
|
64
|
+
toolbarTools: ['point', 'line'],
|
|
65
|
+
language: 'en',
|
|
66
|
+
};
|
|
67
|
+
const props = { ...defaults, ...extras };
|
|
68
|
+
return render(<ToolMenu {...props} />);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
describe('rendering', () => {
|
|
72
|
+
it('renders without crashing', () => {
|
|
73
|
+
const { container } = renderComponent();
|
|
74
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('renders ToggleBar with correct props', () => {
|
|
78
|
+
renderComponent({ toolbarTools: ['point', 'line', 'circle'] });
|
|
79
|
+
expect(screen.getByText(/point/i)).toBeInTheDocument();
|
|
80
|
+
expect(screen.getByText(/line/i)).toBeInTheDocument();
|
|
81
|
+
expect(screen.getByText(/circle/i)).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('passes currentToolType to ToggleBar', () => {
|
|
85
|
+
renderComponent({ currentToolType: 'line' });
|
|
86
|
+
const selectedButton = screen.getByText(/line/i).closest('button');
|
|
87
|
+
expect(selectedButton).toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('interactions', () => {
|
|
92
|
+
it('calls onChange when tool is selected', async () => {
|
|
93
|
+
const user = userEvent.setup();
|
|
94
|
+
renderComponent();
|
|
95
|
+
|
|
96
|
+
const lineButton = screen.getByText(/line/i).closest('button');
|
|
97
|
+
await user.click(lineButton);
|
|
98
|
+
|
|
99
|
+
expect(onChange).toHaveBeenCalledWith('line');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('calls onChangeTools when tools order changes', () => {
|
|
103
|
+
renderComponent({ draggableTools: true });
|
|
104
|
+
// Note: Drag-and-drop testing requires more complex setup with @dnd-kit/test-utils
|
|
105
|
+
// For now, we verify the component renders with draggableTools enabled
|
|
106
|
+
expect(screen.getByText(/point/i)).toBeInTheDocument();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('disables tools when disabled prop is true', () => {
|
|
110
|
+
renderComponent({ disabled: true });
|
|
111
|
+
const pointButton = screen.getByText(/point/i).closest('button');
|
|
112
|
+
expect(pointButton).toBeDisabled();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
const renderComponent = (extras) => {
|
|
10
|
+
const defaults = {
|
|
11
|
+
onUndo,
|
|
12
|
+
onRedo,
|
|
13
|
+
onReset,
|
|
14
|
+
};
|
|
15
|
+
const props = { ...defaults, ...extras };
|
|
16
|
+
return render(<UndoRedo {...props} />);
|
|
17
|
+
};
|
|
18
|
+
describe('rendering', () => {
|
|
19
|
+
it('renders without crashing', () => {
|
|
20
|
+
const { container } = renderComponent();
|
|
21
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const scaleMock = () => {
|
|
2
|
+
const fn = jest.fn((n) => n);
|
|
3
|
+
fn.invert = jest.fn((n) => n);
|
|
4
|
+
fn.domain = jest.fn(() => fn);
|
|
5
|
+
fn.range = jest.fn(() => fn);
|
|
6
|
+
fn.copy = jest.fn(() => scaleMock());
|
|
7
|
+
return fn;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
11
|
+
scale: {
|
|
12
|
+
x: scaleMock(),
|
|
13
|
+
y: scaleMock(),
|
|
14
|
+
},
|
|
15
|
+
snap: {
|
|
16
|
+
x: jest.fn((n) => n),
|
|
17
|
+
y: jest.fn((n) => n),
|
|
18
|
+
},
|
|
19
|
+
domain: {
|
|
20
|
+
min: dmin,
|
|
21
|
+
max: dmax,
|
|
22
|
+
step: 1,
|
|
23
|
+
},
|
|
24
|
+
range: {
|
|
25
|
+
min: rmin,
|
|
26
|
+
max: rmax,
|
|
27
|
+
step: 1,
|
|
28
|
+
},
|
|
29
|
+
size: {
|
|
30
|
+
width: 400,
|
|
31
|
+
height: 400,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const xy = (x, y, index) => {
|
|
36
|
+
const out = { x, y, index };
|
|
37
|
+
if (!Number.isFinite(index)) {
|
|
38
|
+
delete out.index;
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as utils from '../utils';
|
|
2
|
+
|
|
3
|
+
const xy = (x, y) => ({ x, y });
|
|
4
|
+
|
|
5
|
+
const tick = (isMajor, v) => ({
|
|
6
|
+
major: isMajor,
|
|
7
|
+
value: v,
|
|
8
|
+
x: v,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const major = tick.bind(null, true);
|
|
12
|
+
const minor = tick.bind(null, false);
|
|
13
|
+
|
|
14
|
+
describe('utils', () => {
|
|
15
|
+
describe('polygonToArea', () => {
|
|
16
|
+
const assertPolygon = (points, area) => {
|
|
17
|
+
it(`converts ${points} -> ${area}`, () => {
|
|
18
|
+
const result = utils.polygonToArea(points);
|
|
19
|
+
expect(result).toEqual(area);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
assertPolygon([xy(0, 0), xy(1, 1), xy(1, -1)], {
|
|
23
|
+
left: 0,
|
|
24
|
+
top: 1,
|
|
25
|
+
bottom: -1,
|
|
26
|
+
right: 1,
|
|
27
|
+
});
|
|
28
|
+
assertPolygon([xy(0, 0), xy(3, 0), xy(2, -1), xy(4, -3), xy(1, -4), xy(2, -2)], {
|
|
29
|
+
left: 0,
|
|
30
|
+
top: 0,
|
|
31
|
+
bottom: -4,
|
|
32
|
+
right: 4,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('lineToArea', () => {
|
|
37
|
+
const assertLine = (from, to, expected) => {
|
|
38
|
+
it(`${from},${to} => ${expected}`, () => {
|
|
39
|
+
const result = utils.lineToArea(from, to);
|
|
40
|
+
expect(result).toEqual(expected);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
assertLine(xy(1, 1), xy(2, 2), { left: 1, top: 2, bottom: 1, right: 2 });
|
|
45
|
+
assertLine(xy(-1, 4), xy(4, -3), {
|
|
46
|
+
left: -1,
|
|
47
|
+
top: 4,
|
|
48
|
+
bottom: -3,
|
|
49
|
+
right: 4,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('getTickValues', () => {
|
|
54
|
+
const assertGetTickValues = (props, expected) => {
|
|
55
|
+
it(` => ${expected}`, () => {
|
|
56
|
+
const result = utils.getTickValues(props);
|
|
57
|
+
expect(result).toEqual(expected);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
assertGetTickValues({ min: 0, max: 10, step: 1 }, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
62
|
+
assertGetTickValues({ min: 0, max: 3, step: 0.5 }, [0, 0.5, 1, 1.5, 2, 2.5, 3]);
|
|
63
|
+
assertGetTickValues({ min: -0.2, max: 2, step: 0.6 }, [0, 0.6, 1.2, 1.8]);
|
|
64
|
+
assertGetTickValues({ min: -3.4, max: 6.2, step: 1.2 }, [0, -1.2, -2.4, 1.2, 2.4, 3.6, 4.8, 6]);
|
|
65
|
+
|
|
66
|
+
assertGetTickValues(
|
|
67
|
+
{ min: 0.6, max: 4.8, step: 0.3 },
|
|
68
|
+
[0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.2, 4.5, 4.8],
|
|
69
|
+
);
|
|
70
|
+
assertGetTickValues(
|
|
71
|
+
{ min: 0.5, max: 4.9, step: 0.3 },
|
|
72
|
+
[0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.2, 4.5, 4.8],
|
|
73
|
+
);
|
|
74
|
+
assertGetTickValues(
|
|
75
|
+
{ min: 0, max: 3, step: 0.125 },
|
|
76
|
+
[
|
|
77
|
+
0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2, 2.125, 2.25,
|
|
78
|
+
2.375, 2.5, 2.625, 2.75, 2.875, 3,
|
|
79
|
+
],
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('countWords', () => {
|
|
84
|
+
it('should return 1 if label is undefined', () => {
|
|
85
|
+
const label = undefined;
|
|
86
|
+
const result = utils.countWords(label);
|
|
87
|
+
|
|
88
|
+
expect(result).toEqual(1);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should return 1 if label is null', () => {
|
|
92
|
+
const label = null;
|
|
93
|
+
const result = utils.countWords(label);
|
|
94
|
+
|
|
95
|
+
expect(result).toEqual(1);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should return 3 if label has 3 words', () => {
|
|
99
|
+
const label = 'Number of months';
|
|
100
|
+
const result = utils.countWords(label);
|
|
101
|
+
|
|
102
|
+
expect(result).toEqual(3);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { render } from '@pie-lib/test-utils';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Arrow } from '../arrow';
|
|
4
|
+
|
|
5
|
+
describe('Arrow', () => {
|
|
6
|
+
let onChange = jest.fn();
|
|
7
|
+
const renderComponent = (extras) => {
|
|
8
|
+
const defaults = {
|
|
9
|
+
classes: {},
|
|
10
|
+
className: 'className',
|
|
11
|
+
onChange,
|
|
12
|
+
scale: {
|
|
13
|
+
x: jest.fn((n) => n),
|
|
14
|
+
y: jest.fn((n) => n),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const props = { ...defaults, ...extras };
|
|
18
|
+
return render(<Arrow {...props} />);
|
|
19
|
+
};
|
|
20
|
+
describe('rendering', () => {
|
|
21
|
+
it('renders with direction up', () => {
|
|
22
|
+
const { container } = renderComponent({ direction: 'up' });
|
|
23
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('renders with direction down', () => {
|
|
26
|
+
const { container } = renderComponent({ direction: 'down' });
|
|
27
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
it('renders with direction left', () => {
|
|
30
|
+
const { container } = renderComponent({ direction: 'left' });
|
|
31
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('renders with direction right', () => {
|
|
34
|
+
const { container } = renderComponent({ direction: 'right' });
|
|
35
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { render } from '@pie-lib/test-utils';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { graphProps } from '../../__tests__/utils';
|
|
4
|
+
|
|
5
|
+
import Axes, { firstNegativeValue, RawXAxis, RawYAxis, sharedValues } from '../axes';
|
|
6
|
+
|
|
7
|
+
describe('RawXAxis', () => {
|
|
8
|
+
let onChange = jest.fn();
|
|
9
|
+
const renderComponent = (extras) => {
|
|
10
|
+
const defaults = {
|
|
11
|
+
classes: {},
|
|
12
|
+
className: 'className',
|
|
13
|
+
onChange,
|
|
14
|
+
graphProps: graphProps(),
|
|
15
|
+
includeArrows: {
|
|
16
|
+
left: true,
|
|
17
|
+
right: true,
|
|
18
|
+
up: true,
|
|
19
|
+
down: true,
|
|
20
|
+
},
|
|
21
|
+
columnTicksValues: [-1, 0, 1],
|
|
22
|
+
skipValues: [],
|
|
23
|
+
distanceFromOriginToFirstNegativeY: 0,
|
|
24
|
+
dy: 0,
|
|
25
|
+
};
|
|
26
|
+
const props = { ...defaults, ...extras };
|
|
27
|
+
return render(<RawXAxis {...props} />);
|
|
28
|
+
};
|
|
29
|
+
describe('rendering', () => {
|
|
30
|
+
it('renders without crashing', () => {
|
|
31
|
+
const { container } = renderComponent();
|
|
32
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('RawYAxis', () => {
|
|
38
|
+
let onChange = jest.fn();
|
|
39
|
+
const renderComponent = (extras) => {
|
|
40
|
+
const defaults = {
|
|
41
|
+
classes: {},
|
|
42
|
+
className: 'className',
|
|
43
|
+
onChange,
|
|
44
|
+
graphProps: graphProps(),
|
|
45
|
+
includeArrows: {
|
|
46
|
+
left: true,
|
|
47
|
+
right: true,
|
|
48
|
+
up: true,
|
|
49
|
+
down: true,
|
|
50
|
+
},
|
|
51
|
+
rowTickValues: [-1, 0, 1],
|
|
52
|
+
skipValues: [],
|
|
53
|
+
};
|
|
54
|
+
const props = { ...defaults, ...extras };
|
|
55
|
+
return render(<RawYAxis {...props} />);
|
|
56
|
+
};
|
|
57
|
+
describe('rendering', () => {
|
|
58
|
+
it('renders without crashing', () => {
|
|
59
|
+
const { container } = renderComponent();
|
|
60
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const customScaleMock = (distance) => {
|
|
66
|
+
const fn = jest.fn((n) => n * distance);
|
|
67
|
+
fn.invert = jest.fn((n) => n * distance);
|
|
68
|
+
fn.domain = jest.fn(() => fn);
|
|
69
|
+
fn.range = jest.fn(() => fn);
|
|
70
|
+
fn.copy = jest.fn(() => customScaleMock(distance));
|
|
71
|
+
return fn;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
describe('Axes', () => {
|
|
75
|
+
let onChange = jest.fn();
|
|
76
|
+
|
|
77
|
+
const customGraphProps = {
|
|
78
|
+
...graphProps(),
|
|
79
|
+
domain: {
|
|
80
|
+
min: -2,
|
|
81
|
+
max: 2,
|
|
82
|
+
labelStep: 1,
|
|
83
|
+
step: 1,
|
|
84
|
+
},
|
|
85
|
+
range: {
|
|
86
|
+
min: -2,
|
|
87
|
+
max: 2,
|
|
88
|
+
step: 1,
|
|
89
|
+
labelStep: 1,
|
|
90
|
+
},
|
|
91
|
+
scale: {
|
|
92
|
+
x: customScaleMock(200),
|
|
93
|
+
y: customScaleMock(150),
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const renderComponent = (extras) => {
|
|
98
|
+
const defaults = {
|
|
99
|
+
classes: {},
|
|
100
|
+
className: 'className',
|
|
101
|
+
onChange,
|
|
102
|
+
graphProps: customGraphProps,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const props = { ...defaults, ...extras };
|
|
106
|
+
return render(<Axes {...props} />);
|
|
107
|
+
};
|
|
108
|
+
describe('rendering', () => {
|
|
109
|
+
it('renders without crashing', () => {
|
|
110
|
+
const { container } = renderComponent();
|
|
111
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('firstNegativeValue', () => {
|
|
117
|
+
it('should return undefined for undefined interval', () => {
|
|
118
|
+
const interval = undefined;
|
|
119
|
+
const result = firstNegativeValue(interval);
|
|
120
|
+
expect(result).toEqual(undefined);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should return undefined for empty interval', () => {
|
|
124
|
+
const interval = [];
|
|
125
|
+
const result = firstNegativeValue(interval);
|
|
126
|
+
expect(result).toEqual(undefined);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should return undefined if there is no negative in interval array', () => {
|
|
130
|
+
const interval = [1, 5, 7, 4, 5];
|
|
131
|
+
const result = firstNegativeValue(interval);
|
|
132
|
+
expect(result).toEqual(undefined);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should return first negative number from interval', () => {
|
|
136
|
+
const interval = [1, 5, 7, -2, 4, 5, -1];
|
|
137
|
+
const result = firstNegativeValue(interval);
|
|
138
|
+
expect(result).toEqual(-2);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('sharedValues', () => {
|
|
143
|
+
it('should be empty array if firstNegativeValue for one of the axes is undefined', () => {
|
|
144
|
+
// x
|
|
145
|
+
const intervalX = [1, 2, 3, 4, 5, 6];
|
|
146
|
+
const firstNegativeX = firstNegativeValue(intervalX);
|
|
147
|
+
const distanceFromOriginToFirstNegativeX = -22;
|
|
148
|
+
|
|
149
|
+
// y
|
|
150
|
+
const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
|
|
151
|
+
const firstNegativeY = firstNegativeValue(intervalY);
|
|
152
|
+
const distanceFromOriginToFirstNegativeY = -22;
|
|
153
|
+
|
|
154
|
+
const deltaAllowance = 5;
|
|
155
|
+
|
|
156
|
+
const result = sharedValues(
|
|
157
|
+
firstNegativeX,
|
|
158
|
+
firstNegativeY,
|
|
159
|
+
distanceFromOriginToFirstNegativeX,
|
|
160
|
+
distanceFromOriginToFirstNegativeY,
|
|
161
|
+
deltaAllowance,
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(result).toEqual([]);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should be empty array if firstNegativeX and firstNegativeY are equal but they do not overlap', () => {
|
|
168
|
+
// x
|
|
169
|
+
const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
|
|
170
|
+
const firstNegativeX = firstNegativeValue(intervalX);
|
|
171
|
+
const distanceFromOriginToFirstNegativeX = -7;
|
|
172
|
+
|
|
173
|
+
// y
|
|
174
|
+
const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
|
|
175
|
+
const firstNegativeY = firstNegativeValue(intervalY);
|
|
176
|
+
const distanceFromOriginToFirstNegativeY = -22;
|
|
177
|
+
|
|
178
|
+
const deltaAllowance = 5;
|
|
179
|
+
|
|
180
|
+
const result = sharedValues(
|
|
181
|
+
firstNegativeX,
|
|
182
|
+
firstNegativeY,
|
|
183
|
+
distanceFromOriginToFirstNegativeX,
|
|
184
|
+
distanceFromOriginToFirstNegativeY,
|
|
185
|
+
deltaAllowance,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(result).toEqual([]);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should be -1 if firstNegativeX and firstNegativeY are equal and they overlap', () => {
|
|
192
|
+
// x
|
|
193
|
+
const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
|
|
194
|
+
const firstNegativeX = firstNegativeValue(intervalX);
|
|
195
|
+
const distanceFromOriginToFirstNegativeX = -20;
|
|
196
|
+
|
|
197
|
+
// y
|
|
198
|
+
const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
|
|
199
|
+
const firstNegativeY = firstNegativeValue(intervalY);
|
|
200
|
+
const distanceFromOriginToFirstNegativeY = -22;
|
|
201
|
+
|
|
202
|
+
const deltaAllowance = 5;
|
|
203
|
+
const dy = -20; // dy needs to be within the range for the condition to pass
|
|
204
|
+
|
|
205
|
+
const result = sharedValues(
|
|
206
|
+
firstNegativeX,
|
|
207
|
+
firstNegativeY,
|
|
208
|
+
distanceFromOriginToFirstNegativeX,
|
|
209
|
+
distanceFromOriginToFirstNegativeY,
|
|
210
|
+
deltaAllowance,
|
|
211
|
+
dy,
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
expect(result).toEqual([-1]);
|
|
215
|
+
});
|
|
216
|
+
});
|