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/_tsup-dts-rollup.d.mts +8 -1
- package/dist/_tsup-dts-rollup.d.ts +8 -1
- package/dist/index.js +33 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
|
@@ -174,7 +174,8 @@ export declare const default_alias_2: ({ windowTime, tick, contentWidth, scrollW
|
|
|
174
174
|
* Hover tooltip for events. Positioned with @floating-ui/dom against the
|
|
175
175
|
* hovered event's rect (viewport coordinates): preferred above the event,
|
|
176
176
|
* flips below when there is no room, and shifts horizontally to stay
|
|
177
|
-
* on-screen.
|
|
177
|
+
* on-screen. Placed only once the hovered event's template has rendered, so
|
|
178
|
+
* it is measured at its own size, not the previous event's.
|
|
178
179
|
*/
|
|
179
180
|
export declare const default_alias_3: React_2.ForwardRefExoticComponent<EventPromptType & React_2.RefAttributes<EventPromptActionsType>>;
|
|
180
181
|
|
|
@@ -1194,6 +1195,12 @@ export declare const TimelinePointerLine: () => React_2.JSX.Element;
|
|
|
1194
1195
|
|
|
1195
1196
|
export declare const TimelinePrimary: () => React_2.JSX.Element;
|
|
1196
1197
|
|
|
1198
|
+
/**
|
|
1199
|
+
* Tooltips of different widths at the right edge. Hover a short bar, then a wide one: the wide
|
|
1200
|
+
* tooltip must stay whole inside the frame, never sized for the bar hovered before it.
|
|
1201
|
+
*/
|
|
1202
|
+
export declare const TimelinePromptWidths: () => React_2.JSX.Element;
|
|
1203
|
+
|
|
1197
1204
|
declare type TimelineProps = {
|
|
1198
1205
|
rows: RowType[];
|
|
1199
1206
|
events: EventType[];
|
|
@@ -174,7 +174,8 @@ export declare const default_alias_2: ({ windowTime, tick, contentWidth, scrollW
|
|
|
174
174
|
* Hover tooltip for events. Positioned with @floating-ui/dom against the
|
|
175
175
|
* hovered event's rect (viewport coordinates): preferred above the event,
|
|
176
176
|
* flips below when there is no room, and shifts horizontally to stay
|
|
177
|
-
* on-screen.
|
|
177
|
+
* on-screen. Placed only once the hovered event's template has rendered, so
|
|
178
|
+
* it is measured at its own size, not the previous event's.
|
|
178
179
|
*/
|
|
179
180
|
export declare const default_alias_3: React_2.ForwardRefExoticComponent<EventPromptType & React_2.RefAttributes<EventPromptActionsType>>;
|
|
180
181
|
|
|
@@ -1194,6 +1195,12 @@ export declare const TimelinePointerLine: () => React_2.JSX.Element;
|
|
|
1194
1195
|
|
|
1195
1196
|
export declare const TimelinePrimary: () => React_2.JSX.Element;
|
|
1196
1197
|
|
|
1198
|
+
/**
|
|
1199
|
+
* Tooltips of different widths at the right edge. Hover a short bar, then a wide one: the wide
|
|
1200
|
+
* tooltip must stay whole inside the frame, never sized for the bar hovered before it.
|
|
1201
|
+
*/
|
|
1202
|
+
export declare const TimelinePromptWidths: () => React_2.JSX.Element;
|
|
1203
|
+
|
|
1197
1204
|
declare type TimelineProps = {
|
|
1198
1205
|
rows: RowType[];
|
|
1199
1206
|
events: EventType[];
|
package/dist/index.js
CHANGED
|
@@ -214,42 +214,16 @@ var import_dom = require("@floating-ui/dom");
|
|
|
214
214
|
var EventPrompt = (0, import_react3.forwardRef)(
|
|
215
215
|
({ template }, ref) => {
|
|
216
216
|
const promptRef = (0, import_react3.useRef)(null);
|
|
217
|
-
const [
|
|
217
|
+
const [shown, setShown] = (0, import_react3.useState)();
|
|
218
218
|
const showSeqRef = (0, import_react3.useRef)(0);
|
|
219
219
|
(0, import_react3.useImperativeHandle)(ref, () => {
|
|
220
220
|
return {
|
|
221
221
|
show(event, anchorRect) {
|
|
222
222
|
const prompt = promptRef.current;
|
|
223
223
|
if (!prompt) return;
|
|
224
|
-
setHoveredEvent(event);
|
|
225
|
-
const seq = ++showSeqRef.current;
|
|
226
|
-
const virtualAnchor = {
|
|
227
|
-
getBoundingClientRect: () => ({
|
|
228
|
-
x: anchorRect.x,
|
|
229
|
-
y: anchorRect.y,
|
|
230
|
-
width: anchorRect.width,
|
|
231
|
-
height: anchorRect.height,
|
|
232
|
-
top: anchorRect.y,
|
|
233
|
-
left: anchorRect.x,
|
|
234
|
-
right: anchorRect.x + anchorRect.width,
|
|
235
|
-
bottom: anchorRect.y + anchorRect.height
|
|
236
|
-
})
|
|
237
|
-
};
|
|
238
224
|
prompt.style.display = "block";
|
|
239
225
|
prompt.style.visibility = "hidden";
|
|
240
|
-
(
|
|
241
|
-
placement: "top",
|
|
242
|
-
middleware: [
|
|
243
|
-
(0, import_dom.offset)(8),
|
|
244
|
-
(0, import_dom.flip)({ padding: 8 }),
|
|
245
|
-
(0, import_dom.shift)({ padding: 8 })
|
|
246
|
-
]
|
|
247
|
-
}).then(({ x, y }) => {
|
|
248
|
-
if (seq !== showSeqRef.current || !promptRef.current) return;
|
|
249
|
-
promptRef.current.style.left = `${x}px`;
|
|
250
|
-
promptRef.current.style.top = `${y}px`;
|
|
251
|
-
promptRef.current.style.visibility = "visible";
|
|
252
|
-
});
|
|
226
|
+
setShown({ event, anchor: anchorRect, seq: ++showSeqRef.current });
|
|
253
227
|
},
|
|
254
228
|
hide() {
|
|
255
229
|
showSeqRef.current++;
|
|
@@ -259,7 +233,37 @@ var EventPrompt = (0, import_react3.forwardRef)(
|
|
|
259
233
|
}
|
|
260
234
|
};
|
|
261
235
|
});
|
|
262
|
-
|
|
236
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
237
|
+
const prompt = promptRef.current;
|
|
238
|
+
if (!shown || !prompt || shown.seq !== showSeqRef.current) return;
|
|
239
|
+
const { x, y, width, height } = shown.anchor;
|
|
240
|
+
const virtualAnchor = {
|
|
241
|
+
getBoundingClientRect: () => ({
|
|
242
|
+
x,
|
|
243
|
+
y,
|
|
244
|
+
width,
|
|
245
|
+
height,
|
|
246
|
+
top: y,
|
|
247
|
+
left: x,
|
|
248
|
+
right: x + width,
|
|
249
|
+
bottom: y + height
|
|
250
|
+
})
|
|
251
|
+
};
|
|
252
|
+
(0, import_dom.computePosition)(virtualAnchor, prompt, {
|
|
253
|
+
placement: "top",
|
|
254
|
+
middleware: [
|
|
255
|
+
(0, import_dom.offset)(8),
|
|
256
|
+
(0, import_dom.flip)({ padding: 8 }),
|
|
257
|
+
(0, import_dom.shift)({ padding: 8 })
|
|
258
|
+
]
|
|
259
|
+
}).then((pos) => {
|
|
260
|
+
if (shown.seq !== showSeqRef.current || !promptRef.current) return;
|
|
261
|
+
promptRef.current.style.left = `${pos.x}px`;
|
|
262
|
+
promptRef.current.style.top = `${pos.y}px`;
|
|
263
|
+
promptRef.current.style.visibility = "visible";
|
|
264
|
+
});
|
|
265
|
+
}, [shown]);
|
|
266
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", { className: "event-prompt", ref: promptRef }, template && shown && template(shown.event));
|
|
263
267
|
}
|
|
264
268
|
);
|
|
265
269
|
var event_prompt_default = EventPrompt;
|