UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

40 lines (39 loc) 1.13 kB
"use client"; import React from 'react'; import Context from "../../shared/Context.js"; import Dialog from "../dialog/Dialog.js"; import HelpButtonInstance from "./HelpButtonInstance.js"; import { extendPropsWithContext } from "../../shared/component-helper.js"; 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, ...params } = props; 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