@dschz/solid-uplot 0.3.0 → 0.4.0
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/plugins/index.d.ts +25 -0
- package/dist/plugins/index.js +3 -2
- package/package.json +1 -1
package/dist/plugins/index.d.ts
CHANGED
|
@@ -384,6 +384,30 @@ type TooltipConfigOptions = {
|
|
|
384
384
|
* @default false
|
|
385
385
|
*/
|
|
386
386
|
readonly fixed?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Optional callback to process or modify the calculated tooltip position.
|
|
389
|
+
* Receives the calculated position and placement preference, and should return a position object with the same structure.
|
|
390
|
+
* Use this to implement custom positioning logic or constraints.
|
|
391
|
+
*
|
|
392
|
+
* @param position - The calculated position with left and top coordinates
|
|
393
|
+
* @param placement - The placement preference that was used for calculation
|
|
394
|
+
* @returns Modified position object with left and top coordinates
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* onPositionCalculated: (position, placement) => ({
|
|
399
|
+
* left: Math.max(0, position.left), // Prevent negative positioning
|
|
400
|
+
* top: placement.includes('top') ? position.top - 5 : position.top + 10
|
|
401
|
+
* })
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
readonly onPositionCalculated?: (position: {
|
|
405
|
+
left: number;
|
|
406
|
+
top: number;
|
|
407
|
+
}, placement: TooltipCursorPlacement) => {
|
|
408
|
+
left: number;
|
|
409
|
+
top: number;
|
|
410
|
+
};
|
|
387
411
|
};
|
|
388
412
|
/**
|
|
389
413
|
* Combined options for the tooltip plugin including container props and behavior config.
|
|
@@ -400,6 +424,7 @@ type TooltipPluginOptions = TooltipRootProps & TooltipConfigOptions;
|
|
|
400
424
|
* - Automatic positioning with edge detection and flipping
|
|
401
425
|
* - Scroll-aware positioning that works with page scrolling
|
|
402
426
|
* - Configurable placement preferences
|
|
427
|
+
* - Position callback for custom positioning logic or overrides
|
|
403
428
|
* - Accessible tooltip with proper ARIA attributes
|
|
404
429
|
* - Automatic cleanup and memory management
|
|
405
430
|
*
|
package/dist/plugins/index.js
CHANGED
|
@@ -279,7 +279,7 @@ var tooltip = (Component, options = {}) => {
|
|
|
279
279
|
zIndex: 20
|
|
280
280
|
}, options);
|
|
281
281
|
const chartCursorData = () => bus.data.cursor?.state[u.root.id];
|
|
282
|
-
const [tooltipOptions, containerProps] = splitProps(_options, ["placement", "fixed"]);
|
|
282
|
+
const [tooltipOptions, containerProps] = splitProps(_options, ["placement", "fixed", "onPositionCalculated"]);
|
|
283
283
|
return createComponent(Show, {
|
|
284
284
|
get when() {
|
|
285
285
|
return chartCursorData();
|
|
@@ -293,7 +293,8 @@ var tooltip = (Component, options = {}) => {
|
|
|
293
293
|
const cursorTop = overRect.top + cursor2().position.top;
|
|
294
294
|
const absoluteLeft = tooltipOptions.fixed ? cursorLeft : cursorLeft + window.scrollX;
|
|
295
295
|
const absoluteTop = tooltipOptions.fixed ? cursorTop : cursorTop + window.scrollY;
|
|
296
|
-
|
|
296
|
+
const calculatedPosition = getTooltipPosition(tooltipOptions.placement, absoluteLeft, absoluteTop, tooltipWidth, tooltipHeight, tooltipOptions.fixed);
|
|
297
|
+
return tooltipOptions.onPositionCalculated ? tooltipOptions.onPositionCalculated(calculatedPosition, tooltipOptions.placement) : calculatedPosition;
|
|
297
298
|
};
|
|
298
299
|
return (() => {
|
|
299
300
|
var _el$ = _tmpl$2();
|
package/package.json
CHANGED