@octanejs/recharts 0.1.62 → 0.1.64

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.
Files changed (73) hide show
  1. package/package.json +5 -5
  2. package/src/animation/AnimatedItems.tsrx +36 -31
  3. package/src/animation/CSSTransitionAnimate.tsrx +1 -2
  4. package/src/animation/JavascriptAnimate.tsrx +1 -2
  5. package/src/cartesian/Area.tsrx +414 -386
  6. package/src/cartesian/AreaRevealShape.tsrx +103 -84
  7. package/src/cartesian/Bar.tsrx +343 -317
  8. package/src/cartesian/BarStack.tsrx +33 -28
  9. package/src/cartesian/CartesianAxis.tsrx +168 -165
  10. package/src/cartesian/CartesianGrid.tsrx +256 -272
  11. package/src/cartesian/ErrorBar.tsrx +108 -104
  12. package/src/cartesian/Funnel.tsrx +405 -382
  13. package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
  14. package/src/cartesian/Line.tsrx +190 -177
  15. package/src/cartesian/LineDrawShape.tsrx +14 -15
  16. package/src/cartesian/ReferenceLine.tsrx +119 -105
  17. package/src/cartesian/Scatter.tsrx +416 -398
  18. package/src/cartesian/XAxis.tsrx +39 -32
  19. package/src/cartesian/YAxis.tsrx +47 -37
  20. package/src/cartesian/ZAxis.tsrx +76 -73
  21. package/src/chart/AreaChart.tsrx +15 -11
  22. package/src/chart/BarChart.tsrx +15 -11
  23. package/src/chart/CategoricalChart.tsrx +32 -26
  24. package/src/chart/ComposedChart.tsrx +15 -11
  25. package/src/chart/FunnelChart.tsrx +15 -11
  26. package/src/chart/LineChart.tsrx +15 -11
  27. package/src/chart/PieChart.tsrx +15 -11
  28. package/src/chart/PolarChart.tsrx +45 -48
  29. package/src/chart/RadarChart.tsrx +38 -32
  30. package/src/chart/RadialBarChart.tsrx +15 -11
  31. package/src/chart/RechartsWrapper.tsrx +214 -162
  32. package/src/chart/Sankey.tsrx +412 -378
  33. package/src/chart/ScatterChart.tsrx +15 -11
  34. package/src/chart/SunburstChart.tsrx +162 -155
  35. package/src/component/ActivePoints.tsrx +19 -13
  36. package/src/component/Cursor.tsrx +25 -18
  37. package/src/component/DefaultLegendContent.tsrx +131 -127
  38. package/src/component/DefaultTooltipContent.tsrx +46 -42
  39. package/src/component/Dots.tsrx +11 -5
  40. package/src/component/Label.tsrx +69 -55
  41. package/src/component/LabelList.tsrx +32 -27
  42. package/src/component/Legend.tsrx +120 -123
  43. package/src/component/ResponsiveContainer.tsrx +18 -11
  44. package/src/component/Text.tsrx +50 -43
  45. package/src/component/Tooltip.tsrx +234 -223
  46. package/src/component/TooltipBoundingBox.tsrx +34 -34
  47. package/src/container/ClipPathProvider.tsrx +1 -3
  48. package/src/container/Layer.tsrx +5 -1
  49. package/src/container/RootSurface.tsrx +31 -21
  50. package/src/container/Surface.tsrx +15 -13
  51. package/src/context/ErrorBarContext.tsrx +5 -5
  52. package/src/polar/Pie.tsrx +541 -487
  53. package/src/polar/PolarAngleAxis.tsrx +245 -227
  54. package/src/polar/PolarGrid.tsrx +139 -127
  55. package/src/polar/PolarRadiusAxis.tsrx +204 -185
  56. package/src/polar/Radar.tsrx +274 -264
  57. package/src/polar/RadialBar.tsrx +408 -361
  58. package/src/shape/Cross.tsrx +13 -7
  59. package/src/shape/Curve.tsrx +54 -44
  60. package/src/shape/Dot.tsrx +10 -8
  61. package/src/shape/Polygon.tsrx +38 -29
  62. package/src/shape/Rectangle.tsrx +73 -28
  63. package/src/shape/Sector.tsrx +30 -18
  64. package/src/shape/Symbols.tsrx +13 -11
  65. package/src/shape/Trapezoid.tsrx +16 -11
  66. package/src/state/RechartsStoreProvider.tsrx +5 -1
  67. package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
  68. package/src/util/BarUtils.tsrx +43 -40
  69. package/src/util/FunnelUtils.tsrx +5 -5
  70. package/src/util/RadialBarUtils.tsrx +3 -4
  71. package/src/util/ScatterUtils.tsrx +13 -8
  72. package/src/zIndex/ZIndexLayer.tsrx +2 -2
  73. package/src/zIndex/ZIndexPortal.tsrx +2 -8
