tdesign-react
Version:
TDesign Component for React
105 lines (101 loc) • 4.34 kB
JavaScript
/**
* tdesign v1.15.1
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _defineProperty } from '../_chunks/dep-cb0a3966.js';
import classNames from 'classnames';
import React from 'react';
import useConfig from '../hooks/useConfig.js';
import TimelineItem from './TimelineItem.js';
import StepsContext from './TimelineContext.js';
import forwardRefWithStatics from '../_util/forwardRefWithStatics.js';
import { useAlign } from './useAlign.js';
import '../_chunks/dep-eca3a3de.js';
import '../config-provider/ConfigContext.js';
import 'lodash-es';
import '../_chunks/dep-f97636ce.js';
import '../_chunks/dep-9dbbf468.js';
import 'dayjs';
import '../_util/parseTNode.js';
import '../_chunks/dep-b908e1fe.js';
import '../loading/index.js';
import '../loading/Loading.js';
import '../_chunks/dep-48805ab8.js';
import '../_chunks/dep-026a4c6b.js';
import '../_chunks/dep-3a09424a.js';
import '../common/Portal.js';
import 'react-dom';
import '../hooks/useLayoutEffect.js';
import '../loading/gradient.js';
import '../_chunks/dep-c48e2ca1.js';
import '../_chunks/dep-6af6bc60.js';
import '../_chunks/dep-87d110df.js';
import '../hooks/useDomRefCallback.js';
import '../loading/defaultProps.js';
import '../hooks/useDefaultProps.js';
import '../loading/plugin.js';
import '../_util/react-render.js';
import '../_chunks/dep-52ff3837.js';
import '../common/PluginContainer.js';
import '../config-provider/ConfigProvider.js';
import 'hoist-non-react-statics';
var Timeline = forwardRefWithStatics(function (props, ref) {
var _props$theme = props.theme,
theme = _props$theme === void 0 ? "default" : _props$theme,
labelAlign = props.labelAlign,
children = props.children,
className = props.className,
style = props.style,
_props$reverse = props.reverse,
reverse = _props$reverse === void 0 ? false : _props$reverse,
_props$layout = props.layout,
layout = _props$layout === void 0 ? "vertical" : _props$layout,
_props$mode = props.mode,
mode = _props$mode === void 0 ? "alternate" : _props$mode;
var _useConfig = useConfig(),
classPrefix = _useConfig.classPrefix;
var renderAlign = useAlign(labelAlign, layout);
var timelineItems = React.Children.toArray(children).filter(function (child) {
var _child$type;
return ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === TimelineItem.displayName;
});
var itemsStatus = React.Children.map(timelineItems, function (child) {
var _child$props;
return ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.dotColor) || "primary";
});
var hasLabelItem = timelineItems.some(function (item) {
var _item$props;
return !!(item !== null && item !== void 0 && (_item$props = item.props) !== null && _item$props !== void 0 && _item$props.label);
});
if (reverse) {
timelineItems.reverse();
}
var itemsCounts = React.Children.count(timelineItems);
var timelineClassName = classNames("".concat(classPrefix, "-timeline"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classPrefix, "-timeline-").concat(renderAlign), true), "".concat(classPrefix, "-timeline-reverse"), reverse), "".concat(classPrefix, "-timeline-").concat(layout), true), "".concat(classPrefix, "-timeline-label"), hasLabelItem), "".concat(classPrefix, "-timeline-label--").concat(mode), true), className);
return /* @__PURE__ */React.createElement(StepsContext.Provider, {
value: {
theme: theme,
reverse: reverse,
itemsStatus: itemsStatus,
layout: layout,
globalAlign: labelAlign,
mode: mode
}
}, /* @__PURE__ */React.createElement("ul", {
className: timelineClassName,
style: style,
ref: ref
}, React.Children.map(timelineItems, function (ele, index) {
var _ele$props;
return /*#__PURE__*/React.cloneElement(ele, {
index: index,
className: classNames([ele === null || ele === void 0 || (_ele$props = ele.props) === null || _ele$props === void 0 ? void 0 : _ele$props.className], _defineProperty({}, "".concat(classPrefix, "-timeline-item--last"), index === itemsCounts - 1))
});
})));
}, {
Item: TimelineItem
});
Timeline.displayName = "Timeline";
export { Timeline as default };
//# sourceMappingURL=Timeline.js.map