@onesy/ui-react
Version:
UI for React
100 lines • 3.9 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
const _excluded = ["version", "size", "values", "onlyWithValues", "maxWidth", "PropertyProps", "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 LineElement from '../Line/Line';
import PropertyElement from '../Property';
import { staticClassName } from '../utils';
import { jsx as _jsx } from "react/jsx-runtime";
const useStyle = styleMethod(theme => ({
root: {},
maxWidth_extra_small: {
maxWidth: '240px'
},
maxWidth_small: {
maxWidth: '340px'
},
maxWidth_regular: {
maxWidth: '440px'
},
maxWidth_large: {
maxWidth: '740px'
},
maxWidth_extra_large: {
maxWidth: '1024px'
},
maxWidth_extra_extra_large: {
maxWidth: '1440px'
}
}), {
name: 'onesy-Properties'
});
const Properties = props_ => {
const $ = _c(7);
const theme = useOnesyTheme();
const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyProperties?.props?.default), props_);
const Line = theme?.elements?.Line || LineElement;
const Property = theme?.elements?.Property || PropertyElement;
const {
version: t0,
size: t1,
values: t2,
onlyWithValues: t3,
maxWidth,
PropertyProps,
className,
children
} = props,
other = _objectWithoutProperties(props, _excluded);
const version = t0 === undefined ? "row-30" : t0;
const size = t1 === undefined ? "regular" : t1;
const values = t2 === undefined ? [] : t2;
const onlyWithValues = t3 === undefined ? true : t3;
const {
classes
} = useStyle();
if (!values?.length || onlyWithValues && !values.every(_temp)) {
return null;
}
const t4 = size === "large" ? 1.5 : size === "regular" ? 1 : 0.5;
const t5 = size === "large" ? 1.5 : size === "regular" ? 1 : 0.5;
const t6 = true;
const t7 = classNames([staticClassName("Properties", theme) && ["onesy-Properties-root", `onesy-Properties-version-${version}`, `onesy-Properties-size-${size}`], className, classes.root, maxWidth && classes[`maxWidth_${maxWidth}`]]);
const t8 = values?.filter(Boolean)?.map((item_0, index) => /*#__PURE__*/_jsx(Property, _objectSpread(_objectSpread({
version: version,
size: size,
name: item_0.name,
value: item_0.value,
separator: item_0.separator
}, PropertyProps), item_0.props), index));
let t9;
if ($[0] !== Line || $[1] !== other || $[2] !== t4 || $[3] !== t5 || $[4] !== t7 || $[5] !== t8) {
t9 = /*#__PURE__*/_jsx(Line, _objectSpread(_objectSpread({
gap: t4,
rowGap: t5,
fullWidth: t6,
className: t7
}, other), {}, {
children: t8
}));
$[0] = Line;
$[1] = other;
$[2] = t4;
$[3] = t5;
$[4] = t7;
$[5] = t8;
$[6] = t9;
} else {
t9 = $[6];
}
return t9;
};
Properties.displayName = 'onesy-Properties';
export default Properties;
function _temp(item) {
return item.value !== undefined;
}