"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Cell", {
    enumerable: true,
    get: function() {
        return Cell;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _typings = require("../../utils/typings");
var _cellgroup = require("../cellgroup/cellgroup");
var _context = /*#__PURE__*/ _interop_require_default._(require("../cellgroup/context"));
var _index = require("../configprovider/index");
var _pxtransform = require("../../utils/taro/px-transform");
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    title: null,
    description: null,
    extra: null,
    radius: '6px',
    align: 'flex-start',
    clickable: false,
    isLast: false,
    onClick: function onClick(event) {}
});
var classPrefix = 'nut-cell';
var Cell = function Cell(props) {
    var ctx = (0, _react.useContext)(_context.default);
    var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), children = _$_object_spread.children, onClick = _$_object_spread.onClick, title = _$_object_spread.title, description = _$_object_spread.description, extra = _$_object_spread.extra, radius = _$_object_spread.radius, align = _$_object_spread.align, isLast = _$_object_spread.isLast, className = _$_object_spread.className, style = _$_object_spread.style, clickable = _$_object_spread.clickable;
    var rtl = (0, _index.useRtl)();
    var handleClick = function handleClick(event) {
        onClick(event);
    };
    var radiusNumber = Number(String(radius).replace(/[^\d]/g, ''));
    var baseStyle = (0, _object_spread_props._)((0, _object_spread._)({}, style), {
        borderRadius: (0, _pxtransform.pxTransform)(radiusNumber),
        alignItems: align
    });
    var _obj;
    return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_components.View, {
        hoverStyle: {
            opacity: clickable ? 0.7 : 1
        },
        className: "".concat((0, _classnames.default)([
            classPrefix,
            className,
            (0, _define_property._)({}, "".concat(classPrefix, "-group-item"), ctx === null || ctx === void 0 ? void 0 : ctx.group)
        ], clickable ? "".concat(classPrefix, "-clickable") : '')),
        onClick: function onClick(event) {
            return handleClick(event);
        },
        style: baseStyle
    }, children || /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, title || description ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-left")
    }, title ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-title")
    }, title) : null, description ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-description")
    }, description) : null) : null, extra ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-extra")
    }, extra) : null)), (ctx === null || ctx === void 0 ? void 0 : ctx.divider) && !isLast ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: (0, _classnames.default)([
            (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-divider"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-divider-rtl"), rtl), _obj)
        ])
    }, /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-divider-inner")
    })) : null);
};
Cell.displayName = 'NutCell';
Cell.Group = _cellgroup.CellGroup;
