UNPKG

@antmjs/vantui

Version:

一套适用于Taro3及React的vantui组件库

63 lines 3.77 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; var _excluded = ["direction", "align", "justify", "wrap", "block", "className", "children", "style", "gap", "gapHorizontal", "gapVertical"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import { Children, useMemo, useState } from 'react'; import classNames from 'classnames'; import { View } from '@tarojs/components'; import { get } from '../default-props'; import { jsx as _jsx } from "react/jsx-runtime"; var classPrefix = "van-space"; export function Space(props) { var _classNames; var _useState = useState(get().Space), _useState2 = _slicedToArray(_useState, 1), d = _useState2[0]; var _d$props = _objectSpread(_objectSpread({}, d), props), _d$props$direction = _d$props.direction, direction = _d$props$direction === void 0 ? 'horizontal' : _d$props$direction, align = _d$props.align, justify = _d$props.justify, _d$props$wrap = _d$props.wrap, wrap = _d$props$wrap === void 0 ? true : _d$props$wrap, block = _d$props.block, _d$props$className = _d$props.className, className = _d$props$className === void 0 ? '' : _d$props$className, children = _d$props.children, _d$props$style = _d$props.style, style = _d$props$style === void 0 ? {} : _d$props$style, gap = _d$props.gap, gapHorizontal = _d$props.gapHorizontal, gapVertical = _d$props.gapVertical, others = _objectWithoutProperties(_d$props, _excluded); var _style = useMemo(function () { var s = _objectSpread({}, style); if (gap) { s = { '--space-gap-horizontal': gap + 'px', '--space-gap-vertical': gap + 'px' }; } if (gapHorizontal) s['--space-gap-horizontal'] = gapHorizontal + 'px'; if (gapVertical) s['--space-gap-vertical'] = gapVertical + 'px'; return s; }, [gap, gapHorizontal, gapVertical, style]); return ( /*#__PURE__*/ // @ts-ignore _jsx(View, _objectSpread(_objectSpread({ style: _style, className: classNames(classPrefix, (_classNames = {}, _defineProperty(_classNames, "".concat(classPrefix, "-wrap"), wrap), _defineProperty(_classNames, "".concat(classPrefix, "-block"), block), _defineProperty(_classNames, "".concat(classPrefix, "-").concat(direction), true), _defineProperty(_classNames, "".concat(classPrefix, "-align-").concat(align), !!align), _defineProperty(_classNames, "".concat(classPrefix, "-justify-").concat(justify), !!justify), _defineProperty(_classNames, className, !!className), _classNames)) }, others), {}, { children: Children.map(children, function (child) { return child !== null && child !== undefined && /*#__PURE__*/_jsx(View, { className: "".concat(classPrefix, "-item"), children: child }); }) })) ); } export default Space;