@amaui/ui-react
Version:
UI for React
116 lines (115 loc) • 6.71 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 utils_1 = require("@amaui/utils");
const style_react_1 = require("@amaui/style-react");
const Line_1 = __importDefault(require("../Line"));
const Section_1 = __importDefault(require("../Section/Section"));
const Type_1 = __importDefault(require("../Type"));
const utils_2 = require("../utils");
const useStyle = (0, style_react_1.style)(theme => ({
root: {},
name: {
wordBreak: 'break-word'
},
items: {
overflow: 'auto hidden',
padding: `${theme.methods.space.value(2, 'px')} 0`,
maxWidth: '100%'
},
wrapper: {
flex: '0 0 auto'
},
wrapper_size_small: {
width: '154px'
},
wrapper_size_regular: {
width: '214px'
},
wrapper_size_large: {
width: '274px'
},
item: {
aspectRatio: '16 / 9',
backgroundSize: 'contain',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat'
},
gray: {
filter: 'grayscale(1)'
}
}), { name: 'amaui-SectionLogos' });
const Element = 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.amauiSectionLogos) === 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 Section = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Section) || Section_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 { values = [], size = 'regular', name, gray, ItemProps, WrapperProps, className } = props, other = __rest(props, ["values", "size", "name", "gray", "ItemProps", "WrapperProps", "className"]);
const { classes } = useStyle();
const refs = {
root: react_1.default.useRef(undefined)
};
return ((0, jsx_runtime_1.jsx)(Section, Object.assign({ ref: (item) => {
if (ref) {
if ((0, utils_1.is)('function', ref))
ref(item);
else
ref.current = item;
}
refs.root.current = item;
}, align: 'center', MainProps: {
justify: 'center',
align: 'center'
}, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionLogos', theme) && [
'amaui-SectionLogos-root',
`amaui-SectionLogos-size-${size}`
],
className,
classes.root
]) }, other, { children: (0, jsx_runtime_1.jsx)(Line, Object.assign({ gap: size === 'large' ? 10 : size === 'regular' ? 8 : 6, direction: 'row', justify: 'flex-start', align: 'center', className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionLogos', theme) && [
'amaui-SectionLogos-items'
],
classes.items,
gray && classes.gray
]) }, { children: values === null || values === void 0 ? void 0 : values.map((item, index) => ((0, jsx_runtime_1.jsxs)(Line, Object.assign({}, WrapperProps, { fullWidth: true, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionLogos', theme) && [
'amaui-SectionLogos-wrapper'
],
WrapperProps === null || WrapperProps === void 0 ? void 0 : WrapperProps.className,
classes.wrapper,
classes[`wrapper_size_${size}`]
]) }, { children: [(0, jsx_runtime_1.jsx)(Line, Object.assign({}, ItemProps, { fullWidth: true, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionLogos', theme) && [
'amaui-SectionLogos-item'
],
ItemProps === null || ItemProps === void 0 ? void 0 : ItemProps.className,
classes.item
]), style: {
backgroundImage: `url(${(item === null || item === void 0 ? void 0 : item.url) || (item === null || item === void 0 ? void 0 : item.urlSmall)})`
} })), name && ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: size === 'large' ? 't1' : size === 'regular' ? 't2' : 't3', align: 'center', fullWidth: true, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionLogos', theme) && [
'amaui-SectionLogos-name'
],
classes.name
]) }, { children: (0, utils_1.cleanValue)((item === null || item === void 0 ? void 0 : item.name) || 'No name', { capitalize: true }) })))] }), index))) })) })));
});
Element.displayName = 'amaui-SectionLogos';
exports.default = Element;
;