pwa-action-sheet.entry.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { r as registerInstance, c as createEvent, h, g as getElement } from './index-1c5c47b4.js';
  2. const actionSheetCss = ":host{z-index:1000;position:fixed;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;contain:strict;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-family:-apple-system, BlinkMacSystemFont, \"Helvetica Neue\", \"Roboto\", sans-serif}.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);-webkit-transition:400ms background-color cubic-bezier(.36,.66,.04,1);transition:400ms background-color cubic-bezier(.36,.66,.04,1)}.wrapper.open{background-color:rgba(0, 0, 0, 0.32)}.title{color:#999;height:23px;line-height:23px;padding-bottom:17px;-webkit-padding-end:16px;padding-inline-end:16px;-webkit-padding-start:16px;padding-inline-start:16px;padding-left:16px;padding-right:16px;padding-top:20px}.content{width:568px;-ms-flex-item-align:end;align-self:flex-end;background-color:#fff;-webkit-transition:400ms -webkit-transform cubic-bezier(.36,.66,.04,1);transition:400ms -webkit-transform cubic-bezier(.36,.66,.04,1);transition:400ms transform cubic-bezier(.36,.66,.04,1);transition:400ms transform cubic-bezier(.36,.66,.04,1), 400ms -webkit-transform cubic-bezier(.36,.66,.04,1);-webkit-transform:translateY(100%);transform:translateY(100%)}.wrapper.open .content{-webkit-transform:translateY(0%);transform:translateY(0%)}@media only screen and (max-width: 568px){.content{width:100%}}.action-sheet-option{cursor:pointer;height:52px;line-height:52px}.action-sheet-button{color:rgb(38, 38, 38);font-size:16px;-webkit-padding-end:16px;padding-inline-end:16px;-webkit-padding-start:16px;padding-inline-start:16px;padding-left:16px;padding-right:16px;padding-top:0px}.action-sheet-button:hover{background-color:#F6F6F6}";
  3. const PWAActionSheet = class {
  4. constructor(hostRef) {
  5. registerInstance(this, hostRef);
  6. this.onSelection = createEvent(this, "onSelection", 7);
  7. this.header = undefined;
  8. this.cancelable = true;
  9. this.options = [];
  10. this.open = false;
  11. }
  12. componentDidLoad() {
  13. requestAnimationFrame(() => {
  14. this.open = true;
  15. });
  16. }
  17. dismiss() {
  18. if (this.cancelable) {
  19. this.close();
  20. }
  21. }
  22. close() {
  23. this.open = false;
  24. setTimeout(() => {
  25. this.el.parentNode.removeChild(this.el);
  26. }, 500);
  27. }
  28. handleOptionClick(e, i) {
  29. e.stopPropagation();
  30. this.onSelection.emit(i);
  31. this.close();
  32. }
  33. render() {
  34. return (h("div", { class: `wrapper${this.open ? ' open' : ''}`, onClick: () => this.dismiss() }, h("div", { class: "content" }, h("div", { class: "title" }, this.header), this.options.map((option, i) => h("div", { class: "action-sheet-option", onClick: (e) => this.handleOptionClick(e, i) }, h("div", { class: "action-sheet-button" }, option.title))))));
  35. }
  36. get el() { return getElement(this); }
  37. };
  38. PWAActionSheet.style = actionSheetCss;
  39. export { PWAActionSheet as pwa_action_sheet };