@pie-lib/charting 7.0.4-next.31 → 7.0.4-next.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +1116 -0
- package/LICENSE.md +5 -0
- package/lib/actions-button.js +145 -0
- package/lib/actions-button.js.map +1 -0
- package/lib/axes.js +643 -0
- package/lib/axes.js.map +1 -0
- package/lib/bars/bar.js +58 -0
- package/lib/bars/bar.js.map +1 -0
- package/lib/bars/common/bars.js +277 -0
- package/lib/bars/common/bars.js.map +1 -0
- package/lib/bars/common/correct-check-icon.js +54 -0
- package/lib/bars/common/correct-check-icon.js.map +1 -0
- package/lib/bars/histogram.js +59 -0
- package/lib/bars/histogram.js.map +1 -0
- package/lib/chart-setup.js +382 -0
- package/lib/chart-setup.js.map +1 -0
- package/lib/chart-type.js +80 -0
- package/lib/chart-type.js.map +1 -0
- package/lib/chart-types.js +22 -0
- package/lib/chart-types.js.map +1 -0
- package/lib/chart.js +384 -0
- package/lib/chart.js.map +1 -0
- package/lib/common/correctness-indicators.js +156 -0
- package/lib/common/correctness-indicators.js.map +1 -0
- package/lib/common/drag-handle.js +160 -0
- package/lib/common/drag-handle.js.map +1 -0
- package/lib/common/drag-icon.js +52 -0
- package/lib/common/drag-icon.js.map +1 -0
- package/lib/common/styles.js +22 -0
- package/lib/common/styles.js.map +1 -0
- package/lib/grid.js +112 -0
- package/lib/grid.js.map +1 -0
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -0
- package/lib/key-legend.js +87 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/line/common/drag-handle.js +146 -0
- package/lib/line/common/drag-handle.js.map +1 -0
- package/lib/line/common/line.js +214 -0
- package/lib/line/common/line.js.map +1 -0
- package/lib/line/line-cross.js +214 -0
- package/lib/line/line-cross.js.map +1 -0
- package/lib/line/line-dot.js +158 -0
- package/lib/line/line-dot.js.map +1 -0
- package/lib/mark-label.js +237 -0
- package/lib/mark-label.js.map +1 -0
- package/lib/plot/common/plot.js +349 -0
- package/lib/plot/common/plot.js.map +1 -0
- package/lib/plot/dot.js +110 -0
- package/lib/plot/dot.js.map +1 -0
- package/lib/plot/line.js +140 -0
- package/lib/plot/line.js.map +1 -0
- package/lib/tool-menu.js +106 -0
- package/lib/tool-menu.js.map +1 -0
- package/lib/utils.js +189 -0
- package/lib/utils.js.map +1 -0
- package/package.json +28 -39
- package/src/__tests__/actions-button.test.jsx +280 -0
- package/src/__tests__/axes.test.jsx +667 -0
- package/src/__tests__/chart-setup.test.jsx +532 -0
- package/src/__tests__/chart-type.test.jsx +23 -0
- package/src/__tests__/chart.test.jsx +86 -0
- package/src/__tests__/grid.test.jsx +37 -0
- package/src/__tests__/key-legend.test.jsx +223 -0
- package/src/__tests__/mark-label.test.jsx +33 -0
- package/src/__tests__/tool-menu.test.jsx +522 -0
- package/src/__tests__/utils.js +36 -0
- package/src/__tests__/utils.test.js +100 -0
- package/src/actions-button.jsx +115 -0
- package/src/axes.jsx +594 -0
- package/src/bars/__tests__/bar.test.jsx +45 -0
- package/src/bars/__tests__/histogram.test.jsx +45 -0
- package/src/bars/__tests__/utils.js +30 -0
- package/src/bars/bar.js +28 -0
- package/src/bars/common/__tests__/bars.test.jsx +68 -0
- package/src/bars/common/__tests__/utils.js +30 -0
- package/src/bars/common/bars.jsx +249 -0
- package/src/bars/common/correct-check-icon.jsx +25 -0
- package/src/bars/histogram.js +28 -0
- package/src/chart-setup.jsx +356 -0
- package/src/chart-type.js +59 -0
- package/src/chart-types.js +8 -0
- package/src/chart.jsx +357 -0
- package/src/common/__tests__/correctness-indicators.test.jsx +720 -0
- package/src/common/__tests__/drag-handle.test.jsx +58 -0
- package/src/common/__tests__/utils.js +30 -0
- package/src/common/correctness-indicators.jsx +128 -0
- package/src/common/drag-handle.jsx +125 -0
- package/src/common/drag-icon.jsx +36 -0
- package/src/common/styles.js +19 -0
- package/src/grid.jsx +80 -0
- package/src/index.js +7 -0
- package/src/key-legend.jsx +77 -0
- package/src/line/__tests__/line-cross.test.jsx +463 -0
- package/src/line/__tests__/line-dot.test.jsx +41 -0
- package/src/line/__tests__/utils.js +36 -0
- package/src/line/common/__tests__/drag-handle.test.jsx +62 -0
- package/src/line/common/__tests__/line.test.jsx +79 -0
- package/src/line/common/__tests__/utils.js +30 -0
- package/src/line/common/drag-handle.jsx +114 -0
- package/src/line/common/line.jsx +171 -0
- package/src/line/line-cross.js +144 -0
- package/src/line/line-dot.js +111 -0
- package/src/mark-label.jsx +238 -0
- package/src/plot/__tests__/dot.test.jsx +344 -0
- package/src/plot/__tests__/line.test.jsx +375 -0
- package/src/plot/__tests__/utils.js +30 -0
- package/src/plot/common/__tests__/plot.test.jsx +69 -0
- package/src/plot/common/__tests__/utils.js +30 -0
- package/src/plot/common/plot.jsx +358 -0
- package/src/plot/dot.js +74 -0
- package/src/plot/line.js +98 -0
- package/src/tool-menu.jsx +85 -0
- package/src/utils.js +201 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -23
- package/dist/actions-button.d.ts +0 -26
- package/dist/actions-button.js +0 -84
- package/dist/autosize-input.d.ts +0 -10
- package/dist/autosize-input.js +0 -66
- package/dist/axes.d.ts +0 -84
- package/dist/axes.js +0 -376
- package/dist/bars/bar.d.ts +0 -47
- package/dist/bars/bar.js +0 -27
- package/dist/bars/common/bars.d.ts +0 -98
- package/dist/bars/common/bars.js +0 -174
- package/dist/bars/common/correct-check-icon.d.ts +0 -18
- package/dist/bars/common/correct-check-icon.js +0 -50
- package/dist/bars/histogram.d.ts +0 -47
- package/dist/bars/histogram.js +0 -28
- package/dist/chart-setup.d.ts +0 -29
- package/dist/chart-setup.js +0 -231
- package/dist/chart-type.d.ts +0 -32
- package/dist/chart-type.js +0 -68
- package/dist/chart-types.d.ts +0 -41
- package/dist/chart-types.js +0 -17
- package/dist/chart.d.ts +0 -88
- package/dist/chart.js +0 -250
- package/dist/common/correctness-indicators.d.ts +0 -70
- package/dist/common/correctness-indicators.js +0 -106
- package/dist/common/drag-handle.d.ts +0 -129
- package/dist/common/drag-handle.js +0 -120
- package/dist/common/drag-icon.d.ts +0 -23
- package/dist/common/drag-icon.js +0 -45
- package/dist/common/styles.d.ts +0 -23
- package/dist/common/styles.js +0 -17
- package/dist/grid.d.ts +0 -45
- package/dist/grid.js +0 -56
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -6
- package/dist/key-legend.d.ts +0 -19
- package/dist/key-legend.js +0 -46
- package/dist/line/common/drag-handle.d.ts +0 -120
- package/dist/line/common/drag-handle.js +0 -92
- package/dist/line/common/line.d.ts +0 -96
- package/dist/line/common/line.js +0 -114
- package/dist/line/line-cross.d.ts +0 -47
- package/dist/line/line-cross.js +0 -133
- package/dist/line/line-dot.d.ts +0 -47
- package/dist/line/line-dot.js +0 -101
- package/dist/mark-label.d.ts +0 -55
- package/dist/mark-label.js +0 -138
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +0 -101
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +0 -46
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +0 -47
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +0 -63
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +0 -44
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +0 -9
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +0 -14
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +0 -21
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +0 -16
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +0 -8
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +0 -15
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +0 -6
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +0 -50
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +0 -18
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +0 -10
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +0 -37
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +0 -7
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +0 -58
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +0 -10
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +0 -29
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +0 -7
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +0 -29
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +0 -29
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +0 -47
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +0 -50
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +0 -9
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +0 -53
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +0 -57
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +0 -91
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +0 -21
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +0 -8
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +0 -8
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +0 -8
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +0 -32
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -33
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +0 -32
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +0 -10
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +0 -15
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +0 -8
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +0 -15
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +0 -19
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +0 -18
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +0 -19
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +0 -10
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +0 -20
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/memoize.js +0 -20
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +0 -37
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +0 -509
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +0 -108
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +0 -31
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +0 -45
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +0 -49
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +0 -34
- package/dist/plot/common/plot.d.ts +0 -103
- package/dist/plot/common/plot.js +0 -227
- package/dist/plot/dot.d.ts +0 -47
- package/dist/plot/dot.js +0 -62
- package/dist/plot/line.d.ts +0 -47
- package/dist/plot/line.js +0 -84
- package/dist/tool-menu.d.ts +0 -31
- package/dist/utils.d.ts +0 -39
- package/dist/utils.js +0 -101
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
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;
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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 };
|
|
@@ -0,0 +1,77 @@
|
|
|
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;
|