123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- exports.__esModule = true;
- exports.default = void 0;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
- var _vue = _interopRequireDefault(require("vue"));
- var _utils = require("../utils");
- var _functional = require("../utils/functional");
- var _popup = require("../mixins/popup");
- var _icon = _interopRequireDefault(require("../icon"));
- var _popup2 = _interopRequireDefault(require("../popup"));
- var _loading = _interopRequireDefault(require("../loading"));
- // Utils
- // Mixins
- // Components
- var _createNamespace = (0, _utils.createNamespace)('action-sheet'),
- createComponent = _createNamespace[0],
- bem = _createNamespace[1];
- function ActionSheet(h, props, slots, ctx) {
- var title = props.title,
- cancelText = props.cancelText,
- closeable = props.closeable;
- function onCancel() {
- (0, _functional.emit)(ctx, 'input', false);
- (0, _functional.emit)(ctx, 'cancel');
- }
- function Header() {
- if (title) {
- return h("div", {
- "class": bem('header')
- }, [title, closeable && h(_icon.default, {
- "attrs": {
- "name": props.closeIcon
- },
- "class": bem('close'),
- "on": {
- "click": onCancel
- }
- })]);
- }
- }
- function Option(item, index) {
- var disabled = item.disabled,
- loading = item.loading,
- callback = item.callback;
- function onClickOption(event) {
- event.stopPropagation();
- if (disabled || loading) {
- return;
- }
- if (callback) {
- callback(item);
- }
- if (props.closeOnClickAction) {
- (0, _functional.emit)(ctx, 'input', false);
- }
- _vue.default.nextTick(function () {
- (0, _functional.emit)(ctx, 'select', item, index);
- });
- }
- function OptionContent() {
- if (loading) {
- return h(_loading.default, {
- "class": bem('loading-icon')
- });
- }
- return [h("span", {
- "class": bem('name')
- }, [item.name]), item.subname && h("div", {
- "class": bem('subname')
- }, [item.subname])];
- }
- return h("button", {
- "attrs": {
- "type": "button"
- },
- "class": [bem('item', {
- disabled: disabled,
- loading: loading
- }), item.className],
- "style": {
- color: item.color
- },
- "on": {
- "click": onClickOption
- }
- }, [OptionContent()]);
- }
- function CancelText() {
- if (cancelText) {
- return [h("div", {
- "class": bem('gap')
- }), h("button", {
- "attrs": {
- "type": "button"
- },
- "class": bem('cancel'),
- "on": {
- "click": onCancel
- }
- }, [cancelText])];
- }
- }
- function Description() {
- var description = (slots.description == null ? void 0 : slots.description()) || props.description;
- if (description) {
- return h("div", {
- "class": bem('description')
- }, [description]);
- }
- }
- return h(_popup2.default, (0, _babelHelperVueJsxMergeProps.default)([{
- "class": bem(),
- "attrs": {
- "position": "bottom",
- "round": props.round,
- "value": props.value,
- "overlay": props.overlay,
- "duration": props.duration,
- "lazyRender": props.lazyRender,
- "lockScroll": props.lockScroll,
- "getContainer": props.getContainer,
- "closeOnPopstate": props.closeOnPopstate,
- "closeOnClickOverlay": props.closeOnClickOverlay,
- "safeAreaInsetBottom": props.safeAreaInsetBottom
- }
- }, (0, _functional.inherit)(ctx, true)]), [Header(), Description(), h("div", {
- "class": bem('content')
- }, [props.actions && props.actions.map(Option), slots.default == null ? void 0 : slots.default()]), CancelText()]);
- }
- ActionSheet.props = (0, _extends2.default)({}, _popup.popupMixinProps, {
- title: String,
- actions: Array,
- duration: [Number, String],
- cancelText: String,
- description: String,
- getContainer: [String, Function],
- closeOnPopstate: Boolean,
- closeOnClickAction: Boolean,
- round: {
- type: Boolean,
- default: true
- },
- closeable: {
- type: Boolean,
- default: true
- },
- closeIcon: {
- type: String,
- default: 'cross'
- },
- safeAreaInsetBottom: {
- type: Boolean,
- default: true
- },
- overlay: {
- type: Boolean,
- default: true
- },
- closeOnClickOverlay: {
- type: Boolean,
- default: true
- }
- });
- var _default = createComponent(ActionSheet);
- exports.default = _default;
|