pwa-camera-modal.cjs.entry.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. const index = require('./index-d7f36e37.js');
  4. const cameraModalCss = ":host{z-index:1000;position:fixed;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;contain:strict}.wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:rgba(0, 0, 0, 0.15)}.content{-webkit-box-shadow:0px 0px 5px rgba(0, 0, 0, 0.2);box-shadow:0px 0px 5px rgba(0, 0, 0, 0.2);width:600px;height:600px}";
  5. const PWACameraModal = class {
  6. constructor(hostRef) {
  7. index.registerInstance(this, hostRef);
  8. this.onPhoto = index.createEvent(this, "onPhoto", 7);
  9. this.noDeviceError = index.createEvent(this, "noDeviceError", 7);
  10. this.facingMode = 'user';
  11. this.hidePicker = false;
  12. }
  13. async present() {
  14. const camera = document.createElement('pwa-camera-modal-instance');
  15. camera.facingMode = this.facingMode;
  16. camera.hidePicker = this.hidePicker;
  17. camera.addEventListener('onPhoto', async (e) => {
  18. if (!this._modal) {
  19. return;
  20. }
  21. const photo = e.detail;
  22. this.onPhoto.emit(photo);
  23. });
  24. camera.addEventListener('noDeviceError', async (e) => {
  25. this.noDeviceError.emit(e);
  26. });
  27. document.body.append(camera);
  28. this._modal = camera;
  29. }
  30. async dismiss() {
  31. if (!this._modal) {
  32. return;
  33. }
  34. this._modal && this._modal.parentNode.removeChild(this._modal);
  35. this._modal = null;
  36. }
  37. render() {
  38. return (index.h("div", null));
  39. }
  40. };
  41. PWACameraModal.style = cameraModalCss;
  42. exports.pwa_camera_modal = PWACameraModal;