@pie-lib/graphing 4.0.5-next.3 → 4.0.5-next.30
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/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/autosize-input.d.ts +10 -0
- package/dist/autosize-input.js +66 -0
- package/dist/axis/arrow.d.ts +13 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +132 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +10 -0
- package/dist/bg.d.ts +51 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +15 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +58 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +10 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +10 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +14 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +88 -0
- package/dist/graph-with-controls.js +154 -0
- package/dist/graph.d.ts +126 -0
- package/dist/graph.js +209 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +43 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7 -0
- package/dist/key-legend.d.ts +21 -0
- package/dist/key-legend.js +231 -0
- package/dist/label-svg-icon.d.ts +18 -0
- package/dist/label-svg-icon.js +42 -0
- package/dist/labels.d.ts +37 -0
- package/dist/labels.js +152 -0
- package/dist/mark-label.d.ts +58 -0
- package/dist/mark-label.js +171 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +101 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +63 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +44 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
- package/dist/node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js +2 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +50 -0
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +18 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +47 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +50 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +53 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +57 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +91 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +21 -0
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +8 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +18 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +20 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +20 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
- package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +471 -0
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
- package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
- 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 +53 -0
- 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 +51 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +10 -0
- package/dist/toggle-bar.d.ts +40 -0
- package/dist/toggle-bar.js +155 -0
- package/dist/tool-menu.d.ts +29 -0
- package/dist/tool-menu.js +41 -0
- package/dist/tools/absolute/component.d.ts +16 -0
- package/dist/tools/absolute/component.js +15 -0
- package/dist/tools/absolute/index.d.ts +20 -0
- package/dist/tools/absolute/index.js +32 -0
- package/dist/tools/circle/bg-circle.d.ts +116 -0
- package/dist/tools/circle/bg-circle.js +72 -0
- package/dist/tools/circle/component.d.ts +83 -0
- package/dist/tools/circle/component.js +195 -0
- package/dist/tools/circle/index.d.ts +20 -0
- package/dist/tools/circle/index.js +22 -0
- package/dist/tools/exponential/component.d.ts +16 -0
- package/dist/tools/exponential/component.js +14 -0
- package/dist/tools/exponential/index.d.ts +20 -0
- package/dist/tools/exponential/index.js +32 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/line/component.d.ts +124 -0
- package/dist/tools/line/component.js +72 -0
- package/dist/tools/line/index.d.ts +13 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/parabola/component.d.ts +16 -0
- package/dist/tools/parabola/component.js +14 -0
- package/dist/tools/parabola/index.d.ts +20 -0
- package/dist/tools/parabola/index.js +32 -0
- package/dist/tools/point/component.d.ts +50 -0
- package/dist/tools/point/component.js +85 -0
- package/dist/tools/point/index.d.ts +15 -0
- package/dist/tools/point/index.js +13 -0
- package/dist/tools/polygon/component.d.ts +120 -0
- package/dist/tools/polygon/component.js +262 -0
- package/dist/tools/polygon/index.d.ts +19 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +125 -0
- package/dist/tools/polygon/line.js +63 -0
- package/dist/tools/polygon/polygon.d.ts +122 -0
- package/dist/tools/polygon/polygon.js +74 -0
- package/dist/tools/ray/component.d.ts +101 -0
- package/dist/tools/ray/component.js +71 -0
- package/dist/tools/ray/index.d.ts +13 -0
- package/dist/tools/ray/index.js +6 -0
- package/dist/tools/segment/component.d.ts +100 -0
- package/dist/tools/segment/component.js +52 -0
- package/dist/tools/segment/index.d.ts +13 -0
- package/dist/tools/segment/index.js +6 -0
- package/dist/tools/shared/arrow-head.d.ts +51 -0
- package/dist/tools/shared/arrow-head.js +63 -0
- package/dist/tools/shared/icons/CorrectSVG.d.ts +26 -0
- package/dist/tools/shared/icons/CorrectSVG.js +29 -0
- package/dist/tools/shared/icons/IncorrectSVG.d.ts +26 -0
- package/dist/tools/shared/icons/IncorrectSVG.js +27 -0
- package/dist/tools/shared/icons/MissingSVG.d.ts +26 -0
- package/dist/tools/shared/icons/MissingSVG.js +28 -0
- package/dist/tools/shared/line/index.d.ts +245 -0
- package/dist/tools/shared/line/index.js +319 -0
- package/dist/tools/shared/line/line-path.d.ts +57 -0
- package/dist/tools/shared/line/line-path.js +71 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +142 -0
- package/dist/tools/shared/line/with-root-edge.js +73 -0
- package/dist/tools/shared/point/arrow-point.d.ts +56 -0
- package/dist/tools/shared/point/arrow-point.js +41 -0
- package/dist/tools/shared/point/arrow.d.ts +45 -0
- package/dist/tools/shared/point/arrow.js +35 -0
- package/dist/tools/shared/point/base-point.d.ts +52 -0
- package/dist/tools/shared/point/base-point.js +103 -0
- package/dist/tools/shared/point/index.d.ts +216 -0
- package/dist/tools/shared/point/index.js +45 -0
- package/dist/tools/shared/styles.d.ts +29 -0
- package/dist/tools/shared/styles.js +20 -0
- package/dist/tools/shared/types.d.ts +21 -0
- package/dist/tools/shared/types.js +11 -0
- package/dist/tools/sine/component.d.ts +16 -0
- package/dist/tools/sine/component.js +22 -0
- package/dist/tools/sine/index.d.ts +20 -0
- package/dist/tools/sine/index.js +32 -0
- package/dist/tools/vector/component.d.ts +100 -0
- package/dist/tools/vector/component.js +44 -0
- package/dist/tools/vector/index.d.ts +13 -0
- package/dist/tools/vector/index.js +6 -0
- package/dist/undo-redo.d.ts +22 -0
- package/dist/undo-redo.js +47 -0
- package/dist/use-debounce.d.ts +9 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.js +75 -0
- package/package.json +45 -33
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1469
- package/LICENSE.md +0 -5
- package/lib/axis/arrow.js +0 -79
- package/lib/axis/arrow.js.map +0 -1
- package/lib/axis/axes.js +0 -329
- package/lib/axis/axes.js.map +0 -1
- package/lib/axis/index.js +0 -21
- package/lib/axis/index.js.map +0 -1
- package/lib/bg.js +0 -114
- package/lib/bg.js.map +0 -1
- package/lib/container/actions.js +0 -18
- package/lib/container/actions.js.map +0 -1
- package/lib/container/index.js +0 -118
- package/lib/container/index.js.map +0 -1
- package/lib/container/marks.js +0 -22
- package/lib/container/marks.js.map +0 -1
- package/lib/container/middleware.js +0 -19
- package/lib/container/middleware.js.map +0 -1
- package/lib/container/reducer.js +0 -18
- package/lib/container/reducer.js.map +0 -1
- package/lib/coordinates-label.js +0 -79
- package/lib/coordinates-label.js.map +0 -1
- package/lib/graph-with-controls.js +0 -294
- package/lib/graph-with-controls.js.map +0 -1
- package/lib/graph.js +0 -327
- package/lib/graph.js.map +0 -1
- package/lib/grid-setup.js +0 -414
- package/lib/grid-setup.js.map +0 -1
- package/lib/grid.js +0 -131
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -47
- package/lib/index.js.map +0 -1
- package/lib/key-legend.js +0 -201
- package/lib/key-legend.js.map +0 -1
- package/lib/label-svg-icon.js +0 -50
- package/lib/label-svg-icon.js.map +0 -1
- package/lib/labels.js +0 -243
- package/lib/labels.js.map +0 -1
- package/lib/mark-label.js +0 -285
- package/lib/mark-label.js.map +0 -1
- package/lib/toggle-bar.js +0 -252
- package/lib/toggle-bar.js.map +0 -1
- package/lib/tool-menu.js +0 -78
- package/lib/tool-menu.js.map +0 -1
- package/lib/tools/absolute/component.js +0 -29
- package/lib/tools/absolute/component.js.map +0 -1
- package/lib/tools/absolute/index.js +0 -50
- package/lib/tools/absolute/index.js.map +0 -1
- package/lib/tools/circle/bg-circle.js +0 -123
- package/lib/tools/circle/bg-circle.js.map +0 -1
- package/lib/tools/circle/component.js +0 -321
- package/lib/tools/circle/component.js.map +0 -1
- package/lib/tools/circle/index.js +0 -41
- package/lib/tools/circle/index.js.map +0 -1
- package/lib/tools/exponential/component.js +0 -28
- package/lib/tools/exponential/component.js.map +0 -1
- package/lib/tools/exponential/index.js +0 -56
- package/lib/tools/exponential/index.js.map +0 -1
- package/lib/tools/index.js +0 -86
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/line/component.js +0 -97
- package/lib/tools/line/component.js.map +0 -1
- package/lib/tools/line/index.js +0 -11
- package/lib/tools/line/index.js.map +0 -1
- package/lib/tools/parabola/component.js +0 -28
- package/lib/tools/parabola/component.js.map +0 -1
- package/lib/tools/parabola/index.js +0 -50
- package/lib/tools/parabola/index.js.map +0 -1
- package/lib/tools/point/component.js +0 -148
- package/lib/tools/point/component.js.map +0 -1
- package/lib/tools/point/index.js +0 -24
- package/lib/tools/point/index.js.map +0 -1
- package/lib/tools/polygon/component.js +0 -437
- package/lib/tools/polygon/component.js.map +0 -1
- package/lib/tools/polygon/index.js +0 -89
- package/lib/tools/polygon/index.js.map +0 -1
- package/lib/tools/polygon/line.js +0 -112
- package/lib/tools/polygon/line.js.map +0 -1
- package/lib/tools/polygon/polygon.js +0 -130
- package/lib/tools/polygon/polygon.js.map +0 -1
- package/lib/tools/ray/component.js +0 -95
- package/lib/tools/ray/component.js.map +0 -1
- package/lib/tools/ray/index.js +0 -11
- package/lib/tools/ray/index.js.map +0 -1
- package/lib/tools/segment/component.js +0 -71
- package/lib/tools/segment/component.js.map +0 -1
- package/lib/tools/segment/index.js +0 -11
- package/lib/tools/segment/index.js.map +0 -1
- package/lib/tools/shared/arrow-head.js +0 -111
- package/lib/tools/shared/arrow-head.js.map +0 -1
- package/lib/tools/shared/icons/CorrectSVG.js +0 -40
- package/lib/tools/shared/icons/CorrectSVG.js.map +0 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +0 -40
- package/lib/tools/shared/icons/IncorrectSVG.js.map +0 -1
- package/lib/tools/shared/icons/MissingSVG.js +0 -39
- package/lib/tools/shared/icons/MissingSVG.js.map +0 -1
- package/lib/tools/shared/line/index.js +0 -550
- package/lib/tools/shared/line/index.js.map +0 -1
- package/lib/tools/shared/line/line-path.js +0 -118
- package/lib/tools/shared/line/line-path.js.map +0 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -121
- package/lib/tools/shared/line/with-root-edge.js.map +0 -1
- package/lib/tools/shared/point/arrow-point.js +0 -72
- package/lib/tools/shared/point/arrow-point.js.map +0 -1
- package/lib/tools/shared/point/arrow.js +0 -67
- package/lib/tools/shared/point/arrow.js.map +0 -1
- package/lib/tools/shared/point/base-point.js +0 -157
- package/lib/tools/shared/point/base-point.js.map +0 -1
- package/lib/tools/shared/point/index.js +0 -68
- package/lib/tools/shared/point/index.js.map +0 -1
- package/lib/tools/shared/styles.js +0 -33
- package/lib/tools/shared/styles.js.map +0 -1
- package/lib/tools/shared/types.js +0 -16
- package/lib/tools/shared/types.js.map +0 -1
- package/lib/tools/sine/component.js +0 -40
- package/lib/tools/sine/component.js.map +0 -1
- package/lib/tools/sine/index.js +0 -50
- package/lib/tools/sine/index.js.map +0 -1
- package/lib/tools/vector/component.js +0 -68
- package/lib/tools/vector/component.js.map +0 -1
- package/lib/tools/vector/index.js +0 -11
- package/lib/tools/vector/index.js.map +0 -1
- package/lib/undo-redo.js +0 -86
- package/lib/undo-redo.js.map +0 -1
- package/lib/use-debounce.js +0 -25
- package/lib/use-debounce.js.map +0 -1
- package/lib/utils.js +0 -229
- package/lib/utils.js.map +0 -1
- package/src/__tests__/bg.test.jsx +0 -250
- package/src/__tests__/coordinates-label.test.jsx +0 -243
- package/src/__tests__/graph-with-controls.test.jsx +0 -198
- package/src/__tests__/graph.test.jsx +0 -721
- package/src/__tests__/grid-setup.test.jsx +0 -645
- package/src/__tests__/grid.test.jsx +0 -22
- package/src/__tests__/key-legend.test.jsx +0 -260
- package/src/__tests__/label-svg-icon.test.jsx +0 -278
- package/src/__tests__/labels.test.jsx +0 -55
- package/src/__tests__/mark-label.test.jsx +0 -63
- package/src/__tests__/toggle-bar.test.jsx +0 -146
- package/src/__tests__/tool-menu.test.jsx +0 -115
- package/src/__tests__/undo-redo.test.jsx +0 -24
- package/src/__tests__/use-debounce.test.js +0 -21
- package/src/__tests__/utils.js +0 -41
- package/src/__tests__/utils.test.js +0 -105
- package/src/axis/__tests__/arrow.test.jsx +0 -38
- package/src/axis/__tests__/axes.test.jsx +0 -216
- package/src/axis/arrow.jsx +0 -57
- package/src/axis/axes.jsx +0 -285
- package/src/axis/index.js +0 -3
- package/src/bg.jsx +0 -96
- package/src/container/__tests__/actions.test.js +0 -105
- package/src/container/__tests__/index.test.jsx +0 -319
- package/src/container/__tests__/marks.test.js +0 -172
- package/src/container/__tests__/middleware.test.js +0 -235
- package/src/container/__tests__/reducer.test.js +0 -324
- package/src/container/actions.js +0 -8
- package/src/container/index.jsx +0 -83
- package/src/container/marks.js +0 -14
- package/src/container/middleware.js +0 -7
- package/src/container/reducer.js +0 -5
- package/src/coordinates-label.jsx +0 -63
- package/src/graph-with-controls.jsx +0 -239
- package/src/graph.jsx +0 -303
- package/src/grid-setup.jsx +0 -432
- package/src/grid.jsx +0 -133
- package/src/index.js +0 -7
- package/src/key-legend.jsx +0 -142
- package/src/label-svg-icon.jsx +0 -39
- package/src/labels.jsx +0 -207
- package/src/mark-label.jsx +0 -244
- package/src/toggle-bar.jsx +0 -224
- package/src/tool-menu.jsx +0 -49
- package/src/tools/absolute/__tests__/component.test.jsx +0 -53
- package/src/tools/absolute/component.jsx +0 -23
- package/src/tools/absolute/index.js +0 -31
- package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
- package/src/tools/circle/__tests__/component.test.jsx +0 -494
- package/src/tools/circle/__tests__/index.test.js +0 -480
- package/src/tools/circle/bg-circle.jsx +0 -81
- package/src/tools/circle/component.jsx +0 -264
- package/src/tools/circle/index.js +0 -25
- package/src/tools/exponential/__tests__/component.test.jsx +0 -53
- package/src/tools/exponential/__tests__/index.test.js +0 -729
- package/src/tools/exponential/component.jsx +0 -23
- package/src/tools/exponential/index.js +0 -39
- package/src/tools/index.js +0 -48
- package/src/tools/line/__tests__/component.test.jsx +0 -37
- package/src/tools/line/component.jsx +0 -93
- package/src/tools/line/index.js +0 -4
- package/src/tools/parabola/__tests__/component.test.jsx +0 -48
- package/src/tools/parabola/__tests__/index.test.js +0 -470
- package/src/tools/parabola/component.jsx +0 -23
- package/src/tools/parabola/index.js +0 -31
- package/src/tools/point/__tests__/component.test.jsx +0 -349
- package/src/tools/point/__tests__/index.test.js +0 -241
- package/src/tools/point/component.jsx +0 -126
- package/src/tools/point/index.js +0 -11
- package/src/tools/polygon/__tests__/component.test.jsx +0 -471
- package/src/tools/polygon/__tests__/index.test.js +0 -294
- package/src/tools/polygon/__tests__/line.test.jsx +0 -35
- package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
- package/src/tools/polygon/component.jsx +0 -409
- package/src/tools/polygon/index.js +0 -52
- package/src/tools/polygon/line.jsx +0 -74
- package/src/tools/polygon/polygon.jsx +0 -110
- package/src/tools/ray/__tests__/component.test.jsx +0 -29
- package/src/tools/ray/component.jsx +0 -92
- package/src/tools/ray/index.js +0 -4
- package/src/tools/segment/__tests__/component.test.jsx +0 -28
- package/src/tools/segment/component.jsx +0 -65
- package/src/tools/segment/index.js +0 -4
- package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
- package/src/tools/shared/arrow-head.jsx +0 -102
- package/src/tools/shared/icons/CorrectSVG.jsx +0 -32
- package/src/tools/shared/icons/IncorrectSVG.jsx +0 -30
- package/src/tools/shared/icons/MissingSVG.jsx +0 -31
- package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
- package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
- package/src/tools/shared/line/index.jsx +0 -487
- package/src/tools/shared/line/line-path.jsx +0 -80
- package/src/tools/shared/line/with-root-edge.jsx +0 -97
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
- package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
- package/src/tools/shared/point/arrow-point.jsx +0 -46
- package/src/tools/shared/point/arrow.jsx +0 -37
- package/src/tools/shared/point/base-point.jsx +0 -121
- package/src/tools/shared/point/index.jsx +0 -54
- package/src/tools/shared/styles.js +0 -27
- package/src/tools/shared/types.js +0 -10
- package/src/tools/sine/__tests__/component.test.jsx +0 -51
- package/src/tools/sine/component.jsx +0 -32
- package/src/tools/sine/index.js +0 -33
- package/src/tools/vector/__tests__/component.test.jsx +0 -25
- package/src/tools/vector/component.jsx +0 -56
- package/src/tools/vector/index.js +0 -4
- package/src/undo-redo.jsx +0 -45
- package/src/use-debounce.js +0 -13
- package/src/utils.js +0 -224
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { ToolPropTypeFields } from '../shared/types';
|
|
4
|
-
import { BasePoint } from '../shared/point';
|
|
5
|
-
import { chunk, initial, isEmpty } from 'lodash-es';
|
|
6
|
-
import debug from 'debug';
|
|
7
|
-
import Line from './line';
|
|
8
|
-
import DraggablePolygon, { Polygon } from './polygon';
|
|
9
|
-
import { types } from '@pie-lib/plot';
|
|
10
|
-
import invariant from 'invariant';
|
|
11
|
-
import ReactDOM from 'react-dom';
|
|
12
|
-
import MarkLabel from '../../mark-label';
|
|
13
|
-
import { equalPoints, getMiddleOfTwoPoints, getRightestPoints, stripEmptyLabel } from '../../utils';
|
|
14
|
-
|
|
15
|
-
const log = debug('pie-lib:graphing:polygon');
|
|
16
|
-
|
|
17
|
-
export const buildLines = (points, closed) => {
|
|
18
|
-
const expanded = points.reduce((acc, p, index) => {
|
|
19
|
-
acc.push({ ...p, index });
|
|
20
|
-
|
|
21
|
-
const isLast = index === points.length - 1;
|
|
22
|
-
const next = isLast ? 0 : index + 1;
|
|
23
|
-
|
|
24
|
-
acc.push({ ...points[next], index: next });
|
|
25
|
-
|
|
26
|
-
return acc;
|
|
27
|
-
}, []);
|
|
28
|
-
|
|
29
|
-
const all = chunk(expanded, 2).map(([from, to]) => {
|
|
30
|
-
return { from, to };
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return closed ? all : initial(all);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const swap = (arr, ...rest) => {
|
|
37
|
-
const pairs = chunk(rest, 2);
|
|
38
|
-
|
|
39
|
-
return pairs.reduce(
|
|
40
|
-
(acc, pr) => {
|
|
41
|
-
if (pr.length === 2) {
|
|
42
|
-
let [e, replacement] = pr;
|
|
43
|
-
|
|
44
|
-
invariant(Number.isFinite(e.index), 'Index must be defined');
|
|
45
|
-
|
|
46
|
-
const index = e.index;
|
|
47
|
-
// const i = acc.findIndex(pt => pt.x === e.x && pt.y === e.y);
|
|
48
|
-
|
|
49
|
-
if (index >= 0) {
|
|
50
|
-
acc.splice(index, 1, replacement);
|
|
51
|
-
|
|
52
|
-
return acc;
|
|
53
|
-
} else {
|
|
54
|
-
return acc;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
return acc;
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
[...arr],
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export class RawBaseComponent extends React.Component {
|
|
65
|
-
static propTypes = {
|
|
66
|
-
classes: PropTypes.object,
|
|
67
|
-
className: PropTypes.string,
|
|
68
|
-
disabled: PropTypes.bool,
|
|
69
|
-
correctness: PropTypes.string,
|
|
70
|
-
points: PropTypes.arrayOf(types.PointType),
|
|
71
|
-
closed: PropTypes.bool,
|
|
72
|
-
coordinatesOnHover: PropTypes.bool,
|
|
73
|
-
onChange: PropTypes.func.isRequired,
|
|
74
|
-
onClosePolygon: PropTypes.func.isRequired,
|
|
75
|
-
onDragStart: PropTypes.func,
|
|
76
|
-
onDragStop: PropTypes.func,
|
|
77
|
-
onClick: PropTypes.func,
|
|
78
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
79
|
-
isToolActive: PropTypes.bool,
|
|
80
|
-
middle: PropTypes.object,
|
|
81
|
-
labelNode: PropTypes.object,
|
|
82
|
-
labelModeEnabled: PropTypes.bool,
|
|
83
|
-
limitLabeling: PropTypes.bool,
|
|
84
|
-
onChangeLabelProps: PropTypes.func,
|
|
85
|
-
onSetMiddleLabel: PropTypes.func,
|
|
86
|
-
onChangeProps: PropTypes.func,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
static defaultProps = {
|
|
90
|
-
points: [],
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
dragPoint = (index, from, to) => {
|
|
94
|
-
log('[dragPoint] from, to:', from, to);
|
|
95
|
-
const { onChange, points } = this.props;
|
|
96
|
-
const update = [...points];
|
|
97
|
-
const overlapPoint = !!(points || []).find((p) => equalPoints(p, to));
|
|
98
|
-
|
|
99
|
-
if (equalPoints(from, to) || overlapPoint) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (points[index].label) {
|
|
104
|
-
to.label = points[index].label;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
update.splice(index, 1, to);
|
|
108
|
-
onChange(update);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
dragLine = (existing, next) => {
|
|
112
|
-
log('[dragLine]: ', existing, next);
|
|
113
|
-
const { onChange } = this.props;
|
|
114
|
-
|
|
115
|
-
if (existing.from.label) {
|
|
116
|
-
next.from.label = existing.from.label;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (existing.to.label) {
|
|
120
|
-
next.to.label = existing.to.label;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const points = swap(this.props.points, existing.from, next.from, existing.to, next.to);
|
|
124
|
-
onChange(points);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
dragPoly = (existing, next) => {
|
|
128
|
-
log('[dragPoly] ', existing, next);
|
|
129
|
-
const { onChange } = this.props;
|
|
130
|
-
|
|
131
|
-
next.forEach((point, index) => {
|
|
132
|
-
if (existing[index].label) {
|
|
133
|
-
next[index].label = existing[index].label;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
onChange(next);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
close = () => {
|
|
141
|
-
const { points, onClosePolygon } = this.props;
|
|
142
|
-
log('[close] ...');
|
|
143
|
-
|
|
144
|
-
if (points.length >= 3) {
|
|
145
|
-
onClosePolygon();
|
|
146
|
-
} else {
|
|
147
|
-
log('[close] - nope');
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
labelChange = (point, index) => {
|
|
152
|
-
const { points, onChangeProps } = this.props;
|
|
153
|
-
const updatedPoint = { ...point };
|
|
154
|
-
|
|
155
|
-
if (!point.label || isEmpty(point.label)) {
|
|
156
|
-
delete updatedPoint.label;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const update = [...points];
|
|
160
|
-
|
|
161
|
-
update.splice(index, 1, updatedPoint);
|
|
162
|
-
onChangeProps(update);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
clickPoint = (point, index, data) => {
|
|
166
|
-
const {
|
|
167
|
-
closed,
|
|
168
|
-
disabled,
|
|
169
|
-
middle: currentMiddle,
|
|
170
|
-
onClick,
|
|
171
|
-
isToolActive,
|
|
172
|
-
labelModeEnabled,
|
|
173
|
-
limitLabeling,
|
|
174
|
-
onSetMiddleLabel,
|
|
175
|
-
points,
|
|
176
|
-
} = this.props;
|
|
177
|
-
|
|
178
|
-
if (labelModeEnabled) {
|
|
179
|
-
// limit labeling the points of the polygon
|
|
180
|
-
if (disabled || limitLabeling) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (points && index === points.length) {
|
|
185
|
-
const { a, b } = getRightestPoints(points);
|
|
186
|
-
const middle = { label: '', ...point, ...getMiddleOfTwoPoints(a, b) };
|
|
187
|
-
|
|
188
|
-
onSetMiddleLabel(middle, points.map(stripEmptyLabel));
|
|
189
|
-
} else {
|
|
190
|
-
const strippedPoints = points.map(stripEmptyLabel);
|
|
191
|
-
strippedPoints.splice(index, 1, { label: '', ...point });
|
|
192
|
-
|
|
193
|
-
const strippedMiddle = currentMiddle ? stripEmptyLabel(currentMiddle) : currentMiddle;
|
|
194
|
-
onSetMiddleLabel(strippedMiddle, strippedPoints);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// defer the focus() call with setTimeout to allow the re-render to complete first.
|
|
198
|
-
setTimeout(() => {
|
|
199
|
-
if (this.input[index]) {
|
|
200
|
-
this.input[index].focus();
|
|
201
|
-
}
|
|
202
|
-
}, 0);
|
|
203
|
-
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (isToolActive && !closed && index === 0) {
|
|
208
|
-
this.close();
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
onClick(point || data);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// IMPORTANT, do not remove
|
|
216
|
-
input = {};
|
|
217
|
-
|
|
218
|
-
render() {
|
|
219
|
-
const {
|
|
220
|
-
closed,
|
|
221
|
-
coordinatesOnHover,
|
|
222
|
-
correctness,
|
|
223
|
-
disabled,
|
|
224
|
-
graphProps,
|
|
225
|
-
onChangeLabelProps,
|
|
226
|
-
onDragStart,
|
|
227
|
-
onDragStop,
|
|
228
|
-
points,
|
|
229
|
-
middle,
|
|
230
|
-
labelNode,
|
|
231
|
-
labelModeEnabled,
|
|
232
|
-
} = this.props;
|
|
233
|
-
const lines = buildLines(points, closed);
|
|
234
|
-
const common = { onDragStart, onDragStop, graphProps, disabled, correctness };
|
|
235
|
-
const polygonLabelIndex = (points && points.length) || 0;
|
|
236
|
-
let polygonLabelNode = null;
|
|
237
|
-
|
|
238
|
-
if (labelNode && middle && Object.prototype.hasOwnProperty.call(middle, 'label')) {
|
|
239
|
-
polygonLabelNode = ReactDOM.createPortal(
|
|
240
|
-
<MarkLabel
|
|
241
|
-
inputRef={(r) => (this.input[polygonLabelIndex] = r)}
|
|
242
|
-
disabled={disabled || !labelModeEnabled}
|
|
243
|
-
mark={middle}
|
|
244
|
-
graphProps={graphProps}
|
|
245
|
-
onChange={(label) => onChangeLabelProps({ ...middle, label })}
|
|
246
|
-
/>,
|
|
247
|
-
labelNode,
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<g>
|
|
253
|
-
{closed ? (
|
|
254
|
-
<React.Fragment>
|
|
255
|
-
<DraggablePolygon
|
|
256
|
-
points={points}
|
|
257
|
-
onDrag={this.dragPoly.bind(this, points)}
|
|
258
|
-
closed={closed}
|
|
259
|
-
{...common}
|
|
260
|
-
onClick={this.clickPoint.bind(this, middle, polygonLabelIndex)}
|
|
261
|
-
/>
|
|
262
|
-
{polygonLabelNode}
|
|
263
|
-
</React.Fragment>
|
|
264
|
-
) : (
|
|
265
|
-
<Polygon points={points} graphProps={graphProps} closed={closed} />
|
|
266
|
-
)}
|
|
267
|
-
{(lines || []).map((l, index) => (
|
|
268
|
-
<Line
|
|
269
|
-
key={`line-${index}`}
|
|
270
|
-
from={l.from}
|
|
271
|
-
to={l.to}
|
|
272
|
-
onDrag={this.dragLine.bind(this, l)}
|
|
273
|
-
{...common}
|
|
274
|
-
onClick={this.clickPoint.bind(this, middle, polygonLabelIndex)}
|
|
275
|
-
/>
|
|
276
|
-
))}
|
|
277
|
-
|
|
278
|
-
{(points || []).map((p, index) => {
|
|
279
|
-
return [
|
|
280
|
-
<BasePoint
|
|
281
|
-
key={`point-${index}`}
|
|
282
|
-
coordinatesOnHover={coordinatesOnHover}
|
|
283
|
-
labelNode={labelNode}
|
|
284
|
-
x={p.x}
|
|
285
|
-
y={p.y}
|
|
286
|
-
onDrag={this.dragPoint.bind(this, index, p)}
|
|
287
|
-
{...common}
|
|
288
|
-
onClick={this.clickPoint.bind(this, p, index)}
|
|
289
|
-
/>,
|
|
290
|
-
labelNode && Object.prototype.hasOwnProperty.call(p, 'label')
|
|
291
|
-
? ReactDOM.createPortal(
|
|
292
|
-
<MarkLabel
|
|
293
|
-
inputRef={(r) => (this.input[index] = r)}
|
|
294
|
-
disabled={disabled || !labelModeEnabled}
|
|
295
|
-
mark={p}
|
|
296
|
-
graphProps={graphProps}
|
|
297
|
-
onChange={(label) => this.labelChange({ ...p, label }, index)}
|
|
298
|
-
/>,
|
|
299
|
-
labelNode,
|
|
300
|
-
)
|
|
301
|
-
: null,
|
|
302
|
-
];
|
|
303
|
-
})}
|
|
304
|
-
</g>
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export const BaseComponent = RawBaseComponent;
|
|
310
|
-
|
|
311
|
-
export default class Component extends React.Component {
|
|
312
|
-
static propTypes = {
|
|
313
|
-
...ToolPropTypeFields,
|
|
314
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
static defaultProps = {};
|
|
318
|
-
|
|
319
|
-
constructor(props) {
|
|
320
|
-
super(props);
|
|
321
|
-
this.state = {};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
change = (points) => {
|
|
325
|
-
const {
|
|
326
|
-
mark: { middle },
|
|
327
|
-
} = this.props;
|
|
328
|
-
const mark = { ...this.state.mark, points };
|
|
329
|
-
|
|
330
|
-
if (middle) {
|
|
331
|
-
const { a, b } = getRightestPoints(points);
|
|
332
|
-
|
|
333
|
-
mark.middle = { ...middle, ...getMiddleOfTwoPoints(a, b) };
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
this.setState({ mark });
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
changeProps = (points) => {
|
|
340
|
-
const mark = { ...this.props.mark, points };
|
|
341
|
-
|
|
342
|
-
this.props.onChange(this.props.mark, mark);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
changeLabelProps = (point) => {
|
|
346
|
-
const { mark, onChange } = this.props;
|
|
347
|
-
const middle = { ...mark.middle, ...point };
|
|
348
|
-
|
|
349
|
-
if (!middle.label || isEmpty(middle.label)) {
|
|
350
|
-
delete middle.label;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
onChange(mark, { ...mark, middle });
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
setMiddleLabel = (middle, strippedPoints) => {
|
|
357
|
-
const { mark, onChange } = this.props;
|
|
358
|
-
const next = { ...mark, middle };
|
|
359
|
-
if (strippedPoints) {
|
|
360
|
-
next.points = strippedPoints;
|
|
361
|
-
}
|
|
362
|
-
onChange(mark, next);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
closePolygon = () => {
|
|
366
|
-
log('[closePolygon] ...');
|
|
367
|
-
const { onComplete, mark } = this.props;
|
|
368
|
-
const update = { ...mark, closed: true };
|
|
369
|
-
|
|
370
|
-
onComplete(mark, update);
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
dragStart = () => this.setState({ mark: this.props.mark });
|
|
374
|
-
|
|
375
|
-
dragStop = () => {
|
|
376
|
-
const { onChange } = this.props;
|
|
377
|
-
const m = { ...this.state.mark };
|
|
378
|
-
|
|
379
|
-
this.setState({ mark: undefined }, () => {
|
|
380
|
-
onChange(this.props.mark, m);
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
render() {
|
|
385
|
-
const { coordinatesOnHover, mark, graphProps, onClick, isToolActive, labelNode, labelModeEnabled, limitLabeling } =
|
|
386
|
-
this.props;
|
|
387
|
-
const { mark: stateMark } = this.state;
|
|
388
|
-
|
|
389
|
-
return (
|
|
390
|
-
<BaseComponent
|
|
391
|
-
{...(stateMark || mark)}
|
|
392
|
-
coordinatesOnHover={coordinatesOnHover}
|
|
393
|
-
onChange={this.change}
|
|
394
|
-
onChangeLabelProps={this.changeLabelProps}
|
|
395
|
-
onSetMiddleLabel={this.setMiddleLabel}
|
|
396
|
-
onChangeProps={this.changeProps}
|
|
397
|
-
onClosePolygon={this.closePolygon}
|
|
398
|
-
onDragStart={this.dragStart}
|
|
399
|
-
onDragStop={this.dragStop}
|
|
400
|
-
onClick={onClick}
|
|
401
|
-
graphProps={graphProps}
|
|
402
|
-
isToolActive={isToolActive}
|
|
403
|
-
labelNode={labelNode}
|
|
404
|
-
labelModeEnabled={labelModeEnabled}
|
|
405
|
-
limitLabeling={limitLabeling}
|
|
406
|
-
/>
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import Polygon from './component';
|
|
2
|
-
import { equalPoints } from '../../utils';
|
|
3
|
-
|
|
4
|
-
export const addPointToArray = (point, arr) => {
|
|
5
|
-
arr = arr || [];
|
|
6
|
-
|
|
7
|
-
if (arr.length === 0) {
|
|
8
|
-
return { points: [point], closed: false };
|
|
9
|
-
} else if (arr.length === 1) {
|
|
10
|
-
if (equalPoints(point, arr[0])) {
|
|
11
|
-
return { points: arr, closed: false };
|
|
12
|
-
} else {
|
|
13
|
-
return { points: [...arr, point], closed: false };
|
|
14
|
-
}
|
|
15
|
-
} else if (arr.length >= 2) {
|
|
16
|
-
const closed = equalPoints(point, arr[0]);
|
|
17
|
-
|
|
18
|
-
if (closed) {
|
|
19
|
-
return { points: arr, closed };
|
|
20
|
-
} else {
|
|
21
|
-
const hasPoint = !!arr.find((p) => equalPoints(p, point));
|
|
22
|
-
|
|
23
|
-
if (hasPoint) {
|
|
24
|
-
return { points: arr, closed: false };
|
|
25
|
-
} else {
|
|
26
|
-
return { points: [...arr, point], closed: false };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const tool = () => ({
|
|
33
|
-
type: 'polygon',
|
|
34
|
-
Component: Polygon,
|
|
35
|
-
complete: (data, mark) => {
|
|
36
|
-
return { ...mark, building: false, closed: true };
|
|
37
|
-
},
|
|
38
|
-
addPoint: (point, mark) => {
|
|
39
|
-
if (!mark) {
|
|
40
|
-
return {
|
|
41
|
-
type: 'polygon',
|
|
42
|
-
points: [point],
|
|
43
|
-
closed: false,
|
|
44
|
-
building: true,
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
const { closed, points } = addPointToArray(point, mark.points);
|
|
48
|
-
|
|
49
|
-
return { ...mark, closed, points, building: !closed };
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { gridDraggable, types } from '@pie-lib/plot';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
|
-
import * as utils from '../../utils';
|
|
7
|
-
import { correct, disabled, incorrect, missing } from '../shared/styles';
|
|
8
|
-
|
|
9
|
-
const StyledLine = styled('line')(({ disabled: isDisabled, correctness }) => ({
|
|
10
|
-
strokeWidth: 7,
|
|
11
|
-
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
12
|
-
stroke: 'transparent',
|
|
13
|
-
pointerEvents: 'stroke',
|
|
14
|
-
'&:hover': {
|
|
15
|
-
strokeWidth: 4,
|
|
16
|
-
stroke: color.defaults.BLACK,
|
|
17
|
-
},
|
|
18
|
-
...((isDisabled || correctness) && { pointerEvents: 'none' }),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
class RawLine extends React.Component {
|
|
22
|
-
static propTypes = {
|
|
23
|
-
className: PropTypes.string,
|
|
24
|
-
from: types.PointType,
|
|
25
|
-
to: types.PointType,
|
|
26
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
27
|
-
disabled: PropTypes.bool,
|
|
28
|
-
correctness: PropTypes.string,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
static defaultProps = {
|
|
32
|
-
from: {},
|
|
33
|
-
to: {},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
render() {
|
|
37
|
-
// eslint-disable-next-line no-unused-vars
|
|
38
|
-
const { graphProps, from, to, className, disabled, correctness, ...rest } = this.props;
|
|
39
|
-
const { scale } = graphProps;
|
|
40
|
-
return (
|
|
41
|
-
<StyledLine
|
|
42
|
-
x1={scale.x(from.x)}
|
|
43
|
-
y1={scale.y(from.y)}
|
|
44
|
-
x2={scale.x(to.x)}
|
|
45
|
-
y2={scale.y(to.y)}
|
|
46
|
-
className={className}
|
|
47
|
-
disabled={disabled}
|
|
48
|
-
correctness={correctness}
|
|
49
|
-
{...rest}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const Line = RawLine;
|
|
56
|
-
|
|
57
|
-
export default gridDraggable({
|
|
58
|
-
bounds: (props, { domain, range }) => {
|
|
59
|
-
const { from, to } = props;
|
|
60
|
-
const area = utils.lineToArea(from, to);
|
|
61
|
-
return utils.bounds(area, domain, range);
|
|
62
|
-
},
|
|
63
|
-
anchorPoint: (props) => {
|
|
64
|
-
const { from } = props;
|
|
65
|
-
return from;
|
|
66
|
-
},
|
|
67
|
-
fromDelta: (props, delta) => {
|
|
68
|
-
const { from, to } = props;
|
|
69
|
-
return {
|
|
70
|
-
from: utils.point(from).add(utils.point(delta)),
|
|
71
|
-
to: utils.point(to).add(utils.point(delta)),
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
})(Line);
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { alpha, styled } from '@mui/material/styles';
|
|
4
|
-
import { gridDraggable, types } from '@pie-lib/plot';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
|
-
|
|
7
|
-
import * as utils from '../../utils';
|
|
8
|
-
import { correct, disabledSecondary, incorrect, missing, graphingShapeFill } from '../shared/styles';
|
|
9
|
-
|
|
10
|
-
const StyledPolygon = styled('polygon')(({ disabled: isDisabled, correctness }) => ({
|
|
11
|
-
fill: alpha(graphingShapeFill(), 0.2),
|
|
12
|
-
strokeWidth: 2,
|
|
13
|
-
stroke: color.defaults.BLACK,
|
|
14
|
-
...(isDisabled && disabledSecondary('stroke')),
|
|
15
|
-
...(correctness === 'correct' && correct('stroke')),
|
|
16
|
-
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
17
|
-
...(correctness === 'missing' && {
|
|
18
|
-
...missing('stroke'),
|
|
19
|
-
stroke: 'inherit',
|
|
20
|
-
}),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const StyledPolyline = styled('polyline')(({ disabled: isDisabled, correctness }) => ({
|
|
24
|
-
fill: alpha(graphingShapeFill(), 0.0),
|
|
25
|
-
strokeWidth: 2,
|
|
26
|
-
stroke: color.defaults.BLACK,
|
|
27
|
-
pointerEvents: 'none',
|
|
28
|
-
...(isDisabled && disabledSecondary('stroke')),
|
|
29
|
-
...(correctness === 'correct' && correct('stroke')),
|
|
30
|
-
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
31
|
-
...(correctness === 'missing' && {
|
|
32
|
-
...missing('stroke'),
|
|
33
|
-
stroke: 'inherit',
|
|
34
|
-
}),
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
export const getPointString = (points, scale) => {
|
|
38
|
-
return (points || [])
|
|
39
|
-
.map((p) => {
|
|
40
|
-
const scaledPoint = {
|
|
41
|
-
x: scale.x(p.x),
|
|
42
|
-
y: scale.y(p.y),
|
|
43
|
-
};
|
|
44
|
-
return `${scaledPoint.x},${scaledPoint.y}`;
|
|
45
|
-
})
|
|
46
|
-
.join(' ');
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export class RawPolygon extends React.Component {
|
|
50
|
-
static propTypes = {
|
|
51
|
-
className: PropTypes.string,
|
|
52
|
-
disabled: PropTypes.bool,
|
|
53
|
-
points: PropTypes.arrayOf(types.PointType),
|
|
54
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
55
|
-
closed: PropTypes.bool.isRequired,
|
|
56
|
-
correctness: PropTypes.string,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
static defaultProps = {
|
|
60
|
-
points: [],
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
render() {
|
|
64
|
-
const { points, className, disabled, correctness, graphProps, closed, ...rest } = this.props;
|
|
65
|
-
const { scale } = graphProps;
|
|
66
|
-
|
|
67
|
-
const pointString = getPointString(points, scale);
|
|
68
|
-
|
|
69
|
-
if (closed) {
|
|
70
|
-
return (
|
|
71
|
-
<StyledPolygon
|
|
72
|
-
points={pointString}
|
|
73
|
-
className={className}
|
|
74
|
-
disabled={disabled}
|
|
75
|
-
correctness={correctness}
|
|
76
|
-
{...rest}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
} else {
|
|
80
|
-
return (
|
|
81
|
-
<StyledPolyline
|
|
82
|
-
points={pointString}
|
|
83
|
-
className={className}
|
|
84
|
-
disabled={disabled}
|
|
85
|
-
correctness={correctness}
|
|
86
|
-
{...rest}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const Polygon = RawPolygon;
|
|
94
|
-
|
|
95
|
-
export default gridDraggable({
|
|
96
|
-
bounds: (props, { domain, range }) => {
|
|
97
|
-
const { points } = props;
|
|
98
|
-
const area = utils.polygonToArea(points);
|
|
99
|
-
return utils.bounds(area, domain, range);
|
|
100
|
-
},
|
|
101
|
-
anchorPoint: (props) => {
|
|
102
|
-
const { points } = props;
|
|
103
|
-
return points[0];
|
|
104
|
-
},
|
|
105
|
-
fromDelta: (props, delta) => {
|
|
106
|
-
const { points } = props;
|
|
107
|
-
|
|
108
|
-
return points.map((p) => utils.point(p).add(utils.point(delta)));
|
|
109
|
-
},
|
|
110
|
-
})(Polygon);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { render } from '@pie-lib/test-utils';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { RayLine } from '../component';
|
|
4
|
-
import { graphProps as getGraphProps } from '../../../__tests__/utils';
|
|
5
|
-
import { utils } from '@pie-lib/plot';
|
|
6
|
-
|
|
7
|
-
describe('RayLine', () => {
|
|
8
|
-
let onChange = jest.fn();
|
|
9
|
-
const renderComponent = (extras) => {
|
|
10
|
-
const defaults = {
|
|
11
|
-
classes: {},
|
|
12
|
-
className: 'className',
|
|
13
|
-
onChange,
|
|
14
|
-
markerId: '1',
|
|
15
|
-
graphProps: getGraphProps(),
|
|
16
|
-
from: utils.xy(0, 0),
|
|
17
|
-
to: utils.xy(1, 1),
|
|
18
|
-
};
|
|
19
|
-
const props = { ...defaults, ...extras };
|
|
20
|
-
return render(<RayLine {...props} />);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe('rendering', () => {
|
|
24
|
-
it('renders without crashing', () => {
|
|
25
|
-
const { container } = renderComponent();
|
|
26
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|