123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { h } from '@stencil/core';
- export class PWACameraModal {
- constructor() {
- this.facingMode = 'user';
- this.hidePicker = false;
- }
- async present() {
- const camera = document.createElement('pwa-camera-modal-instance');
- camera.facingMode = this.facingMode;
- camera.hidePicker = this.hidePicker;
- camera.addEventListener('onPhoto', async (e) => {
- if (!this._modal) {
- return;
- }
- const photo = e.detail;
- this.onPhoto.emit(photo);
- });
- camera.addEventListener('noDeviceError', async (e) => {
- this.noDeviceError.emit(e);
- });
- document.body.append(camera);
- this._modal = camera;
- }
- async dismiss() {
- if (!this._modal) {
- return;
- }
- this._modal && this._modal.parentNode.removeChild(this._modal);
- this._modal = null;
- }
- render() {
- return (h("div", null));
- }
- static get is() { return "pwa-camera-modal"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["camera-modal.css"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["camera-modal.css"]
- };
- }
- static get properties() {
- return {
- "facingMode": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": ""
- },
- "attribute": "facing-mode",
- "reflect": false,
- "defaultValue": "'user'"
- },
- "hidePicker": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": ""
- },
- "attribute": "hide-picker",
- "reflect": false,
- "defaultValue": "false"
- }
- };
- }
- static get events() {
- return [{
- "method": "onPhoto",
- "name": "onPhoto",
- "bubbles": true,
- "cancelable": true,
- "composed": true,
- "docs": {
- "tags": [],
- "text": ""
- },
- "complexType": {
- "original": "any",
- "resolved": "any",
- "references": {}
- }
- }, {
- "method": "noDeviceError",
- "name": "noDeviceError",
- "bubbles": true,
- "cancelable": true,
- "composed": true,
- "docs": {
- "tags": [],
- "text": ""
- },
- "complexType": {
- "original": "any",
- "resolved": "any",
- "references": {}
- }
- }];
- }
- static get methods() {
- return {
- "present": {
- "complexType": {
- "signature": "() => Promise<void>",
- "parameters": [],
- "references": {
- "Promise": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "",
- "tags": []
- }
- },
- "dismiss": {
- "complexType": {
- "signature": "() => Promise<void>",
- "parameters": [],
- "references": {
- "Promise": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "",
- "tags": []
- }
- }
- };
- }
- }
|