UNPKG

@scuticode/shop-sdk

Version:

ScutiCode shop sdk

122 lines (121 loc) 7.82 kB
"use strict"; var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; }; var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DialogComponent = void 0; const lit_1 = require("lit"); const decorators_js_1 = require("lit/decorators.js"); const button_style_1 = require("./styles/button.style"); const dialog_style_1 = require("./styles/dialog.style"); require("./components/main-chat.component"); let DialogComponent = (() => { var _DialogComponent_position_accessor_storage, _DialogComponent_chatBaseUrl_accessor_storage; let _classDecorators = [(0, decorators_js_1.customElement)('scuticode-shop-dialog')]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; let _classSuper = lit_1.LitElement; let _instanceExtraInitializers = []; let _position_decorators; let _position_initializers = []; let _chatBaseUrl_decorators; let _chatBaseUrl_initializers = []; var DialogComponent = _classThis = class extends _classSuper { constructor() { super(...arguments); _DialogComponent_position_accessor_storage.set(this, (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _position_initializers, "center"))); _DialogComponent_chatBaseUrl_accessor_storage.set(this, __runInitializers(this, _chatBaseUrl_initializers, void 0)); this.toggled = true; } get position() { return __classPrivateFieldGet(this, _DialogComponent_position_accessor_storage, "f"); } set position(value) { __classPrivateFieldSet(this, _DialogComponent_position_accessor_storage, value, "f"); } get chatBaseUrl() { return __classPrivateFieldGet(this, _DialogComponent_chatBaseUrl_accessor_storage, "f"); } set chatBaseUrl(value) { __classPrivateFieldSet(this, _DialogComponent_chatBaseUrl_accessor_storage, value, "f"); } render() { return (0, lit_1.html) ` <button class="btn btn-primary" @click="${this.toggle}">ScutiCode Shop</button> <div class="dialog ${!this.toggled ? this.dialogStyle() : 'hidden'}"> <main-chat @close-event="${this.close}" chatBaseUrl="${this.chatBaseUrl}"></main-chat> </div> `; } toggle() { this.toggled = !this.toggled; this.requestUpdate(); } dialogStyle() { return this.position ? `dialog-${this.position}` : 'dialog-center'; } close() { this.toggled = true; this.requestUpdate(); } }; _DialogComponent_position_accessor_storage = new WeakMap(); _DialogComponent_chatBaseUrl_accessor_storage = new WeakMap(); __setFunctionName(_classThis, "DialogComponent"); (() => { const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; _position_decorators = [(0, decorators_js_1.property)()]; _chatBaseUrl_decorators = [(0, decorators_js_1.property)()]; __esDecorate(_classThis, null, _position_decorators, { kind: "accessor", name: "position", static: false, private: false, access: { has: obj => "position" in obj, get: obj => obj.position, set: (obj, value) => { obj.position = value; } }, metadata: _metadata }, _position_initializers, _instanceExtraInitializers); __esDecorate(_classThis, null, _chatBaseUrl_decorators, { kind: "accessor", name: "chatBaseUrl", static: false, private: false, access: { has: obj => "chatBaseUrl" in obj, get: obj => obj.chatBaseUrl, set: (obj, value) => { obj.chatBaseUrl = value; } }, metadata: _metadata }, _chatBaseUrl_initializers, _instanceExtraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); DialogComponent = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); })(); _classThis.styles = [button_style_1.button, dialog_style_1.dialog, (0, lit_1.css) ` `]; (() => { __runInitializers(_classThis, _classExtraInitializers); })(); return DialogComponent = _classThis; })(); exports.DialogComponent = DialogComponent;