@pie-lib/charting 7.0.3 → 7.0.4-next.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/actions-button.d.ts +26 -0
- package/dist/actions-button.js +84 -0
- package/dist/axes.d.ts +84 -0
- package/dist/axes.js +376 -0
- package/dist/bars/bar.d.ts +47 -0
- package/dist/bars/bar.js +27 -0
- package/dist/bars/common/bars.d.ts +98 -0
- package/dist/bars/common/bars.js +174 -0
- package/dist/bars/common/correct-check-icon.d.ts +18 -0
- package/dist/bars/common/correct-check-icon.js +50 -0
- package/dist/bars/histogram.d.ts +47 -0
- package/dist/bars/histogram.js +28 -0
- package/dist/chart-setup.d.ts +29 -0
- package/dist/chart-setup.js +231 -0
- package/dist/chart-type.d.ts +32 -0
- package/dist/chart-type.js +68 -0
- package/dist/chart-types.d.ts +41 -0
- package/dist/chart-types.js +17 -0
- package/dist/chart.d.ts +88 -0
- package/dist/chart.js +250 -0
- package/dist/common/correctness-indicators.d.ts +70 -0
- package/dist/common/correctness-indicators.js +106 -0
- package/dist/common/drag-handle.d.ts +129 -0
- package/dist/common/drag-handle.js +120 -0
- package/dist/common/drag-icon.d.ts +23 -0
- package/dist/common/drag-icon.js +45 -0
- package/dist/common/styles.d.ts +23 -0
- package/dist/common/styles.js +17 -0
- package/dist/grid.d.ts +45 -0
- package/dist/grid.js +56 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -0
- package/dist/key-legend.d.ts +19 -0
- package/dist/key-legend.js +46 -0
- package/dist/line/common/drag-handle.d.ts +120 -0
- package/dist/line/common/drag-handle.js +92 -0
- package/dist/line/common/line.d.ts +96 -0
- package/dist/line/common/line.js +114 -0
- package/dist/line/line-cross.d.ts +47 -0
- package/dist/line/line-cross.js +133 -0
- package/dist/line/line-dot.d.ts +47 -0
- package/dist/line/line-dot.js +101 -0
- package/dist/mark-label.d.ts +55 -0
- package/dist/mark-label.js +139 -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/AxisBottom.js +45 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +46 -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/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/operators/align.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +58 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +9 -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/createColorInterpolator.js +29 -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/isUtcScale.js +7 -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/Bar.js +28 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +28 -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/esm/shapes/LinePath.js +49 -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 +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/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +8 -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/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-input-autosize@2.2.2_f4eacebf2041cd4f/node_modules/react-input-autosize/lib/AutosizeInput.js +216 -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/plot/common/plot.d.ts +103 -0
- package/dist/plot/common/plot.js +227 -0
- package/dist/plot/dot.d.ts +47 -0
- package/dist/plot/dot.js +62 -0
- package/dist/plot/line.d.ts +47 -0
- package/dist/plot/line.js +84 -0
- package/dist/tool-menu.d.ts +31 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.js +101 -0
- package/package.json +35 -25
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -1116
- package/LICENSE.md +0 -5
- package/lib/actions-button.js +0 -145
- package/lib/actions-button.js.map +0 -1
- package/lib/axes.js +0 -643
- package/lib/axes.js.map +0 -1
- package/lib/bars/bar.js +0 -58
- package/lib/bars/bar.js.map +0 -1
- package/lib/bars/common/bars.js +0 -277
- package/lib/bars/common/bars.js.map +0 -1
- package/lib/bars/common/correct-check-icon.js +0 -54
- package/lib/bars/common/correct-check-icon.js.map +0 -1
- package/lib/bars/histogram.js +0 -59
- package/lib/bars/histogram.js.map +0 -1
- package/lib/chart-setup.js +0 -382
- package/lib/chart-setup.js.map +0 -1
- package/lib/chart-type.js +0 -80
- package/lib/chart-type.js.map +0 -1
- package/lib/chart-types.js +0 -22
- package/lib/chart-types.js.map +0 -1
- package/lib/chart.js +0 -384
- package/lib/chart.js.map +0 -1
- package/lib/common/correctness-indicators.js +0 -156
- package/lib/common/correctness-indicators.js.map +0 -1
- package/lib/common/drag-handle.js +0 -160
- package/lib/common/drag-handle.js.map +0 -1
- package/lib/common/drag-icon.js +0 -52
- package/lib/common/drag-icon.js.map +0 -1
- package/lib/common/styles.js +0 -22
- package/lib/common/styles.js.map +0 -1
- package/lib/grid.js +0 -112
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -42
- package/lib/index.js.map +0 -1
- package/lib/key-legend.js +0 -87
- package/lib/key-legend.js.map +0 -1
- package/lib/line/common/drag-handle.js +0 -146
- package/lib/line/common/drag-handle.js.map +0 -1
- package/lib/line/common/line.js +0 -214
- package/lib/line/common/line.js.map +0 -1
- package/lib/line/line-cross.js +0 -214
- package/lib/line/line-cross.js.map +0 -1
- package/lib/line/line-dot.js +0 -158
- package/lib/line/line-dot.js.map +0 -1
- package/lib/mark-label.js +0 -237
- package/lib/mark-label.js.map +0 -1
- package/lib/plot/common/plot.js +0 -349
- package/lib/plot/common/plot.js.map +0 -1
- package/lib/plot/dot.js +0 -110
- package/lib/plot/dot.js.map +0 -1
- package/lib/plot/line.js +0 -140
- package/lib/plot/line.js.map +0 -1
- package/lib/tool-menu.js +0 -106
- package/lib/tool-menu.js.map +0 -1
- package/lib/utils.js +0 -189
- package/lib/utils.js.map +0 -1
- package/src/__tests__/actions-button.test.jsx +0 -280
- package/src/__tests__/axes.test.jsx +0 -667
- package/src/__tests__/chart-setup.test.jsx +0 -532
- package/src/__tests__/chart-type.test.jsx +0 -23
- package/src/__tests__/chart.test.jsx +0 -86
- package/src/__tests__/grid.test.jsx +0 -37
- package/src/__tests__/key-legend.test.jsx +0 -223
- package/src/__tests__/mark-label.test.jsx +0 -33
- package/src/__tests__/tool-menu.test.jsx +0 -522
- package/src/__tests__/utils.js +0 -36
- package/src/__tests__/utils.test.js +0 -100
- package/src/actions-button.jsx +0 -115
- package/src/axes.jsx +0 -594
- package/src/bars/__tests__/bar.test.jsx +0 -45
- package/src/bars/__tests__/histogram.test.jsx +0 -45
- package/src/bars/__tests__/utils.js +0 -30
- package/src/bars/bar.js +0 -28
- package/src/bars/common/__tests__/bars.test.jsx +0 -68
- package/src/bars/common/__tests__/utils.js +0 -30
- package/src/bars/common/bars.jsx +0 -249
- package/src/bars/common/correct-check-icon.jsx +0 -25
- package/src/bars/histogram.js +0 -28
- package/src/chart-setup.jsx +0 -356
- package/src/chart-type.js +0 -59
- package/src/chart-types.js +0 -8
- package/src/chart.jsx +0 -357
- package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
- package/src/common/__tests__/drag-handle.test.jsx +0 -58
- package/src/common/__tests__/utils.js +0 -30
- package/src/common/correctness-indicators.jsx +0 -128
- package/src/common/drag-handle.jsx +0 -125
- package/src/common/drag-icon.jsx +0 -36
- package/src/common/styles.js +0 -19
- package/src/grid.jsx +0 -80
- package/src/index.js +0 -7
- package/src/key-legend.jsx +0 -77
- package/src/line/__tests__/line-cross.test.jsx +0 -463
- package/src/line/__tests__/line-dot.test.jsx +0 -41
- package/src/line/__tests__/utils.js +0 -36
- package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
- package/src/line/common/__tests__/line.test.jsx +0 -79
- package/src/line/common/__tests__/utils.js +0 -30
- package/src/line/common/drag-handle.jsx +0 -114
- package/src/line/common/line.jsx +0 -171
- package/src/line/line-cross.js +0 -144
- package/src/line/line-dot.js +0 -111
- package/src/mark-label.jsx +0 -238
- package/src/plot/__tests__/dot.test.jsx +0 -344
- package/src/plot/__tests__/line.test.jsx +0 -375
- package/src/plot/__tests__/utils.js +0 -30
- package/src/plot/common/__tests__/plot.test.jsx +0 -69
- package/src/plot/common/__tests__/utils.js +0 -30
- package/src/plot/common/plot.jsx +0 -358
- package/src/plot/dot.js +0 -74
- package/src/plot/line.js +0 -98
- package/src/tool-menu.jsx +0 -85
- package/src/utils.js +0 -201
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import DragHandle from '../drag-handle';
|
|
4
|
-
import { gridDraggable } from '@pie-lib/plot';
|
|
5
|
-
import { graphProps } from './utils';
|
|
6
|
-
|
|
7
|
-
jest.mock('../../utils', () => {
|
|
8
|
-
const { point } = jest.requireActual('../../utils');
|
|
9
|
-
return {
|
|
10
|
-
bounds: jest.fn(),
|
|
11
|
-
point,
|
|
12
|
-
getScale: jest.fn(() => ({ scale: 1 })),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
jest.mock('@pie-lib/plot', () => {
|
|
17
|
-
const { types, utils } = jest.requireActual('@pie-lib/plot');
|
|
18
|
-
return {
|
|
19
|
-
gridDraggable: jest.fn((opts) => (Comp) => Comp),
|
|
20
|
-
types,
|
|
21
|
-
utils,
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('BasePoint', () => {
|
|
26
|
-
let onChange = jest.fn();
|
|
27
|
-
const renderComponent = (extras) => {
|
|
28
|
-
const defaults = {
|
|
29
|
-
classes: {},
|
|
30
|
-
className: 'className',
|
|
31
|
-
onChange,
|
|
32
|
-
graphProps: graphProps(),
|
|
33
|
-
x: 0,
|
|
34
|
-
y: 0,
|
|
35
|
-
width: 100,
|
|
36
|
-
};
|
|
37
|
-
const props = { ...defaults, ...extras };
|
|
38
|
-
return render(<DragHandle {...props} />);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
describe('rendering', () => {
|
|
42
|
-
it('renders without crashing', () => {
|
|
43
|
-
const { container } = renderComponent();
|
|
44
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('gridDraggable options', () => {
|
|
49
|
-
it('configures gridDraggable with correct options', () => {
|
|
50
|
-
// The gridDraggable HOC is tested by verifying that it's called with the component
|
|
51
|
-
// Detailed unit tests for the HOC options would require accessing internal
|
|
52
|
-
// implementation details which is not recommended with RTL
|
|
53
|
-
const { container } = renderComponent();
|
|
54
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
55
|
-
expect(gridDraggable).toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const scaleMock = () => {
|
|
2
|
-
const fn = jest.fn((n) => n);
|
|
3
|
-
fn.invert = jest.fn((n) => n);
|
|
4
|
-
return fn;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
8
|
-
scale: {
|
|
9
|
-
x: scaleMock(),
|
|
10
|
-
y: scaleMock(),
|
|
11
|
-
},
|
|
12
|
-
snap: {
|
|
13
|
-
x: jest.fn((n) => n),
|
|
14
|
-
y: jest.fn((n) => n),
|
|
15
|
-
},
|
|
16
|
-
domain: {
|
|
17
|
-
min: dmin,
|
|
18
|
-
max: dmax,
|
|
19
|
-
step: 1,
|
|
20
|
-
},
|
|
21
|
-
range: {
|
|
22
|
-
min: rmin,
|
|
23
|
-
max: rmax,
|
|
24
|
-
step: 1,
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
width: 400,
|
|
28
|
-
height: 400,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import Check from '@mui/icons-material/Check';
|
|
5
|
-
import Close from '@mui/icons-material/Close';
|
|
6
|
-
import { color as enumColor } from '@pie-lib/render-ui';
|
|
7
|
-
|
|
8
|
-
const StyledCorrectIcon = styled(Check)(({ theme }) => ({
|
|
9
|
-
borderRadius: theme.spacing(2),
|
|
10
|
-
color: enumColor.defaults.WHITE,
|
|
11
|
-
fontSize: '16px',
|
|
12
|
-
width: '16px',
|
|
13
|
-
height: '16px',
|
|
14
|
-
padding: '2px',
|
|
15
|
-
border: `1px solid ${enumColor.defaults.WHITE}`,
|
|
16
|
-
stroke: 'initial',
|
|
17
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
18
|
-
backgroundColor: enumColor.correct(),
|
|
19
|
-
display: 'block',
|
|
20
|
-
'&.small': {
|
|
21
|
-
fontSize: '10px',
|
|
22
|
-
width: '10px',
|
|
23
|
-
height: '10px',
|
|
24
|
-
},
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
const StyledIncorrectIcon = styled(Close)(({ theme }) => ({
|
|
28
|
-
borderRadius: theme.spacing(2),
|
|
29
|
-
color: enumColor.defaults.WHITE,
|
|
30
|
-
fontSize: '16px',
|
|
31
|
-
width: '16px',
|
|
32
|
-
height: '16px',
|
|
33
|
-
padding: '2px',
|
|
34
|
-
border: `1px solid ${enumColor.defaults.WHITE}`,
|
|
35
|
-
stroke: 'initial',
|
|
36
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
37
|
-
backgroundColor: enumColor.incorrectWithIcon(),
|
|
38
|
-
display: 'block',
|
|
39
|
-
'&.small': {
|
|
40
|
-
fontSize: '10px',
|
|
41
|
-
width: '10px',
|
|
42
|
-
height: '10px',
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
export const CorrectnessIndicator = ({ scale, x, y, correctness, interactive }) => {
|
|
47
|
-
if (!correctness || !interactive) return null;
|
|
48
|
-
const cx = scale ? scale.x(x) : x;
|
|
49
|
-
const cy = scale ? scale.y(y) : y;
|
|
50
|
-
const isCorrect = correctness.value === 'correct';
|
|
51
|
-
|
|
52
|
-
// the icon is 16px + 2px padding + 1px border, so total size is 22px
|
|
53
|
-
return (
|
|
54
|
-
<foreignObject x={cx - 11} y={cy - 11} width={22} height={22}>
|
|
55
|
-
{isCorrect ? <StyledCorrectIcon title={correctness.label} /> : <StyledIncorrectIcon title={correctness.label} />}
|
|
56
|
-
</foreignObject>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const SmallCorrectPointIndicator = ({ scale, x, correctness, correctData, label }) => {
|
|
61
|
-
if (correctness && correctness.value === 'incorrect') {
|
|
62
|
-
const correctVal = parseFloat(correctData.find((d) => d.label === label)?.value);
|
|
63
|
-
if (isNaN(correctVal)) return null;
|
|
64
|
-
const correctPxY = scale.y(correctVal);
|
|
65
|
-
const yToRender = correctPxY - 7.5;
|
|
66
|
-
const xToRender = scale.x(x) - 7.5;
|
|
67
|
-
|
|
68
|
-
// small circle has 10px font + 2px padding + 1px border, so total size is 15px
|
|
69
|
-
return (
|
|
70
|
-
<foreignObject x={xToRender} y={yToRender} width={15} height={15}>
|
|
71
|
-
<StyledCorrectIcon className="small" title={correctness.label} />
|
|
72
|
-
</foreignObject>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return null;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const TickCorrectnessIndicator = ({ correctness, interactive }) => {
|
|
80
|
-
if (!correctness || !interactive) return null;
|
|
81
|
-
|
|
82
|
-
return correctness.value === 'correct' ? (
|
|
83
|
-
<StyledCorrectIcon title={correctness.label} />
|
|
84
|
-
) : (
|
|
85
|
-
<StyledIncorrectIcon title={correctness.label} />
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
CorrectnessIndicator.propTypes = {
|
|
90
|
-
scale: PropTypes.shape({
|
|
91
|
-
x: PropTypes.func,
|
|
92
|
-
y: PropTypes.func,
|
|
93
|
-
}),
|
|
94
|
-
x: PropTypes.number.isRequired,
|
|
95
|
-
y: PropTypes.number.isRequired,
|
|
96
|
-
correctness: PropTypes.shape({
|
|
97
|
-
value: PropTypes.string,
|
|
98
|
-
label: PropTypes.string,
|
|
99
|
-
}),
|
|
100
|
-
interactive: PropTypes.bool,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
SmallCorrectPointIndicator.propTypes = {
|
|
104
|
-
scale: PropTypes.shape({
|
|
105
|
-
x: PropTypes.func,
|
|
106
|
-
y: PropTypes.func,
|
|
107
|
-
}).isRequired,
|
|
108
|
-
x: PropTypes.number.isRequired,
|
|
109
|
-
correctness: PropTypes.shape({
|
|
110
|
-
value: PropTypes.string,
|
|
111
|
-
label: PropTypes.string,
|
|
112
|
-
}),
|
|
113
|
-
correctData: PropTypes.arrayOf(
|
|
114
|
-
PropTypes.shape({
|
|
115
|
-
label: PropTypes.string,
|
|
116
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
117
|
-
}),
|
|
118
|
-
),
|
|
119
|
-
label: PropTypes.string,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
TickCorrectnessIndicator.propTypes = {
|
|
123
|
-
correctness: PropTypes.shape({
|
|
124
|
-
value: PropTypes.string,
|
|
125
|
-
label: PropTypes.string,
|
|
126
|
-
}),
|
|
127
|
-
interactive: PropTypes.bool,
|
|
128
|
-
};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import Check from '@mui/icons-material/Check';
|
|
5
|
-
import Close from '@mui/icons-material/Close';
|
|
6
|
-
|
|
7
|
-
import { gridDraggable, types, utils } from '@pie-lib/plot';
|
|
8
|
-
import { color as enumColor } from '@pie-lib/render-ui';
|
|
9
|
-
import { getScale } from '../utils';
|
|
10
|
-
import DragIcon from './drag-icon';
|
|
11
|
-
|
|
12
|
-
const StyledSvg = styled('svg')(() => ({
|
|
13
|
-
overflow: 'visible !important',
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
const StyledEllipse = styled('ellipse')(() => ({
|
|
17
|
-
fill: 'transparent',
|
|
18
|
-
clipPath: 'polygon(50% 0%, 100% 0%, 100% 50%, 0% 50%, 0% 0%)',
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const StyledCorrectIcon = styled(Check)(() => ({
|
|
22
|
-
backgroundColor: enumColor.correct(),
|
|
23
|
-
borderRadius: '16px', // equivalent to theme.spacing(2) for most themes
|
|
24
|
-
color: enumColor.defaults.WHITE,
|
|
25
|
-
fontSize: '16px',
|
|
26
|
-
padding: '2px',
|
|
27
|
-
border: `4px solid ${enumColor.defaults.WHITE}`,
|
|
28
|
-
width: '16px',
|
|
29
|
-
height: '16px',
|
|
30
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
const StyledIncorrectIcon = styled(Close)(() => ({
|
|
34
|
-
backgroundColor: enumColor.incorrectWithIcon(),
|
|
35
|
-
borderRadius: '16px', // equivalent to theme.spacing(2) for most themes
|
|
36
|
-
color: enumColor.defaults.WHITE,
|
|
37
|
-
fontSize: '16px',
|
|
38
|
-
padding: '2px',
|
|
39
|
-
border: `4px solid ${enumColor.defaults.WHITE}`,
|
|
40
|
-
width: '16px',
|
|
41
|
-
height: '16px',
|
|
42
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
const RawDragHandle = ({ x, y, width, graphProps, interactive, isHovered, correctness, isPlot, ...rest }) => {
|
|
46
|
-
const { scale } = graphProps;
|
|
47
|
-
const scaleValue = getScale(width)?.scale;
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<StyledSvg x={x} y={scale.y(y) - 10} width={width} overflow="visible">
|
|
51
|
-
{isHovered && !correctness && interactive && (
|
|
52
|
-
<DragIcon width={width} scaleValue={scaleValue} color={enumColor.defaults.BORDER_GRAY} />
|
|
53
|
-
)}
|
|
54
|
-
{interactive && !correctness && (
|
|
55
|
-
<StyledEllipse
|
|
56
|
-
cx={width / 2}
|
|
57
|
-
cy={10}
|
|
58
|
-
rx={width / 2}
|
|
59
|
-
// the drag icon has a 22px fixed r value, so the ry value is 3 times that in order to cover all the area
|
|
60
|
-
ry={66}
|
|
61
|
-
{...rest}
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
|
|
65
|
-
<defs>
|
|
66
|
-
<filter id="bottomShadow" x="0" y="0" width="140%" height="140%">
|
|
67
|
-
<feGaussianBlur in="SourceAlpha" stdDeviation="3" />
|
|
68
|
-
<feOffset dx="0" dy="5" result="offsetblur" />
|
|
69
|
-
<feFlood floodColor="#00000033" />
|
|
70
|
-
<feComposite in2="offsetblur" operator="in" />
|
|
71
|
-
<feMerge>
|
|
72
|
-
<feMergeNode />
|
|
73
|
-
<feMergeNode in="SourceGraphic" />
|
|
74
|
-
</feMerge>
|
|
75
|
-
</filter>
|
|
76
|
-
</defs>
|
|
77
|
-
|
|
78
|
-
{correctness && interactive && !isPlot && (
|
|
79
|
-
<foreignObject x={width / 2 - 14} y={0} width={40} height={40}>
|
|
80
|
-
{correctness.value === 'correct' ? (
|
|
81
|
-
<StyledCorrectIcon title={correctness.label} />
|
|
82
|
-
) : (
|
|
83
|
-
<StyledIncorrectIcon title={correctness.label} />
|
|
84
|
-
)}
|
|
85
|
-
</foreignObject>
|
|
86
|
-
)}
|
|
87
|
-
</StyledSvg>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
RawDragHandle.propTypes = {
|
|
92
|
-
x: PropTypes.number.isRequired,
|
|
93
|
-
y: PropTypes.number.isRequired,
|
|
94
|
-
width: PropTypes.number,
|
|
95
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
96
|
-
interactive: PropTypes.bool,
|
|
97
|
-
isHovered: PropTypes.bool,
|
|
98
|
-
correctness: PropTypes.shape({
|
|
99
|
-
value: PropTypes.string,
|
|
100
|
-
label: PropTypes.string,
|
|
101
|
-
}),
|
|
102
|
-
isPlot: PropTypes.bool,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const DragHandle = RawDragHandle;
|
|
106
|
-
|
|
107
|
-
export const D = gridDraggable({
|
|
108
|
-
axis: 'y',
|
|
109
|
-
fromDelta: (props, delta) => {
|
|
110
|
-
//TODO: should be in grid-draggable, if axis is y delta.x should always be 0.
|
|
111
|
-
delta.x = 0;
|
|
112
|
-
const newPoint = utils.point(props).add(utils.point(delta));
|
|
113
|
-
|
|
114
|
-
return newPoint.y;
|
|
115
|
-
},
|
|
116
|
-
bounds: (props, { domain, range }) => {
|
|
117
|
-
const area = { left: 0, top: props.y, bottom: props.y, right: 0 };
|
|
118
|
-
return utils.bounds(area, domain, range);
|
|
119
|
-
},
|
|
120
|
-
anchorPoint: (props) => {
|
|
121
|
-
return { x: props.x, y: props.y };
|
|
122
|
-
},
|
|
123
|
-
})(DragHandle);
|
|
124
|
-
|
|
125
|
-
export default D;
|
package/src/common/drag-icon.jsx
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { getAdjustedX, getScale } from '../utils';
|
|
4
|
-
|
|
5
|
-
const DragIcon = ({ width, scaleValue, color }) => (
|
|
6
|
-
<svg
|
|
7
|
-
x={getAdjustedX(width, scaleValue)}
|
|
8
|
-
y={getScale(width)?.deltay}
|
|
9
|
-
color={color}
|
|
10
|
-
width={width}
|
|
11
|
-
height={width}
|
|
12
|
-
overflow="visible"
|
|
13
|
-
viewBox={`0 0 ${width} ${width}`}
|
|
14
|
-
style={{ overflow: 'visible !important' }}
|
|
15
|
-
>
|
|
16
|
-
<g xmlns="http://www.w3.org/2000/svg" fill="currentColor" stroke="currentColor" transform={`scale(${scaleValue})`}>
|
|
17
|
-
<circle cx="28.5" cy="23.5" r="22" fill="white" stroke="currentColor" />
|
|
18
|
-
<path
|
|
19
|
-
d="M33.5 21.25H23.4609C22.7578 21.25 22.4062 20.4297 22.9141 19.9219L27.9141 14.9219C28.2266 14.6094 28.7344 14.6094 29.0469 14.9219L34.0469 19.9219C34.5547 20.4297 34.2031 21.25 33.5 21.25Z"
|
|
20
|
-
fill="currentColor"
|
|
21
|
-
/>
|
|
22
|
-
<path
|
|
23
|
-
d="M23.5 25.75L33.5391 25.75C34.2422 25.75 34.5938 26.5703 34.0859 27.0781L29.0859 32.0781C28.7734 32.3906 28.2656 32.3906 27.9531 32.0781L22.9531 27.0781C22.4453 26.5703 22.7969 25.75 23.5 25.75Z"
|
|
24
|
-
fill="currentColor"
|
|
25
|
-
/>
|
|
26
|
-
</g>
|
|
27
|
-
</svg>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
DragIcon.propTypes = {
|
|
31
|
-
width: PropTypes.number.isRequired,
|
|
32
|
-
scaleValue: PropTypes.number.isRequired,
|
|
33
|
-
color: PropTypes.string,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default DragIcon;
|
package/src/common/styles.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { color } from '@pie-lib/render-ui';
|
|
2
|
-
|
|
3
|
-
export const disabled = (key = 'fill') => ({
|
|
4
|
-
[key]: `var(--graph-disabled, ${color.disabled()})`,
|
|
5
|
-
pointerEvents: 'none',
|
|
6
|
-
border: 'none',
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const correct = (key = 'fill') => ({
|
|
10
|
-
[key]: color.correct(),
|
|
11
|
-
pointerEvents: 'none',
|
|
12
|
-
border: `solid 1px ${color.correct()}`,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const incorrect = (key = 'fill') => ({
|
|
16
|
-
[key]: color.incorrect(),
|
|
17
|
-
pointerEvents: 'none',
|
|
18
|
-
border: `solid 1px ${color.incorrect()}`,
|
|
19
|
-
});
|
package/src/grid.jsx
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { GridColumns, GridRows } from '@visx/grid';
|
|
5
|
-
|
|
6
|
-
import { types } from '@pie-lib/plot';
|
|
7
|
-
import { color } from '@pie-lib/render-ui';
|
|
8
|
-
|
|
9
|
-
const StyledGridGroup = styled('g')(() => ({
|
|
10
|
-
stroke: color.primaryLight(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
export class Grid extends React.Component {
|
|
14
|
-
static propTypes = {
|
|
15
|
-
className: PropTypes.string,
|
|
16
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
17
|
-
xBand: PropTypes.func,
|
|
18
|
-
columnTickValues: PropTypes.array,
|
|
19
|
-
rowTickValues: PropTypes.array,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
static defaultProps = {};
|
|
23
|
-
|
|
24
|
-
render() {
|
|
25
|
-
const { graphProps, xBand, rowTickValues, columnTickValues } = this.props;
|
|
26
|
-
const { scale = {}, size = {}, range = {} } = graphProps || {};
|
|
27
|
-
const { step = 0, labelStep = 0 } = range;
|
|
28
|
-
const highlightNonLabel = step && labelStep && step < labelStep;
|
|
29
|
-
|
|
30
|
-
// Avoid floating-point precision errors in the % operator.
|
|
31
|
-
// e.g. 0.6 % 0.2 = 0.19999999999999996, but safeModulo(0.6, 0.2) = 0
|
|
32
|
-
const safeModulo = (value, step) => {
|
|
33
|
-
const valueDecimals = (value.toString().split('.')[1] || '').length;
|
|
34
|
-
const stepDecimals =(step.toString().split('.')[1] || '').length
|
|
35
|
-
const decimals = Math.max(valueDecimals, stepDecimals);
|
|
36
|
-
const factor = Math.pow(10, decimals);
|
|
37
|
-
|
|
38
|
-
return ((value * factor) % (step * factor)) / factor;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// if highlightNonLabel is true, we need to separate the unlabeled lines in order to render them in a different color
|
|
42
|
-
const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(
|
|
43
|
-
(acc, value) => {
|
|
44
|
-
if (highlightNonLabel && safeModulo(value, labelStep) !== 0) {
|
|
45
|
-
acc.unlabeledLines.push(value);
|
|
46
|
-
} else {
|
|
47
|
-
acc.labeledLines.push(value);
|
|
48
|
-
}
|
|
49
|
-
return acc;
|
|
50
|
-
},
|
|
51
|
-
{ unlabeledLines: [], labeledLines: [] },
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<StyledGridGroup>
|
|
56
|
-
<GridRows
|
|
57
|
-
scale={scale.y}
|
|
58
|
-
width={size.width}
|
|
59
|
-
tickValues={unlabeledLines}
|
|
60
|
-
lineStyle={{
|
|
61
|
-
stroke: color.fadedPrimary(),
|
|
62
|
-
strokeWidth: 1,
|
|
63
|
-
}}
|
|
64
|
-
/>
|
|
65
|
-
<GridRows
|
|
66
|
-
scale={scale.y}
|
|
67
|
-
width={size.width}
|
|
68
|
-
tickValues={labeledLines}
|
|
69
|
-
lineStyle={{
|
|
70
|
-
stroke: unlabeledLines.length ? color.visualElementsColors.GRIDLINES_COLOR : color.fadedPrimary(),
|
|
71
|
-
strokeWidth: 1,
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
<GridColumns scale={xBand} height={size.height} offset={xBand.bandwidth() / 2} tickValues={columnTickValues} />
|
|
75
|
-
</StyledGridGroup>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default Grid;
|
package/src/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import Chart from './chart';
|
|
2
|
-
import chartTypes from './chart-types';
|
|
3
|
-
import ConfigureChartPanel from './chart-setup';
|
|
4
|
-
import ChartType from './chart-type';
|
|
5
|
-
import KeyLegend from './key-legend';
|
|
6
|
-
|
|
7
|
-
export { Chart, chartTypes, ChartType, ConfigureChartPanel, KeyLegend };
|
package/src/key-legend.jsx
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import Check from '@mui/icons-material/Check';
|
|
5
|
-
import Close from '@mui/icons-material/Close';
|
|
6
|
-
import { color } from '@pie-lib/render-ui';
|
|
7
|
-
import Translator from '@pie-lib/translator';
|
|
8
|
-
|
|
9
|
-
const StyledContainer = styled('div')(({ theme }) => ({
|
|
10
|
-
backgroundColor: color.defaults.WHITE,
|
|
11
|
-
padding: theme.spacing(2),
|
|
12
|
-
width: '355px',
|
|
13
|
-
boxShadow: 'inset 0px 1px 5px 0px #9297A6',
|
|
14
|
-
display: 'flex',
|
|
15
|
-
flexDirection: 'column',
|
|
16
|
-
gap: '16px',
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const StyledRow = styled('div')(() => ({
|
|
20
|
-
display: 'flex',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
gap: '12px',
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
const StyledTitle = styled('div')(({ theme }) => ({
|
|
26
|
-
fontSize: theme.typography.h6.fontSize,
|
|
27
|
-
fontWeight: '700',
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
const StyledSmallText = styled('div')(() => ({
|
|
31
|
-
marginLeft: '2px',
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const StyledCorrectIcon = styled(Check)(({ theme }) => ({
|
|
35
|
-
backgroundColor: color.correct(),
|
|
36
|
-
borderRadius: theme.spacing(2),
|
|
37
|
-
color: color.defaults.WHITE,
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
const StyledIncorrectIcon = styled(Close)(({ theme }) => ({
|
|
41
|
-
backgroundColor: color.incorrectWithIcon(),
|
|
42
|
-
borderRadius: theme.spacing(2),
|
|
43
|
-
color: color.defaults.WHITE,
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
const StyledLastRow = styled('div')(() => ({
|
|
47
|
-
marginLeft: '3px',
|
|
48
|
-
display: 'flex',
|
|
49
|
-
alignItems: 'center',
|
|
50
|
-
gap: '12px',
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
const { translator } = Translator;
|
|
54
|
-
|
|
55
|
-
const KeyLegend = ({ language }) => (
|
|
56
|
-
<StyledContainer>
|
|
57
|
-
<StyledTitle>Key</StyledTitle>
|
|
58
|
-
<StyledRow>
|
|
59
|
-
<StyledIncorrectIcon />
|
|
60
|
-
<div>{translator.t('charting.keyLegend.incorrectAnswer', { lng: language })}</div>
|
|
61
|
-
</StyledRow>
|
|
62
|
-
<StyledRow>
|
|
63
|
-
<StyledCorrectIcon />
|
|
64
|
-
<div>{translator.t('charting.keyLegend.correctAnswer', { lng: language })}</div>
|
|
65
|
-
</StyledRow>
|
|
66
|
-
<StyledLastRow>
|
|
67
|
-
<StyledCorrectIcon fontSize={'small'} />
|
|
68
|
-
<StyledSmallText>{translator.t('charting.keyLegend.correctKeyAnswer', { lng: language })}</StyledSmallText>
|
|
69
|
-
</StyledLastRow>
|
|
70
|
-
</StyledContainer>
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
KeyLegend.propTypes = {
|
|
74
|
-
language: PropTypes.string,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default KeyLegend;
|