@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
47 lines (46 loc) • 1.28 kB
JavaScript
"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";
import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js";
import { jsx as _jsx } from "react/jsx-runtime";
const defaultProps = {
variant: 'secondary',
iconPosition: '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 _jsx(Dialog, {
triggerAttributes: params,
children: children
});
}
return _jsx(HelpButtonInstance, {
...params
});
}
withComponentMarkers(HelpButton, {
_supportsSpacingProps: true
});
//# sourceMappingURL=HelpButton.js.map