awesome-timeline-react 0.15.0 → 0.15.1

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
@@ -186,6 +186,7 @@ var rt_indicator_default = RTIndicator;
186
186
  import React2, {
187
187
  forwardRef,
188
188
  useImperativeHandle,
189
+ useLayoutEffect,
189
190
  useRef as useRef2,
190
191
  useState as useState2
191
192
  } from "react";
@@ -193,42 +194,16 @@ import { computePosition, flip, offset, shift } from "@floating-ui/dom";
193
194
  var EventPrompt = forwardRef(
194
195
  ({ template }, ref) => {
195
196
  const promptRef = useRef2(null);
196
- const [hoveredEvent, setHoveredEvent] = useState2();
197
+ const [shown, setShown] = useState2();
197
198
  const showSeqRef = useRef2(0);
198
199
  useImperativeHandle(ref, () => {
199
200
  return {
200
201
  show(event, anchorRect) {
201
202
  const prompt = promptRef.current;
202
203
  if (!prompt) return;
203
- setHoveredEvent(event);
204
- const seq = ++showSeqRef.current;
205
- const virtualAnchor = {
206
- getBoundingClientRect: () => ({
207
- x: anchorRect.x,
208
- y: anchorRect.y,
209
- width: anchorRect.width,
210
- height: anchorRect.height,
211
- top: anchorRect.y,
212
- left: anchorRect.x,
213
- right: anchorRect.x + anchorRect.width,
214
- bottom: anchorRect.y + anchorRect.height
215
- })
216
- };
217
204
  prompt.style.display = "block";
218
205
  prompt.style.visibility = "hidden";
219
- computePosition(virtualAnchor, prompt, {
220
- placement: "top",
221
- middleware: [
222
- offset(8),
223
- flip({ padding: 8 }),
224
- shift({ padding: 8 })
225
- ]
226
- }).then(({ x, y }) => {
227
- if (seq !== showSeqRef.current || !promptRef.current) return;
228
- promptRef.current.style.left = `${x}px`;
229
- promptRef.current.style.top = `${y}px`;
230
- promptRef.current.style.visibility = "visible";
231
- });
206
+ setShown({ event, anchor: anchorRect, seq: ++showSeqRef.current });
232
207
  },
233
208
  hide() {
234
209
  showSeqRef.current++;
@@ -238,7 +213,37 @@ var EventPrompt = forwardRef(
238
213
  }
239
214
  };
240
215
  });
241
- return /* @__PURE__ */ React2.createElement("div", { className: "event-prompt", ref: promptRef }, template && hoveredEvent && template(hoveredEvent));
216
+ useLayoutEffect(() => {
217
+ const prompt = promptRef.current;
218
+ if (!shown || !prompt || shown.seq !== showSeqRef.current) return;
219
+ const { x, y, width, height } = shown.anchor;
220
+ const virtualAnchor = {
221
+ getBoundingClientRect: () => ({
222
+ x,
223
+ y,
224
+ width,
225
+ height,
226
+ top: y,
227
+ left: x,
228
+ right: x + width,
229
+ bottom: y + height
230
+ })
231
+ };
232
+ computePosition(virtualAnchor, prompt, {
233
+ placement: "top",
234
+ middleware: [
235
+ offset(8),
236
+ flip({ padding: 8 }),
237
+ shift({ padding: 8 })
238
+ ]
239
+ }).then((pos) => {
240
+ if (shown.seq !== showSeqRef.current || !promptRef.current) return;
241
+ promptRef.current.style.left = `${pos.x}px`;
242
+ promptRef.current.style.top = `${pos.y}px`;
243
+ promptRef.current.style.visibility = "visible";
244
+ });
245
+ }, [shown]);
246
+ return /* @__PURE__ */ React2.createElement("div", { className: "event-prompt", ref: promptRef }, template && shown && template(shown.event));
242
247
  }
243
248
  );
244
249
  var event_prompt_default = EventPrompt;
@@ -711,7 +716,7 @@ import React5, {
711
716
  forwardRef as forwardRef2,
712
717
  useCallback as useCallback2,
713
718
  useEffect as useEffect5,
714
- useLayoutEffect,
719
+ useLayoutEffect as useLayoutEffect2,
715
720
  useRef as useRef5,
716
721
  useState as useState3,
717
722
  useSyncExternalStore
@@ -2417,7 +2422,7 @@ var CanvasBoard = forwardRef2(
2417
2422
  useCallback2((listener) => scene.subscribe(listener), [scene]),
2418
2423
  () => scene.version
2419
2424
  );
2420
- useLayoutEffect(() => {
2425
+ useLayoutEffect2(() => {
2421
2426
  if (renderRowLabel) return;
2422
2427
  const wrapper = headerWrapperRef.current;
2423
2428
  if (!wrapper) return;
@@ -2455,7 +2460,7 @@ var CanvasBoard = forwardRef2(
2455
2460
  wrapper.removeChild(measurer);
2456
2461
  };
2457
2462
  }, [rows, scene, theme.rowPaddingY, rowsHeaderClassName, renderRowLabel]);
2458
- useLayoutEffect(() => {
2463
+ useLayoutEffect2(() => {
2459
2464
  if (!renderRowLabel) return;
2460
2465
  const layer = measureLayerRef.current;
2461
2466
  const wrapper = headerWrapperRef.current;
@@ -2519,7 +2524,7 @@ var CanvasBoard = forwardRef2(
2519
2524
  }, [getSelection, rendererRef]);
2520
2525
  const { offsetOf, totalHeight } = scene.getRowOffsets();
2521
2526
  totalHeightRef.current = totalHeight;
2522
- useLayoutEffect(() => {
2527
+ useLayoutEffect2(() => {
2523
2528
  measureViewport();
2524
2529
  }, [totalHeight, measureViewport]);
2525
2530
  const lastChildOf = /* @__PURE__ */ new Map();