pwa-camera-modal-instance.entry.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { r as registerInstance, c as createEvent, h, g as getElement } from './index-1c5c47b4.js';
  2. const cameraModalInstanceCss = ":host{z-index:1000;position:fixed;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;contain:strict;--inset-width:600px;--inset-height:600px}.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:var(--inset-width);height:var(--inset-height);max-height:100%}@media only screen and (max-width: 600px){.content{width:100%;height:100%}}";
  3. const PWACameraModal = class {
  4. constructor(hostRef) {
  5. registerInstance(this, hostRef);
  6. this.onPhoto = createEvent(this, "onPhoto", 7);
  7. this.noDeviceError = createEvent(this, "noDeviceError", 7);
  8. this.handlePhoto = async (photo) => {
  9. this.onPhoto.emit(photo);
  10. };
  11. this.handleNoDeviceError = async (photo) => {
  12. this.noDeviceError.emit(photo);
  13. };
  14. this.facingMode = 'user';
  15. this.hidePicker = false;
  16. this.noDevicesText = 'No camera found';
  17. this.noDevicesButtonText = 'Choose image';
  18. }
  19. handleBackdropClick(e) {
  20. if (e.target !== this.el) {
  21. this.onPhoto.emit(null);
  22. }
  23. }
  24. handleComponentClick(e) {
  25. e.stopPropagation();
  26. }
  27. handleBackdropKeyUp(e) {
  28. if (e.key === "Escape") {
  29. this.onPhoto.emit(null);
  30. }
  31. }
  32. render() {
  33. return (h("div", { class: "wrapper", onClick: e => this.handleBackdropClick(e) }, h("div", { class: "content" }, h("pwa-camera", { onClick: e => this.handleComponentClick(e), facingMode: this.facingMode, hidePicker: this.hidePicker, handlePhoto: this.handlePhoto, handleNoDeviceError: this.handleNoDeviceError, noDevicesButtonText: this.noDevicesButtonText, noDevicesText: this.noDevicesText }))));
  34. }
  35. get el() { return getElement(this); }
  36. };
  37. PWACameraModal.style = cameraModalInstanceCss;
  38. export { PWACameraModal as pwa_camera_modal_instance };