UNPKG

miniapp-web-jsapi

Version:

JSAPI/View adapter for miniprogram running on the web

212 lines (210 loc) 8.15 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/alert/Alert.svelte generated by Svelte v3.49.0 */ import { SvelteComponent, append, append_styles, attr, create_component, destroy_component, detach, element, init, insert, is_function, listen, mount_component, null_to_empty, safe_not_equal, set_data, space, text, transition_in, transition_out } from "svelte/internal"; import { getPrefixCls } from "../../../../lib/web"; import JsUtils from "../../../../lib/utils/js-utils"; import Modal from '../modal'; function add_css(target) { append_styles(target, "svelte-1pl0sex", ".alipay-mwj-alert.svelte-1pl0sex{width:100vw;height:100vh;background-color:rgba(0, 0, 0, 0.4);display:flex;flex-direction:column;align-items:center;justify-content:center}.alipay-mwj-alert-content.svelte-1pl0sex{background-color:#fff;width:270px;border-radius:7px;padding-top:15px;text-align:center;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center}.alipay-mwj-alert-title.svelte-1pl0sex{font-size:18px;color:#000;padding:6px 15px 15px;word-break:break-word}.alipay-mwj-alert-text.svelte-1pl0sex{color:#888;font-size:15px;padding:0 15px 15px;overflow:auto;word-break:break-word}.alipay-mwj-alert-line.svelte-1pl0sex{width:100%;height:1px;background-color:#eee}.alipay-mwj-alert-button.svelte-1pl0sex{color:#3F8DE2;font-size:18px;height:50px;line-height:50px}"); } // (17:6) {#if isContentNotEmpty} function create_if_block(ctx) { var span; var t; var span_class_value; return { c: function c() { span = element("span"); t = text(/*content*/ctx[1]); attr(span, "class", span_class_value = "" + (/*prefixCls*/ctx[5] + "-text" + " svelte-1pl0sex")); }, m: function m(target, anchor) { insert(target, span, anchor); append(span, t); }, p: function p(ctx, dirty) { if (dirty & /*content*/2) set_data(t, /*content*/ctx[1]); }, d: function d(detaching) { if (detaching) detach(span); } }; } // (12:0) <Modal> function create_default_slot(ctx) { var div2; var div1; var span0; var t0_value = (/*title*/ctx[0] || '') + ""; var t0; var span0_class_value; var t1; var t2; var div0; var div0_class_value; var t3; var span1; var t4_value = (/*buttonText*/ctx[2] || 'OK') + ""; var t4; var span1_class_value; var div1_class_value; var div2_class_value; var mounted; var dispose; var if_block = /*isContentNotEmpty*/ctx[4] && create_if_block(ctx); return { c: function c() { div2 = element("div"); div1 = element("div"); span0 = element("span"); t0 = text(t0_value); t1 = space(); if (if_block) if_block.c(); t2 = space(); div0 = element("div"); t3 = space(); span1 = element("span"); t4 = text(t4_value); attr(span0, "class", span0_class_value = "" + (/*prefixCls*/ctx[5] + "-title" + " svelte-1pl0sex")); attr(div0, "class", div0_class_value = "" + (/*prefixCls*/ctx[5] + "-line" + " svelte-1pl0sex")); attr(span1, "class", span1_class_value = "" + (/*prefixCls*/ctx[5] + "-button" + " svelte-1pl0sex")); attr(div1, "class", div1_class_value = "" + (/*prefixCls*/ctx[5] + "-content" + " svelte-1pl0sex")); attr(div2, "class", div2_class_value = "" + (null_to_empty(/*prefixCls*/ctx[5]) + " svelte-1pl0sex")); }, m: function m(target, anchor) { insert(target, div2, anchor); append(div2, div1); append(div1, span0); append(span0, t0); append(div1, t1); if (if_block) if_block.m(div1, null); append(div1, t2); append(div1, div0); append(div1, t3); append(div1, span1); append(span1, t4); if (!mounted) { dispose = listen(span1, "click", function () { if (is_function(/*onClose*/ctx[3])) /*onClose*/ctx[3].apply(this, arguments); }); mounted = true; } }, p: function p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*title*/1 && t0_value !== (t0_value = (/*title*/ctx[0] || '') + "")) set_data(t0, t0_value); if (/*isContentNotEmpty*/ctx[4]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block(ctx); if_block.c(); if_block.m(div1, t2); } } else if (if_block) { if_block.d(1); if_block = null; } if (dirty & /*buttonText*/4 && t4_value !== (t4_value = (/*buttonText*/ctx[2] || 'OK') + "")) set_data(t4, t4_value); }, d: function d(detaching) { if (detaching) detach(div2); if (if_block) if_block.d(); mounted = false; dispose(); } }; } function create_fragment(ctx) { var modal; var current; modal = new Modal({ props: { $$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 & /*$$scope, onClose, buttonText, content, isContentNotEmpty, title*/95) { 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 isContentNotEmpty; var title = $$props.title; var content = $$props.content; var buttonText = $$props.buttonText; var onClose = $$props.onClose; var prefixCls = getPrefixCls('alert'); $$self.$$set = function ($$props) { if ('title' in $$props) $$invalidate(0, title = $$props.title); if ('content' in $$props) $$invalidate(1, content = $$props.content); if ('buttonText' in $$props) $$invalidate(2, buttonText = $$props.buttonText); if ('onClose' in $$props) $$invalidate(3, onClose = $$props.onClose); }; $$self.$$.update = function () { if ($$self.$$.dirty & /*content*/2) { $: $$invalidate(4, isContentNotEmpty = JsUtils.isNotEmpty(content)); } }; return [title, content, buttonText, onClose, isContentNotEmpty, prefixCls]; } var Alert = /*#__PURE__*/function (_SvelteComponent) { _inherits(Alert, _SvelteComponent); var _super = _createSuper(Alert); function Alert(options) { var _this; _classCallCheck(this, Alert); _this = _super.call(this); init(_assertThisInitialized(_this), options, instance, create_fragment, safe_not_equal, { title: 0, content: 1, buttonText: 2, onClose: 3 }, add_css); return _this; } return _createClass(Alert); }(SvelteComponent); export default Alert;