@cainiaofe/cn-ui-m
Version:
23 lines (22 loc) • 1.77 kB
JavaScript
import { __assign, __rest } from "tslib";
import $i18n from "../../locales/i18n";
import classNames from 'classnames';
import React, { useEffect, useState } from 'react';
import { CnDrawer } from "../cn-drawer";
import { CnButton } from '../cn-button';
export default (function (props) {
var _a = props.prefix, prefix = _a === void 0 ? 'cn-ui-m-' : _a, _b = props.visible, visible = _b === void 0 ? false : _b, drawerClassName = props.drawerClassName, drawerTitle = props.drawerTitle, onCancel = props.onCancel, onClose = props.onClose, onOk = props.onOk, children = props.children, others = __rest(props, ["prefix", "visible", "drawerClassName", "drawerTitle", "onCancel", "onClose", "onOk", "children"]);
var _c = useState(false), drawerVisible = _c[0], setDrawerVisible = _c[1];
var clsPrefix = "".concat(prefix, "selectdrawer");
useEffect(function () {
if (drawerVisible !== visible) {
setDrawerVisible(visible);
}
}, [visible]);
return (React.createElement(CnDrawer, __assign({}, others, { visible: drawerVisible, placement: "bottom", closeMode: ['mask'], onClose: onClose, className: classNames("".concat(clsPrefix, "-drawer"), drawerClassName), noCard: true }),
React.createElement("div", { className: "".concat(clsPrefix, "-toolbar") },
React.createElement(CnButton, { text: true, onClick: onCancel }, $i18n.get({ id: 'Cancel', dm: '取消' })),
React.createElement("div", { className: "".concat(clsPrefix, "-toolbar-title") }, drawerTitle),
React.createElement(CnButton, { text: true, type: "primary", onClick: onOk }, $i18n.get({ id: 'OK', dm: '确定' }))),
React.createElement("div", { className: "".concat(clsPrefix, "-drawer-content") }, children)));
});