@onesy/ui-react
Version:
UI for React
122 lines (121 loc) • 6.64 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireDefault(require("react"));
var _utils = require("@onesy/utils");
var _styleReact = require("@onesy/style-react");
var _Line = _interopRequireDefault(require("../Line"));
var _Section = _interopRequireDefault(require("../Section/Section"));
var _Type = _interopRequireDefault(require("../Type"));
var _utils2 = require("../utils");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["ref", "values", "size", "name", "gray", "ItemProps", "WrapperProps", "className"];
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) { (0, _defineProperty2.default)(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; }
const useStyle = (0, _styleReact.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: 'onesy-SectionLogos'
});
const Element = props_ => {
var _theme$ui, _theme$ui2, _theme$elements, _theme$elements2, _theme$elements3;
const theme = (0, _styleReact.useOnesyTheme)();
const props = _objectSpread(_objectSpread(_objectSpread({}, theme === null || theme === void 0 || (_theme$ui = theme.ui) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.elements) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.all) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.props) === null || _theme$ui === void 0 ? void 0 : _theme$ui.default), theme === null || theme === void 0 || (_theme$ui2 = theme.ui) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.elements) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.onesySectionLogos) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_);
const Line = (theme === null || theme === void 0 || (_theme$elements = theme.elements) === null || _theme$elements === void 0 ? void 0 : _theme$elements.Line) || _Line.default;
const Section = (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.Section) || _Section.default;
const Type = (theme === null || theme === void 0 || (_theme$elements3 = theme.elements) === null || _theme$elements3 === void 0 ? void 0 : _theme$elements3.Type) || _Type.default;
const {
ref,
values = [],
size = 'regular',
name,
gray,
ItemProps,
WrapperProps,
className
} = props,
other = (0, _objectWithoutProperties2.default)(props, _excluded);
const {
classes
} = useStyle();
const refs = {
root: _react.default.useRef(undefined)
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Section, _objectSpread(_objectSpread({
ref: item => {
if (ref) {
if ((0, _utils.is)('function', ref)) ref(item);else ref.current = item;
}
refs.root.current = item;
},
align: "center",
MainProps: {
justify: 'center',
align: 'center'
},
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('SectionLogos', theme) && ['onesy-SectionLogos-root', `onesy-SectionLogos-size-${size}`], className, classes.root])
}, other), {}, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, {
gap: size === 'large' ? 10 : size === 'regular' ? 8 : 6,
direction: "row",
justify: "flex-start",
align: "center",
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('SectionLogos', theme) && ['onesy-SectionLogos-items'], classes.items, gray && classes.gray]),
children: values === null || values === void 0 ? void 0 : values.map((item_0, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(Line, _objectSpread(_objectSpread({}, WrapperProps), {}, {
fullWidth: true,
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('SectionLogos', theme) && ['onesy-SectionLogos-wrapper'], WrapperProps === null || WrapperProps === void 0 ? void 0 : WrapperProps.className, classes.wrapper, classes[`wrapper_size_${size}`]]),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Line, _objectSpread(_objectSpread({}, ItemProps), {}, {
fullWidth: true,
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('SectionLogos', theme) && ['onesy-SectionLogos-item'], ItemProps === null || ItemProps === void 0 ? void 0 : ItemProps.className, classes.item]),
style: {
backgroundImage: `url(${(item_0 === null || item_0 === void 0 ? void 0 : item_0.url) || (item_0 === null || item_0 === void 0 ? void 0 : item_0.urlSmall)})`
}
})), name && /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, {
version: size === 'large' ? 't1' : size === 'regular' ? 't2' : 't3',
align: "center",
fullWidth: true,
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('SectionLogos', theme) && ['onesy-SectionLogos-name'], classes.name]),
children: (0, _utils.cleanValue)((item_0 === null || item_0 === void 0 ? void 0 : item_0.name) || 'No name', {
capitalize: true
})
})]
}), index))
})
}));
};
Element.displayName = 'onesy-SectionLogos';
var _default = exports.default = Element;