diff --git a/src/action-sheet/index.js b/src/action-sheet/index.js
index 214971c35..dd707ad1d 100644
--- a/src/action-sheet/index.js
+++ b/src/action-sheet/index.js
@@ -8,6 +8,51 @@ import Loading from '../loading';
const [createComponent, bem] = createNamespace('action-sheet');
+function Header({ title, closeIcon, onCancel }) {
+ if (title) {
+ return (
+
+ );
+ }
+}
+
+function Option({ item }) {
+ const { name, color, subname, loading, disabled, className } = item;
+
+ const Content = loading ? (
+
+ ) : (
+ [
+ {name},
+ subname && {subname}
,
+ ]
+ );
+
+ return (
+
+ );
+}
+
+function CancelText({ cancelText, onCancel }) {
+ if (cancelText) {
+ return [
+ ,
+ ,
+ ];
+ }
+}
+
export default createComponent({
props: {
...popupSharedProps,
@@ -41,139 +86,66 @@ export default createComponent({
},
},
- emits: [
- 'open',
- 'close',
- 'opened',
- 'closed',
- 'cancel',
- 'select',
- 'update:show',
- 'click-overlay',
- ],
+ emits: ['select', 'cancel', 'update:show'],
setup(props, { slots, emit }) {
+ function onUpdateShow(show) {
+ emit('update:show', show);
+ }
+
function onCancel() {
- emit('update:show', false);
+ onUpdateShow(false);
emit('cancel');
}
- const createEmitter = (name) => () => emit(name);
- const listeners = {
- onOpen: createEmitter('open'),
- onClose: createEmitter('close'),
- onOpened: createEmitter('opened'),
- onClosed: createEmitter('closed'),
- 'onClick-overlay': createEmitter('click-overlay'),
- 'onUpdate:show': (show) => {
- emit('update:show', show);
- },
- };
-
return function () {
- const { title, cancelText } = props;
+ const {
+ title,
+ actions,
+ closeIcon,
+ cancelText,
+ description,
+ closeOnClickAction,
+ ...restProps
+ } = props;
- function Header() {
- if (title) {
- return (
-
- );
- }
- }
-
- function Content() {
- if (slots.default) {
- return {slots.default()}
;
- }
- }
-
- function Option(item, index) {
- const { disabled, loading, callback } = item;
-
- function onClickOption(event) {
- event.stopPropagation();
-
- if (disabled || loading) {
- return;
- }
-
- if (callback) {
- callback(item);
- }
-
- emit('select', item, index);
-
- if (props.closeOnClickAction) {
- emit('update:show', false);
- }
- }
-
- function OptionContent() {
- if (loading) {
- return ;
- }
-
- return [
- {item.name},
- item.subname && {item.subname}
,
- ];
- }
-
- return (
-
- );
- }
-
- function CancelText() {
- if (cancelText) {
- return [
- ,
- ,
- ];
- }
- }
-
- const Description = props.description && (
- {props.description}
+ const Content = slots.default && (
+ {slots.default()}
);
+ const Description = description && (
+ {description}
+ );
+
+ const Options =
+ actions &&
+ actions.map((item, index) => (
+