solely 0.4.4 → 0.4.5
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/components/elements/icon/index.cjs +1 -0
- package/dist/components/elements/icon/index.d.ts +107 -0
- package/dist/components/elements/icon/index.html.cjs +1 -0
- package/dist/components/elements/icon/index.html.js +1 -0
- package/dist/components/elements/icon/index.js +1 -0
- package/dist/components/elements/icon/style.css.cjs +1 -0
- package/dist/components/elements/icon/style.css.js +1 -0
- package/dist/components/elements/icon/types.d.ts +24 -0
- package/dist/components/elements/index.cjs +1 -1
- package/dist/components/elements/index.d.ts +4 -0
- package/dist/components/elements/index.js +1 -1
- package/dist/components/elements/not-found/index.cjs +1 -0
- package/dist/components/elements/not-found/index.d.ts +10 -0
- package/dist/components/elements/not-found/index.html.cjs +1 -0
- package/dist/components/elements/not-found/index.html.js +1 -0
- package/dist/components/elements/not-found/index.js +1 -0
- package/dist/components/elements/not-found/style.css.cjs +1 -0
- package/dist/components/elements/not-found/style.css.js +1 -0
- package/dist/components/elements/not-found/types.d.ts +20 -0
- package/dist/components/elements/select/option.d.ts +18 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/icons/bootstrap-icons.svg +1 -0
- package/dist/router/router-view.cjs +1 -1
- package/dist/router/router-view.d.ts +3 -1
- package/dist/router/router-view.js +1 -1
- package/dist/router/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,e=(e,r,o)=>((e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o)(e,"symbol"!=typeof r?r+"":r,o);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./core.cjs"),o=require("../runtime/component/base-element.cjs"),
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,r,o)=>((e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o)(e,"symbol"!=typeof r?r+"":r,o);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./core.cjs"),o=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const s=new Map;exports.default=class extends o.default{constructor(){super(...arguments),e(this,"unsubscribe"),e(this,"level",0),e(this,"currentElement",null),e(this,"currentTagName",null),e(this,"routerAttrs",new Set),e(this,"prevPropKeys",new Set),e(this,"scheduled",!1),e(this,"latestLoadId",0),e(this,"abortController",null),e(this,"router",null)}async mounted(){this.detectLevel(),this.router=await r.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,e=this.parentElement;for(;e;){const r=e.closest("router-view");if(r){if(t++,e=r.parentElement,!e){const t=r.getRootNode();e=t instanceof ShadowRoot?t.host:null}}else{const t=e.getRootNode();e=t instanceof ShadowRoot?t.host:null}}this.level=t}async loadRoute(t){var e,r;this.abortController&&(this.abortController.abort(),this.abortController=null);const o=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:s}=n;let i=s.tagName;if(!i&&"function"==typeof s.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let l;const a=null==(r=null==(e=this.router)?void 0:e.getComponentFromCache)?void 0:r.call(e,null==t?void 0:t.fullPath);if(l=a?await a:await s.component(),n.aborted||o!==this.latestLoadId)return;i="string"==typeof l?l:l.tagName}catch(a){if(n.aborted||o!==this.latestLoadId)return;return this.renderError(`Load Error: ${a}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(o!==this.latestLoadId)return;if(!i)return void this.clear();if(!s.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props);this.clear();const l=this.getOrCreateComponent(i,s);this.syncState(l,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props),this.appendChild(l),this.currentElement=l,this.currentTagName=i.toLowerCase()}getOrCreateComponent(t,e){const r=`${this.level}-${t.toLowerCase()}`;if(e.keepAlive&&s.has(r)){const t=s.get(r);if(t)return t}const o=document.createElement(t);return e.keepAlive&&s.set(r,o),o}syncState(t,e,r,o={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=new Map;Object.entries(e).forEach(([t,e])=>s.set(n(t),String(e))),Object.entries(r).forEach(([t,e])=>s.set(`query-${n(t)}`,String(e))),this.routerAttrs.forEach(e=>{s.has(e)||(t.removeAttribute(e),this.routerAttrs.delete(e))}),s.forEach((e,r)=>{t.getAttribute(r)!==e&&t.setAttribute(r,e),this.routerAttrs.add(r)});const i=new Set(Object.keys(o));this.prevPropKeys.forEach(e=>{i.has(e)||(t[e]=void 0)}),Object.entries(o).forEach(([e,r])=>{t[e]!==r&&(t[e]=r)}),this.prevPropKeys=i}handleEmptyRoute(){var t,e,r;if(this.clear(),0===this.level){const o=null==(t=this.router)?void 0:t.getCurrentRoute(),n=null==(e=null==o?void 0:o.matched)?void 0:e[0],s=null==(r=null==n?void 0:n.config)?void 0:r.notFoundComponent;if(s){const t=document.createElement(s);this.appendChild(t),this.currentElement=t,this.currentTagName=s.toLowerCase()}else if(this.$data.notFound){const t=document.createElement(this.$data.notFound);this.appendChild(t),this.currentElement=t,this.currentTagName=this.$data.notFound.toLowerCase()}else this.renderError("404 Not Found")}}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const e=document.createElement("div");e.style.cssText="padding:20px; color:#ff4d4f;",e.textContent=String(t),this.appendChild(e)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}},exports.default=((t,e)=>{for(var r,o=e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=r(o)||o);return o})([n.CustomElement({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],exports.default);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BaseElement } from '../runtime/component';
|
|
2
2
|
import { RouteMatch } from './types';
|
|
3
|
-
declare class RouterView extends BaseElement
|
|
3
|
+
declare class RouterView extends BaseElement<{
|
|
4
|
+
notFound: string;
|
|
5
|
+
}> {
|
|
4
6
|
private unsubscribe?;
|
|
5
7
|
private level;
|
|
6
8
|
private currentElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty,e=(e,r,o)=>((e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o)(e,"symbol"!=typeof r?r+"":r,o);import{routerReady as r}from"./core.js";import o from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const s=new Map;let i=class extends o{constructor(){super(...arguments),e(this,"unsubscribe"),e(this,"level",0),e(this,"currentElement",null),e(this,"currentTagName",null),e(this,"routerAttrs",new Set),e(this,"prevPropKeys",new Set),e(this,"scheduled",!1),e(this,"latestLoadId",0),e(this,"abortController",null),e(this,"router",null)}async mounted(){this.detectLevel(),this.router=await r,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,e=this.parentElement;for(;e;){const r=e.closest("router-view");if(r){if(t++,e=r.parentElement,!e){const t=r.getRootNode();e=t instanceof ShadowRoot?t.host:null}}else{const t=e.getRootNode();e=t instanceof ShadowRoot?t.host:null}}this.level=t}async loadRoute(t){var e,r;this.abortController&&(this.abortController.abort(),this.abortController=null);const o=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:s}=n;let i=s.tagName;if(!i&&"function"==typeof s.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let l;const a=null==(r=null==(e=this.router)?void 0:e.getComponentFromCache)?void 0:r.call(e,null==t?void 0:t.fullPath);if(l=a?await a:await s.component(),n.aborted||o!==this.latestLoadId)return;i="string"==typeof l?l:l.tagName}catch(a){if(n.aborted||o!==this.latestLoadId)return;return this.renderError(`Load Error: ${a}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(o!==this.latestLoadId)return;if(!i)return void this.clear();if(!s.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props);this.clear();const l=this.getOrCreateComponent(i,s);this.syncState(l,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props),this.appendChild(l),this.currentElement=l,this.currentTagName=i.toLowerCase()}getOrCreateComponent(t,e){const r=`${this.level}-${t.toLowerCase()}`;if(e.keepAlive&&s.has(r)){const t=s.get(r);if(t)return t}const o=document.createElement(t);return e.keepAlive&&s.set(r,o),o}syncState(t,e,r,o={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=new Map;Object.entries(e).forEach(([t,e])=>s.set(n(t),String(e))),Object.entries(r).forEach(([t,e])=>s.set(`query-${n(t)}`,String(e))),this.routerAttrs.forEach(e=>{s.has(e)||(t.removeAttribute(e),this.routerAttrs.delete(e))}),s.forEach((e,r)=>{t.getAttribute(r)!==e&&t.setAttribute(r,e),this.routerAttrs.add(r)});const i=new Set(Object.keys(o));this.prevPropKeys.forEach(e=>{i.has(e)||(t[e]=void 0)}),Object.entries(o).forEach(([e,r])=>{t[e]!==r&&(t[e]=r)}),this.prevPropKeys=i}handleEmptyRoute(){this.clear(),0===this.level
|
|
1
|
+
var t=Object.defineProperty,e=(e,r,o)=>((e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o)(e,"symbol"!=typeof r?r+"":r,o);import{routerReady as r}from"./core.js";import o from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const s=new Map;let i=class extends o{constructor(){super(...arguments),e(this,"unsubscribe"),e(this,"level",0),e(this,"currentElement",null),e(this,"currentTagName",null),e(this,"routerAttrs",new Set),e(this,"prevPropKeys",new Set),e(this,"scheduled",!1),e(this,"latestLoadId",0),e(this,"abortController",null),e(this,"router",null)}async mounted(){this.detectLevel(),this.router=await r,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,e=this.parentElement;for(;e;){const r=e.closest("router-view");if(r){if(t++,e=r.parentElement,!e){const t=r.getRootNode();e=t instanceof ShadowRoot?t.host:null}}else{const t=e.getRootNode();e=t instanceof ShadowRoot?t.host:null}}this.level=t}async loadRoute(t){var e,r;this.abortController&&(this.abortController.abort(),this.abortController=null);const o=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:s}=n;let i=s.tagName;if(!i&&"function"==typeof s.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let l;const a=null==(r=null==(e=this.router)?void 0:e.getComponentFromCache)?void 0:r.call(e,null==t?void 0:t.fullPath);if(l=a?await a:await s.component(),n.aborted||o!==this.latestLoadId)return;i="string"==typeof l?l:l.tagName}catch(a){if(n.aborted||o!==this.latestLoadId)return;return this.renderError(`Load Error: ${a}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(o!==this.latestLoadId)return;if(!i)return void this.clear();if(!s.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props);this.clear();const l=this.getOrCreateComponent(i,s);this.syncState(l,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props),this.appendChild(l),this.currentElement=l,this.currentTagName=i.toLowerCase()}getOrCreateComponent(t,e){const r=`${this.level}-${t.toLowerCase()}`;if(e.keepAlive&&s.has(r)){const t=s.get(r);if(t)return t}const o=document.createElement(t);return e.keepAlive&&s.set(r,o),o}syncState(t,e,r,o={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=new Map;Object.entries(e).forEach(([t,e])=>s.set(n(t),String(e))),Object.entries(r).forEach(([t,e])=>s.set(`query-${n(t)}`,String(e))),this.routerAttrs.forEach(e=>{s.has(e)||(t.removeAttribute(e),this.routerAttrs.delete(e))}),s.forEach((e,r)=>{t.getAttribute(r)!==e&&t.setAttribute(r,e),this.routerAttrs.add(r)});const i=new Set(Object.keys(o));this.prevPropKeys.forEach(e=>{i.has(e)||(t[e]=void 0)}),Object.entries(o).forEach(([e,r])=>{t[e]!==r&&(t[e]=r)}),this.prevPropKeys=i}handleEmptyRoute(){var t,e,r;if(this.clear(),0===this.level){const o=null==(t=this.router)?void 0:t.getCurrentRoute(),n=null==(e=null==o?void 0:o.matched)?void 0:e[0],s=null==(r=null==n?void 0:n.config)?void 0:r.notFoundComponent;if(s){const t=document.createElement(s);this.appendChild(t),this.currentElement=t,this.currentTagName=s.toLowerCase()}else if(this.$data.notFound){const t=document.createElement(this.$data.notFound);this.appendChild(t),this.currentElement=t,this.currentTagName=this.$data.notFound.toLowerCase()}else this.renderError("404 Not Found")}}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const e=document.createElement("div");e.style.cssText="padding:20px; color:#ff4d4f;",e.textContent=String(t),this.appendChild(e)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};i=((t,e)=>{for(var r,o=e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=r(o)||o);return o})([n({tagName:"router-view",props:[{name:"notFound",type:"string",default:""}]})],i);export{i as default};
|
package/dist/router/types.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export interface RouteConfig {
|
|
|
35
35
|
* 实际上通常可以通过判断 component 属性是否存在来推断。
|
|
36
36
|
*/
|
|
37
37
|
async?: boolean;
|
|
38
|
+
/** * 404 页面组件标签名。
|
|
39
|
+
* 当没有匹配到路由时显示的组件,优先级高于 RouterView 的 not-found 属性。
|
|
40
|
+
*/
|
|
41
|
+
notFoundComponent?: string;
|
|
38
42
|
}
|
|
39
43
|
export interface MatchedRoute {
|
|
40
44
|
config: RouteConfig;
|
package/package.json
CHANGED