@onesy/ui-react
Version:
UI for React
172 lines • 4.99 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
const _excluded = ["size", "maxWidth", "actions", "start", "end", "Component", "style", "className", "children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { c as _c } from "react/compiler-runtime";
import React from 'react';
import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react';
import ListItemElement from '../ListItem';
import GridElement from '../Grid';
import LineElement from '../Line';
import { staticClassName } from '../utils';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const useStyle = styleMethod(theme => ({
root: {
width: '100%',
'&.onesy-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: 'onesy-Banner'
});
const Banner = props_ => {
const $ = _c(15);
const theme = useOnesyTheme();
const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyBanner?.props?.default), props_);
const Line = theme?.elements?.Line || LineElement;
const ListItem = theme?.elements?.ListItem || ListItemElement;
const Grid = theme?.elements?.Grid || GridElement;
const {
size: t0,
maxWidth,
actions,
start,
end,
Component: t1,
style,
className,
children
} = props,
other = _objectWithoutProperties(props, _excluded);
const size = t0 === undefined ? "regular" : t0;
const Component = t1 === undefined ? "div" : t1;
const {
classes
} = useStyle();
const styles = {
root: {}
};
if (actions) {
other.line = true;
other.RootProps = {};
other.RootProps.values = {
md: 7
};
let t2;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t2 = {
gap: 1,
direction: "row"
};
$[0] = t2;
} else {
t2 = $[0];
}
let t3;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t3 = {
md: 2
};
$[1] = t3;
} else {
t3 = $[1];
}
let t4;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t4 = {
md: 1
};
$[2] = t4;
} else {
t4 = $[2];
}
other.footer = /*#__PURE__*/_jsx(Grid, {
Component: Line,
RootProps: t2,
justify: "flex-end",
align: "flex-end",
values: t3,
offsets: t4,
children: actions
});
}
if (!classes[`maxWidth_${maxWidth}`]) {
styles.root.maxWidth = maxWidth;
}
const t2 = classNames([staticClassName("Banner", theme) && ["onesy-Banner-root", `onesy-Banner-size-${size}`], className, classes.root]);
let t3;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t3 = {
version: "b2"
};
$[3] = t3;
} else {
t3 = $[3];
}
let t4;
if ($[4] !== classes || $[5] !== maxWidth || $[6] !== theme) {
t4 = classNames([staticClassName("Banner", theme) && ["onesy-Banner-list-item"], classes.listItem, classes[`maxWidth_${maxWidth}`]]);
$[4] = classes;
$[5] = maxWidth;
$[6] = theme;
$[7] = t4;
} else {
t4 = $[7];
}
let t5;
if ($[8] !== Grid || $[9] !== ListItem || $[10] !== children || $[11] !== other || $[12] !== size || $[13] !== t4) {
t5 = /*#__PURE__*/_jsx(ListItem, _objectSpread(_objectSpread({
size: size,
Component: Grid,
RootComponent: Grid,
PrimaryProps: t3,
className: t4
}, other), {}, {
children: children
}));
$[8] = Grid;
$[9] = ListItem;
$[10] = children;
$[11] = other;
$[12] = size;
$[13] = t4;
$[14] = t5;
} else {
t5 = $[14];
}
return /*#__PURE__*/_jsxs(Component, {
role: "alert",
className: t2,
style: _objectSpread(_objectSpread({}, styles.root), style),
children: [start, t5, end]
});
};
Banner.displayName = 'onesy-Banner';
export default Banner;