@spider-analyzer/timeline 5.0.8 → 5.0.9

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/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { forwardRef, useRef, useEffect, useState, useCallback, useImperativeHandle, useMemo } from 'react';
1
+ import { forwardRef, memo, useRef, useEffect, useState, useCallback, useImperativeHandle, useMemo } from 'react';
2
+ import { flushSync } from 'react-dom';
2
3
  import { DateTime, Duration } from 'luxon';
3
4
  import { scaleLinear, scaleTime } from 'd3-scale';
4
5
  import PropTypes11 from 'prop-types';
@@ -1419,6 +1420,7 @@ Histogram.propTypes = {
1419
1420
  barHovered: PropTypes11.number,
1420
1421
  tooltipVisible: PropTypes11.bool
1421
1422
  };
1423
+ var Histogram_default = memo(Histogram);
1422
1424
 
1423
1425
  // src/timeLineElements/axesStyles.jsx
1424
1426
  var arrow = `m 0,-5 5,5 -5,5`;
@@ -1504,6 +1506,7 @@ XAxis.propTypes = {
1504
1506
  arrowPath: PropTypes11.string,
1505
1507
  onFormatTimeLegend: PropTypes11.func.isRequired
1506
1508
  };
1509
+ var XAxis_default = memo(XAxis);
1507
1510
  function YAxis({ classes, marks, yAxis, onFormatMetricLegend, maxHeight, origin, arrowPath = arrow }) {
1508
1511
  const className = (n) => cn(n, classes);
1509
1512
  return /* @__PURE__ */ jsxs(
@@ -1958,6 +1961,7 @@ XAxis2.propTypes = {
1958
1961
  xAxis: PropTypes11.func,
1959
1962
  yAxisHeight: PropTypes11.number
1960
1963
  };
1964
+ var XGrid_default = memo(XAxis2);
1961
1965
 
1962
1966
  // src/time.ts
1963
1967
  function toMoment(x, zone) {
@@ -1980,8 +1984,8 @@ function timeSpanToMoments(t, zone) {
1980
1984
  return { start: toMomentOpt(t.start, zone), stop: toMomentOpt(t.stop, zone) };
1981
1985
  }
1982
1986
  var Cursor2 = Cursor;
1983
- var Histogram2 = Histogram;
1984
- var XAxis3 = XAxis;
1987
+ var Histogram2 = Histogram_default;
1988
+ var XAxis3 = XAxis_default;
1985
1989
  var YAxis3 = YAxis;
1986
1990
  var Legend2 = Legend;
1987
1991
  var Tools2 = Tools;
@@ -2076,6 +2080,11 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2076
2080
  const patchState = useCallback((patch) => {
2077
2081
  setStateRaw((s) => ({ ...s, ...typeof patch === "function" ? patch(s) : patch }));
2078
2082
  }, []);
2083
+ const patchStateSync = useCallback((patch) => {
2084
+ flushSync(() => {
2085
+ setStateRaw((s) => ({ ...s, ...typeof patch === "function" ? patch(s) : patch }));
2086
+ });
2087
+ }, []);
2079
2088
  const checkAndCorrectDomain = useCallback(({ domain: domain2 }) => {
2080
2089
  return checkAndCorrectDomainPure({
2081
2090
  domain: domain2,
@@ -2319,9 +2328,9 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2319
2328
  movedSinceLastFetchedRef.current = 0;
2320
2329
  getItems(p, { min, max: max2 });
2321
2330
  }
2322
- patchState({ domain: { min, max: max2 }, minTime, maxTime, ticks: ticks2 });
2331
+ patchStateSync({ domain: { min, max: max2 }, minTime, maxTime, ticks: ticks2 });
2323
2332
  }
2324
- }, [moveTimeLineCore, getItems, patchState]);
2333
+ }, [moveTimeLineCore, getItems, patchStateSync]);
2325
2334
  const onResizeLeftCursor = useCallback((delta, mouse) => {
2326
2335
  const xAxis = xAxisRef.current;
2327
2336
  const s = stateRef.current;
@@ -2341,9 +2350,9 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2341
2350
  }
2342
2351
  handleAutoSliding(mouse, onResizeLeftCursor);
2343
2352
  if (newStop !== s.stop && newStop.isSameOrBefore(s.domain.max) || newStart.isSameOrAfter(s.domain.min)) {
2344
- patchState({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2353
+ patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2345
2354
  }
2346
- }, [handleAutoSliding, patchState]);
2355
+ }, [handleAutoSliding, patchStateSync]);
2347
2356
  const onResizeRightCursor = useCallback((delta, mouse) => {
2348
2357
  const xAxis = xAxisRef.current;
2349
2358
  const s = stateRef.current;
@@ -2363,9 +2372,9 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2363
2372
  }
2364
2373
  handleAutoSliding(mouse, onResizeRightCursor);
2365
2374
  if (newStop.isSameOrBefore(s.domain.max) && newStart.isSameOrAfter(s.domain.min)) {
2366
- patchState({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2375
+ patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2367
2376
  }
2368
- }, [handleAutoSliding, patchState]);
2377
+ }, [handleAutoSliding, patchStateSync]);
2369
2378
  const onDragCursor = useCallback((delta, mouse) => {
2370
2379
  const xAxis = xAxisRef.current;
2371
2380
  const s = stateRef.current;
@@ -2379,8 +2388,8 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2379
2388
  if (maxDomain.min && newStart.isBefore(maxDomain.min)) newStart = moment_shim_default(maxDomain.min);
2380
2389
  if (maxDomain.max && newStop.isAfter(maxDomain.max)) newStop = moment_shim_default(maxDomain.max);
2381
2390
  handleAutoSliding(mouse, onDragCursor);
2382
- patchState({ start: newStart, stop: newStop });
2383
- }, [handleAutoSliding, patchState]);
2391
+ patchStateSync({ start: newStart, stop: newStop });
2392
+ }, [handleAutoSliding, patchStateSync]);
2384
2393
  const onStartDrawCursor = useCallback((pos) => {
2385
2394
  const xAxis = xAxisRef.current;
2386
2395
  patchState({
@@ -2408,9 +2417,9 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2408
2417
  }
2409
2418
  handleAutoSliding(mouse, onDrawCursor);
2410
2419
  if (newStop.isSameOrBefore(s.domain.max) && newStart.isSameOrAfter(s.domain.min)) {
2411
- patchState({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2420
+ patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
2412
2421
  }
2413
- }, [handleAutoSliding, patchState]);
2422
+ }, [handleAutoSliding, patchStateSync]);
2414
2423
  const onEndDrawCursor = useCallback(() => {
2415
2424
  stopAutoMove();
2416
2425
  const { onCustomRange, selectBarOnClick } = propsRef.current;
@@ -2603,7 +2612,7 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
2603
2612
  }
2604
2613
  ),
2605
2614
  xAxisProp.showGrid && /* @__PURE__ */ jsx(
2606
- XAxis2,
2615
+ XGrid_default,
2607
2616
  {
2608
2617
  classes,
2609
2618
  origin: pointZero,