@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
53 lines • 1.23 kB
JavaScript
import React from 'react';
import clsx from 'clsx';
export function injectTooltipSemantic(params) {
params.tabIndex = '0';
params.className = clsx("dnb-tooltip__wrapper dnb-tab-focus", params.className);
return params;
}
export const defaultProps = {
id: null,
size: 'default',
open: null,
placement: 'top',
arrow: 'center',
align: null,
fixedPosition: false,
skipPortal: null,
noAnimation: false,
showDelay: 300,
hideDelay: 500,
targetSelector: null,
targetElement: null,
className: null,
children: null,
tooltip: null,
triggerOffset: 16
};
export function getTargetElement(target) {
if (typeof document !== 'undefined') {
return typeof target === 'string' ? typeof document !== 'undefined' && document.querySelector(target) : target;
}
return undefined;
}
export function getPropsFromTooltipProp(localProps) {
const {
tooltip
} = localProps;
if (!tooltip) {
return null;
}
if (React.isValidElement(tooltip)) {
const type = tooltip.type;
if (type?.isTooltipComponent) {
return tooltip.props;
}
}
return {
children: tooltip
};
}
export const isTouch = type => {
return /touch/i.test(type);
};
//# sourceMappingURL=TooltipHelpers.js.map