@@ -37,14 +37,10 @@ export function GraphicalItemClipPath(props: GraphicalItemClipPathProps) @{
37
37
  return null;
38
38
  }
39
39
  const { x, y, width, height } = plotArea;
40
- const clipX =
41
- needClipX && xAxisRange ? Math.min(xAxisRange[0], xAxisRange[1]) : x - width / 2;
42
- const clipY =
43
- needClipY && yAxisRange ? Math.min(yAxisRange[0], yAxisRange[1]) : y - height / 2;
44
- const clipWidth =
45
- needClipX && xAxisRange ? Math.abs(xAxisRange[1] - xAxisRange[0]) : width * 2;
46
- const clipHeight =
47
- needClipY && yAxisRange ? Math.abs(yAxisRange[1] - yAxisRange[0]) : height * 2;
40
+ const clipX = needClipX && xAxisRange ? Math.min(xAxisRange[0], xAxisRange[1]) : x - width / 2;
41
+ const clipY = needClipY && yAxisRange ? Math.min(yAxisRange[0], yAxisRange[1]) : y - height / 2;
42
+ const clipWidth = needClipX && xAxisRange ? Math.abs(xAxisRange[1] - xAxisRange[0]) : width * 2;
43
+ const clipHeight = needClipY && yAxisRange ? Math.abs(yAxisRange[1] - yAxisRange[0]) : height * 2;
48
44
  <clipPath id={'clipPath-' + clipPathId}>
49
45
  <rect x={clipX} y={clipY} width={clipWidth} height={clipHeight} />
50
46
  </clipPath>
@@ -71,9 +71,8 @@ interface InternalLineProps extends ZIndexable {
71
71
  xAxisId: AxisId;
72
72
  yAxisId: AxisId;
73
73
  }
