@pie-lib/graphing-solution-set 0.1.0
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/axis/arrow.d.ts +14 -0
- package/dist/axis/arrow.d.ts.map +1 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +133 -0
- package/dist/axis/axes.d.ts.map +1 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +11 -0
- package/dist/axis/index.d.ts.map +1 -0
- package/dist/bg.d.ts +52 -0
- package/dist/bg.d.ts.map +1 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +16 -0
- package/dist/container/actions.d.ts.map +1 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +27 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +11 -0
- package/dist/container/marks.d.ts.map +1 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +11 -0
- package/dist/container/middleware.d.ts.map +1 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +13 -0
- package/dist/container/reducer.d.ts.map +1 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.d.ts.map +1 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +86 -0
- package/dist/graph-with-controls.d.ts.map +1 -0
- package/dist/graph-with-controls.js +155 -0
- package/dist/graph.d.ts +120 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +221 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.d.ts.map +1 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +44 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/labels.d.ts +74 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +134 -0
- package/dist/mark-label.d.ts +50 -0
- package/dist/mark-label.d.ts.map +1 -0
- package/dist/mark-label.js +84 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +25 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +100 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +61 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +42 -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_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +78 -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 +49 -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 +46 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +52 -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/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js +68 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +10 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +15 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +8 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +15 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +19 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +18 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +19 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +10 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +20 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/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-input-autosize@2.2.2_f4eacebf2041cd4f/node_modules/react-input-autosize/lib/AutosizeInput.js +216 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +82 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +62 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/index.js +10 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/Context.js +5 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/Provider.js +47 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/connectAdvanced.js +95 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/connect.js +52 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mapDispatchToProps.js +23 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mapStateToProps.js +13 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mergeProps.js +26 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/selectorFactory.js +41 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/verifySubselectors.js +11 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/wrapMapToProps.js +28 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/index.js +4 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/isPlainObject.js +10 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/shallowEqual.js +15 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/verifyPlainObject.js +8 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/warning.js +9 -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@4.2.1/node_modules/redux/es/redux.js +225 -0
- package/dist/toggle-bar.d.ts +41 -0
- package/dist/toggle-bar.d.ts.map +1 -0
- package/dist/tool-menu.d.ts +22 -0
- package/dist/tool-menu.d.ts.map +1 -0
- package/dist/tool-menu.js +188 -0
- package/dist/tools/index.d.ts +18 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/line/component.d.ts +92 -0
- package/dist/tools/line/component.d.ts.map +1 -0
- package/dist/tools/line/component.js +58 -0
- package/dist/tools/line/index.d.ts +14 -0
- package/dist/tools/line/index.d.ts.map +1 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/polygon/component.d.ts +115 -0
- package/dist/tools/polygon/component.d.ts.map +1 -0
- package/dist/tools/polygon/component.js +194 -0
- package/dist/tools/polygon/index.d.ts +20 -0
- package/dist/tools/polygon/index.d.ts.map +1 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +105 -0
- package/dist/tools/polygon/line.d.ts.map +1 -0
- package/dist/tools/polygon/polygon.d.ts +102 -0
- package/dist/tools/polygon/polygon.d.ts.map +1 -0
- package/dist/tools/polygon/polygon.js +62 -0
- package/dist/tools/shared/arrow-head.d.ts +43 -0
- package/dist/tools/shared/arrow-head.d.ts.map +1 -0
- package/dist/tools/shared/arrow-head.js +37 -0
- package/dist/tools/shared/line/index.d.ts +165 -0
- package/dist/tools/shared/line/index.d.ts.map +1 -0
- package/dist/tools/shared/line/index.js +320 -0
- package/dist/tools/shared/line/line-path.d.ts +58 -0
- package/dist/tools/shared/line/line-path.d.ts.map +1 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +89 -0
- package/dist/tools/shared/line/with-root-edge.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow-point.d.ts +58 -0
- package/dist/tools/shared/point/arrow-point.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow-point.js +47 -0
- package/dist/tools/shared/point/arrow.d.ts +47 -0
- package/dist/tools/shared/point/arrow.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow.js +36 -0
- package/dist/tools/shared/point/base-point.d.ts +51 -0
- package/dist/tools/shared/point/base-point.d.ts.map +1 -0
- package/dist/tools/shared/point/base-point.js +88 -0
- package/dist/tools/shared/point/index.d.ts +154 -0
- package/dist/tools/shared/point/index.d.ts.map +1 -0
- package/dist/tools/shared/point/index.js +51 -0
- package/dist/tools/shared/styles.d.ts +25 -0
- package/dist/tools/shared/styles.d.ts.map +1 -0
- package/dist/tools/shared/styles.js +17 -0
- package/dist/tools/shared/types.d.ts +16 -0
- package/dist/tools/shared/types.d.ts.map +1 -0
- package/dist/tools/shared/types.js +10 -0
- package/dist/undo-redo.d.ts +21 -0
- package/dist/undo-redo.d.ts.map +1 -0
- package/dist/undo-redo.js +33 -0
- package/dist/use-debounce.d.ts +10 -0
- package/dist/use-debounce.d.ts.map +1 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +59 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +72 -0
- package/package.json +64 -0
- package/src/axis/arrow.tsx +67 -0
- package/src/axis/axes.tsx +321 -0
- package/src/axis/index.ts +13 -0
- package/src/bg.tsx +106 -0
- package/src/container/actions.ts +18 -0
- package/src/container/index.tsx +95 -0
- package/src/container/marks.ts +24 -0
- package/src/container/middleware.ts +17 -0
- package/src/container/reducer.ts +15 -0
- package/src/coordinates-label.tsx +72 -0
- package/src/graph-with-controls.tsx +252 -0
- package/src/graph.tsx +343 -0
- package/src/grid-setup.tsx +470 -0
- package/src/grid.tsx +143 -0
- package/src/index.ts +17 -0
- package/src/labels.tsx +211 -0
- package/src/mark-label.tsx +135 -0
- package/src/toggle-bar.tsx +231 -0
- package/src/tool-menu.tsx +245 -0
- package/src/tools/index.ts +18 -0
- package/src/tools/line/component.tsx +87 -0
- package/src/tools/line/index.ts +14 -0
- package/src/tools/polygon/component.tsx +334 -0
- package/src/tools/polygon/index.ts +62 -0
- package/src/tools/polygon/line.tsx +90 -0
- package/src/tools/polygon/polygon.tsx +103 -0
- package/src/tools/shared/arrow-head.tsx +56 -0
- package/src/tools/shared/line/index.tsx +481 -0
- package/src/tools/shared/line/line-path.tsx +95 -0
- package/src/tools/shared/line/with-root-edge.tsx +107 -0
- package/src/tools/shared/point/arrow-point.tsx +70 -0
- package/src/tools/shared/point/arrow.tsx +50 -0
- package/src/tools/shared/point/base-point.tsx +123 -0
- package/src/tools/shared/point/index.tsx +68 -0
- package/src/tools/shared/styles.ts +30 -0
- package/src/tools/shared/types.ts +18 -0
- package/src/undo-redo.tsx +47 -0
- package/src/use-debounce.ts +23 -0
- package/src/utils.ts +240 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/tools/polygon/index.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Polygon from './component.js';
|
|
12
|
+
import { equalPoints } from '../../utils.js';
|
|
13
|
+
|
|
14
|
+
export const addPointToArray = (point, arr) => {
|
|
15
|
+
arr = arr || [];
|
|
16
|
+
|
|
17
|
+
if (arr.length === 0) {
|
|
18
|
+
return { points: [point], closed: false };
|
|
19
|
+
} else if (arr.length === 1) {
|
|
20
|
+
if (equalPoints(point, arr[0])) {
|
|
21
|
+
return { points: arr, closed: false };
|
|
22
|
+
} else {
|
|
23
|
+
return { points: [...arr, point], closed: false };
|
|
24
|
+
}
|
|
25
|
+
} else if (arr.length >= 2) {
|
|
26
|
+
const closed = equalPoints(point, arr[0]);
|
|
27
|
+
|
|
28
|
+
if (closed) {
|
|
29
|
+
return { points: arr, closed };
|
|
30
|
+
} else {
|
|
31
|
+
const hasPoint = !!arr.find((p) => equalPoints(p, point));
|
|
32
|
+
|
|
33
|
+
if (hasPoint) {
|
|
34
|
+
return { points: arr, closed: false };
|
|
35
|
+
} else {
|
|
36
|
+
return { points: [...arr, point], closed: false };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const tool = () => ({
|
|
43
|
+
type: 'polygon',
|
|
44
|
+
Component: Polygon,
|
|
45
|
+
complete: (data, mark) => {
|
|
46
|
+
return { ...mark, building: false, closed: true };
|
|
47
|
+
},
|
|
48
|
+
addPoint: (point, mark) => {
|
|
49
|
+
if (!mark) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'polygon',
|
|
52
|
+
points: [point],
|
|
53
|
+
closed: false,
|
|
54
|
+
building: true,
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
const { closed, points } = addPointToArray(point, mark.points);
|
|
58
|
+
|
|
59
|
+
return { ...mark, closed, points, building: !closed };
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/tools/polygon/line.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { gridDraggable, types } from '@pie-lib/plot';
|
|
15
|
+
import { color } from '@pie-lib/render-ui';
|
|
16
|
+
import * as utils from '../../utils.js';
|
|
17
|
+
import { correct, disabled, incorrect, missing } from '../shared/styles.js';
|
|
18
|
+
|
|
19
|
+
const StyledLine: any = styled('line', {
|
|
20
|
+
shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
|
|
21
|
+
})(({ disabled: isDisabled, correctness }) => ({
|
|
22
|
+
strokeWidth: 6,
|
|
23
|
+
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
24
|
+
stroke: 'transparent',
|
|
25
|
+
'&:hover': {
|
|
26
|
+
strokeWidth: 7,
|
|
27
|
+
stroke: color.defaults.SECONDARY,
|
|
28
|
+
},
|
|
29
|
+
...(isDisabled && {
|
|
30
|
+
...disabled('stroke'),
|
|
31
|
+
strokeWidth: 2,
|
|
32
|
+
}),
|
|
33
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
34
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
35
|
+
...(correctness === 'missing' && missing('stroke')),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
class RawLine extends React.Component {
|
|
39
|
+
static propTypes = {
|
|
40
|
+
className: PropTypes.string,
|
|
41
|
+
from: types.PointType,
|
|
42
|
+
to: types.PointType,
|
|
43
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
44
|
+
disabled: PropTypes.bool,
|
|
45
|
+
correctness: PropTypes.string,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
from: {},
|
|
50
|
+
to: {},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
const { graphProps, from, to, className, disabled, correctness, ...rest } = this.props;
|
|
55
|
+
const { scale } = graphProps;
|
|
56
|
+
return (
|
|
57
|
+
<StyledLine
|
|
58
|
+
x1={scale.x(from.x)}
|
|
59
|
+
y1={scale.y(from.y)}
|
|
60
|
+
x2={scale.x(to.x)}
|
|
61
|
+
y2={scale.y(to.y)}
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
correctness={correctness}
|
|
64
|
+
className={className}
|
|
65
|
+
{...rest}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Line = RawLine;
|
|
72
|
+
|
|
73
|
+
export default gridDraggable({
|
|
74
|
+
bounds: (props, { domain, range }) => {
|
|
75
|
+
const { from, to } = props;
|
|
76
|
+
const area = utils.lineToArea(from, to);
|
|
77
|
+
return utils.bounds(area, domain, range);
|
|
78
|
+
},
|
|
79
|
+
anchorPoint: (props) => {
|
|
80
|
+
const { from } = props;
|
|
81
|
+
return from;
|
|
82
|
+
},
|
|
83
|
+
fromDelta: (props, delta) => {
|
|
84
|
+
const { from, to } = props;
|
|
85
|
+
return {
|
|
86
|
+
from: utils.point(from).add(utils.point(delta)),
|
|
87
|
+
to: utils.point(to).add(utils.point(delta)),
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
})(Line);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/tools/polygon/polygon.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { gridDraggable, types } from '@pie-lib/plot';
|
|
15
|
+
import * as utils from '../../utils.js';
|
|
16
|
+
import { correct, incorrect } from '../shared/styles.js';
|
|
17
|
+
|
|
18
|
+
const StyledPolygon: any = styled('polygon', {
|
|
19
|
+
shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
|
|
20
|
+
})(({ isSolution, correctness }) => ({
|
|
21
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
|
|
22
|
+
strokeWidth: 2,
|
|
23
|
+
'&:hover': {
|
|
24
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
|
|
25
|
+
},
|
|
26
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
27
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const StyledPolyline: any = styled('polyline', {
|
|
31
|
+
shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
|
|
32
|
+
})(({ isSolution, correctness }) => ({
|
|
33
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
|
|
34
|
+
strokeWidth: 2,
|
|
35
|
+
'&:hover': {
|
|
36
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
|
|
37
|
+
},
|
|
38
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
39
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
export const getPointString = (points, scale) => {
|
|
43
|
+
return (points || [])
|
|
44
|
+
.map((p) => {
|
|
45
|
+
const scaledPoint = {
|
|
46
|
+
x: scale.x(p.x),
|
|
47
|
+
y: scale.y(p.y),
|
|
48
|
+
};
|
|
49
|
+
return `${scaledPoint.x},${scaledPoint.y}`;
|
|
50
|
+
})
|
|
51
|
+
.join(' ');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export class RawPolygon extends React.Component {
|
|
55
|
+
static propTypes = {
|
|
56
|
+
className: PropTypes.string,
|
|
57
|
+
isSolution: PropTypes.bool,
|
|
58
|
+
points: PropTypes.arrayOf(types.PointType),
|
|
59
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
60
|
+
closed: PropTypes.bool.isRequired,
|
|
61
|
+
correctness: PropTypes.string,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
static defaultProps = {
|
|
65
|
+
points: [],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
render() {
|
|
69
|
+
const { points, className, correctness, graphProps, closed, isSolution, ...rest } = this.props;
|
|
70
|
+
const { scale } = graphProps;
|
|
71
|
+
|
|
72
|
+
const pointString = getPointString(points, scale);
|
|
73
|
+
const Component = closed ? StyledPolygon : StyledPolyline;
|
|
74
|
+
return (
|
|
75
|
+
<Component
|
|
76
|
+
points={pointString}
|
|
77
|
+
isSolution={isSolution}
|
|
78
|
+
correctness={correctness}
|
|
79
|
+
className={className}
|
|
80
|
+
{...rest}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const Polygon = RawPolygon;
|
|
87
|
+
|
|
88
|
+
export default gridDraggable({
|
|
89
|
+
bounds: (props, { domain, range }) => {
|
|
90
|
+
const { points } = props;
|
|
91
|
+
const area = utils.polygonToArea(points);
|
|
92
|
+
return utils.bounds(area, domain, range);
|
|
93
|
+
},
|
|
94
|
+
anchorPoint: (props) => {
|
|
95
|
+
const { points } = props;
|
|
96
|
+
return points[0];
|
|
97
|
+
},
|
|
98
|
+
fromDelta: (props, delta) => {
|
|
99
|
+
const { points } = props;
|
|
100
|
+
|
|
101
|
+
return points.map((p) => utils.point(p).add(utils.point(delta)));
|
|
102
|
+
},
|
|
103
|
+
})(Polygon);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/tools/shared/arrow-head.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { color } from '@pie-lib/render-ui';
|
|
14
|
+
|
|
15
|
+
export const ArrowHead = ({ size, transform, points }) => (
|
|
16
|
+
<polygon points={points || `0,0 ${size},${size / 2} 0,${size}`} transform={transform} />
|
|
17
|
+
);
|
|
18
|
+
ArrowHead.propTypes = {
|
|
19
|
+
points: PropTypes.string,
|
|
20
|
+
size: PropTypes.number,
|
|
21
|
+
transform: PropTypes.string,
|
|
22
|
+
};
|
|
23
|
+
ArrowHead.defaultProps = {
|
|
24
|
+
points: '',
|
|
25
|
+
size: 10,
|
|
26
|
+
transform: '',
|
|
27
|
+
};
|
|
28
|
+
export const genUid = () => {
|
|
29
|
+
const v = (Math.random() * 1000).toFixed(0);
|
|
30
|
+
return `arrow-${v}`;
|
|
31
|
+
};
|
|
32
|
+
export const ArrowMarker = ({ id, size, className }) => {
|
|
33
|
+
return (
|
|
34
|
+
<marker
|
|
35
|
+
id={id}
|
|
36
|
+
viewBox={`0 0 ${size} ${size}`}
|
|
37
|
+
refX={size / 2}
|
|
38
|
+
refY={size / 2}
|
|
39
|
+
markerWidth={size}
|
|
40
|
+
markerHeight={size}
|
|
41
|
+
orient="auto-start-reverse"
|
|
42
|
+
className={className}
|
|
43
|
+
style={{ fill: color.defaults.BLACK }}
|
|
44
|
+
>
|
|
45
|
+
<ArrowHead size={size} />
|
|
46
|
+
</marker>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
ArrowMarker.propTypes = {
|
|
50
|
+
id: PropTypes.string,
|
|
51
|
+
size: PropTypes.number,
|
|
52
|
+
className: PropTypes.string,
|
|
53
|
+
};
|
|
54
|
+
ArrowMarker.defaultProps = {
|
|
55
|
+
size: 5,
|
|
56
|
+
};
|