@ecopages/radiant-ui 0.1.0-rc.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/components/ui/autocomplete/autocomplete.css +1 -2
- package/dist/components/ui/avatar/avatar.css +10 -8
- package/dist/components/ui/avatar/avatar.d.ts +3 -1
- package/dist/components/ui/calendar/calendar.css +10 -5
- package/dist/components/ui/calendar/calendar.script.d.ts +1 -0
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +3 -3
- package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
- package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
- package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
- package/dist/components/ui/carousel/carousel.css +71 -18
- package/dist/components/ui/carousel/carousel.d.ts +1 -1
- package/dist/components/ui/carousel/carousel.script.d.ts +49 -21
- package/dist/components/ui/carousel/index.js +1 -1
- package/dist/components/ui/carousel/index.js.map +4 -4
- package/dist/components/ui/checkbox/checkbox.script.d.ts +0 -3
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/checkbox-group/checkbox-group.d.ts +0 -1
- package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +8 -7
- package/dist/components/ui/checkbox-group/index.js +1 -1
- package/dist/components/ui/checkbox-group/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +2 -2
- package/dist/components/ui/combobox/combobox.d.ts +1 -2
- package/dist/components/ui/combobox/combobox.script.d.ts +13 -6
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +4 -4
- package/dist/components/ui/cycle-toggle/index.js +1 -1
- package/dist/components/ui/cycle-toggle/index.js.map +3 -3
- package/dist/components/ui/date-field/date-field.css +13 -17
- package/dist/components/ui/date-field/date-field.d.ts +7 -5
- package/dist/components/ui/date-field/date-field.script.d.ts +16 -48
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +4 -4
- package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
- package/dist/components/ui/date-input/date-input.css +50 -0
- package/dist/components/ui/date-input/date-input.d.ts +8 -0
- package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
- package/dist/components/ui/date-input/index.d.ts +2 -0
- package/dist/components/ui/date-input/index.js +2 -0
- package/dist/components/ui/date-input/index.js.map +7 -0
- package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +8 -6
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +24 -47
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +4 -4
- package/dist/components/ui/dialog/dialog.css +18 -14
- package/dist/components/ui/dialog/dialog.script.d.ts +10 -3
- package/dist/components/ui/dialog/index.js +1 -1
- package/dist/components/ui/dialog/index.js.map +4 -4
- package/dist/components/ui/disclosure/disclosure.css +3 -6
- package/dist/components/ui/disclosure/disclosure.d.ts +15 -5
- package/dist/components/ui/disclosure/disclosure.script.d.ts +2 -2
- package/dist/components/ui/disclosure/index.d.ts +1 -1
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/field/field.d.ts +1 -1
- package/dist/components/ui/field/field.script.d.ts +27 -4
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +4 -4
- package/dist/components/ui/form/control-protocol.d.ts +38 -1
- package/dist/components/ui/form/form-context.d.ts +3 -0
- package/dist/components/ui/form/form.script.d.ts +7 -0
- package/dist/components/ui/form/index.d.ts +2 -1
- package/dist/components/ui/form/index.js +1 -1
- package/dist/components/ui/form/index.js.map +4 -4
- package/dist/components/ui/hover-card/hover-card.css +12 -101
- package/dist/components/ui/hover-card/hover-card.script.d.ts +7 -0
- package/dist/components/ui/hover-card/index.js +1 -1
- package/dist/components/ui/hover-card/index.js.map +4 -4
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- package/dist/components/ui/input/input.css +1 -1
- package/dist/components/ui/knob/index.js +1 -1
- package/dist/components/ui/knob/index.js.map +3 -3
- package/dist/components/ui/knob/knob.css +6 -1
- package/dist/components/ui/knob/knob.d.ts +1 -1
- package/dist/components/ui/knob/knob.script.d.ts +25 -10
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/listbox/index.js +1 -1
- package/dist/components/ui/listbox/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.d.ts +1 -2
- package/dist/components/ui/listbox/listbox.script.d.ts +7 -5
- package/dist/components/ui/menu-button/index.js +1 -1
- package/dist/components/ui/menu-button/index.js.map +4 -4
- package/dist/components/ui/menu-button/menu-button.script.d.ts +1 -1
- package/dist/components/ui/menubar/index.js +1 -1
- package/dist/components/ui/menubar/index.js.map +4 -4
- package/dist/components/ui/meter/index.js +1 -1
- package/dist/components/ui/meter/index.js.map +3 -3
- package/dist/components/ui/meter/meter.css +27 -2
- package/dist/components/ui/meter/meter.script.d.ts +14 -4
- package/dist/components/ui/navigation-menu/index.d.ts +1 -1
- package/dist/components/ui/navigation-menu/index.js +1 -1
- package/dist/components/ui/navigation-menu/index.js.map +4 -4
- package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +33 -4
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +71 -9
- package/dist/components/ui/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +4 -4
- package/dist/components/ui/number-field/number-field.css +1 -1
- package/dist/components/ui/number-field/number-field.d.ts +1 -1
- package/dist/components/ui/number-field/number-field.script.d.ts +7 -9
- package/dist/components/ui/pagination/index.d.ts +1 -1
- package/dist/components/ui/pagination/index.js +1 -1
- package/dist/components/ui/pagination/index.js.map +3 -3
- package/dist/components/ui/pagination/pagination.css +50 -13
- package/dist/components/ui/pagination/pagination.d.ts +25 -6
- package/dist/components/ui/popover/index.js +1 -1
- package/dist/components/ui/popover/index.js.map +4 -4
- package/dist/components/ui/popover/popover.script.d.ts +5 -0
- package/dist/components/ui/radio-group/index.js +1 -1
- package/dist/components/ui/radio-group/index.js.map +4 -4
- package/dist/components/ui/radio-group/radio-group.script.d.ts +2 -1
- package/dist/components/ui/select/index.d.ts +1 -1
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +4 -4
- package/dist/components/ui/select/select.css +4 -3
- package/dist/components/ui/select/select.d.ts +7 -5
- package/dist/components/ui/select/select.script.d.ts +32 -12
- package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
- package/dist/components/ui/shared/listbox-host-controller.d.ts +5 -4
- package/dist/components/ui/shared/multi-value.d.ts +18 -8
- package/dist/components/ui/shared/numeric-range.d.ts +8 -0
- package/dist/components/ui/shared/popover.css +10 -99
- package/dist/components/ui/sidebar/index.d.ts +2 -1
- package/dist/components/ui/sidebar/index.js +1 -1
- package/dist/components/ui/sidebar/index.js.map +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +42 -29
- package/dist/components/ui/sidebar/sidebar.css +67 -61
- package/dist/components/ui/sidebar/sidebar.d.ts +1 -7
- package/dist/components/ui/sidebar/sidebar.script.d.ts +12 -7
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +4 -4
- package/dist/components/ui/slider/slider.css +5 -5
- package/dist/components/ui/slider/slider.d.ts +5 -6
- package/dist/components/ui/slider/slider.script.d.ts +72 -29
- package/dist/components/ui/switch/index.js +1 -1
- package/dist/components/ui/switch/index.js.map +4 -4
- package/dist/components/ui/switch/switch.css +28 -22
- package/dist/components/ui/switch/switch.script.d.ts +10 -3
- package/dist/components/ui/table/index.js +1 -1
- package/dist/components/ui/table/index.js.map +4 -4
- package/dist/components/ui/table/table.d.ts +5 -3
- package/dist/components/ui/table/table.script.d.ts +25 -10
- package/dist/components/ui/tabs/tabs.css +18 -12
- package/dist/components/ui/tabs/tabs.script.d.ts +7 -0
- package/dist/components/ui/tag-group/index.js +1 -1
- package/dist/components/ui/tag-group/index.js.map +4 -4
- package/dist/components/ui/tag-group/tag-group.d.ts +7 -4
- package/dist/components/ui/tag-group/tag-group.script.d.ts +7 -5
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/components/ui/textarea/textarea.css +1 -1
- package/dist/components/ui/toast/index.js +1 -1
- package/dist/components/ui/toast/index.js.map +3 -3
- package/dist/components/ui/toast/toast.css +35 -32
- package/dist/components/ui/toast/toast.script.d.ts +2 -1
- package/dist/components/ui/toast/toaster.script.d.ts +6 -0
- package/dist/components/ui/tooltip/index.js +1 -1
- package/dist/components/ui/tooltip/index.js.map +4 -4
- package/dist/components/ui/tooltip/tooltip.css +14 -94
- package/dist/components/ui/tooltip/tooltip.script.d.ts +9 -1
- package/dist/components/ui/window-splitter/index.d.ts +1 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +3 -3
- package/dist/components/ui/window-splitter/window-splitter.d.ts +1 -1
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/icons/chevron-down.d.ts +0 -1
- package/dist/lib/intl-date/index.d.ts +4 -2
- package/dist/lib/intl-date/segment-editing.d.ts +34 -0
- package/dist/lib/intl-date/segments.d.ts +26 -4
- package/dist/lib/non-empty.d.ts +6 -0
- package/dist/lib/unique-id.d.ts +11 -0
- package/dist/lib/viewport/breakpoints.d.ts +6 -0
- package/dist/lib/viewport/mobile-layout.d.ts +15 -0
- package/dist/styles/primitives.css +10 -7
- package/dist/styles/radiant-ui-core.css +10 -0
- package/dist/styles/radiant-ui.css +40 -3
- package/dist/styles/style-dependencies.json +18 -6
- package/dist/styles/styles.css +456 -246
- package/dist/styles/tailwind.css +40 -93
- package/dist/styles/tokens/presets/colors/aurora.css +2 -0
- package/dist/styles/tokens/presets/colors/basalt.css +2 -0
- package/dist/styles/tokens/presets/colors/ember.css +2 -0
- package/dist/styles/tokens/presets/colors/glacier.css +2 -0
- package/dist/styles/tokens/semantic.css +1 -0
- package/dist/styles/tokens/system.css +11 -3
- package/dist/styles/tokens/typography/default.css +8 -0
- package/package.json +20 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as j,jsxs as oe}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as re,bound as Et,customElement as Ke,onEvent as ae,onUpdated as Ot,prop as L,query as Ge}from"@ecopages/radiant";function pt(...i){return i.filter(Boolean).join(" ")}import{jsx as Rt}from"@ecopages/jsx/jsx-runtime";function gt({class:i,size:t="sm",...e}){return Rt("svg",{...e,class:pt("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:Rt("path",{d:"m5 12 4 4L19 6"})})}import{jsx as Lt,jsxs as Fe}from"@ecopages/jsx/jsx-runtime";function ft({class:i,size:t="sm",...e}){return Fe("svg",{...e,class:pt("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Lt("path",{d:"m18 6-12 12"}),Lt("path",{d:"m6 6 12 12"})]})}var at="rui-toast-show",lt="rui-toast-dismiss",Ne=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"],ct=4e3,Tt=356,bt=14,_t=24,St=3,xt=3,ut=45,wt=200,ht="bottom-end";function K(i){let[t,e]=i.split("-");return{y:t,x:e}}var $e=1;function We(){return $e++}function kt(i,t){return typeof i=="function"?i(t):i}var It=class{subscribers=[];toasts=[];subscribe=t=>(this.subscribers.push(t),t(this.toasts),()=>{let e=this.subscribers.indexOf(t);e>=0&&this.subscribers.splice(e,1)});getSnapshot=()=>this.toasts;publish(){let t=this.toasts;for(let e of this.subscribers)e(t)}create=(t,e={})=>{let s=e.id??We(),a=e.dismissible??!0,h=this.toasts.findIndex(o=>o.id===s),p={id:s,title:t,description:e.description,variant:e.variant??"default",duration:e.duration,action:e.action,dismissible:a,closeButton:e.closeButton,position:e.position,delete:!1};return h>=0?this.toasts=this.toasts.map(o=>o.id===s?{...o,...p,delete:!1}:o):this.toasts=[p,...this.toasts],this.publish(),s};dismiss=t=>{if(t==null){if(this.toasts.length===0)return;this.toasts=this.toasts.map(e=>({...e,delete:!0}))}else{let e=this.toasts.find(s=>s.id===t);if(!e||e.delete)return;this.toasts=this.toasts.map(s=>s.id===t?{...s,delete:!0}:s)}this.publish()};remove=t=>{this.toasts=this.toasts.filter(e=>e.id!==t),this.publish()};clear=()=>{this.toasts.length!==0&&(this.toasts=[],this.publish())};message=(t,e)=>this.create(t,e);success=(t,e)=>this.create(t,{...e,variant:"success"});error=(t,e)=>this.create(t,{...e,variant:"error"});info=(t,e)=>this.create(t,{...e,variant:"info"});warning=(t,e)=>this.create(t,{...e,variant:"warning"});loading=(t,e)=>this.create(t,{...e,variant:"loading",duration:e?.duration??Number.POSITIVE_INFINITY});promise=(t,e)=>{let s=this.loading(e.loading,{duration:Number.POSITIVE_INFINITY,action:e.action,closeButton:e.closeButton,position:e.position,description:typeof e.description=="string"?e.description:void 0});return(typeof t=="function"?t():t).then(h=>{let p=typeof e.description=="function"?e.description(h):e.description;this.create(kt(e.success,h),{id:s,variant:"success",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}).catch(h=>{let p=typeof e.description=="function"?e.description(h):e.description;this.create(kt(e.error,h),{id:s,variant:"error",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}),s}},b=new It;var Ct,Mt,Vt,Bt,Ut,jt,Ht,Ft,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se;function qe(i,t,e,s,a,h){var p,o,I,k,f,c,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),F=Object.defineProperty,R=Object.create,$=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var T=0;T<n.length;T++)l=n[T].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,T,O,v,_,S,Z){function W(d){if(!Z(d))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(g[0]),tt=g[3],Y=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(d,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),u[d].call(U,rt)}}if(!Y){var u={},X=[],w=et?"get":it||A?"set":"value";if(_?(S||A?u={get:ne(function(){return tt(this)},r,"get"),set:function(d){g[4](this,d)}}:u[w]=tt,S||ne(u[w],r,M?"":w)):S||(u=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=$[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+u[w].name+") is not supported yet");$[+v][r]=l<3?1:l}}for(var m=n,B=q.length-1;B>=0;B-=y?2:1){var st=x(q[B],"A decorator","be",!0),nt=y?q[B-1]:void 0,z={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(d,P){if(d.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),T.push(P)}.bind(null,z)};if(Y)o=st.call(nt,m,D),z.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(d){return r in d}},it||(o.get=_?M?function(d){return W(d),u.value}:V("get",0,W):function(d){return d[r]}),M||et||(o.set=_?V("set",0,W):function(d,P){d[r]=P}),m=st.call(nt,A?{get:u.get,set:u.set}:u[w],D),z.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(u.get=o),(o=x(m.set,"accessor.set"))&&(u.set=o),(o=x(m.init,"accessor.init"))&&X.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?X.unshift(m):u[w]=m)}return l<2&&O.push(C(X,v,1),C(T,v,0)),S||Y||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?u[w]:x.call.bind(u[w])):F(n,r,u)),m}function Q(n){return F(n,H,{configurable:!0,enumerable:!0,value:p})}return h!==void 0&&(p=h[H]),p=R(p??null),f=[],c=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],T=7&l;if((8&l)==n&&!T==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:Ye(O),T,T<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return ze(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),c(I),c(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function Ye(i){var t=Xe(i,"string");return typeof t=="symbol"?t:t+""}function Xe(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function ne(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function ze(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}var dt=new Map,yt=new Map;function Pt(i){return String(i)}function mt(i){if(i==="")return;let t=Pt(i);dt.delete(t),yt.delete(t)}function Je(i){if(i==="")return;let t=Pt(i),e=dt.get(t);e!=null&&(yt.set(t,Math.max(0,e-Date.now())),dt.delete(t))}var ce,le=class extends re{static{({e:[Vt,Bt,Ut,jt,Ht,Ft,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se,Ct],c:[ce,Mt]}=qe(this,[Ke("rui-toast")],[[L({type:String,reflect:!0,defaultValue:""}),0,"toastId"],[L({type:String,defaultValue:""}),0,"title"],[L({type:String,defaultValue:""}),0,"description"],[L({type:String,reflect:!0,defaultValue:"default"}),0,"variant"],[L({type:Number,defaultValue:4e3}),0,"duration"],[L({type:Boolean,defaultValue:!0}),0,"dismissible"],[L({type:Boolean,defaultValue:!1}),0,"closeButton"],[L({type:String,defaultValue:""}),0,"actionLabel"],[L({type:String,defaultValue:ht}),0,"position"],[L({type:Boolean,defaultValue:!1}),0,"markedDelete"],[Ge({ref:"toast"}),0,"toastTarget"],[Ot("position"),2,"onPositionUpdated"],[Ot("duration"),2,"onDurationUpdated"],[Ot("markedDelete"),2,"onMarkedDeleteUpdated"],[Et,2,"onPointerDown"],[Et,2,"onPointerMove"],[Et,2,"onPointerUp"],[ae({selector:"[data-toast-close]",type:"click"}),2,"onCloseClick"],[ae({selector:"[data-toast-action]",type:"click"}),2,"onActionClick"]],0,void 0,re))}toastId=(Ct(this),Vt(this));title=(Bt(this),Ut(this));description=(jt(this),Ht(this));variant=(Ft(this),Nt(this));duration=($t(this),Wt(this));dismissible=(qt(this),Yt(this));closeButton=(Xt(this),zt(this));actionLabel=(Kt(this),Gt(this));position=(Jt(this),Qt(this));markedDelete=(Zt(this),te(this));toastTarget=(ee(this),ie(this));mounted=(se(this),!1);removed=!1;swiping=!1;swipeOut=!1;swipeAxis=null;swipeOutDirection=null;held=!1;timerReady=!1;timeoutId=null;pointerStart=null;dragStartTime=null;exitTimer=null;connectedCallback(){super.connectedCallback();let t=this.mounted;if(this.addEventListener("pointerdown",this.onPointerDown),this.addEventListener("pointermove",this.onPointerMove),this.addEventListener("pointerup",this.onPointerUp),this.addEventListener("pointercancel",this.onPointerUp),t){this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer();return}this.timerReady=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.isConnected&&(this.mounted=!0,this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer())})}),this.syncDomState()}disconnectedCallback(){this.clearTimer(),this.exitTimer&&(clearTimeout(this.exitTimer),this.exitTimer=null);let t=this.resolvedId;t!==""&&this.removed&&b.remove(t),this.held=!1,this.timerReady=!1,this.removeEventListener("pointerdown",this.onPointerDown),this.removeEventListener("pointermove",this.onPointerMove),this.removeEventListener("pointerup",this.onPointerUp),this.removeEventListener("pointercancel",this.onPointerUp),super.disconnectedCallback()}onPositionUpdated(){this.syncDomState()}setPaused(t){if(this.held===t){!t&&this.timerReady&&this.mounted&&!this.removed&&!this.timeoutId&&this.startTimer();return}this.held=t,!(!this.timerReady||!this.mounted||this.removed)&&(t||document.hidden?(Je(this.resolvedId),this.clearTimer()):this.startTimer())}onDurationUpdated(){!this.timerReady||!this.mounted||this.removed||this.held||(mt(this.resolvedId),this.startTimer())}onMarkedDeleteUpdated(){this.markedDelete&&!this.removed&&this.beginRemove()}get resolvedId(){let t=this.toastId;if(t==null||t==="")return"";let e=Number(t);return Number.isFinite(e)&&String(e)===t?e:t}clearTimer(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=null}startTimer(){if(this.held||this.removed||document.hidden||this.duration===Number.POSITIVE_INFINITY||this.variant==="loading")return;if(this.duration<=0){this.beginRemove();return}let t=this.resolvedId,e=Pt(t),s=Date.now(),a=yt.get(e);if(yt.delete(e),a==null){let h=dt.get(e);a=h!=null?h-s:this.duration}if(a<=0){mt(t),this.beginRemove();return}dt.set(e,s+a),this.clearTimer(),this.timeoutId=setTimeout(()=>{mt(t),this.beginRemove()},a)}beginRemove(){this.removed||(this.removed=!0,this.clearTimer(),mt(this.resolvedId),this.syncDomState(),this.markedDelete||b.dismiss(this.resolvedId),this.exitTimer=setTimeout(()=>{this.exitTimer=null,b.remove(this.resolvedId)},200))}onPointerDown(t){!this.dismissible||this.variant==="loading"||t.button!==0||t.target?.closest("[data-toast-close], [data-toast-action], button, a")||(this.dragStartTime=Date.now(),this.pointerStart={x:t.clientX,y:t.clientY},this.swipeAxis=null,this.setPointerCapture(t.pointerId))}onPointerMove(t){if(!this.pointerStart)return;let e={x:t.clientX-this.pointerStart.x,y:t.clientY-this.pointerStart.y};if(!this.startSwipe(e))return;this.swipeAxis??=Math.abs(e.x)>Math.abs(e.y)?"x":"y";let s=this.swipeAxis==="x"?{x:e.x,y:0}:{x:0,y:e.y};this.isSwipeReversing(s)?this.resetSwipeTranslation():this.setSwipeTranslation(s)}startSwipe(t){return this.swiping?!0:Math.abs(t.x)<8&&Math.abs(t.y)<8?!1:(this.swiping=!0,this.syncDomState(),!0)}isSwipeReversing(t){let{x:e,y:s}=K(this.position);return this.swipeAxis==="y"?(s==="bottom"?t.y<0:t.y>0)&&Math.abs(t.y)<45:e!=="center"&&(e==="start"?t.x>0:t.x<0)&&Math.abs(t.x)<45}setSwipeTranslation(t){this.style.setProperty("--swipe-amount-x",`${t.x}px`),this.style.setProperty("--swipe-amount-y",`${t.y}px`)}resetSwipeTranslation(){this.setSwipeTranslation({x:0,y:0})}onPointerUp(t){if(!this.pointerStart)return;this.releaseToastPointer(t.pointerId);let e=this.readSwipe();this.swiping=!1,e&&this.dismissible&&this.shouldDismissSwipe(e)?this.dismissFromSwipe(e):this.cancelSwipe(),this.clearPointerState()}releaseToastPointer(t){try{this.releasePointerCapture(t)}catch{}}readSwipe(){if(this.swiping)return{x:Number.parseFloat(this.style.getPropertyValue("--swipe-amount-x")||"0"),y:Number.parseFloat(this.style.getPropertyValue("--swipe-amount-y")||"0")}}shouldDismissSwipe(t){let e=this.swipeAxis==="x"?t.x:t.y,s=this.dragStartTime?Date.now()-this.dragStartTime:0;return Math.abs(e)>=45||Math.abs(e)/Math.max(s,1)>.11}dismissFromSwipe(t){let{x:e,y:s}=K(this.position);this.swipeOutDirection=this.swipeAxis==="y"?s==="bottom"?"down":"up":e==="start"?"left":e==="end"?"right":t.x<0?"left":"right",this.swipeOut=!0,this.syncDomState(),this.beginRemove()}cancelSwipe(){this.resetSwipeTranslation(),this.swipeAxis=null,this.syncDomState()}clearPointerState(){this.pointerStart=null,this.dragStartTime=null}onCloseClick(t){t.stopPropagation(),this.dismissible&&this.beginRemove()}onActionClick(t){t.stopPropagation(),b.getSnapshot().find(s=>s.id===this.resolvedId)?.action?.onClick(t),this.dismissible&&this.beginRemove()}syncDomState(){let{y:t,x:e}=K(this.position);this.setAttribute("role","listitem"),this.dataset.mounted=String(this.mounted),this.dataset.removed=String(this.removed),this.dataset.swiping=String(this.swiping),this.dataset.swipeOut=String(this.swipeOut),this.dataset.dismissible=String(this.dismissible),this.dataset.yPosition=t,this.dataset.xPosition=e,this.dataset.variant=this.variant??"default",this.swipeOutDirection?this.dataset.swipeDirection=this.swipeOutDirection:delete this.dataset.swipeDirection}iconForVariant(){switch(this.variant){case"success":return j(gt,{});case"error":return j(ft,{});case"warning":return"!";case"info":return"i";default:return""}}render(){let t=this.variant??"default",e=this.iconForVariant(),s=t!=="default";return oe("div",{ref:"toast",class:`rui-toast rui-toast--${t}`,role:"status","aria-live":"off","data-ref":"toast",children:[this.closeButton&&t!=="loading"?j("button",{type:"button",class:"rui-toast__close","data-toast-close":!0,"aria-label":"Close toast",children:j(ft,{})}):null,s?j("span",{class:"rui-toast__icon","data-icon":!0,"aria-hidden":"true",children:t==="loading"?j("span",{class:"rui-toast__loader"}):e}):null,oe("div",{class:"rui-toast__content",children:[j("div",{class:"rui-toast__title","data-title":!0,children:this.$.title}),this.description?j("div",{class:"rui-toast__description","data-description":!0,children:this.$.description}):null]}),this.actionLabel?j("button",{type:"button",class:"rui-toast__action rui-button rui-button--outline rui-button--sm","data-toast-action":!0,children:this.$.actionLabel}):null]})}static{Mt()}};import{jsx as At}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Ve,bound as vt,customElement as ii,onEvent as Dt,onUpdated as si,prop as N,query as ni,state as oi}from"@ecopages/radiant";function ue(i,t,e){let s=0;for(let a=0;a<i;a+=1)s+=t[a]??0;return s+i*e}function he(i,t){return i.length===0?0:i.reduce((s,a)=>s+a,0)+Math.max(0,i.length-1)*t}function de(i,t,e){return t<=0?0:i+Math.max(0,t-1)*e}var pe,fe,me,ye,ve,ge,Te,be,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce;function Qe(i,t,e,s,a,h){var p,o,I,k,f,c,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),F=Object.defineProperty,R=Object.create,$=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var T=0;T<n.length;T++)l=n[T].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,T,O,v,_,S,Z){function W(d){if(!Z(d))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(g[0]),tt=g[3],Y=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(d,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),u[d].call(U,rt)}}if(!Y){var u={},X=[],w=et?"get":it||A?"set":"value";if(_?(S||A?u={get:Me(function(){return tt(this)},r,"get"),set:function(d){g[4](this,d)}}:u[w]=tt,S||Me(u[w],r,M?"":w)):S||(u=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=$[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+u[w].name+") is not supported yet");$[+v][r]=l<3?1:l}}for(var m=n,B=q.length-1;B>=0;B-=y?2:1){var st=x(q[B],"A decorator","be",!0),nt=y?q[B-1]:void 0,z={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(d,P){if(d.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),T.push(P)}.bind(null,z)};if(Y)o=st.call(nt,m,D),z.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(d){return r in d}},it||(o.get=_?M?function(d){return W(d),u.value}:V("get",0,W):function(d){return d[r]}),M||et||(o.set=_?V("set",0,W):function(d,P){d[r]=P}),m=st.call(nt,A?{get:u.get,set:u.set}:u[w],D),z.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(u.get=o),(o=x(m.set,"accessor.set"))&&(u.set=o),(o=x(m.init,"accessor.init"))&&X.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?X.unshift(m):u[w]=m)}return l<2&&O.push(C(X,v,1),C(T,v,0)),S||Y||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?u[w]:x.call.bind(u[w])):F(n,r,u)),m}function Q(n){return F(n,H,{configurable:!0,enumerable:!0,value:p})}return h!==void 0&&(p=h[H]),p=R(p??null),f=[],c=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],T=7&l;if((8&l)==n&&!T==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:Ze(O),T,T<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return ei(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),c(I),c(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function Ze(i){var t=ti(i,"string");return typeof t=="symbol"?t:t+""}function ti(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Me(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function ei(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}function Be(i,t){return i instanceof Node&&t.contains(i)}var je,Ue=class extends Ve{static{({e:[me,ye,ve,ge,Te,be,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce,pe],c:[je,fe]}=Qe(this,[ii("rui-toaster")],[[N({type:String,reflect:!0,defaultValue:ht}),0,"position"],[N({type:Number,defaultValue:4e3}),0,"duration"],[N({type:Number,defaultValue:3}),0,"visibleToasts"],[N({type:Boolean,defaultValue:!1}),0,"closeButton"],[N({type:Boolean,defaultValue:!1}),0,"expand"],[N({type:Number,defaultValue:14}),0,"gap"],[N({type:Number,defaultValue:24}),0,"offset"],[N({type:String,reflect:!0,defaultValue:""}),0,"container"],[ni({ref:"list"}),0,"listTarget"],[oi,0,"toasts"],[si(["position","duration","visibleToasts","closeButton","expand","gap","offset","container"]),2,"onConfigUpdated"],[Dt({document:!0,type:at}),2,"onDocumentShow"],[Dt({document:!0,type:lt}),2,"onDocumentDismiss"],[Dt({selector:"rui-toast",type:"rui-toast-mounted"}),2,"onToastMounted"],[vt,2,"onPointerOver"],[vt,2,"onPointerOut"],[vt,2,"onPointerDown"],[vt,2,"onPointerUp"]],0,void 0,Ve))}position=(pe(this),me(this));duration=(ye(this),ve(this));visibleToasts=(ge(this),Te(this));closeButton=(be(this),_e(this));expand=(Se(this),xe(this));gap=(we(this),Ie(this));offset=(Ee(this),Oe(this));container=(Pe(this),Ae(this));listTarget=(De(this),Re(this));toasts=(Le(this),ke(this,[]));expanded=(Ce(this),!1);interacting=!1;unsubscribe=null;visibilityHandler=null;heights=new Map;observers=new Map;layoutFrame=null;measuring=!1;connectedCallback(){super.connectedCallback(),this.syncHostPosition(),this.syncContainer(),this.unsubscribe=b.subscribe(t=>{this.toasts=t,t.length===0&&this.resetLayoutState(),this.scheduleLayoutSync()}),this.visibilityHandler=()=>this.syncPauseState(),document.addEventListener("visibilitychange",this.visibilityHandler)}disconnectedCallback(){this.unsubscribe?.(),this.unsubscribe=null,this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerUp),this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.resetLayoutState(),super.disconnectedCallback()}onConfigUpdated(){this.syncHostPosition(),this.syncContainer(),this.scheduleLayoutSync()}onDocumentShow(t){let e=t.detail;e?.title&&b.create(e.title,{id:e.id,description:e.description,variant:e.variant,duration:e.duration,action:e.action,dismissible:e.dismissible,closeButton:e.closeButton,position:e.position})}onDocumentDismiss(t){let e=t.detail;b.dismiss(e?.id)}onToastMounted(){this.scheduleLayoutSync()}filteredToasts(){let t=this.toasts.filter(a=>(a.position??this.position)===this.position),e=[],s=[];for(let a of t)a.delete?s.push(a):e.push(a);return[...e.slice(0,this.visibleToasts),...s]}syncHostPosition(){let{y:t,x:e}=K(this.position);this.dataset.yPosition=t,this.dataset.xPosition=e,this.style.setProperty("--width",`${356}px`),this.style.setProperty("--gap",`${this.gap}px`),this.style.setProperty("--viewport-offset",`${this.offset}px`)}syncContainer(){let t=this.container.trim();if(!t){this.removeAttribute("data-contained"),this.style.position="";return}let e=this.closest(t)??document.querySelector(t);if(!e){this.removeAttribute("data-contained"),this.style.position="";return}getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.contains(this)||e.appendChild(this),this.dataset.contained="true",this.style.position="absolute"}isStackExpanded(){return this.expanded||this.expand}isPaused(){return this.expanded||this.interacting||document.hidden}resetLayoutState(){for(let e of this.observers.values())e.disconnect();this.observers.clear(),this.heights.clear(),this.expanded=!1,this.interacting=!1;let t=this.listTarget;t&&(t.style.height="0px",t.dataset.expanded="false"),this.dataset.expanded="false"}syncPauseState(){let t=this.isPaused();for(let e of this.querySelectorAll("rui-toast"))e.setPaused(t);this.patchStackLayout()}scheduleLayoutSync(){this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame(()=>{if(this.layoutFrame=null,this.toasts.length>0&&!this.interacting){let e=!!(this.listTarget?.matches(":hover")||this.matches(":hover"));this.expanded=e}this.observeToasts(),this.syncPauseState()})}measureToast(t){this.measuring=!0;let e=t.style.height,s=t.style.overflow;t.style.height="auto",t.style.overflow="visible";let a=t.getRef("toast"),h=Math.round(a instanceof HTMLElement?a.offsetHeight:t.offsetHeight)||64;return t.style.height=e,t.style.overflow=s,this.measuring=!1,h}observeToasts(){let t=this.listTarget;if(!t)return;let e=[...t.querySelectorAll("rui-toast")],s=new Set;for(let a of e){let h=a.toastId;if(!h)continue;s.add(h);let p=a.getRef("toast")??a;if(!this.observers.has(h)){let o=new ResizeObserver(()=>{if(this.measuring)return;let I=this.measureToast(a);this.heights.get(h)!==I&&(this.heights.set(h,I),this.patchStackLayout())});o.observe(p),this.observers.set(h,o)}this.heights.set(h,this.measureToast(a))}for(let[a,h]of[...this.observers])s.has(a)||(h.disconnect(),this.observers.delete(a),this.heights.delete(a))}patchStackLayout(){let t=this.listTarget;if(!t)return;let e=this.isStackExpanded(),{y:s}=K(this.position),a=s==="bottom"?-1:1,h=Math.min(3,Math.max(1,this.visibleToasts));this.dataset.expanded=String(e),t.dataset.expanded=String(e),this.style.setProperty("--lift",String(a)),t.style.setProperty("--gap",`${this.gap}px`);let p=[...t.querySelectorAll("rui-toast")].filter(f=>f.dataset.mounted==="true"&&f.dataset.removed!=="true");if(p.length===0){t.style.height="0px";return}let o=p.map(f=>{let c=this.measureToast(f);return this.heights.set(f.toastId,c),c}),I=o[0]??64;this.style.setProperty("--front-toast-height",`${I}px`);for(let f=0;f<p.length;f+=1){let c=p[f];if(!c)continue;let E=o[f]??64,H=f===0,F=ue(f,o,this.gap),R=f<h;if(c.dataset.index=String(f),c.dataset.front=String(H),c.dataset.expanded=String(e),c.dataset.visible=String(e||R),c.style.setProperty("--z-index",String(p.length-f)),c.style.setProperty("--index",String(f)),c.style.setProperty("--offset",`${F}px`),c.style.setProperty("--initial-height",`${E}px`),c.style.setProperty("--gap",`${this.gap}px`),e)c.style.setProperty("--y",`translateY(${a*F}px)`),c.style.height=`${E}px`,c.style.overflow="visible";else if(!R)c.style.setProperty("--y",`translateY(${a*(h-1)*this.gap}px) scale(0.7)`),c.style.height=`${I}px`,c.style.overflow="hidden";else if(H)c.style.setProperty("--y","translateY(0px)"),c.style.height=`${E}px`,c.style.overflow="visible";else{let $=Math.max(.7,1-f*.05);c.style.setProperty("--y",`translateY(${a*f*this.gap}px) scale(${$})`),c.style.height=`${I}px`,c.style.overflow="hidden"}}let k=Math.min(h,p.length);t.style.height=`${e?he(o,this.gap):de(I,k,this.gap)}px`}onPointerOver(t){Be(t.relatedTarget,this)||(this.expanded=!0,this.syncPauseState())}onPointerOut(t){Be(t.relatedTarget,this)||this.interacting||(this.expanded=!1,this.syncPauseState())}onPointerDown(){this.interacting=!0,this.expanded=!0,this.syncPauseState(),document.addEventListener("pointerup",this.onPointerUp,{once:!0}),document.addEventListener("pointercancel",this.onPointerUp,{once:!0})}onPointerUp(){if(!this.interacting)return;this.interacting=!1,this.listTarget?.matches(":hover")||this.querySelector("rui-toast:hover")||(this.expanded=!1),this.syncPauseState()}render(){let t=this.filteredToasts();return At("section",{class:"rui-toaster-region","aria-label":"Notifications","aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",tabIndex:-1,children:At("ol",{class:"rui-toaster","data-ref":"list","data-rui-toaster":!0,"on:pointerover":this.onPointerOver,"on:pointerout":this.onPointerOut,"on:pointerdown":this.onPointerDown,children:t.map(e=>{let s=e.duration??(e.variant==="loading"?Number.POSITIVE_INFINITY:this.duration);return At("rui-toast",{"prop:toastId":String(e.id),"prop:title":e.title,"prop:description":e.description??"","prop:variant":e.variant,"prop:duration":s,"prop:dismissible":e.dismissible,"prop:closeButton":e.closeButton??this.closeButton,"prop:actionLabel":e.action?.label??"","prop:position":e.position??this.position,"prop:markedDelete":!!e.delete},String(e.id))})})})}static{fe()}};import{jsx as He}from"@ecopages/jsx/jsx-runtime";function ri({toastId:i,...t}){return He("rui-toast",{...t,toastId:i!=null?String(i):void 0})}function ai({children:i,...t}){return He("rui-toaster",{...t,children:i})}var li=Object.assign((i,t)=>b.create(i,t),{message:(i,t)=>b.message(i,t),success:(i,t)=>b.success(i,t),error:(i,t)=>b.error(i,t),info:(i,t)=>b.info(i,t),warning:(i,t)=>b.warning(i,t),loading:(i,t)=>b.loading(i,t),promise:(i,t)=>b.promise(i,t),dismiss:i=>b.dismiss(i),clear:()=>b.clear()});function ci(i){document.dispatchEvent(new CustomEvent(at,{detail:i,bubbles:!0,composed:!0}))}function ui(i){let t=i==null?{}:{id:i};document.dispatchEvent(new CustomEvent(lt,{detail:t,bubbles:!0,composed:!0}))}export{ht as DEFAULT_TOAST_POSITION,lt as RUI_TOAST_DISMISS_EVENT,at as RUI_TOAST_SHOW_EVENT,ri as RuiToast,ce as RuiToastElement,ai as RuiToaster,je as RuiToasterElement,xt as TOAST_COLLAPSED_PEEK,wt as TOAST_EXIT_MS,bt as TOAST_GAP,ct as TOAST_LIFETIME,Ne as TOAST_POSITIONS,ut as TOAST_SWIPE_THRESHOLD,_t as TOAST_VIEWPORT_OFFSET,St as TOAST_VISIBLE_AMOUNT,Tt as TOAST_WIDTH,ui as dismissToast,ci as showToast,li as toast};
|
|
1
|
+
import{jsx as F,jsxs as oe}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as re,bindTo as It,bound as Et,customElement as Ge,onEvent as ae,onUpdated as Ot,prop as L,query as Je}from"@ecopages/radiant";function pt(...i){return i.filter(Boolean).join(" ")}import{jsx as Rt}from"@ecopages/jsx/jsx-runtime";function gt({class:i,size:t="sm",...e}){return Rt("svg",{...e,class:pt("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:Rt("path",{d:"m5 12 4 4L19 6"})})}import{jsx as Lt,jsxs as He}from"@ecopages/jsx/jsx-runtime";function ft({class:i,size:t="sm",...e}){return He("svg",{...e,class:pt("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Lt("path",{d:"m18 6-12 12"}),Lt("path",{d:"m6 6 12 12"})]})}var at="rui-toast-show",lt="rui-toast-dismiss",Ne=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"],ut=4e3,$e=356,bt=14,Tt=24,_t=3,St=3,ct=45,xt=200,dt="bottom-end";function j(i){let[t,e]=i.split("-");return{y:t,x:e}}var We=1;function qe(){return We++}function kt(i,t){return typeof i=="function"?i(t):i}var wt=class{subscribers=[];toasts=[];subscribe=t=>(this.subscribers.push(t),t(this.toasts),()=>{let e=this.subscribers.indexOf(t);e>=0&&this.subscribers.splice(e,1)});getSnapshot=()=>this.toasts;publish(){let t=this.toasts;for(let e of this.subscribers)e(t)}create=(t,e={})=>{let s=e.id??qe(),a=e.dismissible??!0,d=this.toasts.findIndex(o=>o.id===s),p={id:s,title:t,description:e.description,variant:e.variant??"default",duration:e.duration,action:e.action,dismissible:a,closeButton:e.closeButton,position:e.position,delete:!1};return d>=0?this.toasts=this.toasts.map(o=>o.id===s?{...o,...p,delete:!1}:o):this.toasts=[p,...this.toasts],this.publish(),s};dismiss=t=>{if(t==null){if(this.toasts.length===0)return;this.toasts=this.toasts.map(e=>({...e,delete:!0}))}else{let e=this.toasts.find(s=>s.id===t);if(!e||e.delete)return;this.toasts=this.toasts.map(s=>s.id===t?{...s,delete:!0}:s)}this.publish()};remove=t=>{this.toasts=this.toasts.filter(e=>e.id!==t),this.publish()};clear=()=>{this.toasts.length!==0&&(this.toasts=[],this.publish())};message=(t,e)=>this.create(t,e);success=(t,e)=>this.create(t,{...e,variant:"success"});error=(t,e)=>this.create(t,{...e,variant:"error"});info=(t,e)=>this.create(t,{...e,variant:"info"});warning=(t,e)=>this.create(t,{...e,variant:"warning"});loading=(t,e)=>this.create(t,{...e,variant:"loading",duration:e?.duration??Number.POSITIVE_INFINITY});promise=(t,e)=>{let s=this.loading(e.loading,{duration:Number.POSITIVE_INFINITY,action:e.action,closeButton:e.closeButton,position:e.position,description:typeof e.description=="string"?e.description:void 0});return(typeof t=="function"?t():t).then(d=>{let p=typeof e.description=="function"?e.description(d):e.description;this.create(kt(e.success,d),{id:s,variant:"success",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}).catch(d=>{let p=typeof e.description=="function"?e.description(d):e.description;this.create(kt(e.error,d),{id:s,variant:"error",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}),s}},T=new wt;var Ct,Mt,Vt,Bt,Ut,jt,Ft,Ht,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se;function Ye(i,t,e,s,a,d){var p,o,I,k,f,u,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),N=Object.defineProperty,R=Object.create,W=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,b,O,v,_,S,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var Y=[].concat(g[0]),tt=g[3],X=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(h,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),c[h].call(U,rt)}}if(!X){var c={},z=[],w=et?"get":it||A?"set":"value";if(_?(S||A?c={get:ne(function(){return tt(this)},r,"get"),set:function(h){g[4](this,h)}}:c[w]=tt,S||ne(c[w],r,M?"":w)):S||(c=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=W[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");W[+v][r]=l<3?1:l}}for(var m=n,B=Y.length-1;B>=0;B-=y?2:1){var st=x(Y[B],"A decorator","be",!0),nt=y?Y[B-1]:void 0,K={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,K)};if(X)o=st.call(nt,m,D),K.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(h){return r in h}},it||(o.get=_?M?function(h){return q(h),c.value}:V("get",0,q):function(h){return h[r]}),M||et||(o.set=_?V("set",0,q):function(h,P){h[r]=P}),m=st.call(nt,A?{get:c.get,set:c.set}:c[w],D),K.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&z.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?z.unshift(m):c[w]=m)}return l<2&&O.push(C(z,v,1),C(b,v,0)),S||X||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?c[w]:x.call.bind(c[w])):N(n,r,c)),m}function Q(n){return N(n,H,{configurable:!0,enumerable:!0,value:p})}return d!==void 0&&(p=d[H]),p=R(p??null),f=[],u=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:Xe(O),b,b<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return Ke(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function Xe(i){var t=ze(i,"string");return typeof t=="symbol"?t:t+""}function ze(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function ne(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function Ke(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}var ht=new Map,yt=new Map;function Pt(i){return String(i)}function mt(i){if(i==="")return;let t=Pt(i);ht.delete(t),yt.delete(t)}function Qe(i){if(i==="")return;let t=Pt(i),e=ht.get(t);e!=null&&(yt.set(t,Math.max(0,e-Date.now())),ht.delete(t))}var ue,le=class extends re{static{({e:[Vt,Bt,Ut,jt,Ft,Ht,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se,Ct],c:[ue,Mt]}=Ye(this,[Ge("rui-toast")],[[L({type:String,reflect:!0,defaultValue:""}),0,"toastId"],[L({type:String,defaultValue:""}),0,"title"],[L({type:String,defaultValue:""}),0,"description"],[[L({type:String,reflect:!0,defaultValue:"default"}),It({attr:"data-variant",map:t=>t??"default"})],0,"variant"],[L({type:Number,defaultValue:4e3}),0,"duration"],[[L({type:Boolean,defaultValue:!0}),It({attr:"data-dismissible"})],0,"dismissible"],[L({type:Boolean,defaultValue:!1}),0,"closeButton"],[L({type:String,defaultValue:""}),0,"actionLabel"],[[L({type:String,defaultValue:dt}),It([{attr:"data-y-position",map:t=>j(t).y},{attr:"data-x-position",map:t=>j(t).x}])],0,"position"],[L({type:Boolean,defaultValue:!1}),0,"markedDelete"],[Je({ref:"toast"}),0,"toastTarget"],[Ot("position"),2,"onPositionUpdated"],[Ot("duration"),2,"onDurationUpdated"],[Ot("markedDelete"),2,"onMarkedDeleteUpdated"],[Et,2,"onPointerDown"],[Et,2,"onPointerMove"],[Et,2,"onPointerUp"],[ae({selector:"[data-toast-close]",type:"click"}),2,"onCloseClick"],[ae({selector:"[data-toast-action]",type:"click"}),2,"onActionClick"]],0,void 0,re))}toastId=(Ct(this),Vt(this));title=(Bt(this),Ut(this));description=(jt(this),Ft(this));variant=(Ht(this),Nt(this));duration=($t(this),Wt(this));dismissible=(qt(this),Yt(this));closeButton=(Xt(this),zt(this));actionLabel=(Kt(this),Gt(this));position=(Jt(this),Qt(this));markedDelete=(Zt(this),te(this));toastTarget=(ee(this),ie(this));mounted=(se(this),!1);removed=!1;swiping=!1;swipeOut=!1;swipeAxis=null;swipeOutDirection=null;held=!1;timerReady=!1;timeoutId=null;pointerStart=null;dragStartTime=null;exitTimer=null;connectedCallback(){super.connectedCallback();let t=this.mounted;if(this.addEventListener("pointerdown",this.onPointerDown),this.addEventListener("pointermove",this.onPointerMove),this.addEventListener("pointerup",this.onPointerUp),this.addEventListener("pointercancel",this.onPointerUp),t){this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer();return}this.timerReady=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.isConnected&&(this.mounted=!0,this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer())})}),this.syncDomState()}disconnectedCallback(){this.clearTimer(),this.exitTimer&&(clearTimeout(this.exitTimer),this.exitTimer=null);let t=this.resolvedId;t!==""&&this.removed&&T.remove(t),this.held=!1,this.timerReady=!1,this.removeEventListener("pointerdown",this.onPointerDown),this.removeEventListener("pointermove",this.onPointerMove),this.removeEventListener("pointerup",this.onPointerUp),this.removeEventListener("pointercancel",this.onPointerUp),super.disconnectedCallback()}onPositionUpdated(){this.syncDomState()}setPaused(t){if(this.held===t){!t&&this.timerReady&&this.mounted&&!this.removed&&!this.timeoutId&&this.startTimer();return}this.held=t,!(!this.timerReady||!this.mounted||this.removed)&&(t||document.hidden?(Qe(this.resolvedId),this.clearTimer()):this.startTimer())}onDurationUpdated(){!this.timerReady||!this.mounted||this.removed||this.held||(mt(this.resolvedId),this.startTimer())}onMarkedDeleteUpdated(){this.markedDelete&&!this.removed&&this.beginRemove()}get resolvedId(){let t=this.toastId;if(t==null||t==="")return"";let e=Number(t);return Number.isFinite(e)&&String(e)===t?e:t}clearTimer(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=null}startTimer(){if(this.held||this.removed||document.hidden||this.duration===Number.POSITIVE_INFINITY||this.variant==="loading")return;if(this.duration<=0){this.beginRemove();return}let t=this.resolvedId,e=Pt(t),s=Date.now(),a=yt.get(e);if(yt.delete(e),a==null){let d=ht.get(e);a=d!=null?d-s:this.duration}if(a<=0){mt(t),this.beginRemove();return}ht.set(e,s+a),this.clearTimer(),this.timeoutId=setTimeout(()=>{mt(t),this.beginRemove()},a)}beginRemove(){this.removed||(this.removed=!0,this.clearTimer(),mt(this.resolvedId),this.syncDomState(),this.markedDelete||T.dismiss(this.resolvedId),this.exitTimer=setTimeout(()=>{this.exitTimer=null,T.remove(this.resolvedId)},200))}onPointerDown(t){!this.dismissible||this.variant==="loading"||t.button!==0||t.target?.closest("[data-toast-close], [data-toast-action], button, a")||(this.dragStartTime=Date.now(),this.pointerStart={x:t.clientX,y:t.clientY},this.swipeAxis=null,this.setPointerCapture(t.pointerId))}onPointerMove(t){if(!this.pointerStart)return;let e={x:t.clientX-this.pointerStart.x,y:t.clientY-this.pointerStart.y};if(!this.startSwipe(e))return;this.swipeAxis??=Math.abs(e.x)>Math.abs(e.y)?"x":"y";let s=this.swipeAxis==="x"?{x:e.x,y:0}:{x:0,y:e.y};this.isSwipeReversing(s)?this.resetSwipeTranslation():this.setSwipeTranslation(s)}startSwipe(t){return this.swiping?!0:Math.abs(t.x)<8&&Math.abs(t.y)<8?!1:(this.swiping=!0,this.syncDomState(),!0)}isSwipeReversing(t){let{x:e,y:s}=j(this.position);return this.swipeAxis==="y"?(s==="bottom"?t.y<0:t.y>0)&&Math.abs(t.y)<45:e!=="center"&&(e==="start"?t.x>0:t.x<0)&&Math.abs(t.x)<45}setSwipeTranslation(t){this.style.setProperty("--rui-toast-swipe-x",`${t.x}px`),this.style.setProperty("--rui-toast-swipe-y",`${t.y}px`)}resetSwipeTranslation(){this.setSwipeTranslation({x:0,y:0})}onPointerUp(t){if(!this.pointerStart)return;this.releaseToastPointer(t.pointerId);let e=this.readSwipe();this.swiping=!1,e&&this.dismissible&&this.shouldDismissSwipe(e)?this.dismissFromSwipe(e):this.cancelSwipe(),this.clearPointerState()}releaseToastPointer(t){try{this.releasePointerCapture(t)}catch{}}readSwipe(){if(this.swiping)return{x:Number.parseFloat(this.style.getPropertyValue("--rui-toast-swipe-x")||"0"),y:Number.parseFloat(this.style.getPropertyValue("--rui-toast-swipe-y")||"0")}}shouldDismissSwipe(t){let e=this.swipeAxis==="x"?t.x:t.y,s=this.dragStartTime?Date.now()-this.dragStartTime:0;return Math.abs(e)>=45||Math.abs(e)/Math.max(s,1)>.11}dismissFromSwipe(t){let{x:e,y:s}=j(this.position);this.swipeOutDirection=this.swipeAxis==="y"?s==="bottom"?"down":"up":e==="start"?"left":e==="end"?"right":t.x<0?"left":"right",this.swipeOut=!0,this.syncDomState(),this.beginRemove()}cancelSwipe(){this.resetSwipeTranslation(),this.swipeAxis=null,this.syncDomState()}clearPointerState(){this.pointerStart=null,this.dragStartTime=null}onCloseClick(t){t.stopPropagation(),this.dismissible&&this.beginRemove()}onActionClick(t){t.stopPropagation(),T.getSnapshot().find(s=>s.id===this.resolvedId)?.action?.onClick(t),this.dismissible&&this.beginRemove()}syncDomState(){this.setAttribute("role","listitem"),this.dataset.mounted=String(this.mounted),this.dataset.removed=String(this.removed),this.dataset.swiping=String(this.swiping),this.dataset.swipeOut=String(this.swipeOut),this.swipeOutDirection?this.dataset.swipeDirection=this.swipeOutDirection:delete this.dataset.swipeDirection}iconForVariant(){switch(this.variant){case"success":return F(gt,{});case"error":return F(ft,{});case"warning":return"!";case"info":return"i";default:return""}}render(){let t=this.variant??"default",e=this.iconForVariant(),s=t!=="default";return oe("div",{ref:"toast",class:`rui-toast rui-toast--${t}`,role:"status","aria-live":"off","data-ref":"toast",children:[this.closeButton&&t!=="loading"?F("button",{type:"button",class:"rui-toast__close","data-toast-close":!0,"aria-label":"Close toast",children:F(ft,{})}):null,s?F("span",{class:"rui-toast__icon","data-icon":!0,"aria-hidden":"true",children:t==="loading"?F("span",{class:"rui-toast__loader"}):e}):null,oe("div",{class:"rui-toast__content",children:[F("div",{class:"rui-toast__title","data-title":!0,children:this.$.title}),this.description?F("div",{class:"rui-toast__description","data-description":!0,children:this.$.description}):null]}),this.actionLabel?F("button",{type:"button",class:"rui-toast__action rui-button rui-button--outline rui-button--sm","data-toast-action":!0,children:this.$.actionLabel}):null]})}static{Mt()}};import{jsx as At}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Ve,bindTo as si,bound as vt,customElement as ni,onEvent as Dt,onUpdated as oi,prop as $,query as ri,state as ai}from"@ecopages/radiant";function ce(i,t,e){let s=0;for(let a=0;a<i;a+=1)s+=t[a]??0;return s+i*e}function de(i,t){return i.length===0?0:i.reduce((s,a)=>s+a,0)+Math.max(0,i.length-1)*t}function he(i,t,e){return t<=0?0:i+Math.max(0,t-1)*e}var pe,fe,me,ye,ve,ge,be,Te,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce;function Ze(i,t,e,s,a,d){var p,o,I,k,f,u,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),N=Object.defineProperty,R=Object.create,W=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,b,O,v,_,S,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var Y=[].concat(g[0]),tt=g[3],X=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(h,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),c[h].call(U,rt)}}if(!X){var c={},z=[],w=et?"get":it||A?"set":"value";if(_?(S||A?c={get:Me(function(){return tt(this)},r,"get"),set:function(h){g[4](this,h)}}:c[w]=tt,S||Me(c[w],r,M?"":w)):S||(c=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=W[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");W[+v][r]=l<3?1:l}}for(var m=n,B=Y.length-1;B>=0;B-=y?2:1){var st=x(Y[B],"A decorator","be",!0),nt=y?Y[B-1]:void 0,K={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,K)};if(X)o=st.call(nt,m,D),K.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(h){return r in h}},it||(o.get=_?M?function(h){return q(h),c.value}:V("get",0,q):function(h){return h[r]}),M||et||(o.set=_?V("set",0,q):function(h,P){h[r]=P}),m=st.call(nt,A?{get:c.get,set:c.set}:c[w],D),K.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&z.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?z.unshift(m):c[w]=m)}return l<2&&O.push(C(z,v,1),C(b,v,0)),S||X||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?c[w]:x.call.bind(c[w])):N(n,r,c)),m}function Q(n){return N(n,H,{configurable:!0,enumerable:!0,value:p})}return d!==void 0&&(p=d[H]),p=R(p??null),f=[],u=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:ti(O),b,b<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return ii(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function ti(i){var t=ei(i,"string");return typeof t=="symbol"?t:t+""}function ei(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Me(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function ii(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}function Be(i,t){return i instanceof Node&&t.contains(i)}var je,Ue=class extends Ve{static{({e:[me,ye,ve,ge,be,Te,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce,pe],c:[je,fe]}=Ze(this,[ni("rui-toaster")],[[[$({type:String,reflect:!0,defaultValue:dt}),si([{attr:"data-y-position",map:t=>j(t).y},{attr:"data-x-position",map:t=>j(t).x}])],0,"position"],[$({type:Number,defaultValue:4e3}),0,"duration"],[$({type:Number,defaultValue:3}),0,"visibleToasts"],[$({type:Boolean,defaultValue:!1}),0,"closeButton"],[$({type:Boolean,defaultValue:!1}),0,"expand"],[$({type:Number,defaultValue:14}),0,"gap"],[$({type:Number,defaultValue:24}),0,"offset"],[$({type:String,reflect:!0,defaultValue:""}),0,"container"],[ri({ref:"list"}),0,"listTarget"],[ai,0,"toasts"],[oi(["position","duration","visibleToasts","closeButton","expand","gap","offset","container"]),2,"onConfigUpdated"],[Dt({document:!0,type:at}),2,"onDocumentShow"],[Dt({document:!0,type:lt}),2,"onDocumentDismiss"],[Dt({selector:"rui-toast",type:"rui-toast-mounted"}),2,"onToastMounted"],[vt,2,"onPointerOver"],[vt,2,"onPointerOut"],[vt,2,"onPointerDown"],[vt,2,"onPointerUp"]],0,void 0,Ve))}position=(pe(this),me(this));duration=(ye(this),ve(this));visibleToasts=(ge(this),be(this));closeButton=(Te(this),_e(this));expand=(Se(this),xe(this));gap=(we(this),Ie(this));offset=(Ee(this),Oe(this));container=(Pe(this),Ae(this));listTarget=(De(this),Re(this));toasts=(Le(this),ke(this,[]));expanded=(Ce(this),!1);interacting=!1;unsubscribe=null;visibilityHandler=null;heights=new Map;observers=new Map;layoutFrame=null;measuring=!1;connectedCallback(){super.connectedCallback(),this.syncHostPosition(),this.syncContainer(),this.unsubscribe=T.subscribe(t=>{this.toasts=t,t.length===0&&this.resetLayoutState(),this.scheduleLayoutSync()}),this.visibilityHandler=()=>this.syncPauseState(),document.addEventListener("visibilitychange",this.visibilityHandler)}disconnectedCallback(){this.unsubscribe?.(),this.unsubscribe=null,this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerUp),this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.resetLayoutState(),super.disconnectedCallback()}onConfigUpdated(){this.syncHostPosition(),this.syncContainer(),this.scheduleLayoutSync()}onDocumentShow(t){let e=t.detail;e?.title&&T.create(e.title,{id:e.id,description:e.description,variant:e.variant,duration:e.duration,action:e.action,dismissible:e.dismissible,closeButton:e.closeButton,position:e.position})}onDocumentDismiss(t){let e=t.detail;T.dismiss(e?.id)}onToastMounted(){this.scheduleLayoutSync()}filteredToasts(){let t=this.toasts.filter(a=>(a.position??this.position)===this.position),e=[],s=[];for(let a of t)a.delete?s.push(a):e.push(a);return[...e.slice(0,this.visibleToasts),...s]}syncHostPosition(){this.style.setProperty("--rui-toaster-gap",`${this.gap}px`),this.style.setProperty("--rui-toaster-offset",`${this.offset}px`)}syncContainer(){let t=this.container.trim();if(!t){this.removeAttribute("data-contained"),this.style.position="";return}let e=this.closest(t)??document.querySelector(t);if(!e){this.removeAttribute("data-contained"),this.style.position="";return}getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.contains(this)||e.appendChild(this),this.dataset.contained="true",this.style.position="absolute"}isStackExpanded(){return this.expanded||this.expand}isPaused(){return this.expanded||this.interacting||document.hidden}resetLayoutState(){for(let e of this.observers.values())e.disconnect();this.observers.clear(),this.heights.clear(),this.expanded=!1,this.interacting=!1;let t=this.listTarget;t&&(t.style.height="0px",t.dataset.expanded="false"),this.dataset.expanded="false"}syncPauseState(){let t=this.isPaused();for(let e of this.querySelectorAll("rui-toast"))e.setPaused(t);this.patchStackLayout()}scheduleLayoutSync(){this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame(()=>{if(this.layoutFrame=null,this.toasts.length>0&&!this.interacting){let e=!!(this.listTarget?.matches(":hover")||this.matches(":hover"));this.expanded=e}this.observeToasts(),this.syncPauseState()})}measureToast(t){this.measuring=!0;let e=t.style.height,s=t.style.overflow;t.style.height="auto",t.style.overflow="visible";let a=t.getRef("toast"),d=Math.round(a instanceof HTMLElement?a.offsetHeight:t.offsetHeight)||64;return t.style.height=e,t.style.overflow=s,this.measuring=!1,d}observeToasts(){let t=this.listTarget;if(!t)return;let e=[...t.querySelectorAll("rui-toast")],s=new Set;for(let a of e){let d=a.toastId;if(!d)continue;s.add(d);let p=a.getRef("toast")??a;if(!this.observers.has(d)){let o=new ResizeObserver(()=>{if(this.measuring)return;let I=this.measureToast(a);this.heights.get(d)!==I&&(this.heights.set(d,I),this.patchStackLayout())});o.observe(p),this.observers.set(d,o)}this.heights.set(d,this.measureToast(a))}for(let[a,d]of[...this.observers])s.has(a)||(d.disconnect(),this.observers.delete(a),this.heights.delete(a))}patchStackLayout(){let t=this.listTarget;if(!t)return;let e=this.isStackExpanded(),{y:s}=j(this.position),a=s==="bottom"?-1:1,d=Math.min(3,Math.max(1,this.visibleToasts));this.dataset.expanded=String(e),t.dataset.expanded=String(e),this.style.setProperty("--rui-toaster-lift",String(a)),t.style.setProperty("--rui-toaster-gap",`${this.gap}px`);let p=[...t.querySelectorAll("rui-toast")].filter(f=>f.dataset.mounted==="true"&&f.dataset.removed!=="true");if(p.length===0){t.style.height="0px";return}let o=p.map(f=>{let u=this.measureToast(f);return this.heights.set(f.toastId,u),u}),I=o[0]??64;this.style.setProperty("--rui-toaster-front-height",`${I}px`);for(let f=0;f<p.length;f+=1){let u=p[f];if(!u)continue;let E=o[f]??64,H=f===0,N=ce(f,o,this.gap),R=f<d;if(u.dataset.index=String(f),u.dataset.front=String(H),u.dataset.expanded=String(e),u.dataset.visible=String(e||R),u.style.setProperty("--rui-toast-z",String(p.length-f)),u.style.setProperty("--rui-toast-index",String(f)),u.style.setProperty("--rui-toast-offset",`${N}px`),u.style.setProperty("--rui-toast-initial-height",`${E}px`),u.style.setProperty("--rui-toaster-gap",`${this.gap}px`),e)u.style.setProperty("--rui-toast-y",`translateY(${a*N}px)`),u.style.height=`${E}px`,u.style.overflow="visible";else if(!R)u.style.setProperty("--rui-toast-y",`translateY(${a*(d-1)*this.gap}px) scale(0.7)`),u.style.height=`${I}px`,u.style.overflow="hidden";else if(H)u.style.setProperty("--rui-toast-y","translateY(0px)"),u.style.height=`${E}px`,u.style.overflow="visible";else{let W=Math.max(.7,1-f*.05);u.style.setProperty("--rui-toast-y",`translateY(${a*f*this.gap}px) scale(${W})`),u.style.height=`${I}px`,u.style.overflow="hidden"}}let k=Math.min(d,p.length);t.style.height=`${e?de(o,this.gap):he(I,k,this.gap)}px`}onPointerOver(t){Be(t.relatedTarget,this)||(this.expanded=!0,this.syncPauseState())}onPointerOut(t){Be(t.relatedTarget,this)||this.interacting||(this.expanded=!1,this.syncPauseState())}onPointerDown(){this.interacting=!0,this.expanded=!0,this.syncPauseState(),document.addEventListener("pointerup",this.onPointerUp,{once:!0}),document.addEventListener("pointercancel",this.onPointerUp,{once:!0})}onPointerUp(){if(!this.interacting)return;this.interacting=!1,this.listTarget?.matches(":hover")||this.querySelector("rui-toast:hover")||(this.expanded=!1),this.syncPauseState()}render(){let t=this.filteredToasts();return At("section",{class:"rui-toaster-region","aria-label":"Notifications","aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",tabIndex:-1,children:At("ol",{class:"rui-toaster","data-ref":"list","data-rui-toaster":!0,"on:pointerover":this.onPointerOver,"on:pointerout":this.onPointerOut,"on:pointerdown":this.onPointerDown,children:t.map(e=>{let s=e.duration??(e.variant==="loading"?Number.POSITIVE_INFINITY:this.duration);return At("rui-toast",{"prop:toastId":String(e.id),"prop:title":e.title,"prop:description":e.description??"","prop:variant":e.variant,"prop:duration":s,"prop:dismissible":e.dismissible,"prop:closeButton":e.closeButton??this.closeButton,"prop:actionLabel":e.action?.label??"","prop:position":e.position??this.position,"prop:markedDelete":!!e.delete},String(e.id))})})})}static{fe()}};import{jsx as Fe}from"@ecopages/jsx/jsx-runtime";function li({toastId:i,...t}){return Fe("rui-toast",{...t,toastId:i!=null?String(i):void 0})}function ui({children:i,...t}){return Fe("rui-toaster",{...t,children:i})}var ci=Object.assign((i,t)=>T.create(i,t),{message:(i,t)=>T.message(i,t),success:(i,t)=>T.success(i,t),error:(i,t)=>T.error(i,t),info:(i,t)=>T.info(i,t),warning:(i,t)=>T.warning(i,t),loading:(i,t)=>T.loading(i,t),promise:(i,t)=>T.promise(i,t),dismiss:i=>T.dismiss(i),clear:()=>T.clear()});function di(i){document.dispatchEvent(new CustomEvent(at,{detail:i,bubbles:!0,composed:!0}))}function hi(i){let t=i==null?{}:{id:i};document.dispatchEvent(new CustomEvent(lt,{detail:t,bubbles:!0,composed:!0}))}export{dt as DEFAULT_TOAST_POSITION,lt as RUI_TOAST_DISMISS_EVENT,at as RUI_TOAST_SHOW_EVENT,li as RuiToast,ue as RuiToastElement,ui as RuiToaster,je as RuiToasterElement,St as TOAST_COLLAPSED_PEEK,xt as TOAST_EXIT_MS,bt as TOAST_GAP,ut as TOAST_LIFETIME,Ne as TOAST_POSITIONS,ct as TOAST_SWIPE_THRESHOLD,Tt as TOAST_VIEWPORT_OFFSET,_t as TOAST_VISIBLE_AMOUNT,$e as TOAST_WIDTH,hi as dismissToast,di as showToast,ci as toast};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|