UNPKG

@onesy/ui-react

Version:
106 lines (105 loc) 5.13 kB
"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 _compilerRuntime = require("react/compiler-runtime"); var _react = _interopRequireDefault(require("react")); var _utils = require("@onesy/utils"); var _styleReact = require("@onesy/style-react"); var _Type = _interopRequireDefault(require("../Type")); var _Line = _interopRequireDefault(require("../Line")); var _utils2 = require("../utils"); var _jsxRuntime = require("react/jsx-runtime"); const _excluded = ["values", "separator", "ItemProps", "SeparatorProps", "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) { (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: { overflow: 'auto hidden', '& > *': { flex: '0 0 auto' } } }), { name: 'onesy-Meta' }); const Meta = props_ => { var _theme$ui, _theme$ui2, _theme$elements, _theme$elements2, _values_$filter; const $ = (0, _compilerRuntime.c)(7); 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.onesyMeta) === 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 Type = (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.Type) || _Type.default; const { values: t0, separator: t1, ItemProps, SeparatorProps, className, children } = props, other = (0, _objectWithoutProperties2.default)(props, _excluded); const values_ = t0 === undefined ? [] : t0; const separator_ = t1 === undefined ? "\u2022" : t1; const { classes } = useStyle(); const separator = (0, _utils.is)("string", separator_) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, _objectSpread(_objectSpread({ version: "b3", priority: "secondary" }, SeparatorProps), {}, { children: separator_ })) : separator_; let t2; if ($[0] !== Type) { t2 = (item, index) => { if ((0, _utils.is)("simple", item)) { return /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, { version: "b3", priority: "secondary", children: item }, index); } return /*#__PURE__*/_react.default.cloneElement(item, { key: index }); }; $[0] = Type; $[1] = t2; } else { t2 = $[1]; } const getItem = t2; const values = values_ === null || values_ === void 0 || (_values_$filter = values_.filter(Boolean)) === null || _values_$filter === void 0 ? void 0 : _values_$filter.flatMap((item_0, index_0) => !index_0 ? getItem(item_0, index_0) : [separator, getItem(item_0, index_0)]); const t3 = 1; const t4 = "row"; const t5 = "center"; const t6 = "flex-start"; const t7 = (0, _styleReact.classNames)([(0, _utils2.staticClassName)("Meta", theme) && ["onesy-Meta-root"], className, classes.root]); let t8; if ($[2] !== Line || $[3] !== other || $[4] !== t7 || $[5] !== values) { t8 = /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, _objectSpread(_objectSpread({ gap: t3, direction: t4, align: t5, justify: t6, className: t7 }, other), {}, { children: values })); $[2] = Line; $[3] = other; $[4] = t7; $[5] = values; $[6] = t8; } else { t8 = $[6]; } return t8; }; Meta.displayName = 'onesy-Meta'; var _default = exports.default = Meta;