UNPKG

miniapp-web-jsapi

Version:

JSAPI/View adapter for miniprogram running on the web

301 lines (297 loc) 10.1 kB
import _createClass from "@babel/runtime/helpers/createClass"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* packages/miniapp-web-jsapi/src/web/components/toast/Toast.svelte generated by Svelte v3.49.0 */ import { SvelteComponent, append, append_styles, attr, check_outros, create_component, destroy_component, detach, element, group_outros, init, insert, mount_component, noop, null_to_empty, safe_not_equal, set_data, space, text, transition_in, transition_out } from "svelte/internal"; import { getPrefixCls } from "../../../../lib/web"; import AdapterEvents from "../../../../lib/web/events/events"; import { defaultEventManager } from "../../../../lib/web/events"; import { onMount, onDestroy } from 'svelte/internal'; import SuccessIcon from "./SuccessIcon"; import FailIcon from "./FailIcon"; import ExceptionIcon from "./ExceptionIcon"; import Modal from '../modal'; function add_css(target) { append_styles(target, "svelte-13dnj4p", ".alipay-mwj-toast.svelte-13dnj4p{background-color:rgba(58, 58, 58, 0.9);max-width:50%;min-width:72px;padding:15px;border-radius:5px;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center}.alipay-mwj-toast-icon{width:72px;height:72px;margin-bottom:12px}.alipay-mwj-toast-text{color:#fff;font-size:14px;text-align:center;width:100%;display:block;word-wrap:break-word}"); } // (28:35) function create_if_block_2(ctx) { var exceptionicon; var current; exceptionicon = new ExceptionIcon({ props: { className: "" + (/*prefixCls*/ctx[4] + "-icon") } }); return { c: function c() { create_component(exceptionicon.$$.fragment); }, m: function m(target, anchor) { mount_component(exceptionicon, target, anchor); current = true; }, p: noop, i: function i(local) { if (current) return; transition_in(exceptionicon.$$.fragment, local); current = true; }, o: function o(local) { transition_out(exceptionicon.$$.fragment, local); current = false; }, d: function d(detaching) { destroy_component(exceptionicon, detaching); } }; } // (26:30) function create_if_block_1(ctx) { var failicon; var current; failicon = new FailIcon({ props: { className: "" + (/*prefixCls*/ctx[4] + "-icon") } }); return { c: function c() { create_component(failicon.$$.fragment); }, m: function m(target, anchor) { mount_component(failicon, target, anchor); current = true; }, p: noop, i: function i(local) { if (current) return; transition_in(failicon.$$.fragment, local); current = true; }, o: function o(local) { transition_out(failicon.$$.fragment, local); current = false; }, d: function d(detaching) { destroy_component(failicon, detaching); } }; } // (24:4) {#if type === 'success'} function create_if_block(ctx) { var successicon; var current; successicon = new SuccessIcon({ props: { className: "" + (/*prefixCls*/ctx[4] + "-icon") } }); return { c: function c() { create_component(successicon.$$.fragment); }, m: function m(target, anchor) { mount_component(successicon, target, anchor); current = true; }, p: noop, i: function i(local) { if (current) return; transition_in(successicon.$$.fragment, local); current = true; }, o: function o(local) { transition_out(successicon.$$.fragment, local); current = false; }, d: function d(detaching) { destroy_component(successicon, detaching); } }; } // (22:0) <Modal {duration} afterClose={onClose}> function create_default_slot(ctx) { var div; var current_block_type_index; var if_block; var t0; var span; var t1; var span_class_value; var div_class_value; var current; var if_block_creators = [create_if_block, create_if_block_1, create_if_block_2]; var if_blocks = []; function select_block_type(ctx, dirty) { if (/*type*/ctx[1] === 'success') return 0; if (/*type*/ctx[1] === 'fail') return 1; if (/*type*/ctx[1] === 'exception') return 2; return -1; } if (~(current_block_type_index = select_block_type(ctx, -1))) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); } return { c: function c() { div = element("div"); if (if_block) if_block.c(); t0 = space(); span = element("span"); t1 = text(/*content*/ctx[0]); attr(span, "class", span_class_value = "" + (/*prefixCls*/ctx[4] + "-text" + " svelte-13dnj4p")); attr(div, "class", div_class_value = "" + (null_to_empty(/*prefixCls*/ctx[4]) + " svelte-13dnj4p")); }, m: function m(target, anchor) { insert(target, div, anchor); if (~current_block_type_index) { if_blocks[current_block_type_index].m(div, null); } append(div, t0); append(div, span); append(span, t1); current = true; }, p: function p(ctx, dirty) { var previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx, dirty); if (current_block_type_index === previous_block_index) { if (~current_block_type_index) { if_blocks[current_block_type_index].p(ctx, dirty); } } else { if (if_block) { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, function () { if_blocks[previous_block_index] = null; }); check_outros(); } if (~current_block_type_index) { if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(div, t0); } else { if_block = null; } } if (!current || dirty & /*content*/1) set_data(t1, /*content*/ctx[0]); }, i: function i(local) { if (current) return; transition_in(if_block); current = true; }, o: function o(local) { transition_out(if_block); current = false; }, d: function d(detaching) { if (detaching) detach(div); if (~current_block_type_index) { if_blocks[current_block_type_index].d(); } } }; } function create_fragment(ctx) { var modal; var current; modal = new Modal({ props: { duration: /*duration*/ctx[2], afterClose: /*onClose*/ctx[3], $$slots: { default: [create_default_slot] }, $$scope: { ctx: ctx } } }); return { c: function c() { create_component(modal.$$.fragment); }, m: function m(target, anchor) { mount_component(modal, target, anchor); current = true; }, p: function p(ctx, _ref) { var _ref2 = _slicedToArray(_ref, 1), dirty = _ref2[0]; var modal_changes = {}; if (dirty & /*duration*/4) modal_changes.duration = /*duration*/ctx[2]; if (dirty & /*onClose*/8) modal_changes.afterClose = /*onClose*/ctx[3]; if (dirty & /*$$scope, content, type*/35) { modal_changes.$$scope = { dirty: dirty, ctx: ctx }; } modal.$set(modal_changes); }, i: function i(local) { if (current) return; transition_in(modal.$$.fragment, local); current = true; }, o: function o(local) { transition_out(modal.$$.fragment, local); current = false; }, d: function d(detaching) { destroy_component(modal, detaching); } }; } function instance($$self, $$props, $$invalidate) { var content = $$props.content; var type = $$props.type; var duration = $$props.duration; var onClose = $$props.onClose; var prefixCls = getPrefixCls('toast'); onMount(function () { defaultEventManager.addListener(AdapterEvents.ToastHide, onClose); }); onDestroy(function () { defaultEventManager.removeListener(AdapterEvents.ToastHide, onClose); }); $$self.$$set = function ($$props) { if ('content' in $$props) $$invalidate(0, content = $$props.content); if ('type' in $$props) $$invalidate(1, type = $$props.type); if ('duration' in $$props) $$invalidate(2, duration = $$props.duration); if ('onClose' in $$props) $$invalidate(3, onClose = $$props.onClose); }; return [content, type, duration, onClose, prefixCls]; } var Toast = /*#__PURE__*/function (_SvelteComponent) { _inherits(Toast, _SvelteComponent); var _super = _createSuper(Toast); function Toast(options) { var _this; _classCallCheck(this, Toast); _this = _super.call(this); init(_assertThisInitialized(_this), options, instance, create_fragment, safe_not_equal, { content: 0, type: 1, duration: 2, onClose: 3 }, add_css); return _this; } return _createClass(Toast); }(SvelteComponent); export default Toast;