UNPKG

@nutui/nutui-react-taro

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

52 lines (51 loc) 2.58 kB
import { _ as _define_property } from "@swc/helpers/_/_define_property"; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties"; import React from "react"; import classNames from "classnames"; import { DataContext } from "./context"; import { ComponentDefaults } from "../../utils/typings"; var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), { direction: 'horizontal', layout: 'single', type: 'text', status: 'default', value: 0, icon: null }); export var Steps = function(props) { var propSteps = _object_spread({}, defaultProps, props); var direction = propSteps.direction, value = propSteps.value, layout = propSteps.layout, status = propSteps.status, type = propSteps.type, className = propSteps.className, children = propSteps.children, onStepClick = propSteps.onStepClick, restProps = _object_without_properties(propSteps, [ "direction", "value", "layout", "status", "type", "className", "children", "onStepClick" ]); var parentSteps = { propSteps: propSteps }; var classPrefix = "nut-steps"; var _obj; var classes = classNames(classPrefix, (_obj = {}, _define_property(_obj, "".concat(classPrefix, "-").concat(direction), true), _define_property(_obj, "".concat(classPrefix, "-").concat(direction, "-count-").concat(React.Children.count(children)), true), _define_property(_obj, "".concat(classPrefix, "-").concat(direction, "-").concat(layout), true), _define_property(_obj, "".concat(classPrefix, "-").concat(direction, "-").concat(type), true), _define_property(_obj, "".concat(classPrefix, "-").concat(direction, "-").concat(status), true), _obj), className); return /*#__PURE__*/ React.createElement(DataContext.Provider, { value: parentSteps }, /*#__PURE__*/ React.createElement("div", _object_spread({ className: classes }, restProps), React.Children.map(children, function(child, index) { if (/*#__PURE__*/ React.isValidElement(child)) { return /*#__PURE__*/ React.cloneElement(child, { // @ts-ignore className: classNames(child.props.className, { 'nut-step-last': index === React.Children.count(children) - 1 }) }); } return child; }))); }; Steps.displayName = 'NutSteps';