@amaui/ui-react
Version:
UI for React
67 lines (66 loc) • 5.4 kB
JavaScript
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const utils_1 = require("@amaui/utils");
const style_react_1 = require("@amaui/style-react");
const IconMaterialInfoW100_1 = __importDefault(require("@amaui/icons-material-rounded-react/IconMaterialInfoW100"));
const IconButton_1 = __importDefault(require("../IconButton"));
const Line_1 = __importDefault(require("../Line"));
const Menu_1 = __importDefault(require("../Menu"));
const Tooltip_1 = __importDefault(require("../Tooltip"));
const Type_1 = __importDefault(require("../Type"));
const utils_2 = require("../utils");
const useStyle = (0, style_react_1.style)(theme => ({
root: {},
menu: {
width: '100vw',
maxWidth: '195px',
background: theme.palette.light ? theme.palette.background.default.primary : theme.palette.background.default.quaternary,
borderRadius: theme.methods.shape.radius.value(2),
boxShadow: theme.shadows.values.default[1],
padding: '16px',
'& .amaui-Type-root': {
whiteSpace: 'normal'
}
}
}), { name: 'amaui-Info' });
const Info = react_1.default.forwardRef((props_, ref) => {
const theme = (0, style_react_1.useAmauiTheme)();
const props = react_1.default.useMemo(() => { var _a, _b, _c, _d, _e, _f, _g, _h; return (Object.assign(Object.assign(Object.assign({}, (_d = (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _a === void 0 ? void 0 : _a.elements) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.default), (_h = (_g = (_f = (_e = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.amauiInfo) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
const IconButton = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.IconButton) || IconButton_1.default; }, [theme]);
const Line = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Line) || Line_1.default; }, [theme]);
const Menu = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Menu) || Menu_1.default; }, [theme]);
const Tooltip = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Tooltip) || Tooltip_1.default; }, [theme]);
const Type = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Type) || Type_1.default; }, [theme]);
const { name, title, render, Icon = IconMaterialInfoW100_1.default, IconProps, IconButtonProps, TitleProps, ContainerProps, TooltipProps, className, children } = props, other = __rest(props, ["name", "title", "render", "Icon", "IconProps", "IconButtonProps", "TitleProps", "ContainerProps", "TooltipProps", "className", "children"]);
const { classes } = useStyle();
return ((0, jsx_runtime_1.jsx)(Menu, Object.assign({ ref: ref, alignment: 'center', name: (0, utils_1.is)('function', render) ? render() : ((0, jsx_runtime_1.jsx)(Line, Object.assign({ gap: 1, fullWidth: true, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('Info', theme) && [
'amaui-Info-menu'
],
classes.menu
]) }, { children: (0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 1, fullWidth: true }, ContainerProps, { children: [(0, jsx_runtime_1.jsx)(Type, Object.assign({ version: 'l2' }, TitleProps, { children: title })), children] })) }))), className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('Info', theme) && [
'amaui-Info-root'
],
className,
classes.root
]) }, other, { children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(Tooltip, Object.assign({ name: name !== undefined ? name : 'Info' }, TooltipProps, { children: (0, jsx_runtime_1.jsx)(IconButton, Object.assign({}, IconButtonProps, { children: (0, jsx_runtime_1.jsx)(Icon, Object.assign({}, IconProps)) })) })) }) })));
});
Info.displayName = 'amaui-Info';
exports.default = Info;