@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
package/src/labels.tsx
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/labels.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 { types } from '@pie-lib/plot';
|
|
15
|
+
import { color, Readable as ReadableImport } from '@pie-lib/render-ui';
|
|
16
|
+
|
|
17
|
+
function isRenderableReactInteropType(value: any) {
|
|
18
|
+
return (
|
|
19
|
+
typeof value === 'function' ||
|
|
20
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
25
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
26
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
27
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
28
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
29
|
+
return maybeSymbol[namedExport];
|
|
30
|
+
}
|
|
31
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
32
|
+
return maybeSymbol[namedExport].default;
|
|
33
|
+
}
|
|
34
|
+
return maybeSymbol;
|
|
35
|
+
}
|
|
36
|
+
const Readable = unwrapReactInteropSymbol(ReadableImport, 'Readable') || unwrapReactInteropSymbol(renderUi.Readable, 'Readable');
|
|
37
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
38
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
39
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
40
|
+
const renderUi =
|
|
41
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
42
|
+
? renderUiDefaultMaybe
|
|
43
|
+
: renderUiNamespaceAny;
|
|
44
|
+
import EditableHtml from '@pie-lib/editable-html-tip-tap';
|
|
45
|
+
import cn from 'classnames';
|
|
46
|
+
|
|
47
|
+
const rotations = {
|
|
48
|
+
left: -90,
|
|
49
|
+
top: 0,
|
|
50
|
+
bottom: 0,
|
|
51
|
+
right: 90,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const getTransform = (side, width, height) => {
|
|
55
|
+
const t = (x, y, rotate) => `translate(${x}, ${y}), rotate(${rotate})`;
|
|
56
|
+
|
|
57
|
+
if (side === 'left') return t(-20, height / 2, rotations[side]);
|
|
58
|
+
if (side === 'right') return t(width + 30, height / 2, rotations[side]);
|
|
59
|
+
if (side === 'top') return t(width / 2, -20, rotations[side]);
|
|
60
|
+
if (side === 'bottom') return t(width / 2, height + 30, rotations[side]);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getY = (side, height) => {
|
|
64
|
+
switch (side) {
|
|
65
|
+
case 'left':
|
|
66
|
+
case 'top':
|
|
67
|
+
return -height;
|
|
68
|
+
case 'right':
|
|
69
|
+
return -height - 10;
|
|
70
|
+
default:
|
|
71
|
+
return -height + 10;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const PREFIX = 'Label';
|
|
76
|
+
const classes = {
|
|
77
|
+
label: `${PREFIX}-label`,
|
|
78
|
+
axisLabel: `${PREFIX}-axisLabel`,
|
|
79
|
+
disabledAxisLabel: `${PREFIX}-disabledAxisLabel`,
|
|
80
|
+
bottomLabel: `${PREFIX}-bottomLabel`,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const Root: any = styled('div')(({ theme }) => ({
|
|
84
|
+
[`& .${classes.label}`]: {
|
|
85
|
+
fill: color.defaults.SECONDARY,
|
|
86
|
+
},
|
|
87
|
+
[`& .${classes.axisLabel}`]: {
|
|
88
|
+
fontSize: theme.typography.fontSize - 2,
|
|
89
|
+
textAlign: 'center',
|
|
90
|
+
padding: '0 4px',
|
|
91
|
+
},
|
|
92
|
+
[`& .${classes.disabledAxisLabel}`]: {
|
|
93
|
+
pointerEvents: 'none',
|
|
94
|
+
},
|
|
95
|
+
[`& .${classes.bottomLabel}`]: {
|
|
96
|
+
marginTop: '44px',
|
|
97
|
+
},
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
class RawLabel extends React.Component {
|
|
101
|
+
static propTypes = {
|
|
102
|
+
text: PropTypes.string,
|
|
103
|
+
side: PropTypes.string,
|
|
104
|
+
disabledLabel: PropTypes.bool,
|
|
105
|
+
placeholder: PropTypes.string,
|
|
106
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
107
|
+
onChange: PropTypes.func,
|
|
108
|
+
mathMlOptions: PropTypes.object,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
static defaultProps = {
|
|
112
|
+
onChange: () => {},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
const { disabledLabel, placeholder, text, side, graphProps, onChange, mathMlOptions = {} } = this.props;
|
|
117
|
+
const { size, domain, range } = graphProps;
|
|
118
|
+
const totalHeight = (size.height || 500) + (range.padding || 0) * 2;
|
|
119
|
+
const totalWidth = (size.width || 500) + (domain.padding || 0) * 2;
|
|
120
|
+
|
|
121
|
+
const transform = getTransform(side, totalWidth, totalHeight);
|
|
122
|
+
const width = side === 'left' || side === 'right' ? totalHeight : totalWidth;
|
|
123
|
+
const height = 36;
|
|
124
|
+
const y = getY(side, height);
|
|
125
|
+
const finalHeight = side === 'bottom' ? height + 22 : height + 18;
|
|
126
|
+
|
|
127
|
+
const activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math'];
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<Root>
|
|
131
|
+
<foreignObject
|
|
132
|
+
x={-(width / 2)}
|
|
133
|
+
y={y}
|
|
134
|
+
width={width}
|
|
135
|
+
height={finalHeight}
|
|
136
|
+
transform={transform}
|
|
137
|
+
textAnchor="middle"
|
|
138
|
+
>
|
|
139
|
+
<Readable>
|
|
140
|
+
<EditableHtml
|
|
141
|
+
className={cn(
|
|
142
|
+
{
|
|
143
|
+
[classes.bottomLabel]: side === 'bottom',
|
|
144
|
+
[classes.disabledAxisLabel]: disabledLabel,
|
|
145
|
+
},
|
|
146
|
+
classes.axisLabel,
|
|
147
|
+
)}
|
|
148
|
+
markup={text || ''}
|
|
149
|
+
onChange={onChange}
|
|
150
|
+
placeholder={!disabledLabel && placeholder}
|
|
151
|
+
toolbarOpts={{
|
|
152
|
+
position: side === 'bottom' ? 'top' : 'bottom',
|
|
153
|
+
noPadding: true,
|
|
154
|
+
noBorder: true,
|
|
155
|
+
}}
|
|
156
|
+
activePlugins={activePlugins}
|
|
157
|
+
mathMlOptions={mathMlOptions}
|
|
158
|
+
/>
|
|
159
|
+
</Readable>
|
|
160
|
+
</foreignObject>
|
|
161
|
+
</Root>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const LabelType = {
|
|
167
|
+
left: PropTypes.string,
|
|
168
|
+
top: PropTypes.string,
|
|
169
|
+
bottom: PropTypes.string,
|
|
170
|
+
right: PropTypes.string,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export class Labels extends React.Component {
|
|
174
|
+
static propTypes = {
|
|
175
|
+
disabledLabels: PropTypes.bool,
|
|
176
|
+
placeholders: PropTypes.object,
|
|
177
|
+
value: PropTypes.shape(LabelType),
|
|
178
|
+
graphProps: PropTypes.object,
|
|
179
|
+
onChange: PropTypes.func,
|
|
180
|
+
mathMlOptions: PropTypes.object,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
onChangeLabel: any = (newValue, side) => {
|
|
184
|
+
const { value, onChange } = this.props;
|
|
185
|
+
const labels = { ...value, [side]: newValue };
|
|
186
|
+
onChange(labels);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
render() {
|
|
190
|
+
const { disabledLabels, placeholders = {}, value = {}, graphProps, mathMlOptions = {} } = this.props;
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
{['left', 'top', 'bottom', 'right'].map((side) => (
|
|
195
|
+
<RawLabel
|
|
196
|
+
key={side}
|
|
197
|
+
side={side}
|
|
198
|
+
text={value[side]}
|
|
199
|
+
disabledLabel={disabledLabels}
|
|
200
|
+
placeholder={placeholders[side]}
|
|
201
|
+
graphProps={graphProps}
|
|
202
|
+
onChange={(val) => this.onChangeLabel(val, side)}
|
|
203
|
+
mathMlOptions={mathMlOptions}
|
|
204
|
+
/>
|
|
205
|
+
))}
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default RawLabel;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/mark-label.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, { useCallback, useEffect, useState } from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import AutosizeInput from 'react-input-autosize';
|
|
15
|
+
import { useDebounce } from './use-debounce.js';
|
|
16
|
+
import { types } from '@pie-lib/plot';
|
|
17
|
+
import { color } from '@pie-lib/render-ui';
|
|
18
|
+
|
|
19
|
+
const StyledAutosizeInput: any = styled(AutosizeInput, {
|
|
20
|
+
shouldForwardProp: (prop) => !['disabled', 'markDisabled'].includes(prop),
|
|
21
|
+
})(({ theme, disabled, markDisabled }) => ({
|
|
22
|
+
'& input': {
|
|
23
|
+
float: 'right',
|
|
24
|
+
padding: theme.spacing(0.5),
|
|
25
|
+
fontFamily: theme.typography.fontFamily,
|
|
26
|
+
fontSize: theme.typography.fontSize,
|
|
27
|
+
border: `solid 1px ${disabled ? color.defaults.PRIMARY_DARK : markDisabled ? color.disabled() : color.defaults.SECONDARY}`,
|
|
28
|
+
borderRadius: '3px',
|
|
29
|
+
color: markDisabled ? color.disabled() : color.defaults.PRIMARY_DARK,
|
|
30
|
+
background: disabled || markDisabled ? theme.palette.background.paper : 'transparent',
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
export const position = (graphProps, mark, rect) => {
|
|
35
|
+
rect = rect || { width: 0, height: 0 };
|
|
36
|
+
const { scale, domain, range } = graphProps;
|
|
37
|
+
const shift = 10;
|
|
38
|
+
|
|
39
|
+
const rightEdge = scale.x(mark.x) + rect.width + shift;
|
|
40
|
+
const bottomEdge = scale.y(mark.y) + rect.height + shift;
|
|
41
|
+
|
|
42
|
+
const h = rightEdge >= scale.x(domain.max) ? 'left' : 'right';
|
|
43
|
+
const v = bottomEdge >= scale.y(range.min) ? 'top' : 'bottom';
|
|
44
|
+
|
|
45
|
+
return `${v}-${h}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const coordinates = (graphProps, mark, rect, position) => {
|
|
49
|
+
const { scale } = graphProps;
|
|
50
|
+
const shift = 10;
|
|
51
|
+
rect = rect || { width: 0, height: 0 };
|
|
52
|
+
|
|
53
|
+
switch (position) {
|
|
54
|
+
case 'bottom-right': {
|
|
55
|
+
return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) + shift };
|
|
56
|
+
}
|
|
57
|
+
case 'bottom-left': {
|
|
58
|
+
return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) + shift };
|
|
59
|
+
}
|
|
60
|
+
case 'top-left': {
|
|
61
|
+
return {
|
|
62
|
+
left: scale.x(mark.x) - shift - rect.width,
|
|
63
|
+
top: scale.y(mark.y) - shift - rect.height,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
case 'top-right': {
|
|
67
|
+
return {
|
|
68
|
+
left: scale.x(mark.x) + shift,
|
|
69
|
+
top: scale.y(mark.y) - shift - rect.height,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const MarkLabel = (props) => {
|
|
76
|
+
const [input, setInput] = useState(null);
|
|
77
|
+
const _ref = useCallback((node) => setInput(node));
|
|
78
|
+
|
|
79
|
+
const { mark, graphProps, disabled, inputRef: externalInputRef } = props;
|
|
80
|
+
|
|
81
|
+
const [label, setLabel] = useState(mark.label);
|
|
82
|
+
|
|
83
|
+
const onChange = (e) => setLabel(e.target.value);
|
|
84
|
+
|
|
85
|
+
const debouncedLabel = useDebounce(label, 200);
|
|
86
|
+
|
|
87
|
+
// useState only sets the value once, to synch props to state need useEffect
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
setLabel(mark.label);
|
|
90
|
+
}, [mark.label]);
|
|
91
|
+
|
|
92
|
+
// pick up the change to debouncedLabel and save it
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (typeof debouncedLabel === 'string' && debouncedLabel !== mark.label) {
|
|
95
|
+
props.onChange(debouncedLabel);
|
|
96
|
+
}
|
|
97
|
+
}, [debouncedLabel]);
|
|
98
|
+
|
|
99
|
+
const rect = input ? input.getBoundingClientRect() : { width: 0, height: 0 };
|
|
100
|
+
const pos = position(graphProps, mark, rect);
|
|
101
|
+
const leftTop = coordinates(graphProps, mark, rect, pos);
|
|
102
|
+
|
|
103
|
+
const style = {
|
|
104
|
+
position: 'fixed',
|
|
105
|
+
pointerEvents: 'auto',
|
|
106
|
+
...leftTop,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const disabledInput = disabled || mark.disabled;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<StyledAutosizeInput
|
|
113
|
+
inputRef={(r) => {
|
|
114
|
+
_ref(r);
|
|
115
|
+
externalInputRef(r);
|
|
116
|
+
}}
|
|
117
|
+
disabled={disabledInput}
|
|
118
|
+
markDisabled={mark.disabled}
|
|
119
|
+
value={label}
|
|
120
|
+
style={style}
|
|
121
|
+
onChange={onChange}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
MarkLabel.propTypes = {
|
|
127
|
+
disabled: PropTypes.bool,
|
|
128
|
+
onChange: PropTypes.func,
|
|
129
|
+
graphProps: types.GraphPropsType,
|
|
130
|
+
inputRef: PropTypes.func,
|
|
131
|
+
mark: PropTypes.object,
|
|
132
|
+
theme: PropTypes.object,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default MarkLabel;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/toggle-bar.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 Button from '@mui/material/Button';
|
|
15
|
+
import { color } from '@pie-lib/render-ui';
|
|
16
|
+
import { allTools } from './tools/index.js';
|
|
17
|
+
import { DragProvider } from '@pie-lib/drag';
|
|
18
|
+
import { useDraggable, useDroppable } from '@dnd-kit/core';
|
|
19
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
20
|
+
import { arrayMove } from '@dnd-kit/sortable';
|
|
21
|
+
import Translator from '@pie-lib/translator';
|
|
22
|
+
|
|
23
|
+
const { translator } = Translator;
|
|
24
|
+
|
|
25
|
+
const StyledMiniButton: any = styled(Button, {
|
|
26
|
+
shouldForwardProp: (prop) => !['selected'].includes(prop),
|
|
27
|
+
})(({ selected, disabled }) => ({
|
|
28
|
+
color: color.text(),
|
|
29
|
+
backgroundColor: color.background(),
|
|
30
|
+
...(selected && {
|
|
31
|
+
border: `1px solid ${color.secondary()}`,
|
|
32
|
+
}),
|
|
33
|
+
...(!selected && {
|
|
34
|
+
'& span': {
|
|
35
|
+
color: color.primary(),
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
...(disabled && {
|
|
39
|
+
'& span': {
|
|
40
|
+
color: color.primary(),
|
|
41
|
+
},
|
|
42
|
+
backgroundColor: color.disabled(),
|
|
43
|
+
}),
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
export const MiniButton = (props) => {
|
|
47
|
+
const { disabled, className, selected, value, onClick, language } = props;
|
|
48
|
+
const translatorKey = value.toLowerCase();
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<StyledMiniButton
|
|
52
|
+
size="small"
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
className={className}
|
|
55
|
+
selected={selected}
|
|
56
|
+
value={value}
|
|
57
|
+
key={value}
|
|
58
|
+
variant="outlined"
|
|
59
|
+
onClick={(e) => onClick({ ...e, buttonValue: value })}
|
|
60
|
+
>
|
|
61
|
+
{translator.t(`graphing.${translatorKey}`, { lng: language })}
|
|
62
|
+
</StyledMiniButton>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
MiniButton.propTypes = {
|
|
67
|
+
disabled: PropTypes.bool,
|
|
68
|
+
className: PropTypes.string,
|
|
69
|
+
disabledClassName: PropTypes.string,
|
|
70
|
+
selected: PropTypes.bool,
|
|
71
|
+
value: PropTypes.string,
|
|
72
|
+
onClick: PropTypes.func,
|
|
73
|
+
language: PropTypes.string,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const StyledToolsContainer: any = styled('div')(() => ({
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexWrap: 'wrap',
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
const StyledButton: any = styled(MiniButton)(({ theme }) => ({
|
|
82
|
+
marginRight: theme.spacing(0.5),
|
|
83
|
+
marginBottom: theme.spacing(0.5),
|
|
84
|
+
color: color.text(),
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
const StyledWrapper: any = styled('div')({
|
|
88
|
+
position: 'relative',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export class ToggleBar extends React.Component {
|
|
92
|
+
static propTypes = {
|
|
93
|
+
className: PropTypes.string,
|
|
94
|
+
options: PropTypes.arrayOf(PropTypes.string),
|
|
95
|
+
selectedToolType: PropTypes.string,
|
|
96
|
+
disabled: PropTypes.bool,
|
|
97
|
+
draggableTools: PropTypes.bool,
|
|
98
|
+
onChange: PropTypes.func,
|
|
99
|
+
onChangeToolsOrder: PropTypes.func,
|
|
100
|
+
language: PropTypes.string,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
static defaultProps = {};
|
|
104
|
+
|
|
105
|
+
select = (e) => this.props.onChange(e.buttonValue || e.target.textContent);
|
|
106
|
+
|
|
107
|
+
moveTool: any = (dragIndex, hoverIndex) => {
|
|
108
|
+
const { options, onChangeToolsOrder } = this.props;
|
|
109
|
+
const newOptions = arrayMove(options, dragIndex, hoverIndex);
|
|
110
|
+
|
|
111
|
+
onChangeToolsOrder(newOptions);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
handleDragEnd: any = (event) => {
|
|
115
|
+
const { active, over } = event;
|
|
116
|
+
|
|
117
|
+
if (!over || !active) return;
|
|
118
|
+
|
|
119
|
+
const activeData = active.data.current;
|
|
120
|
+
const overData = over.data.current;
|
|
121
|
+
|
|
122
|
+
if (activeData?.type === 'tool' && overData?.type === 'tool') {
|
|
123
|
+
const dragIndex = activeData.index;
|
|
124
|
+
const hoverIndex = overData.index;
|
|
125
|
+
|
|
126
|
+
if (dragIndex !== hoverIndex) {
|
|
127
|
+
this.moveTool(dragIndex, hoverIndex);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
render() {
|
|
133
|
+
const { className, disabled, options, selectedToolType, draggableTools, language } = this.props;
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<DragProvider onDragEnd={this.handleDragEnd}>
|
|
137
|
+
<StyledToolsContainer className={className}>
|
|
138
|
+
{(options || []).map((option, index) => {
|
|
139
|
+
if ((allTools || []).includes(option)) {
|
|
140
|
+
const isSelected = option === selectedToolType;
|
|
141
|
+
const toolRef = React.createRef();
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<DragTool
|
|
145
|
+
key={option}
|
|
146
|
+
index={index}
|
|
147
|
+
value={option}
|
|
148
|
+
draggable={draggableTools}
|
|
149
|
+
moveTool={this.moveTool}
|
|
150
|
+
toolRef={toolRef}
|
|
151
|
+
>
|
|
152
|
+
<StyledButton
|
|
153
|
+
disabled={disabled}
|
|
154
|
+
disableRipple={true}
|
|
155
|
+
onClick={this.select}
|
|
156
|
+
value={option}
|
|
157
|
+
selected={isSelected}
|
|
158
|
+
language={language}
|
|
159
|
+
/>
|
|
160
|
+
</DragTool>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
})}
|
|
164
|
+
</StyledToolsContainer>
|
|
165
|
+
</DragProvider>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// DragTool functional component using @dnd-kit hooks
|
|
171
|
+
function DragTool({ children, index, draggable, toolRef, value }) {
|
|
172
|
+
const {
|
|
173
|
+
attributes,
|
|
174
|
+
listeners,
|
|
175
|
+
setNodeRef: setDragNodeRef,
|
|
176
|
+
transform,
|
|
177
|
+
transition,
|
|
178
|
+
isDragging,
|
|
179
|
+
} = useDraggable({
|
|
180
|
+
id: `tool-${value}-${index}`,
|
|
181
|
+
disabled: !draggable,
|
|
182
|
+
data: {
|
|
183
|
+
type: 'tool',
|
|
184
|
+
index,
|
|
185
|
+
value,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const { setNodeRef: setDropNodeRef } = useDroppable({
|
|
190
|
+
id: `drop-tool-${value}-${index}`,
|
|
191
|
+
data: {
|
|
192
|
+
type: 'tool',
|
|
193
|
+
index,
|
|
194
|
+
accepts: ['tool'],
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Combine refs
|
|
199
|
+
const setNodeRef = (node) => {
|
|
200
|
+
setDragNodeRef(node);
|
|
201
|
+
setDropNodeRef(node);
|
|
202
|
+
if (toolRef?.current) {
|
|
203
|
+
toolRef.current = node;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const style = {
|
|
208
|
+
transform: CSS.Transform.toString(transform),
|
|
209
|
+
transition,
|
|
210
|
+
opacity: isDragging ? 0.5 : 1,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<StyledWrapper ref={setNodeRef} style={style}>
|
|
215
|
+
<div {...attributes} {...listeners}>
|
|
216
|
+
{children}
|
|
217
|
+
</div>
|
|
218
|
+
</StyledWrapper>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
DragTool.propTypes = {
|
|
223
|
+
children: PropTypes.node,
|
|
224
|
+
index: PropTypes.number,
|
|
225
|
+
draggable: PropTypes.bool,
|
|
226
|
+
moveTool: PropTypes.func,
|
|
227
|
+
toolRef: PropTypes.object,
|
|
228
|
+
value: PropTypes.string,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export default ToggleBar;
|