@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
52 lines • 1.26 kB
JavaScript
import React from 'react';
import classnames from 'classnames';
export function injectTooltipSemantic(params) {
params.tabIndex = '0';
params.className = classnames("dnb-tooltip__wrapper dnb-tab-focus", params.className);
return params;
}
export const defaultProps = {
id: null,
size: 'basis',
active: null,
position: '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;
}
}
export function getPropsFromTooltipProp(localProps) {
const {
tooltip
} = localProps;
if (!tooltip) {
return null;
}
if (React.isValidElement(tooltip)) {
const type = tooltip.type;
if (type !== null && type !== void 0 && type.isTooltipComponent) {
return tooltip.props;
}
}
return {
children: tooltip
};
}
export const isTouch = type => {
return /touch/i.test(type);
};
//# sourceMappingURL=TooltipHelpers.js.map