UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

42 lines (41 loc) 1.3 kB
"use client"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; const _excluded = ["children", "render"]; import React from 'react'; import Context from '../../shared/Context'; import Dialog from '../dialog/Dialog'; import HelpButtonInstance from './HelpButtonInstance'; import { extendPropsWithContext } from '../../shared/component-helper'; const defaultProps = { variant: 'secondary', icon_position: 'left' }; export default function HelpButton(localProps) { const context = React.useContext(Context); const props = extendPropsWithContext(localProps, defaultProps); const { children, render } = props, params = _objectWithoutProperties(props, _excluded); if (params.size === 'small') { params.bounding = true; } if (params.icon === null) { params.icon = 'question'; } if (children) { if (!params.title) { params.title = context.getTranslation(props).HelpButton.title; } if (typeof render === 'function') { return render(children, params); } return React.createElement(Dialog, { triggerAttributes: params }, children); } return React.createElement(HelpButtonInstance, params); } HelpButton._supportsSpacingProps = true; //# sourceMappingURL=HelpButton.js.map