@tarojsx/ui
Version:
We reinvents the UI for Taro3+
30 lines • 1.43 kB
JavaScript
import React, { useCallback } from 'react';
import classNames from 'classnames';
import { View } from '@tarojs/components';
import '../style/ActionSheet.scss';
export const ActionSheet = props => {
const { className, style = {}, isOpened, title, cancelText = '取消', children } = props;
const onClose = useCallback(e => {
if (props.onClose) {
props.onClose(e);
}
}, [props.onClose]);
const onCancel = useCallback(e => {
if (props.onCancel) {
props.onCancel(e);
}
onClose(e);
}, [onClose, props.onCancel]);
const onTouchMove = useCallback(e => {
e.stopPropagation();
e.preventDefault();
}, []);
return (React.createElement(View, { className: classNames('at-action-sheet', { 'at-action-sheet--active': isOpened }, className), style: style, onTouchMove: onTouchMove },
React.createElement(View, { onClick: onClose, className: "at-action-sheet__overlay" }),
React.createElement(View, { className: "at-action-sheet__container" },
title && React.createElement(View, { className: "at-action-sheet__header" }, title),
React.createElement(View, { className: "at-action-sheet__body" },
children,
cancelText && (React.createElement(View, { className: "at-action-sheet__footer", onClick: onCancel }, cancelText))))));
};
//# sourceMappingURL=ActionSheet.js.map