@mhmo91/schmancy 0.4.96 → 0.4.97
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/dist/area.cjs +1 -1
- package/dist/{area.component-DbHc6U3D.js → area.component-5hvsA6_h.js} +13 -13
- package/dist/{area.component-DbHc6U3D.js.map → area.component-5hvsA6_h.js.map} +1 -1
- package/dist/area.component-DSAxybsX.cjs +12 -0
- package/dist/{area.component-DA4tYUkZ.cjs.map → area.component-DSAxybsX.cjs.map} +1 -1
- package/dist/area.js +1 -1
- package/dist/{avatar-C-SwQh5Z.cjs → avatar-B51KRC34.cjs} +2 -2
- package/dist/{avatar-C-SwQh5Z.cjs.map → avatar-B51KRC34.cjs.map} +1 -1
- package/dist/{avatar-BGzMoyIf.js → avatar-Dpy9JzIW.js} +2 -2
- package/dist/{avatar-BGzMoyIf.js.map → avatar-Dpy9JzIW.js.map} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/package.json +1 -1
- package/dist/area.component-DA4tYUkZ.cjs +0 -12
package/dist/teleport.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./avatar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./avatar-B51KRC34.cjs");exports.HereMorty=e.HereMorty,Object.defineProperty(exports,"SchmancyTeleportation",{enumerable:!0,get:()=>e.SchmancyTeleportation}),exports.WhereAreYouRicky=e.WhereAreYouRicky,exports.teleport=e.teleport;
|
|
2
2
|
//# sourceMappingURL=teleport.cjs.map
|
package/dist/teleport.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("rxjs");require("lit/directives/class-map.js"),require("lit/directives/style-map.js");const m=require("lit/decorators.js");require("./tailwind.mixin-DvXzFSLc.cjs");const R=require("./litElement.mixin-BnXm63YO.cjs"),b=require("lit"),A=new a.Subject,C="FINDING_MORTIES",j="HERE_RICKY",O=new WeakMap;class f{constructor(){this.prettyURL=!1,this.mode="HISTORY",this.request=new a.ReplaySubject(1),this.current=new Map,this.$current=new a.ReplaySubject(1),this.enableHistoryMode=!0,this.findingMortiesEvent=new CustomEvent(C),this.disposed=!1,this.isProcessingPopstate=!1,this.$current.next(this.current),this.$current.subscribe(e=>{this.disposed||e.forEach((t,r)=>{this.getOrCreateAreaSubject(r).next(t)})}),this.initializeFromBrowserState(),typeof window<"u"&&(this.unloadSubscription=a.fromEvent(window,"unload").subscribe(()=>{this.dispose()}))}get areaSubjects(){let e=O.get(this);return e||(e=new Map,O.set(this,e)),e}initializeFromBrowserState(){try{const e=history.state;e&&e.schmancyAreas&&(Object.entries(e.schmancyAreas).forEach(([t,r])=>{this.current.set(t,r)}),this.$current.next(this.current))}catch{}}getOrCreateAreaSubject(e){let t=this.areaSubjects.get(e);if(!t||t.closed){t=new a.ReplaySubject(1),this.areaSubjects.set(e,t);const r=this.current.get(e);r&&t.next({...r,state:r.state||{},params:r.params||{},props:r.props||{}})}return t}on(e,t=!1){if(!e)throw new Error("Area name is required");const r=this.getOrCreateAreaSubject(e).asObservable().pipe(a.distinctUntilChanged((o,n)=>o.component===n.component&&JSON.stringify(o.state)===JSON.stringify(n.state)&&JSON.stringify(o.params)===JSON.stringify(n.params)),a.shareReplay(1));return t?r.pipe(a.skip(1)):r}all(e=!1){const t=this.$current.asObservable().pipe(a.shareReplay(1));return e?t.pipe(a.skip(1)):t}getState(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(a.map(t=>t.state),a.filter(t=>t!=null),a.distinctUntilChanged((t,r)=>JSON.stringify(t)===JSON.stringify(r)),a.map(t=>t),a.catchError(t=>a.EMPTY))}params(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(a.map(t=>t.params),a.filter(t=>t!=null),a.distinctUntilChanged((t,r)=>JSON.stringify(t)===JSON.stringify(r)),a.map(t=>t),a.catchError(t=>a.EMPTY))}param(e,t){if(!e||!t)throw new Error("Area name and key are required");return this.params(e).pipe(a.map(r=>r[t]),a.filter(r=>r!==void 0),a.distinctUntilChanged(),a.map(r=>r),a.catchError(r=>a.EMPTY))}props(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(a.map(t=>t.props),a.filter(t=>t!=null),a.distinctUntilChanged((t,r)=>JSON.stringify(t)===JSON.stringify(r)),a.map(t=>t),a.catchError(t=>a.EMPTY))}prop(e,t){if(!e||!t)throw new Error("Area name and key are required");return this.props(e).pipe(a.map(r=>r[t]),a.filter(r=>r!==void 0),a.distinctUntilChanged(),a.map(r=>r),a.catchError(r=>a.EMPTY))}find(){return a.zip([a.fromEvent(window,j).pipe(a.map(e=>e.detail),a.bufferTime(0)),a.of(1).pipe(a.tap(()=>window.dispatchEvent(this.findingMortiesEvent)))]).pipe(a.map(([e])=>e),a.timeout(1),a.catchError(()=>a.EMPTY))}push(e){if(!e.area)throw new Error("Area is required for route action");if(this.isProcessingPopstate)return;const t={...e,state:e.state||{},params:e.params||{},props:e.props||{},_source:"programmatic"};this.enableHistoryMode&&A.next(t),this.request.next(t),this.dispatchAreaEvent(t.area,t)}_updateFromBrowser(e){const t={...e,state:e.state||{},params:e.params||{},props:e.props||{},_source:"browser"};this.isProcessingPopstate=!0,this.request.next(t),this.isProcessingPopstate=!1}_updateBrowserHistory(e,t,r,o){if(this.enableHistoryMode)try{const n=history.state||{},i=n.schmancyAreas||{},p={component:t.component,area:t.area};t.state&&Object.keys(t.state).length>0&&(p.state=t.state),t.params&&Object.keys(t.params).length>0&&(p.params=t.params),t.props&&Object.keys(t.props).length>0&&(p.props=t.props),i[e]=p;const c={...n,schmancyAreas:i},u=this.createCleanURL(i,o);r==="replace"||r==="pop"?history.replaceState(c,"",u):r!=="push"&&r||history.pushState(c,"",u)}catch{}}createCleanURL(e,t){const r=location.pathname,o=r.split("/");let n="/";const i=o[o.length-1];i&&(i.includes("{")||i.includes("%7B"))?(o.pop(),n=o.join("/")||"/"):n=r,n==="/"||n.endsWith("/")||(n+="/");let p="";if(t!==!0){const c=new URLSearchParams(location.search);Array.isArray(t)&&t.forEach(u=>c.delete(u)),p=c.toString(),p=p?`?${p}`:""}if(this.prettyURL){const c=e.main;if(c){let u=n==="/"?`/${c.component}`:`${n}${c.component}`;const S=new URLSearchParams(p);c.params&&Object.entries(c.params).forEach(([d,E])=>{typeof E!="string"&&typeof E!="number"||S.set(d,String(E))});const h=S.toString();return u+(h?`?${h}`:"")}}try{const c={};if(Object.entries(e).forEach(([S,h])=>{const d={component:h.component};h.state&&Object.keys(h.state).length>0&&(d.state=h.state),h.params&&Object.keys(h.params).length>0&&(d.params=h.params),h.props&&Object.keys(h.props).length>0&&(d.props=h.props),c[S]=d}),Object.keys(c).length===0)return`${n==="/"?"":n.replace(/\/$/,"")}${p}`;const u=encodeURIComponent(JSON.stringify(c));return`${n==="/"?"":n.replace(/\/$/,"")}/${u}${p}`}catch{return location.pathname}}restoreFromBrowserState(e){try{if(e&&e.schmancyAreas)return e.schmancyAreas}catch{}return this.parseStateFromURL()}parseStateFromURL(){const e=location.pathname.split("/").pop();if(!e)return{};try{const t=decodeURIComponent(e),r=JSON.parse(t);if(typeof r=="object"&&r!==null)return r}catch{}return{}}dispatchAreaEvent(e,t){const r=new CustomEvent(`schmancy-area-${e}-changed`,{detail:{area:e,component:t.component,state:t.state,params:t.params,props:t.props,historyStrategy:t.historyStrategy},bubbles:!0,composed:!0});window.dispatchEvent(r)}pop(e){if(!e)throw new Error("Area name is required");const t=this.areaSubjects.get(e);if(t&&!t.closed&&t.next({component:null,state:{},area:e,params:{},props:{}}),this.request.next({area:e,component:null,state:{},params:{},props:{},historyStrategy:"silent",_source:"programmatic"}),this.current.delete(e),this.$current.next(this.current),this.enableHistoryMode)try{const r=history.state||{},o={...r.schmancyAreas||{}};delete o[e];const n={...r,schmancyAreas:o},i=this.createCleanURL(o);history.replaceState(n,"",i)}catch{}}clear(){if(this.areaSubjects.forEach(e=>e.complete()),this.areaSubjects.clear(),this.current.clear(),this.$current.next(this.current),this.enableHistoryMode){const e=this.createCleanURL({});history.replaceState({schmancyAreas:{}},"",e)}}dispose(){this.disposed||(this.disposed=!0,this.unloadSubscription&&(this.unloadSubscription.unsubscribe(),this.unloadSubscription=void 0),this.areaSubjects.forEach(e=>e.complete()),this.areaSubjects.clear(),this.request.complete(),this.$current.complete(),A.complete(),this.current.clear(),O.delete(this))}static getInstance(){return f.instance||(f.instance=new f),f.instance}get state(){try{const e=history.state;if(e&&e.schmancyAreas)return e.schmancyAreas}catch{}return this.parseStateFromURL()}hasArea(e){return this.current.has(e)}getActiveAreas(){return Array.from(this.current.keys())}getRoute(e){return this.current.get(e)}}const y=f.getInstance();var v=Object.defineProperty,P=Object.getOwnPropertyDescriptor,g=(s,e,t,r)=>{for(var o,n=r>1?void 0:r?P(e,t):e,i=s.length-1;i>=0;i--)(o=s[i])&&(n=(r?o(e,t,n):o(n))||n);return r&&n&&v(e,t,n),n};exports.SchmancyRoute=class extends R.$LitElement(b.css`
|
|
2
|
-
:host {
|
|
3
|
-
display: none;
|
|
4
|
-
}
|
|
5
|
-
`){constructor(){super(...arguments),this.exact=!1}getConfig(){return{when:this.when,component:this.component,exact:this.exact,guard:this.guard}}render(){return b.html``}},g([m.property({type:String})],exports.SchmancyRoute.prototype,"when",2),g([m.property({type:Object})],exports.SchmancyRoute.prototype,"component",2),g([m.property({type:Boolean})],exports.SchmancyRoute.prototype,"exact",2),g([m.property({type:Object})],exports.SchmancyRoute.prototype,"guard",2),exports.SchmancyRoute=g([m.customElement("schmancy-route")],exports.SchmancyRoute);var l=(s=>(s.push="push",s.replace="replace",s.pop="pop",s.silent="silent",s))(l||{}),$=Object.defineProperty,M=Object.getOwnPropertyDescriptor,w=(s,e,t,r)=>{for(var o,n=r>1?void 0:r?M(e,t):e,i=s.length-1;i>=0;i--)(o=s[i])&&(n=(r?o(e,t,n):o(n))||n);return r&&n&&$(e,t,n),n};exports.SchmancyArea=class extends R.$LitElement(b.css`
|
|
6
|
-
:host {
|
|
7
|
-
position: relative;
|
|
8
|
-
display: block;
|
|
9
|
-
inset: 0;
|
|
10
|
-
}
|
|
11
|
-
`){firstUpdated(){if(!this.name)throw new Error("Area name is required");a.merge(y.request.pipe(a.filter(({area:s})=>s===this.name)),a.of(location.pathname).pipe(a.take(1),a.switchMap(()=>{const s=location.pathname,e=s.split("/").pop()||"";let t,r;if(e&&(e.includes("{")||e.includes("%7B")))try{const n=JSON.parse(decodeURIComponent(e));if(n[this.name]){const i=n[this.name];return t=this.routes?.find(p=>p.when===i.component),r=i.component,t?a.of({area:this.name,component:t.component,state:n[this.name].state||{},params:n[this.name].params||{},historyStrategy:l.replace,originalWhen:r}):a.of({area:this.name,component:n[this.name].component,state:n[this.name].state||{},params:n[this.name].params||{},historyStrategy:l.replace,originalWhen:n[this.name].component})}}catch{}const o=s.split("/").filter(Boolean);return t=this.routes?.find(n=>o.includes(n.when)),r=t?.when,t?a.of({area:this.name,component:t.component,state:{},params:{},historyStrategy:l.silent,originalWhen:r}):this.default?a.of({area:this.name,component:this.default,state:{},params:{},historyStrategy:l.silent}):a.EMPTY})),a.fromEvent(window,"popstate").pipe(a.map(s=>s.state?.schmancyAreas?.[this.name]?{area:this.name,component:s.state.schmancyAreas[this.name].component,state:s.state.schmancyAreas[this.name].state||{},params:s.state.schmancyAreas[this.name].params||{},historyStrategy:l.pop}:null),a.filter(s=>s!==null))).pipe(a.filter(s=>s?.component!==void 0),a.switchMap(async s=>{let e=s.component;if(typeof e=="function"&&("preload"in e||"_promise"in e||"_module"in e))try{e=(await e()).default}catch{return{component:null,route:s}}return{component:e,route:s}}),a.map(({component:s,route:e})=>{let t="";return s&&s!==""?typeof s=="string"?t=s:s instanceof HTMLElement?t=s.tagName:typeof s=="function"&&(t=s.name||"CustomElement"):t="null",{component:s,route:e,key:`${t}${JSON.stringify(e.params)}${JSON.stringify(e.state)}`}}),a.distinctUntilChanged((s,e)=>s.key===e.key),a.switchMap(s=>{const e=typeof s.component=="string"?s.component:s.route?.originalWhen||s.route?.component,t=this.routes.find(r=>r.when===e);return t?.guard?t.guard.pipe(a.tap(r=>{}),a.switchMap(r=>{if(r===!0)return a.of(s);const o=new CustomEvent("redirect",{detail:{blockedRoute:e,area:this.name,params:s.route?.params||{},state:s.route?.state||{},redirectTarget:typeof r=="object"?r:void 0},bubbles:!0,composed:!0});return t.dispatchEvent(o),a.EMPTY})):a.of(s)}),a.map(({component:s,route:e})=>{let t=null;if(s&&s!==""){if(typeof s=="string")try{t=document.createElement(s)}catch{}else if(s instanceof HTMLElement)t=s;else if(typeof s=="function")try{t=new s}catch{}}else t=null;return t&&(e.params&&Object.assign(t,e.params),e.props&&Object.assign(t,e.props),e.state&&(t.state=e.state)),{element:t,route:e}}),a.shareReplay(1),a.tap(({element:s,route:e})=>this.swapComponents(s,e)),a.catchError(s=>a.EMPTY),a.takeUntil(this.disconnecting)).subscribe()}swapComponents(s,e){const t=Array.from(this.children).find(r=>!(r instanceof exports.SchmancyRoute));if(s){if(t?t.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}).onfinish=()=>{t.remove(),this.appendChild(s),s.animate([{opacity:0},{opacity:1}],{duration:150,easing:"ease-in"})}:(this.appendChild(s),s.animate([{opacity:0},{opacity:1}],{duration:100,easing:"ease-in"})),s){const r={component:s.tagName.toLowerCase(),state:e.state||{},area:this.name,params:e.params||{}};y.current.set(this.name,r),y.$current.next(y.current)}if(y.enableHistoryMode&&s){const r={component:s.tagName.toLowerCase(),state:e.state||{},area:this.name,params:e.params||{}};y._updateBrowserHistory(this.name,r,e.historyStrategy||l.push,e.clearQueryParams)}}else t&&t.remove()}newPath(s,e){const t=location.pathname.split("/").pop();let r={};try{r=t?JSON.parse(decodeURIComponent(t)):{}}catch{r={}}e.state=e.state??{};const o=e.clearQueryParams?this.queryParamClear(e.clearQueryParams):document.location.search;return encodeURIComponent(JSON.stringify({...r,[this.name]:{component:s.toLowerCase(),state:e.state,params:e.params}})).concat(`${o}`)}queryParamClear(s){if(!s)return"";const e=new URLSearchParams(location.search);return s===!0?"":(s.forEach(t=>e.delete(t)),e.toString()===""?"":`?${e.toString()}`)}disconnectedCallback(){super.disconnectedCallback()}render(){return b.html`<slot></slot>`}},w([m.property()],exports.SchmancyArea.prototype,"name",2),w([m.property()],exports.SchmancyArea.prototype,"default",2),w([m.queryAssignedElements({selector:"schmancy-route",flatten:!0})],exports.SchmancyArea.prototype,"routes",2),exports.SchmancyArea=w([m.customElement("schmancy-area")],exports.SchmancyArea),exports.FINDING_MORTIES=C,exports.HERE_RICKY=j,exports.HISTORY_STRATEGY=l,exports.area=y,exports.routerHistory=A;
|
|
12
|
-
//# sourceMappingURL=area.component-DA4tYUkZ.cjs.map
|