@amaui/ui-react
Version:
UI for React
101 lines (100 loc) • 7.64 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 Section_1 = __importDefault(require("../Section/Section"));
const ListItem_1 = __importDefault(require("../ListItem"));
const Timeline_1 = __importDefault(require("../Timeline"));
const TimelineItem_1 = __importDefault(require("../TimelineItem"));
const Type_1 = __importDefault(require("../Type"));
const utils_2 = require("../utils");
const useStyle = (0, style_react_1.style)(theme => ({
root: {},
timeline: {},
timelineItem: {
'&.amaui-TimelineItem-root': {
width: '100%'
},
'& .amaui-TimelineItem-aside': {
width: 'calc(50% - 6px)'
}
}
}), { name: 'amaui-SectionTimeline' });
const SectionTimeline = 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.amauiSectionTimeline) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
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 ListItem = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.ListItem) || ListItem_1.default; }, [theme]);
const Timeline = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Timeline) || Timeline_1.default; }, [theme]);
const TimelineItem = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.TimelineItem) || TimelineItem_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 { size = 'regular', values = [], TimelineProps, TimelineItemProps, TitleProps, HeadingProps, DescriptionProps, ItemStartProps, ItemEndProps, className } = props, other = __rest(props, ["size", "values", "TimelineProps", "TimelineItemProps", "TitleProps", "HeadingProps", "DescriptionProps", "ItemStartProps", "ItemEndProps", "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;
}, className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionTimeline', theme) && [
'amaui-SectionTimeline-root',
`amaui-SectionTimeline-size-${size}`
],
className,
classes.root
]) }, other, { children: (0, jsx_runtime_1.jsx)(Timeline, Object.assign({ fullWidth: true }, TimelineProps, { className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionTimeline', theme) && [
'amaui-SectionTimeline-timeline'
],
TimelineProps === null || TimelineProps === void 0 ? void 0 : TimelineProps.className,
classes.timeline
]) }, { children: values === null || values === void 0 ? void 0 : values.map((item, index) => ((0, jsx_runtime_1.jsx)(TimelineItem, Object.assign({ start: (0, utils_1.is)('string', item.title) ? ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: size === 'large' ? 'b1' : size === 'regular' ? 'b2' : 'b3', align: 'right' }, ItemStartProps, { className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionTimeline', theme) && [
'amaui-SectionTimeline-item-start'
],
ItemStartProps === null || ItemStartProps === void 0 ? void 0 : ItemStartProps.className,
classes.start
]), dangerouslySetInnerHTML: {
__html: (0, utils_1.textToInnerHTML)(item.title)
} }))) : item.title, end: ((0, jsx_runtime_1.jsx)(ListItem, Object.assign({ Component: 'div', primary: (0, utils_1.is)('string', item.heading) ? ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: size === 'large' ? 't1' : size === 'regular' ? 't2' : 't3' }, HeadingProps, { dangerouslySetInnerHTML: {
__html: (0, utils_1.textToInnerHTML)(item.heading)
} }))) : item.heading, secondary: (0, utils_1.is)('string', item.description) ? ((0, jsx_runtime_1.jsx)(Type, Object.assign({ version: size === 'large' ? 'b2' : size === 'regular' ? 'b3' : 'b3' }, DescriptionProps, { dangerouslySetInnerHTML: {
__html: (0, utils_1.textToInnerHTML)(item.description)
} }))) : item.description, noBackground: true }, ItemEndProps, { className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionTimeline', theme) && [
'amaui-SectionTimeline-item-end'
],
ItemEndProps === null || ItemEndProps === void 0 ? void 0 : ItemEndProps.className,
classes.end
]), noPadding: true }))) }, TimelineItemProps, { className: (0, style_react_1.classNames)([
(0, utils_2.staticClassName)('SectionTimeline', theme) && [
'amaui-SectionTimeline-timeline-item'
],
TimelineItemProps === null || TimelineItemProps === void 0 ? void 0 : TimelineItemProps.className,
classes.timelineItem
]) }), index))) })) })));
});
SectionTimeline.displayName = 'amaui-SectionTimeline';
exports.default = SectionTimeline;
;