-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-dbaf6e8a.entry.js
5 lines (5 loc) · 16.5 KB
/
p-dbaf6e8a.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as o,d as i,h as a,H as s,g as e}from"./p-00e3df8e.js";import{l as d}from"./p-f5397639.js";import"./p-384ad3a0.js";import{i as h}from"./p-89a330bf.js";import{t as r}from"./p-dc076e70.js";import{h as l}from"./p-3e9fe89f.js";import"./p-21e654a9.js";import"./p-58156e74.js";import"./p-5119ef20.js";import"./p-ece60743.js";var n;!function(t){t.API="API",t.OUTSIDE_CLICK="OUTSIDE_CLICK",t.ESCAPE="ESCAPE"}(n||(n={}));class c{constructor(t,o){this.enabled=!1,this.state={distX:0,distY:0},this.box={left:null,top:null,right:null,bottom:null},this.element=t,this.options=Object.assign({handler:t,snapThreshold:0,parent:window},o),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this)}enable(){return this.enabled||(this.options.handler.addEventListener("pointerdown",this.handleMouseDown),this.enabled=!0),this}disable(){if(this.enabled)return this.options.handler.removeEventListener("pointerdown",this.handleMouseDown),this.enabled=!1,this}isEnabled(){return this.enabled}updateOptions(t){return this.options=Object.assign(this.options,t),this}handleMouseDown(t){if(t.preventDefault(),2===t.button||3==t.which)return;const o=this.options,i=this.element;this.state={distX:Math.abs(i.offsetLeft-t.clientX),distY:Math.abs(i.offsetTop-t.clientY)},this.box={left:i.style.left,top:i.style.top,right:i.style.right,bottom:i.style.bottom},document.addEventListener("pointerup",this.handleMouseUp),document.addEventListener("pointermove",this.handleMouseMove),o.onStart&&o.onStart({element:i,state:this.state,box:this.box})}handleMouseMove(t){const o=this.options,i=this.element,a=this.state;this.box={left:t.clientX-a.distX+"px",top:t.clientY-a.distY+"px",right:"auto",bottom:"auto"},i.setAttribute("data-moving",""),o.onMove&&o.onMove({element:i,state:a,box:this.box})}handleMouseUp(){const t=this.element,o=this.options,i=o.parent;if(i){const a=o.snapThreshold;let s,e;if("undefined"!=typeof Window&&i instanceof Window)e=window.innerWidth,s=window.innerHeight;else{const t=i.getBoundingClientRect();e=t.width,s=t.height}s-(t.offsetTop+t.offsetHeight)<a&&(this.box={left:"auto",top:"auto",right:"auto",bottom:"0px"}),e-(t.offsetLeft+t.offsetWidth)<a&&(this.box={left:"auto",top:"auto",right:"0px",bottom:"auto"}),t.offsetTop<a&&(this.box={left:"auto",top:"0px",right:"auto",bottom:"auto"}),t.offsetLeft<a&&(this.box={left:"0px",top:"auto",right:"auto",bottom:"auto"})}t.removeAttribute("data-moving"),document.removeEventListener("pointerup",this.handleMouseUp),document.removeEventListener("pointermove",this.handleMouseMove),o.onEnd&&o.onEnd({element:t,state:this.state,box:this.box})}}const p=class{constructor(i){t(this,i),this.closedEvent=o(this,"dwc-dialog-closed",7),this.openedEvent=o(this,"dwc-dialog-opened",7),this.$lastActiveElement=null,this.animated=!1,this.oldPosx="",this.oldPosy="",this.oldMaxWidth="",this.oldMaxHeight="",this.wasMovable=!0,this.alignment="center",this.autofocus=!1,this.backdrop=!0,this.blurred=!1,this.breakpoint="",this.cancelOnEscKey=!0,this.cancelOnOutsideClick=!0,this.container=document.documentElement,this.fullscreen=!1,this.hoist=!0,this.moveable=!0,this.maxWidth="",this.maxHeight="",this.opened=!1,this.posx="",this.posy="",this.snapToEdge=!0,this.snapThreshold=0,this.theme="default"}onBreakpointChanged(t){this.msl&&this.msl.removeEventListener("change",this.handleBreakpointChange),t&&(this.msl=window.matchMedia(t),this.msl.addEventListener("change",this.handleBreakpointChange),this.handleBreakpointChange())}onMoveableChanged(t){this.switchDragging(t)}onOpenedChanged(){this.opened?this.doOpen():this.doClose()}onSnapToEdgeChanged(t){this.dragMoveInstance&&this.dragMoveInstance.updateOptions({parent:t?this.$modal:null})}onSnapThresholdChanged(t){this.dragMoveInstance&&this.dragMoveInstance.updateOptions({snapThreshold:t})}onStyleChanged(){this.updateStyle()}connectedCallback(){this.handleClick=this.handleClick.bind(this),this.handleSlotChange=this.handleSlotChange.bind(this),this.handleSectionScroll=this.handleSectionScroll.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleBreakpointChange=this.handleBreakpointChange.bind(this)}componentWillLoad(){this.onBreakpointChanged(this.breakpoint)}componentDidRender(){this.updateIsScrollable()}componentDidLoad(){null!=window.applyFocusVisiblePolyfill&&window.applyFocusVisiblePolyfill(this.el.shadowRoot),this.updateStyle(),this.switchDragging(this.moveable),this.updateIsScrollable(),this.opened&&this.doOpen()}handleKeyDown(t){!0===this.cancelOnEscKey&&"Escape"==t.key&&this.opened&&(this.close(),this.fireClosedEvent(n.ESCAPE),t.stopImmediatePropagation())}async open(){this.opened=!0}async close(){this.opened=!1}doOpen(){this.$lastActiveElement=r(document.activeElement),this.container.style.overflow="hidden",this.setCount(this.container,this.getCount(this.container)+1),this.listenToModalClick(!0),this.fireOpenedEvent()}doClose(t=n.API){if(this.animated=!1,this.setCount(this.container,Math.max(0,this.getCount(this.container)-1)),this.getCount(this.container)<=0&&(this.container.style.overflow=""),this.el.tabIndex=-1,null!=this.$lastActiveElement){this.$lastActiveElement.focus();try{this.$lastActiveElement.setFocus()}catch(t){}this.$lastActiveElement=null}this.fireClosedEvent(t),this.listenToModalClick(!1)}updateStyle(){const t=this.el.style;this.maxWidth&&t.setProperty("--_dwc-dialog-max-width",this.maxWidth),this.maxHeight&&t.setProperty("--_dwc-dialog-max-height",this.maxHeight),this.posx&&t.setProperty("--_dwc-dialog-posx",this.posx),this.posy&&t.setProperty("--_dwc-dialog-posy",this.posy)}switchDragging(t){if(t){if(!this.dragMoveInstance){let t=this.el.querySelector('[slot="header"]');t||(t=this.$dialog),this.dragMoveInstance=new c(this.$dialog,{handler:t,parent:this.snapToEdge?this.$modal:null,snapThreshold:this.snapThreshold,onStart:()=>{this.listenToModalClick(!1),this.el.setAttribute("data-moving","")},onMove:t=>{this.posx=t.box.left,this.posy=t.box.top,this.el.style.setProperty("--_dwc-dialog-bottom",t.box.bottom),this.el.style.setProperty("--_dwc-dialog-right",t.box.right)},onEnd:t=>{this.posx=t.box.left,this.posy=t.box.top,this.listenToModalClick(!0),this.el.removeAttribute("data-moving")}})}this.dragMoveInstance.enable()}else this.dragMoveInstance&&this.dragMoveInstance.disable()}listenToModalClick(t){t?this.$modal.addEventListener("click",this.handleClick):this.$modal.removeEventListener("click",this.handleClick)}updateIsScrollable(){this.$content&&i((()=>{h(this.$content)?this.el.setAttribute("data-scrollable",""):this.el.removeAttribute("data-scrollable")}))}getCount(t){return Number(t.getAttribute("data-dwc-dialog-count"))||0}setCount(t,o){t.setAttribute("data-dwc-dialog-count",o.toString())}fireOpenedEvent(){this.animated?(this.openedEvent.emit(),this.autofocus&&requestAnimationFrame((()=>{this.$focusTrap.focusFirstElement()}))):requestAnimationFrame((()=>{this.fireOpenedEvent()}))}fireClosedEvent(t=n.API){this.closedEvent.emit({reason:t})}handleClick(t){if(!0===this.cancelOnOutsideClick&&this.opened){const o=t.target;o.closest("[data-dialog-close]")?(t.preventDefault(),this.opened=!1,this.fireClosedEvent(n.OUTSIDE_CLICK)):o.isSameNode(this.$modal)&&(this.opened=!1,this.fireClosedEvent(n.OUTSIDE_CLICK))}}handleSlotChange(){const t=this.el.querySelector('[slot="content"]');t&&!t.isSameNode(this.$content)&&(this.$content=t,t.addEventListener("scroll",this.handleSectionScroll)),this.updateIsScrollable()}handleSectionScroll(){const t=this.el,o=this.$content,i=o.scrollHeight-o.scrollTop-10<=o.clientHeight;this.updateScrollAttribute(t,p.FROM_TOP_ATTR,o.scrollTop>0),this.updateScrollAttribute(t,p.TO_BOTTOM_ATTR,i)}updateScrollAttribute(t,o,i){i?t.hasAttribute(o)||t.setAttribute(o,""):t.hasAttribute(o)&&t.removeAttribute(o)}handleAnimationEnd(){this.animated=!0}handleBreakpointChange(){this.msl.matches?(this.wasMovable=this.moveable,this.oldPosx=this.posx,this.oldPosy=this.posy,this.oldMaxWidth=this.maxWidth,this.oldMaxHeight=this.maxHeight,this.moveable=!1,this.posx=null,this.posy=null,this.maxWidth=null,this.maxHeight=null,this.fullscreen=!0):(this.fullscreen=!1,this.moveable=this.wasMovable,this.oldPosx&&(this.posx=this.oldPosx),this.oldPosy&&(this.posy=this.oldPosy),this.oldMaxWidth&&(this.maxWidth=this.oldMaxWidth),this.oldMaxHeight&&(this.maxHeight=this.oldMaxHeight))}render(){return a(s,{key:"ea9dcb09ce3a094a3fe200f9c1f468c8e69ae45d","data-positioned":null!==this.posx||null!=this.posy,class:l({"bbj-opened":this.opened})},a("focus-trap",{key:"f85c05966783b771b827bb4f4625e5a643dff176",ref:t=>this.$focusTrap=t},a("div",{key:"ef07f7a7191aba7fc340831c2f955718fca0cad3",ref:t=>this.$modal=t,part:"modal"},a("div",{key:"3b813c9320d0c3b6002e44b2fc705a2a51a77e08",ref:t=>this.$dialog=t,part:"dialog",role:"dialog","aria-modal":"true","aria-hidden":this.opened?"false":"true","aria-labelledby":"header","aria-describedby":"content",onAnimationEnd:this.handleAnimationEnd},a("slot",{key:"72567d111dcc0e2a01a7808629e8cc61b0e86578",name:"header"}),a("slot",{key:"9109800c7b24783626e42e37dd992535852ad6ed",name:"content",onSlotchange:this.handleSlotChange}),a("slot",{key:"5aecbb10d3781358cf5f630856905e6efcb267de",name:"footer"})))))}get el(){return e(this)}static get watchers(){return{breakpoint:["onBreakpointChanged"],moveable:["onMoveableChanged"],opened:["onOpenedChanged"],snapToEdge:["onSnapToEdgeChanged"],snapThreshold:["onSnapThresholdChanged"],maxWidth:["onStyleChanged"],maxHeight:["onStyleChanged"],posx:["onStyleChanged"],posy:["onStyleChanged"]}}};p.FROM_TOP_ATTR="data-scrolled-from-top",p.TO_BOTTOM_ATTR="data-scrolled-to-bottom",function(t,o,i,a){var s,e=arguments.length,d=e<3?o:null===a?a=Object.getOwnPropertyDescriptor(o,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(t,o,i,a);else for(var h=t.length-1;h>=0;h--)(s=t[h])&&(d=(e<3?s(d):e>3?s(o,i,d):s(o,i))||d);e>3&&d&&Object.defineProperty(o,i,d)}([d.debounce(250,{trailing:!0})],p.prototype,"fireClosedEvent",null),p.style="@media (prefers-reduced-motion: reduce){*,::before,::after{animation-delay:-1ms !important;animation-duration:1ms !important;animation-iteration-count:1 !important;background-attachment:initial !important;scroll-behavior:auto !important;transition-delay:0s !important;transition-duration:0s !important}}:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:relative;-webkit-tap-highlight-color:transparent;text-size-adjust:100%}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{--_bd-width:var(--dwc-dialog-width, 100vw);--_bd-max-width:var(--dwc-dialog-max-width, var(--_dwc-dialog-max-width, 700px));--_bd-height:var(--dwc-dialog-height, auto);--_bd-max-height:var(--dwc-dialog-max-height, var(--_dwc-dialog-max-height, 85vh));--dwc-dialog-scroll-top-shadow:inset 0 7px 9px -7px rgba(0, 0, 0, 0.4);--dwc-dialog-scroll-bottom-shadow:inset 0 -7px 9px -7px rgba(0, 0, 0, 0.4);display:block;z-index:var(--dwc-dialog-zindex, var(--dwc-zindex-h1))}:host,[part=modal]{bottom:0;left:0;position:fixed;right:0;top:0}:host(:not([hoist])){--_bd-width:var(--dwc-dialog-width, 100%);--_bd-max-height:var(--dwc-dialog-max-height, 90%)}:host(:not([hoist])),:host(:not([hoist])) [part=modal]{position:absolute}:host(:not([opened])),:host(:not(.hydrated)),:host(:not(:defined)){display:none}[part=modal]{animation:modal var(--dwc-transition) ease-in-out both;box-sizing:border-box;display:flex;justify-content:center;opacity:0;overflow:hidden;padding:var(--dwc-dialog-modal-padding, 5vw 0);will-change:opacity, transform}:host([backdrop]) [part=modal]{background:var(--dwc-dialog-modal-background, var(--dwc-overlay-background))}:host([alignment=top]) [part=modal]{align-items:flex-start}:host([alignment=center]) [part=modal]{align-items:center}:host([alignment=bottom]) [part=modal]{align-items:flex-end}:host([snap-to-edge]:not([snap-to-edge=false])) [part=modal]{overflow:auto}:host([opened]) [part=modal]{opacity:1}:host([cancel-on-outside-click]) [part=modal]{cursor:var(--dwc-cursor-click)}:host([data-moving]) [part=modal]{cursor:var(--dwc-cursor-move);touch-action:none}:host([blurred]) [part=modal]{-webkit-backdrop-filter:blur(var(--dwc-dialog-modal-blur, 2px));backdrop-filter:blur(var(--dwc-dialog-modal-blur, 2px))}:host([fullscreen]) [part=modal]{align-items:unset;margin:0;padding:0}:host([fullscreen]) [part=modal] ::slotted([slot=content]){--dwc-fileopen-dialog-server-height:100%;height:100%;max-height:100%}:host([fullscreen]) [part=dialog]{height:calc(var(--dwc-vh) * 100);left:0;max-height:calc(var(--dwc-vh) * 100);max-width:calc(var(--dwc-vw) * 100);position:relative;top:0;width:calc(var(--dwc-vw) * 100)}[part=dialog]{animation:dialog var(--dwc-transition) ease-in-out both;background:var(--dwc-dialog-background, var(--dwc-surface-3));border:var(--dwc-dialog-border, thin solid var(--dwc-color-default));border-radius:var(--dwc-dialog-border-radius, max(0px, min(8px, (100vw - 4px - 100%) * 9999)));box-shadow:var(--dwc-dialog-shadow, var(--dwc-shadow-xl));box-sizing:border-box;color:var(--dwc-dialog-color, var(--dwc-color-body-text));cursor:auto;display:flex;flex-direction:column;height:var(--_bd-height);margin:0 auto;max-height:var(--_bd-max-height);max-width:var(--_bd-max-width);overflow:hidden;position:relative;width:var(--_bd-width);will-change:opacity, transform}[part=dialog][data-moving]{user-select:none}:host([opened]) [part=dialog]{transform:scale(1)}:host([fullscreen]) [part=dialog]{border:0}:host([data-positioned]) [part=dialog]{bottom:var(--_dwc-dialog-bottom) auto;left:var(--dwc-dialog-posx, var(--_dwc-dialog-posx, auto));position:absolute;right:var(--_dwc-dialog-right) auto;top:var(--dwc-dialog-posy, var(--_dwc-dialog-posy, auto))}::slotted([slot=content]),::slotted([slot=header]),::slotted([slot=footer]){padding:var(--dwc-dialog-padding, var(--dwc-space-m))}::slotted(.BBjSimpleWindow){padding:var(--dwc-dialog-padding, var(--dwc-space-m)) !important}::slotted([slot=header]),::slotted([slot=footer]){flex-shrink:0;user-select:none}::slotted([slot=header]){border-bottom:var(--dwc-border-width) solid var(--dwc-color-default);font-size:var(--dwc-font-size-xl);font-weight:var(--dwc-font-weight-semibold);list-style:var(--dwc-font-line-height-xl)}::slotted([slot=footer]){align-items:center;background-color:var(--dwc-surface-1);display:flex;gap:var(--dwc-space-s);justify-content:end}::slotted([slot=content]){flex-grow:1;height:var(--_bd-height);max-height:var(--_bd-max-height);-webkit-overflow-scrolling:touch;overflow-x:var(--dwc-dialog-overflow-x, hidden);overflow-y:var(--dwc-dialog-overflow-y, auto);overscroll-behavior:contain}:host([data-scrollable]) ::slotted([slot=content]){box-shadow:var(--dwc-dialog-scroll-bottom-shadow)}:host([data-scrolled-from-top]) ::slotted([slot=content]){box-shadow:var(--dwc-dialog-scroll-top-shadow), var(--dwc-dialog-scroll-bottom-shadow)}:host([data-scrolled-from-bottom]) ::slotted([slot=content]){box-shadow:var(--dwc-dialog-scroll-top-shadow)}:host([moveable]:not([moveable=false])) ::slotted([slot=header]){cursor:var(--dwc-cursor-move)}:host([type=msgbox]) ::slotted([slot=content]),:host([type=prompt]) ::slotted([slot=content]){align-items:flex-start;display:flex;gap:var(--dwc-space-m);overflow:auto}:host([type=prompt]) ::slotted([slot=content]){align-items:initial;flex-direction:column}:host([type=msgbox]) ::slotted([slot=footer]),:host([type=prompt]) ::slotted([slot=footer]){display:flex;flex-wrap:wrap;justify-content:flex-end}:host([type=fs-client]) ::slotted([slot=content]),:host([type=fs-server]) ::slotted([slot=content]),:host([type=fs-save]) ::slotted([slot=content]){padding:0}:host([type=fs-server]) ::slotted([slot=content]){height:var(--dwc-fileopen-dialog-server-height, 50vh)}@keyframes modal{0%{opacity:0;transform:translate3d(0, 0, 0);}100%{opacity:1;transform:translate3d(0, 0, 0)}}@keyframes dialog{0%{opacity:0;transform:scale(0.95) translateY(-30px) translate3d(0, 0, 0)}100%{opacity:1;transform:scale(1) translateY(0) translate3d(0, 0, 0)}}[part=modal] ::slotted([slot=header]){background:var(--dwc-dialog-header-background, var(--dwc-dialog-background, var(--dwc-surface-3)));color:var(--dwc-dialog-header-color, var(--dwc-dialog-color, var(--dwc-color-body-text)))}:host([theme=primary]){--dwc-dialog-header-color:var(--dwc-color-primary-text)}:host([theme=success]){--dwc-dialog-header-color:var(--dwc-color-success-text)}:host([theme=warning]){--dwc-dialog-header-color:var(--dwc-color-warning-text)}:host([theme=danger]){--dwc-dialog-header-color:var(--dwc-color-danger-text)}:host([theme=info]){--dwc-dialog-header-color:var(--dwc-color-info-text)}:host([theme=gray]){--dwc-dialog-header-color:var(--dwc-color-gray-text)}";export{p as dwc_dialog}