@amaui/ui-react
Version:
UI for React
90 lines (89 loc) • 4.98 kB
JavaScript
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 style_react_1 = require("@amaui/style-react");
const ListItem_1 = __importDefault(require("../ListItem"));
const Grid_1 = __importDefault(require("../Grid"));
const Line_1 = __importDefault(require("../Line"));
const utils_1 = require("../utils");
const useStyle = (0, style_react_1.style)(theme => ({
root: {
width: '100%',
'&.amaui-ListItem-root': {
padding: '0px'
}
},
listItem: {
margin: '0 auto'
},
// maxWidth
maxWidth_xxs: { maxWidth: '320px' },
maxWidth_xs: { maxWidth: '400px' },
maxWidth_sm: { maxWidth: '600px' },
maxWidth_rg: { maxWidth: '960px' },
maxWidth_lg: { maxWidth: '1240px' },
maxWidth_xl: { maxWidth: '1920px' },
maxWidth_unset: { maxWidth: 'unset' }
}), { name: 'amaui-Banner' });
const Banner = 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.amauiBanner) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
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 ListItem = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.ListItem) || ListItem_1.default; }, [theme]);
const Grid = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Grid) || Grid_1.default; }, [theme]);
const { size = 'regular', maxWidth, actions, start, end, Component = 'div', style, className, children } = props, other = __rest(props, ["size", "maxWidth", "actions", "start", "end", "Component", "style", "className", "children"]);
const { classes } = useStyle();
const styles = {
root: {}
};
if (actions) {
other.line = true;
other.RootProps = {};
other.RootProps.values = {
md: 7
};
other.footer = ((0, jsx_runtime_1.jsx)(Grid, Object.assign({ Component: Line, RootProps: {
gap: 1,
direction: 'row'
}, justify: 'flex-end', align: 'flex-end', values: {
md: 2
}, offsets: {
md: 1
} }, { children: actions })));
}
if (!classes[`maxWidth_${maxWidth}`])
styles.root.maxWidth = maxWidth;
return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ ref: ref, role: 'alert', className: (0, style_react_1.classNames)([
(0, utils_1.staticClassName)('Banner', theme) && [
'amaui-Banner-root',
`amaui-Banner-size-${size}`
],
className,
classes.root
]), style: Object.assign(Object.assign({}, styles.root), style) }, { children: [start, (0, jsx_runtime_1.jsx)(ListItem, Object.assign({ size: size, Component: Grid, RootComponent: Grid, PrimaryProps: {
version: 'b2'
}, className: (0, style_react_1.classNames)([
(0, utils_1.staticClassName)('Banner', theme) && [
'amaui-Banner-list-item'
],
classes.listItem,
classes[`maxWidth_${maxWidth}`]
]) }, other, { children: children })), end] })));
});
Banner.displayName = 'amaui-Banner';
exports.default = Banner;
;