@amaui/ui-react
Version:
UI for React
68 lines (67 loc) • 4.26 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 style_react_1 = require("@amaui/style-react");
const Line_1 = __importDefault(require("../Line/Line"));
const Property_1 = __importDefault(require("../Property"));
const utils_1 = require("../utils");
const useStyle = (0, style_react_1.style)(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: 'amaui-Properties' });
const Properties = react_1.default.forwardRef((props_, ref) => {
var _a;
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.amauiProperties) === 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 Property = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Property) || Property_1.default; }, [theme]);
const { version = 'row-20', size = 'regular', values = [], onlyWithValues = true, maxWidth, PropertyProps, className, children } = props, other = __rest(props, ["version", "size", "values", "onlyWithValues", "maxWidth", "PropertyProps", "className", "children"]);
const { classes } = useStyle();
if (!(values === null || values === void 0 ? void 0 : values.length) ||
onlyWithValues && !values.every((item) => item.value !== undefined))
return null;
return ((0, jsx_runtime_1.jsx)(Line, Object.assign({ ref: ref, gap: size === 'large' ? 1.5 : size === 'regular' ? 1 : 0.5, rowGap: size === 'large' ? 1.5 : size === 'regular' ? 1 : 0.5, fullWidth: true, className: (0, style_react_1.classNames)([
(0, utils_1.staticClassName)('Properties', theme) && [
'amaui-Properties-root',
`amaui-Properties-version-${version}`,
`amaui-Properties-size-${size}`
],
className,
classes.root,
maxWidth && classes[`maxWidth_${maxWidth}`]
]) }, other, { children: (_a = values === null || values === void 0 ? void 0 : values.filter(Boolean)) === null || _a === void 0 ? void 0 : _a.map((item, index) => ((0, jsx_runtime_1.jsx)(Property, Object.assign({ version: version, size: size, name: item.name, value: item.value, separator: item.separator }, PropertyProps, item.props), index))) })));
});
Properties.displayName = 'amaui-Properties';
exports.default = Properties;
;