74
- interface LineProps<DataPointType = any, DataValueType = any> extends DataProvider<
75
- DataPointType
76
- >, DataConsumer<DataPointType, DataValueType>, ZIndexable {
74
+ interface LineProps<DataPointType = any, DataValueType = any>
75
+ extends DataProvider<DataPointType>, DataConsumer<DataPointType, DataValueType>, ZIndexable {
77
76
  activeDot?: ActiveDotType;
78
77
  animateNewValues?: boolean;
79
78
  animationBegin?: number;
@@ -106,8 +105,8 @@ interface LineProps<DataPointType = any, DataValueType = any> extends DataProvid
106
105
  }
107
106
  type LineSvgProps = Omit<CurveProps, 'points' | 'pathRef' | 'ref' | 'layout' | 'baseLine'>;
108
107
  type InternalProps = LineSvgProps & InternalLineProps;
109
- export type Props<DataPointType = any, ValueAxisType = any> =
110
- LineSvgProps & LineProps<DataPointType, ValueAxisType>;
108
+ export type Props<DataPointType = any, ValueAxisType = any> = LineSvgProps &
109
+ LineProps<DataPointType, ValueAxisType>;
111
110
  // Port of cartesian/Line.tsx — the line graphical item: redux registration,
112
111
  // store-computed points, the draw-in curve, dots, labels, active points.
113
112
  // `computeLinePoints` stays here (vendored lineSelectors imports it through
@@ -150,7 +149,7 @@ import { Dots } from '../component/Dots.tsrx';
150
149
 
151
150
  function getTotalLength(mainCurve: SVGPathElement | null) {
152
151
  try {
153
- return mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength() || 0;
152
+ return (mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength()) || 0;
154
153
  } catch {
155
154
  return 0;
156
155
  }
@@ -258,55 +257,57 @@ const computeLegendPayloadFromAreaData = (props: Props) => {
258
257
  ];
259
258
  };
260
259
 
261
- const SetLineTooltipEntrySettings = memo((
262
- props: Pick<
263
- InternalProps,
264
- | 'dataKey'
265
- | 'data'
266
- | 'stroke'
267
- | 'strokeWidth'
268
- | 'fill'
269
- | 'name'
270
- | 'hide'
271
- | 'unit'
272
- | 'formatter'
273
- | 'tooltipType'
274
- | 'id'
275
- >,
276
- ) => {
277
- const {
278
- dataKey,
279
- data,
280
- stroke,
281
- strokeWidth,
282
- fill,
283
- name,
284
- hide,
285
- unit,
286
- formatter,
287
- tooltipType,
288
- id,
289
- } = props;
290
- const tooltipEntrySettings: TooltipPayloadConfiguration = {
291
- dataDefinedOnItem: data,
292
- getPosition: noop,
293
- settings: {
260
+ const SetLineTooltipEntrySettings = memo(
261
+ (
262
+ props: Pick<
263
+ InternalProps,
264
+ | 'dataKey'
265
+ | 'data'
266
+ | 'stroke'
267
+ | 'strokeWidth'
268
+ | 'fill'
269
+ | 'name'
270
+ | 'hide'
271
+ | 'unit'
272
+ | 'formatter'
273
+ | 'tooltipType'
274
+ | 'id'
275
+ >,
276
+ ) => {
277
+ const {
278
+ dataKey,
279
+ data,
294
280
  stroke,
295
281
  strokeWidth,
296
282
  fill,
297
- dataKey,
298
- nameKey: undefined,
299
- name: getTooltipNameProp(name, dataKey),
283
+ name,
300
284
  hide,
301
- type: tooltipType,
302
- color: stroke,
303
285
  unit,
304
286
  formatter,
305
- graphicalItemId: id,
306
- },
307
- };
308
- return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
309
- });
287
+ tooltipType,
288
+ id,
289
+ } = props;
290
+ const tooltipEntrySettings: TooltipPayloadConfiguration = {
291
+ dataDefinedOnItem: data,
292
+ getPosition: noop,
293
+ settings: {
294
+ stroke,
295
+ strokeWidth,
296
+ fill,
297
+ dataKey,
298
+ nameKey: undefined,
299
+ name: getTooltipNameProp(name, dataKey),
300
+ hide,
301
+ type: tooltipType,
302
+ color: stroke,
303
+ unit,
304
+ formatter,
305
+ graphicalItemId: id,
306
+ },
307
+ };
308
+ return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
309
+ },
310
+ );
310
311
 
311
312
  function LineDotsWrapper(props: {
312
313
  points: ReadonlyArray<LinePointItem>;
@@ -318,16 +319,18 @@ function LineDotsWrapper(props: {
318
319
  // Exclude ID so it isn't duplicated across every dot.
319
320
  const { id, ...propsWithoutId } = props.props;
320
321
  const lineProps = svgPropertiesNoEvents(propsWithoutId);
321
- return <Dots
322
- points={points}
323
- dot={dot}
324
- className="recharts-line-dots"
325
- dotClassName="recharts-line-dot"
326
- dataKey={dataKey}
327
- baseProps={lineProps}
328
- needClip={needClip}
329
- clipPathId={clipPathId}
330
- />;
322
+ return (
323
+ <Dots
324
+ points={points}
325
+ dot={dot}
326
+ className="recharts-line-dots"
327
+ dotClassName="recharts-line-dot"
328
+ dataKey={dataKey}
329
+ baseProps={lineProps}
330
+ needClip={needClip}
331
+ clipPathId={clipPathId}
332
+ />
333
+ );
331
334
  }
332
335
 
333
336
  function LineLabelListProvider(props: {
@@ -356,9 +359,9 @@ function LineLabelListProvider(props: {
356
359
  };
357
360
  });
358
361
  }, [points]);
359
- <CartesianLabelListContextProvider
360
- value={showLabels ? labelListEntries : undefined}
361
- >{children}</CartesianLabelListContextProvider>
362
+ <CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
363
+ {children}
364
+ </CartesianLabelListContextProvider>
362
365
  }
363
366
 
364
367
  function StaticCurve(staticCurveProps: {
@@ -398,11 +401,14 @@ function StaticCurve(staticCurveProps: {
398
401
  isEntrance: props.animateNewValues ? isEntrance : false,
399
402
  visibleLength,
400
403
  };
401
- return <>
402
- {points?.length > 1 &&
403
- <Shape option={shape} DefaultShape={defaultLineProps.shape} shapeProps={curveProps} />}
404
- <LineDotsWrapper points={points} clipPathId={clipPathId} props={props} />
405
- </>;
404
+ return (
405
+ <>
406
+ {points?.length > 1 && (
407
+ <Shape option={shape} DefaultShape={defaultLineProps.shape} shapeProps={curveProps} />
408
+ )}
409
+ <LineDotsWrapper points={points} clipPathId={clipPathId} props={props} />
410
+ </>
411
+ );
406
412
  }
407
413
 
408
414
  function CurveWithAnimation(curveWithAnimationProps: {
@@ -434,57 +440,61 @@ function CurveWithAnimation(curveWithAnimationProps: {
434
440
  (animationElapsedTime: number) => animationElapsedTime > 0 && totalLength > 0,
435
441
  [totalLength],
436
442
  );
437
- return <LineLabelListProvider points={points} showLabels={showLabels}>
438
- {props.children}
439
- <AnimatedItems
440
- animationInput={points}
441
- animationIdPrefix="recharts-line-"
442
- items={points}
443
- previousItemsRef={previousPointsRef}
444
- isAnimationActive={isAnimationActive}
445
- animationBegin={animationBegin}
446
- animationDuration={animationDuration}
447
- animationEasing={animationEasing}
448
- onAnimationStart={handleAnimationStart}
449
- onAnimationEnd={handleAnimationEnd}
450
- animationInterpolateFn={animationInterpolateFn}
451
- animationMatchBy={animationMatchBy}
452
- shouldUpdatePreviousRef={shouldUpdatePreviousRef}
453
- layout={layout}
454
- >
455
- {(stepData, animationElapsedTime, isEntrance) => {
456
- const animationActive = isAnimating || animationElapsedTime < 1;
457
- const visibleLength =
458
- animationActive ? getVisibleLength(animationElapsedTime, totalLength) : null;
459
- return <StaticCurve
460
- props={props}
461
- points={stepData}
462
- clipPathId={clipPathId}
463
- pathRef={pathRef}
464
- animationElapsedTime={animationElapsedTime}
465
- isAnimating={animationActive}
466
- isEntrance={isEntrance}
467
- visibleLength={visibleLength}
468
- />;
469
- }}
470
- </AnimatedItems>
471
- <LabelListFromLabelProp label={props.label} />
472
- </LineLabelListProvider>;
443
+ return (
444
+ <LineLabelListProvider points={points} showLabels={showLabels}>
445
+ {props.children}
446
+ <AnimatedItems
447
+ animationInput={points}
448
+ animationIdPrefix="recharts-line-"
449
+ items={points}
450
+ previousItemsRef={previousPointsRef}
451
+ isAnimationActive={isAnimationActive}
452
+ animationBegin={animationBegin}
453
+ animationDuration={animationDuration}
454
+ animationEasing={animationEasing}
455
+ onAnimationStart={handleAnimationStart}
456
+ onAnimationEnd={handleAnimationEnd}
457
+ animationInterpolateFn={animationInterpolateFn}
458
+ animationMatchBy={animationMatchBy}
459
+ shouldUpdatePreviousRef={shouldUpdatePreviousRef}
460
+ layout={layout}
461
+ >
462
+ {(stepData, animationElapsedTime, isEntrance) => {
463
+ const animationActive = isAnimating || animationElapsedTime < 1;
464
+ const visibleLength = animationActive
465
+ ? getVisibleLength(animationElapsedTime, totalLength)
466
+ : null;
467
+ return (
468
+ <StaticCurve
469
+ props={props}
470
+ points={stepData}
471
+ clipPathId={clipPathId}
472
+ pathRef={pathRef}
473
+ animationElapsedTime={animationElapsedTime}
474
+ isAnimating={animationActive}
475
+ isEntrance={isEntrance}
476
+ visibleLength={visibleLength}
477
+ />
478
+ );
479
+ }}
480
+ </AnimatedItems>
481
+ <LabelListFromLabelProp label={props.label} />
482
+ </LineLabelListProvider>
483
+ );
473
484
  }
474
485
 
475
- function RenderCurve(props: {
476
- clipPathId: string;
477
- props: InternalProps;
478
- }) {
486
+ function RenderCurve(props: { clipPathId: string; props: InternalProps }) {
479
487
  const { clipPathId } = props;
480
488
  const previousPointsRef = useRef<ReadonlyArray<LinePointItem> | null>(null);
481
489
  const pathRef = useRef<SVGPathElement | null>(null);
482
- return <CurveWithAnimation
483
- props={props.props}
484
- clipPathId={clipPathId}
485
- previousPointsRef={previousPointsRef}
486
- pathRef={pathRef}
487
- />;
490
+ return (
491
+ <CurveWithAnimation
492
+ props={props.props}
493
+ clipPathId={clipPathId}
494
+ previousPointsRef={previousPointsRef}
495
+ pathRef={pathRef}
496
+ />
497
+ );
488
498
  }
489
499
 
490
500
  const errorBarDataPointFormatter: ErrorBarDataPointFormatter<LinePointItem> = (
@@ -588,38 +598,40 @@ function LineImpl(props: WithIdRequired<Props>) {
588
598
  const plotArea = usePlotArea();
589
599
  const layout = useChartLayout();
590
600
  const isPanorama = useIsPanorama();
591
- const points: ReadonlyArray<LinePointItem> | undefined = useAppSelector(
592
- (state) => selectLinePoints(state, xAxisId, yAxisId, isPanorama, id),
601
+ const points: ReadonlyArray<LinePointItem> | undefined = useAppSelector((state) =>
602
+ selectLinePoints(state, xAxisId, yAxisId, isPanorama, id),
593
603
  );
594
- if (layout !== 'horizontal' && layout !== 'vertical' || points == null || plotArea == null) {
604
+ if ((layout !== 'horizontal' && layout !== 'vertical') || points == null || plotArea == null) {
595
605
  // Cannot render Line in an unsupported layout
596
606
  return null;
597
607
  }
598
608
  const { height, width, x: left, y: top } = plotArea;
599
- return <LineWithState
600
- {...everythingElse}
601
- id={id}
602
- connectNulls={connectNulls}
603
- dot={dot}
604
- activeDot={activeDot}
605
- animateNewValues={animateNewValues}
606
- animationBegin={animationBegin}
607
- animationDuration={animationDuration}
608
- animationEasing={animationEasing}
609
- isAnimationActive={isAnimationActive}
610
- hide={hide}
611
- label={label}
612
- legendType={legendType}
613
- xAxisId={xAxisId}
614
- yAxisId={yAxisId}
615
- points={points}
616
- layout={layout}
617
- height={height}
618
- width={width}
619
- left={left}
620
- top={top}
621
- needClip={needClip}
622
- />;
609
+ return (
610
+ <LineWithState
611
+ {...everythingElse}
612
+ id={id}
613
+ connectNulls={connectNulls}
614
+ dot={dot}
615
+ activeDot={activeDot}
616
+ animateNewValues={animateNewValues}
617
+ animationBegin={animationBegin}
618
+ animationDuration={animationDuration}
619
+ animationEasing={animationEasing}
620
+ isAnimationActive={isAnimationActive}
621
+ hide={hide}
622
+ label={label}
623
+ legendType={legendType}
624
+ xAxisId={xAxisId}
625
+ yAxisId={yAxisId}
626
+ points={points}
627
+ layout={layout}
628
+ height={height}
629
+ width={width}
630
+ left={left}
631
+ top={top}
632
+ needClip={needClip}
633
+ />
634
+ );
623
635
  }
624
636
 
625
637
  export function computeLinePoints({
@@ -646,8 +658,7 @@ export function computeLinePoints({
646
658
  const value: number = getValueByDataKey(entry, dataKey);
647
659
  if (layout === 'horizontal') {
648
660
  const x = getCateCoordinateOfLine({ axis: xAxis, ticks: xAxisTicks, bandSize, entry, index });
649
- const y =
650
- isNullish(value) ? null : yAxis.scale.map(value);
661
+ const y = isNullish(value) ? null : yAxis.scale.map(value);
651
662
  return {
652
663
  x,
653
664
  y: y ?? null,
@@ -655,8 +666,7 @@ export function computeLinePoints({
655
666
  payload: entry,
656
667
  };
657
668
  }
658
- const x =
659
- isNullish(value) ? null : xAxis.scale.map(value);
669
+ const x = isNullish(value) ? null : xAxis.scale.map(value);
660
670
  const y = getCateCoordinateOfLine({ axis: yAxis, ticks: yAxisTicks, bandSize, entry, index });
661
671
  if (x == null || y == null) {
662
672
  return null;
@@ -665,9 +675,8 @@ export function computeLinePoints({
665
675
  });
666
676
  // This map returns only objects or null, so Boolean removes exactly the nulls.
667
677
  return points.filter(
668
- Boolean as BooleanConstructor & ((point: (typeof points)[number]) => point is NonNullable<
669
- typeof point
670
- >),
678
+ Boolean as BooleanConstructor &
679
+ ((point: (typeof points)[number]) => point is NonNullable<typeof point>),
671
680
  );
672
681
  }
673
682
 
@@ -676,36 +685,40 @@ function LineFn<DataPointType = any, ValueAxisType = any>(
676
685
  ) {
677
686
  const props = resolveDefaultProps(outsideProps, defaultLineProps);
678
687
  const isPanorama = useIsPanorama();
679
- return <RegisterGraphicalItemId id={props.id} type="line">
680
- {(id) => <>
681
- <SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
682
- <SetLineTooltipEntrySettings
683
- dataKey={props.dataKey}
684
- data={props.data}
685
- stroke={props.stroke}
686
- strokeWidth={props.strokeWidth}
687
- fill={props.fill}
688
- name={props.name}
689
- hide={props.hide}
690
- unit={props.unit}
691
- formatter={props.formatter}
692
- tooltipType={props.tooltipType}
693
- id={id}
694
- />
695
- <SetCartesianGraphicalItem
696
- type="line"
697
- id={id}
698
- data={props.data}
699
- xAxisId={props.xAxisId}
700
- yAxisId={props.yAxisId}
701
- zAxisId={0}
702
- dataKey={props.dataKey}
703
- hide={props.hide}
704
- isPanorama={isPanorama}
705
- />
706
- <LineImpl {...props} id={id} />
707
- </>}
708
- </RegisterGraphicalItemId>;
688
+ return (
689
+ <RegisterGraphicalItemId id={props.id} type="line">
690
+ {(id) => (
691
+ <>
692
+ <SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
693
+ <SetLineTooltipEntrySettings
694
+ dataKey={props.dataKey}
695
+ data={props.data}
696
+ stroke={props.stroke}
697
+ strokeWidth={props.strokeWidth}
698
+ fill={props.fill}
699
+ name={props.name}
700
+ hide={props.hide}
701
+ unit={props.unit}
702
+ formatter={props.formatter}
703
+ tooltipType={props.tooltipType}
704
+ id={id}
705
+ />
706
+ <SetCartesianGraphicalItem
707
+ type="line"
708
+ id={id}
709
+ data={props.data}
710
+ xAxisId={props.xAxisId}
711
+ yAxisId={props.yAxisId}
712
+ zAxisId={0}
713
+ dataKey={props.dataKey}
714
+ hide={props.hide}
715
+ isPanorama={isPanorama}
716
+ />
717
+ <LineImpl {...props} id={id} />
718
+ </>
719
+ )}
720
+ </RegisterGraphicalItemId>
721
+ );
709
722
  }
710
723
 
711
724
  /**
@@ -2,8 +2,8 @@ import type { RefObject } from '../util/OctaneTypes.ts';
2
2
  import type { Props as CurveProps } from '../shape/Curve.tsrx';
3
3
  import type { ShapeAnimationProps } from '../util/types';
4
4
 
5
- export type LineDrawShapeProps =
6
- Omit<CurveProps, 'pathRef'> & ShapeAnimationProps & {
5
+ export type LineDrawShapeProps = Omit<CurveProps, 'pathRef'> &
6
+ ShapeAnimationProps & {
7
7
  pathRef: RefObject<SVGPathElement | null>;
8
8
  visibleLength?: number | null;
9
9
  };
@@ -17,7 +17,7 @@ import { Curve } from '../shape/Curve.tsrx';
17
17
  */
18
18
  function getTotalLength(path: SVGPathElement | null) {
19
19
  try {
20
- return path && path.getTotalLength && path.getTotalLength() || 0;
20
+ return (path && path.getTotalLength && path.getTotalLength()) || 0;
21
21
  } catch {
22
22
  return 0;
23
23
  }
@@ -57,18 +57,17 @@ function getStrokeDasharray(length: number, totalLength: number, lines: number[]
57
57
  const count = Math.floor(length / lineLength);
58
58
  const remainLength = length % lineLength;
59
59
  let remainLines: number[] = [];
60
- for (let i = 0, sum = 0; i < normalizedLines.length; (sum += normalizedLines[i] ?? 0, ++i)) {
60
+ for (let i = 0, sum = 0; i < normalizedLines.length; sum += normalizedLines[i] ?? 0, ++i) {
61
61
  const lineValue = normalizedLines[i];
62
62
  if (lineValue != null && sum + lineValue > remainLength) {
63
63
  remainLines = [...normalizedLines.slice(0, i), remainLength - sum];
64
64
  break;
65
65
  }
66
66
  }
67
- const emptyLines =
68
- remainLines.length % 2 === 0 ? [0, totalLength] : [totalLength];
69
- return [...repeat(normalizedLines, count), ...remainLines, ...emptyLines].map(
70
- (line) => line + 'px',
71
- ).join(', ');
67
+ const emptyLines = remainLines.length % 2 === 0 ? [0, totalLength] : [totalLength];
68
+ return [...repeat(normalizedLines, count), ...remainLines, ...emptyLines]
69
+ .map((line) => line + 'px')
70
+ .join(', ');
72
71
  }
73
72
 
74
73
  function computeAnimatedStrokeDasharray(
@@ -77,7 +76,9 @@ function computeAnimatedStrokeDasharray(
77
76
  visibleLength: number,
78
77
  ) {
79
78
  if (userStrokeDasharray) {
80
- const lines = String(userStrokeDasharray).split(/[,\s]+/gim).map((num) => parseFloat(num));
79
+ const lines = String(userStrokeDasharray)
80
+ .split(/[,\s]+/gim)
81
+ .map((num) => parseFloat(num));
81
82
  return getStrokeDasharray(visibleLength, totalLength, lines);
82
83
  }
83
84
  return generateSimpleStrokeDasharray(totalLength, visibleLength);
@@ -111,9 +112,7 @@ export function LineDrawShape(props: LineDrawShapeProps) {
111
112
  } else if (userStrokeDasharray != null) {
112
113
  strokeDasharray = String(userStrokeDasharray);
113
114
  }
114
- return <Curve
115
- {...curveProps}
116
- connectNulls={finalConnectNulls}
117
- strokeDasharray={strokeDasharray}
118
- />;
115
+ return (
116
+ <Curve {...curveProps} connectNulls={finalConnectNulls} strokeDasharray={strokeDasharray} />
117
+ );
119
118
  }