@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
138 lines (137 loc) • 6.05 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Prompt", {
enumerable: true,
get: function() {
return Prompt;
}
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _jsxruntime = require("react/jsx-runtime");
var _core = require("@mantine/core");
var _react = require("react");
var _InfoToken = require("../InfoToken/InfoToken.js");
var _Modal = require("../Modal/Modal.js");
var _Promptcontext = require("./Prompt.context.js");
var _Promptmodulecss = /*#__PURE__*/ _interop_require_default._(require("./Prompt.module.css"));
var _PromptCancelButton = require("./PromptCancelButton.js");
var _PromptConfirmButton = require("./PromptConfirmButton.js");
var PromptVariantIconsMapping = {
success: _InfoToken.InfoToken.Success,
warning: _InfoToken.InfoToken.Warning,
critical: _InfoToken.InfoToken.Error,
information: _InfoToken.InfoToken.Information
};
var defaultProps = {
variant: 'information',
centered: true
};
var _Prompt = (0, _core.factory)(function(_props, ref) {
var props = (0, _core.useProps)('Prompt', defaultProps, _props);
var variant = props.variant, title = props.title, children = props.children, className = props.className, classNames = props.classNames, style = props.style, styles = props.styles, unstyled = props.unstyled, vars = props.vars, _attributes = props.attributes, others = _object_without_properties._(props, [
"variant",
"title",
"children",
"className",
"classNames",
"style",
"styles",
"unstyled",
"vars",
"attributes"
]);
var getStyles = (0, _core.useStyles)({
name: 'Prompt',
props: props,
classes: _Promptmodulecss.default,
className: className,
style: style,
classNames: classNames,
styles: styles,
unstyled: unstyled,
vars: vars
});
var stylesApiProps = {
classNames: classNames,
styles: styles
};
var footers = [];
var otherChildren = [];
_react.Children.forEach(children, function(child) {
(child.type === PromptFooter ? footers : otherChildren).push(child);
});
var IconComponent = PromptVariantIconsMapping[variant];
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Promptcontext.PromptContextProvider, {
value: {
variant: variant,
getStyles: getStyles
},
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Modal.Modal.Root, _object_spread_props._(_object_spread._({
ref: ref,
variant: "prompt",
size: "sm"
}, others, getStyles('root')), {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Modal.Modal.Overlay, _object_spread._({}, getStyles('overlay', stylesApiProps))),
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_Modal.Modal.Content, _object_spread_props._(_object_spread._({}, getStyles('content', stylesApiProps)), {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_Modal.Modal.Header, _object_spread_props._(_object_spread._({}, getStyles('header', stylesApiProps)), {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)(IconComponent, _object_spread_props._(_object_spread._({}, getStyles('icon', stylesApiProps)), {
variant: "light",
size: "sm",
"aria-label": variant
})),
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Modal.Modal.Title, {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Title, {
order: 3,
component: "div",
children: title
})
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Modal.Modal.CloseButton, _object_spread._({}, getStyles('close', stylesApiProps)))
]
})),
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_Modal.Modal.Body, _object_spread_props._(_object_spread._({}, getStyles('body', stylesApiProps)), {
children: [
otherChildren,
footers
]
}))
]
}))
]
}))
});
});
_Prompt.displayName = 'Prompt';
var PromptFooter = function PromptFooter(props) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Modal.Modal.Footer, _object_spread._({}, props));
};
PromptFooter.displayName = 'Prompt.Footer';
var createPromptCompound = function createPromptCompound(variant, displayName) {
var Component = /*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Prompt, _object_spread_props._(_object_spread._({
ref: ref
}, props), {
variant: variant
}));
});
Component.displayName = displayName;
return Component;
};
var Prompt = {
Information: createPromptCompound('information', 'Prompt.Information'),
Success: createPromptCompound('success', 'Prompt.Success'),
Warning: createPromptCompound('warning', 'Prompt.Warning'),
Critical: createPromptCompound('critical', 'Prompt.Critical'),
CancelButton: _PromptCancelButton.PromptCancelButton,
ConfirmButton: _PromptConfirmButton.PromptConfirmButton,
Footer: PromptFooter
};
//# sourceMappingURL=Prompt.js.map