@darkchest/wck 0.0.9 → 0.0.11
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/example/dist/index.es.min.js +3 -0
- package/example/dist/index.iife.min.js +1 -1
- package/example/dist/index.umd.min.js +1 -1
- package/example/package.json +1 -1
- package/example/pnpm-lock.yaml +1249 -0
- package/package.json +1 -1
- package/src/compiler-helper.js +0 -9
- package/src/compiler-template.js +3 -0
- package/src/compilers/compileTemplate.js +0 -62
|
@@ -441,4 +441,4 @@ footer {
|
|
|
441
441
|
</div>
|
|
442
442
|
</div>
|
|
443
443
|
</div>
|
|
444
|
-
</div>`,this._el=o.firstElementChild,this.shadowRoot.appendChild(e),this.shadowRoot.appendChild(this._el),this.app=null}connectedCallback(){const e=this;this.app=B({initialTodos:function(){return[]},appTitle:"我的待办清单",enableLocalStorage:!0,newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0,get filteredTodos(){switch(this.filter){case"active":return this.todos.filter(n=>!n.completed);case"completed":return this.todos.filter(n=>n.completed);default:return this.todos}},get activeTodosCount(){return this.todos.filter(n=>!n.completed).length},get completedTodosCount(){return this.todos.filter(n=>n.completed).length},get totalTodos(){return this.todos.length},get completionRate(){return this.totalTodos===0?0:Math.round(this.completedTodosCount/this.totalTodos*100)},get hasCompletedTodos(){return this.completedTodosCount>0},$todos_handler(n,i){e._watchers.$todos=n,i?.split?.(",")?.shift?.()?.trim?.(),this.enableLocalStorage&&localStorage.setItem("vue-todos",JSON.stringify(n)),this.$emit("todos-updated",n)},get $todos(){const n=this.todos;return e._watchers.$todos!==n&&this.$todos_handler(n,e._watchers.$todos),n},$filter_handler(n,i){e._watchers.$filter=n,i?.split?.(",")?.shift?.()?.trim?.(),console.log("过滤器已更改为: "+n)},get $filter(){const n=this.filter;return e._watchers.$filter!==n&&this.$filter_handler(n,e._watchers.$filter),n},addTodo(){this.newTodo.trim()!==""&&(this.todos.push({id:++this.lastTodoId,text:this.newTodo.trim(),completed:!1,createdAt:new Date}),this.newTodo="",console.log("已添加新的待办事项"))},deleteTodo(n){const i=this.todos.findIndex(s=>s.id===n);i!==-1&&(this.todos.splice(i,1),console.log("已删除待办事项 ID: "+n))},editTodo(n){this.editingTodo={...n}},saveEdit(){if(this.editingTodo&&this.editingTodo.text.trim()!==""){const n=this.todos.findIndex(i=>i.id===this.editingTodo.id);n!==-1&&(this.$set(this.todos,n,{...this.editingTodo}),console.log("已更新待办事项 ID: "+this.editingTodo.id))}this.editingTodo=null},cancelEdit(){this.editingTodo=null},clearCompleted(){const n=this.todos.length;this.todos=this.todos.filter(s=>!s.completed);const i=n-this.todos.length;console.log("已清除 "+i+" 个已完成事项")},formatDate(n){return new Date(n).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},$lifecycle_mounted(){console.log("TodoApp 组件已挂载到 DOM"),this.$nextTick(()=>{document.querySelectorAll(".todo-item").forEach(i=>{i.addEventListener("dblclick",()=>{const s=parseInt(i.dataset.id),r=this.todos.findIndex(l=>l.id===s);r!==-1&&(this.todos[r].completed=!this.todos[r].completed,console.log("双击切换待办事项状态 ID: "+s))})})})},$lifecycle_unmounted(){console.log("TodoApp 组件已销毁")},get $el(){return e.$el},get $parent(){return e.$parent},get $children(){return e.$children},get $root(){return e.$root},$emit(n,i){e.dispatchEvent(new CustomEvent(e._eventPrefix+n,{detail:i}))}}),this.$app=Yt(this.app).mount(this._el);let o=this.parentElement;for(;o&&!Xt(o);)o=o.parentElement;o&&(this._parent=o,o._children.push(this)),this.dispatchEvent(new CustomEvent("mounted")),this.app?.$lifecycle_mounted?.(),(function(){const n=(function(){return{newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0}})();Object.keys(n).forEach(i=>{(e?.constructor?.observedAttributes??[]).indexOf?.(i)>=0?te.info("当前属性 "+i+" 已定义为 prop 属性, 无法初始化."):e.app[i]=n[i]})})()}attributeChangedCallback(e,o,n){if(!this.app){var i=this;setTimeout(function(){i.attributeChangedCallback(e,o,n)},10);return}if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){const s=this._types[e];s&&(this.app[s.attr]=this._typeChcker(n,s.type))}}disconnectedCallback(){this._children&&(this._children.forEach(e=>e.disconnectedCallback()),this._children=[]),this._parent&&(this._parent._children=this._parent._children.filter(e=>e!==this),this._parent=null),Object.keys(this._listeners).forEach(e=>this.off(e)),this._listeners={},this.dispatchEvent(new CustomEvent("unmounted")),this.app?.$lifecycle_unmounted?.(),this.app=null,this.$app.unmount(),this.$app=null,this._el=null}get __isDarkchest(){return this._isDarkchest}get __componentId(){return this._componentId}get $el(){return this._el||null}get $parent(){return this._parent||null}get $children(){return this._children||[]}get $root(){let e=this;for(;e.$parent&&Xt(e.$parent);)e=e.$parent;return e}_typeChcker(e,o){return e}prop(e,o){if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){if(o===void 0)return this.getAttribute(e);this.setAttribute(e,o)}else te.info(`未定义的prop [${e}]`)}get initialTodos(){return this?.app?.initialTodos}set initialTodos(e){this.app.initialTodos=this?._typeChcker?.(e,"Array","Object")}get appTitle(){return this?.app?.appTitle}set appTitle(e){this.app.appTitle=this?._typeChcker?.(e,"String")}get enableLocalStorage(){return this?.app?.enableLocalStorage}set enableLocalStorage(e){this.app.enableLocalStorage=this?._typeChcker?.(e,"Boolean")}on(e,o,n){const i=this._eventPrefix+e;return this._listeners[i]=o,this.addEventListener(i,o,n),this}off(e,o){if(e){const n=this._eventPrefix+e;if(o)this.removeEventListener(n,o),delete this._listeners[n];else{const i=this._listeners[n];i&&(this.removeEventListener(n,i),delete this._listeners[n])}}return this}once(e,o,n){const i=this._eventPrefix+e,s=(...r)=>{this.removeEventListener(i,s),o(...r)};return this.addEventListener(i,s,n),this}addTodo(){return this.app.addTodo()}deleteTodo(e){return this.app.deleteTodo(e)}editTodo(e){return this.app.editTodo(e)}saveEdit(){return this.app.saveEdit()}cancelEdit(){return this.app.cancelEdit()}clearCompleted(){return this.app.clearCompleted()}formatDate(e){return this.app.formatDate(e)}}customElements.define("todo-list",mo)})();
|
|
444
|
+
</div>`,this._el=o.firstElementChild,this.shadowRoot.appendChild(e),this.shadowRoot.appendChild(this._el),this.app=null}connectedCallback(){const e=this;this.app=B({initialTodos:function(){return[]},appTitle:"我的待办清单",enableLocalStorage:!0,newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0,get filteredTodos(){switch(this.filter){case"active":return this.todos.filter(n=>!n.completed);case"completed":return this.todos.filter(n=>n.completed);default:return this.todos}},get activeTodosCount(){return this.todos.filter(n=>!n.completed).length},get completedTodosCount(){return this.todos.filter(n=>n.completed).length},get totalTodos(){return this.todos.length},get completionRate(){return this.totalTodos===0?0:Math.round(this.completedTodosCount/this.totalTodos*100)},get hasCompletedTodos(){return this.completedTodosCount>0},$todos_handler(n,i){e._watchers.$todos=n,i?.split?.(",")?.shift?.()?.trim?.(),this.enableLocalStorage&&localStorage.setItem("vue-todos",JSON.stringify(n)),this.$emit("todos-updated",n)},get $todos(){const n=this.todos;return e._watchers.$todos!==n&&this.$todos_handler(n,e._watchers.$todos),n},$filter_handler(n,i){e._watchers.$filter=n,i?.split?.(",")?.shift?.()?.trim?.(),console.log("过滤器已更改为: "+n)},get $filter(){const n=this.filter;return e._watchers.$filter!==n&&this.$filter_handler(n,e._watchers.$filter),n},addTodo(){this.newTodo.trim()!==""&&(this.todos.push({id:++this.lastTodoId,text:this.newTodo.trim(),completed:!1,createdAt:new Date}),this.newTodo="",console.log("已添加新的待办事项"))},deleteTodo(n){const i=this.todos.findIndex(s=>s.id===n);i!==-1&&(this.todos.splice(i,1),console.log("已删除待办事项 ID: "+n))},editTodo(n){this.editingTodo={...n}},saveEdit(){if(this.editingTodo&&this.editingTodo.text.trim()!==""){const n=this.todos.findIndex(i=>i.id===this.editingTodo.id);n!==-1&&(this.$set(this.todos,n,{...this.editingTodo}),console.log("已更新待办事项 ID: "+this.editingTodo.id))}this.editingTodo=null},cancelEdit(){this.editingTodo=null},clearCompleted(){const n=this.todos.length;this.todos=this.todos.filter(s=>!s.completed);const i=n-this.todos.length;console.log("已清除 "+i+" 个已完成事项")},formatDate(n){return new Date(n).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},$lifecycle_mounted(){console.log("TodoApp 组件已挂载到 DOM"),this.$nextTick(()=>{document.querySelectorAll(".todo-item").forEach(i=>{i.addEventListener("dblclick",()=>{const s=parseInt(i.dataset.id),r=this.todos.findIndex(l=>l.id===s);r!==-1&&(this.todos[r].completed=!this.todos[r].completed,console.log("双击切换待办事项状态 ID: "+s))})})})},$lifecycle_unmounted(){console.log("TodoApp 组件已销毁")},get $el(){return e.$el},get $parent(){return e.$parent},get $children(){return e.$children},get $root(){return e.$root},$set(n,i,s){n[i]=s},$emit(n,i){e.dispatchEvent(new CustomEvent(e._eventPrefix+n,{detail:i}))}}),this.$app=Yt(this.app).mount(this._el);let o=this.parentElement;for(;o&&!Xt(o);)o=o.parentElement;o&&(this._parent=o,o._children.push(this)),this.dispatchEvent(new CustomEvent("mounted")),this.app?.$lifecycle_mounted?.(),(function(){const n=(function(){return{newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0}})();Object.keys(n).forEach(i=>{(e?.constructor?.observedAttributes??[]).indexOf?.(i)>=0?te.info("当前属性 "+i+" 已定义为 prop 属性, 无法初始化."):e.app[i]=n[i]})})()}attributeChangedCallback(e,o,n){if(!this.app){var i=this;setTimeout(function(){i.attributeChangedCallback(e,o,n)},10);return}if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){const s=this._types[e];s&&(this.app[s.attr]=this._typeChcker(n,s.type))}}disconnectedCallback(){this._children&&(this._children.forEach(e=>e.disconnectedCallback()),this._children=[]),this._parent&&(this._parent._children=this._parent._children.filter(e=>e!==this),this._parent=null),Object.keys(this._listeners).forEach(e=>this.off(e)),this._listeners={},this.dispatchEvent(new CustomEvent("unmounted")),this.app?.$lifecycle_unmounted?.(),this.app=null,this.$app.unmount(),this.$app=null,this._el=null}get __isDarkchest(){return this._isDarkchest}get __componentId(){return this._componentId}get $el(){return this._el||null}get $parent(){return this._parent||null}get $children(){return this._children||[]}get $root(){let e=this;for(;e.$parent&&Xt(e.$parent);)e=e.$parent;return e}_typeChcker(e,o){return e}prop(e,o){if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){if(o===void 0)return this.getAttribute(e);this.setAttribute(e,o)}else te.info(`未定义的prop [${e}]`)}get initialTodos(){return this?.app?.initialTodos}set initialTodos(e){this.app.initialTodos=this?._typeChcker?.(e,"Array","Object")}get appTitle(){return this?.app?.appTitle}set appTitle(e){this.app.appTitle=this?._typeChcker?.(e,"String")}get enableLocalStorage(){return this?.app?.enableLocalStorage}set enableLocalStorage(e){this.app.enableLocalStorage=this?._typeChcker?.(e,"Boolean")}on(e,o,n){const i=this._eventPrefix+e;return this._listeners[i]=o,this.addEventListener(i,o,n),this}off(e,o){if(e){const n=this._eventPrefix+e;if(o)this.removeEventListener(n,o),delete this._listeners[n];else{const i=this._listeners[n];i&&(this.removeEventListener(n,i),delete this._listeners[n])}}return this}once(e,o,n){const i=this._eventPrefix+e,s=(...r)=>{this.removeEventListener(i,s),o(...r)};return this.addEventListener(i,s,n),this}addTodo(){return this.app.addTodo()}deleteTodo(e){return this.app.deleteTodo(e)}editTodo(e){return this.app.editTodo(e)}saveEdit(){return this.app.saveEdit()}cancelEdit(){return this.app.cancelEdit()}clearCompleted(){return this.app.clearCompleted()}formatDate(e){return this.app.formatDate(e)}}customElements.define("todo-list",mo)})();
|
|
@@ -441,4 +441,4 @@ footer {
|
|
|
441
441
|
</div>
|
|
442
442
|
</div>
|
|
443
443
|
</div>
|
|
444
|
-
</div>`,this._el=o.firstElementChild,this.shadowRoot.appendChild(e),this.shadowRoot.appendChild(this._el),this.app=null}connectedCallback(){const e=this;this.app=B({initialTodos:function(){return[]},appTitle:"我的待办清单",enableLocalStorage:!0,newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0,get filteredTodos(){switch(this.filter){case"active":return this.todos.filter(n=>!n.completed);case"completed":return this.todos.filter(n=>n.completed);default:return this.todos}},get activeTodosCount(){return this.todos.filter(n=>!n.completed).length},get completedTodosCount(){return this.todos.filter(n=>n.completed).length},get totalTodos(){return this.todos.length},get completionRate(){return this.totalTodos===0?0:Math.round(this.completedTodosCount/this.totalTodos*100)},get hasCompletedTodos(){return this.completedTodosCount>0},$todos_handler(n,i){e._watchers.$todos=n,i?.split?.(",")?.shift?.()?.trim?.(),this.enableLocalStorage&&localStorage.setItem("vue-todos",JSON.stringify(n)),this.$emit("todos-updated",n)},get $todos(){const n=this.todos;return e._watchers.$todos!==n&&this.$todos_handler(n,e._watchers.$todos),n},$filter_handler(n,i){e._watchers.$filter=n,i?.split?.(",")?.shift?.()?.trim?.(),console.log("过滤器已更改为: "+n)},get $filter(){const n=this.filter;return e._watchers.$filter!==n&&this.$filter_handler(n,e._watchers.$filter),n},addTodo(){this.newTodo.trim()!==""&&(this.todos.push({id:++this.lastTodoId,text:this.newTodo.trim(),completed:!1,createdAt:new Date}),this.newTodo="",console.log("已添加新的待办事项"))},deleteTodo(n){const i=this.todos.findIndex(s=>s.id===n);i!==-1&&(this.todos.splice(i,1),console.log("已删除待办事项 ID: "+n))},editTodo(n){this.editingTodo={...n}},saveEdit(){if(this.editingTodo&&this.editingTodo.text.trim()!==""){const n=this.todos.findIndex(i=>i.id===this.editingTodo.id);n!==-1&&(this.$set(this.todos,n,{...this.editingTodo}),console.log("已更新待办事项 ID: "+this.editingTodo.id))}this.editingTodo=null},cancelEdit(){this.editingTodo=null},clearCompleted(){const n=this.todos.length;this.todos=this.todos.filter(s=>!s.completed);const i=n-this.todos.length;console.log("已清除 "+i+" 个已完成事项")},formatDate(n){return new Date(n).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},$lifecycle_mounted(){console.log("TodoApp 组件已挂载到 DOM"),this.$nextTick(()=>{document.querySelectorAll(".todo-item").forEach(i=>{i.addEventListener("dblclick",()=>{const s=parseInt(i.dataset.id),r=this.todos.findIndex(l=>l.id===s);r!==-1&&(this.todos[r].completed=!this.todos[r].completed,console.log("双击切换待办事项状态 ID: "+s))})})})},$lifecycle_unmounted(){console.log("TodoApp 组件已销毁")},get $el(){return e.$el},get $parent(){return e.$parent},get $children(){return e.$children},get $root(){return e.$root},$emit(n,i){e.dispatchEvent(new CustomEvent(e._eventPrefix+n,{detail:i}))}}),this.$app=Qt(this.app).mount(this._el);let o=this.parentElement;for(;o&&!te(o);)o=o.parentElement;o&&(this._parent=o,o._children.push(this)),this.dispatchEvent(new CustomEvent("mounted")),this.app?.$lifecycle_mounted?.(),(function(){const n=(function(){return{newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0}})();Object.keys(n).forEach(i=>{(e?.constructor?.observedAttributes??[]).indexOf?.(i)>=0?ee.info("当前属性 "+i+" 已定义为 prop 属性, 无法初始化."):e.app[i]=n[i]})})()}attributeChangedCallback(e,o,n){if(!this.app){var i=this;setTimeout(function(){i.attributeChangedCallback(e,o,n)},10);return}if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){const s=this._types[e];s&&(this.app[s.attr]=this._typeChcker(n,s.type))}}disconnectedCallback(){this._children&&(this._children.forEach(e=>e.disconnectedCallback()),this._children=[]),this._parent&&(this._parent._children=this._parent._children.filter(e=>e!==this),this._parent=null),Object.keys(this._listeners).forEach(e=>this.off(e)),this._listeners={},this.dispatchEvent(new CustomEvent("unmounted")),this.app?.$lifecycle_unmounted?.(),this.app=null,this.$app.unmount(),this.$app=null,this._el=null}get __isDarkchest(){return this._isDarkchest}get __componentId(){return this._componentId}get $el(){return this._el||null}get $parent(){return this._parent||null}get $children(){return this._children||[]}get $root(){let e=this;for(;e.$parent&&te(e.$parent);)e=e.$parent;return e}_typeChcker(e,o){return e}prop(e,o){if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){if(o===void 0)return this.getAttribute(e);this.setAttribute(e,o)}else ee.info(`未定义的prop [${e}]`)}get initialTodos(){return this?.app?.initialTodos}set initialTodos(e){this.app.initialTodos=this?._typeChcker?.(e,"Array","Object")}get appTitle(){return this?.app?.appTitle}set appTitle(e){this.app.appTitle=this?._typeChcker?.(e,"String")}get enableLocalStorage(){return this?.app?.enableLocalStorage}set enableLocalStorage(e){this.app.enableLocalStorage=this?._typeChcker?.(e,"Boolean")}on(e,o,n){const i=this._eventPrefix+e;return this._listeners[i]=o,this.addEventListener(i,o,n),this}off(e,o){if(e){const n=this._eventPrefix+e;if(o)this.removeEventListener(n,o),delete this._listeners[n];else{const i=this._listeners[n];i&&(this.removeEventListener(n,i),delete this._listeners[n])}}return this}once(e,o,n){const i=this._eventPrefix+e,s=(...r)=>{this.removeEventListener(i,s),o(...r)};return this.addEventListener(i,s,n),this}addTodo(){return this.app.addTodo()}deleteTodo(e){return this.app.deleteTodo(e)}editTodo(e){return this.app.editTodo(e)}saveEdit(){return this.app.saveEdit()}cancelEdit(){return this.app.cancelEdit()}clearCompleted(){return this.app.clearCompleted()}formatDate(e){return this.app.formatDate(e)}}customElements.define("todo-list",mo)}));
|
|
444
|
+
</div>`,this._el=o.firstElementChild,this.shadowRoot.appendChild(e),this.shadowRoot.appendChild(this._el),this.app=null}connectedCallback(){const e=this;this.app=B({initialTodos:function(){return[]},appTitle:"我的待办清单",enableLocalStorage:!0,newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0,get filteredTodos(){switch(this.filter){case"active":return this.todos.filter(n=>!n.completed);case"completed":return this.todos.filter(n=>n.completed);default:return this.todos}},get activeTodosCount(){return this.todos.filter(n=>!n.completed).length},get completedTodosCount(){return this.todos.filter(n=>n.completed).length},get totalTodos(){return this.todos.length},get completionRate(){return this.totalTodos===0?0:Math.round(this.completedTodosCount/this.totalTodos*100)},get hasCompletedTodos(){return this.completedTodosCount>0},$todos_handler(n,i){e._watchers.$todos=n,i?.split?.(",")?.shift?.()?.trim?.(),this.enableLocalStorage&&localStorage.setItem("vue-todos",JSON.stringify(n)),this.$emit("todos-updated",n)},get $todos(){const n=this.todos;return e._watchers.$todos!==n&&this.$todos_handler(n,e._watchers.$todos),n},$filter_handler(n,i){e._watchers.$filter=n,i?.split?.(",")?.shift?.()?.trim?.(),console.log("过滤器已更改为: "+n)},get $filter(){const n=this.filter;return e._watchers.$filter!==n&&this.$filter_handler(n,e._watchers.$filter),n},addTodo(){this.newTodo.trim()!==""&&(this.todos.push({id:++this.lastTodoId,text:this.newTodo.trim(),completed:!1,createdAt:new Date}),this.newTodo="",console.log("已添加新的待办事项"))},deleteTodo(n){const i=this.todos.findIndex(s=>s.id===n);i!==-1&&(this.todos.splice(i,1),console.log("已删除待办事项 ID: "+n))},editTodo(n){this.editingTodo={...n}},saveEdit(){if(this.editingTodo&&this.editingTodo.text.trim()!==""){const n=this.todos.findIndex(i=>i.id===this.editingTodo.id);n!==-1&&(this.$set(this.todos,n,{...this.editingTodo}),console.log("已更新待办事项 ID: "+this.editingTodo.id))}this.editingTodo=null},cancelEdit(){this.editingTodo=null},clearCompleted(){const n=this.todos.length;this.todos=this.todos.filter(s=>!s.completed);const i=n-this.todos.length;console.log("已清除 "+i+" 个已完成事项")},formatDate(n){return new Date(n).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},$lifecycle_mounted(){console.log("TodoApp 组件已挂载到 DOM"),this.$nextTick(()=>{document.querySelectorAll(".todo-item").forEach(i=>{i.addEventListener("dblclick",()=>{const s=parseInt(i.dataset.id),r=this.todos.findIndex(l=>l.id===s);r!==-1&&(this.todos[r].completed=!this.todos[r].completed,console.log("双击切换待办事项状态 ID: "+s))})})})},$lifecycle_unmounted(){console.log("TodoApp 组件已销毁")},get $el(){return e.$el},get $parent(){return e.$parent},get $children(){return e.$children},get $root(){return e.$root},$set(n,i,s){n[i]=s},$emit(n,i){e.dispatchEvent(new CustomEvent(e._eventPrefix+n,{detail:i}))}}),this.$app=Qt(this.app).mount(this._el);let o=this.parentElement;for(;o&&!te(o);)o=o.parentElement;o&&(this._parent=o,o._children.push(this)),this.dispatchEvent(new CustomEvent("mounted")),this.app?.$lifecycle_mounted?.(),(function(){const n=(function(){return{newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0}})();Object.keys(n).forEach(i=>{(e?.constructor?.observedAttributes??[]).indexOf?.(i)>=0?ee.info("当前属性 "+i+" 已定义为 prop 属性, 无法初始化."):e.app[i]=n[i]})})()}attributeChangedCallback(e,o,n){if(!this.app){var i=this;setTimeout(function(){i.attributeChangedCallback(e,o,n)},10);return}if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){const s=this._types[e];s&&(this.app[s.attr]=this._typeChcker(n,s.type))}}disconnectedCallback(){this._children&&(this._children.forEach(e=>e.disconnectedCallback()),this._children=[]),this._parent&&(this._parent._children=this._parent._children.filter(e=>e!==this),this._parent=null),Object.keys(this._listeners).forEach(e=>this.off(e)),this._listeners={},this.dispatchEvent(new CustomEvent("unmounted")),this.app?.$lifecycle_unmounted?.(),this.app=null,this.$app.unmount(),this.$app=null,this._el=null}get __isDarkchest(){return this._isDarkchest}get __componentId(){return this._componentId}get $el(){return this._el||null}get $parent(){return this._parent||null}get $children(){return this._children||[]}get $root(){let e=this;for(;e.$parent&&te(e.$parent);)e=e.$parent;return e}_typeChcker(e,o){return e}prop(e,o){if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){if(o===void 0)return this.getAttribute(e);this.setAttribute(e,o)}else ee.info(`未定义的prop [${e}]`)}get initialTodos(){return this?.app?.initialTodos}set initialTodos(e){this.app.initialTodos=this?._typeChcker?.(e,"Array","Object")}get appTitle(){return this?.app?.appTitle}set appTitle(e){this.app.appTitle=this?._typeChcker?.(e,"String")}get enableLocalStorage(){return this?.app?.enableLocalStorage}set enableLocalStorage(e){this.app.enableLocalStorage=this?._typeChcker?.(e,"Boolean")}on(e,o,n){const i=this._eventPrefix+e;return this._listeners[i]=o,this.addEventListener(i,o,n),this}off(e,o){if(e){const n=this._eventPrefix+e;if(o)this.removeEventListener(n,o),delete this._listeners[n];else{const i=this._listeners[n];i&&(this.removeEventListener(n,i),delete this._listeners[n])}}return this}once(e,o,n){const i=this._eventPrefix+e,s=(...r)=>{this.removeEventListener(i,s),o(...r)};return this.addEventListener(i,s,n),this}addTodo(){return this.app.addTodo()}deleteTodo(e){return this.app.deleteTodo(e)}editTodo(e){return this.app.editTodo(e)}saveEdit(){return this.app.saveEdit()}cancelEdit(){return this.app.cancelEdit()}clearCompleted(){return this.app.clearCompleted()}formatDate(e){return this.app.formatDate(e)}}customElements.define("todo-list",mo)}));
|