@darkchest/wck 0.0.3 → 0.0.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/example/dist/index.es.min.js +1357 -0
- package/example/dist/index.iife.min.js +444 -0
- package/example/dist/index.umd.min.js +444 -0
- package/example/index.html +12 -0
- package/example/package.json +18 -0
- package/example/src/index.js +3 -0
- package/example/vite.config.js +17 -0
- package/package.json +1 -1
- package/readme.md +15 -2
- /package/{demo/Todo.vue → example/src/components/TodoList.vue} +0 -0
|
@@ -0,0 +1,1357 @@
|
|
|
1
|
+
var ie = Object.defineProperty, se = (t, e, o) => e in t ? ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, L = (t, e, o) => (se(t, typeof e != "symbol" ? e + "" : e, o), o);
|
|
2
|
+
function re(t, e) {
|
|
3
|
+
const o = /* @__PURE__ */ Object.create(null), n = t.split(",");
|
|
4
|
+
for (let i = 0; i < n.length; i++) o[n[i]] = !0;
|
|
5
|
+
return (i) => !!o[i];
|
|
6
|
+
}
|
|
7
|
+
function jt(t) {
|
|
8
|
+
if (b(t)) {
|
|
9
|
+
const e = {};
|
|
10
|
+
for (let o = 0; o < t.length; o++) {
|
|
11
|
+
const n = t[o], i = N(n) ? ae(n) : jt(n);
|
|
12
|
+
if (i) for (const s in i) e[s] = i[s];
|
|
13
|
+
}
|
|
14
|
+
return e;
|
|
15
|
+
} else if (N(t) || S(t)) return t;
|
|
16
|
+
}
|
|
17
|
+
const le = /;(?![^(]*\))/g, ce = /:(.+)/;
|
|
18
|
+
function ae(t) {
|
|
19
|
+
const e = {};
|
|
20
|
+
return t.split(le).forEach((o) => {
|
|
21
|
+
if (o) {
|
|
22
|
+
const n = o.split(ce);
|
|
23
|
+
n.length > 1 && (e[n[0].trim()] = n[1].trim());
|
|
24
|
+
}
|
|
25
|
+
}), e;
|
|
26
|
+
}
|
|
27
|
+
function Pt(t) {
|
|
28
|
+
let e = "";
|
|
29
|
+
if (N(t)) e = t;
|
|
30
|
+
else if (b(t)) for (let o = 0; o < t.length; o++) {
|
|
31
|
+
const n = Pt(t[o]);
|
|
32
|
+
n && (e += n + " ");
|
|
33
|
+
}
|
|
34
|
+
else if (S(t)) for (const o in t) t[o] && (e += o + " ");
|
|
35
|
+
return e.trim();
|
|
36
|
+
}
|
|
37
|
+
function de(t, e) {
|
|
38
|
+
if (t.length !== e.length) return !1;
|
|
39
|
+
let o = !0;
|
|
40
|
+
for (let n = 0; o && n < t.length; n++) o = R(t[n], e[n]);
|
|
41
|
+
return o;
|
|
42
|
+
}
|
|
43
|
+
function R(t, e) {
|
|
44
|
+
if (t === e) return !0;
|
|
45
|
+
let o = gt(t), n = gt(e);
|
|
46
|
+
if (o || n) return o && n ? t.getTime() === e.getTime() : !1;
|
|
47
|
+
if (o = b(t), n = b(e), o || n) return o && n ? de(t, e) : !1;
|
|
48
|
+
if (o = S(t), n = S(e), o || n) {
|
|
49
|
+
if (!o || !n) return !1;
|
|
50
|
+
const i = Object.keys(t).length, s = Object.keys(e).length;
|
|
51
|
+
if (i !== s) return !1;
|
|
52
|
+
for (const r in t) {
|
|
53
|
+
const l = t.hasOwnProperty(r), a = e.hasOwnProperty(r);
|
|
54
|
+
if (l && !a || !l && a || !R(t[r], e[r])) return !1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return String(t) === String(e);
|
|
58
|
+
}
|
|
59
|
+
function G(t, e) {
|
|
60
|
+
return t.findIndex((o) => R(o, e));
|
|
61
|
+
}
|
|
62
|
+
const pe = Object.assign, ue = (t, e) => {
|
|
63
|
+
const o = t.indexOf(e);
|
|
64
|
+
o > -1 && t.splice(o, 1);
|
|
65
|
+
}, fe = Object.prototype.hasOwnProperty, ct = (t, e) => fe.call(t, e), b = Array.isArray, U = (t) => It(t) === "[object Map]", gt = (t) => t instanceof Date, N = (t) => typeof t == "string", at = (t) => typeof t == "symbol", S = (t) => t !== null && typeof t == "object", he = Object.prototype.toString, It = (t) => he.call(t), ge = (t) => It(t).slice(8, -1), dt = (t) => N(t) && t !== "NaN" && t[0] !== "-" && "" + parseInt(t, 10) === t, Rt = (t) => {
|
|
66
|
+
const e = /* @__PURE__ */ Object.create(null);
|
|
67
|
+
return (o) => e[o] || (e[o] = t(o));
|
|
68
|
+
}, me = /-(\w)/g, be = Rt((t) => t.replace(me, (e, o) => o ? o.toUpperCase() : "")), ve = /\B([A-Z])/g, Nt = Rt((t) => t.replace(ve, "-$1").toLowerCase()), xe = (t, e) => !Object.is(t, e), mt = (t) => {
|
|
69
|
+
const e = parseFloat(t);
|
|
70
|
+
return isNaN(e) ? t : e;
|
|
71
|
+
};
|
|
72
|
+
let ye;
|
|
73
|
+
function Dt(t, e) {
|
|
74
|
+
e = e || ye, e && e.active && e.effects.push(t);
|
|
75
|
+
}
|
|
76
|
+
const Mt = (t) => {
|
|
77
|
+
const e = new Set(t);
|
|
78
|
+
return e.w = 0, e.n = 0, e;
|
|
79
|
+
}, zt = (t) => (t.w & C) > 0, Bt = (t) => (t.n & C) > 0, _e = ({ deps: t }) => {
|
|
80
|
+
if (t.length) for (let e = 0; e < t.length; e++) t[e].w |= C;
|
|
81
|
+
}, we = (t) => {
|
|
82
|
+
const { deps: e } = t;
|
|
83
|
+
if (e.length) {
|
|
84
|
+
let o = 0;
|
|
85
|
+
for (let n = 0; n < e.length; n++) {
|
|
86
|
+
const i = e[n];
|
|
87
|
+
zt(i) && !Bt(i) ? i.delete(t) : e[o++] = i, i.w &= ~C, i.n &= ~C;
|
|
88
|
+
}
|
|
89
|
+
e.length = o;
|
|
90
|
+
}
|
|
91
|
+
}, X = /* @__PURE__ */ new WeakMap();
|
|
92
|
+
let z = 0, C = 1;
|
|
93
|
+
const tt = 30, M = [];
|
|
94
|
+
let j;
|
|
95
|
+
const W = /* @__PURE__ */ Symbol(""), bt = /* @__PURE__ */ Symbol("");
|
|
96
|
+
class ke {
|
|
97
|
+
constructor(e, o = null, n) {
|
|
98
|
+
this.fn = e, this.scheduler = o, this.active = !0, this.deps = [], Dt(this, n);
|
|
99
|
+
}
|
|
100
|
+
run() {
|
|
101
|
+
if (!this.active) return this.fn();
|
|
102
|
+
if (!M.includes(this)) try {
|
|
103
|
+
return M.push(j = this), Se(), C = 1 << ++z, z <= tt ? _e(this) : vt(this), this.fn();
|
|
104
|
+
} finally {
|
|
105
|
+
z <= tt && we(this), C = 1 << --z, Ht(), M.pop();
|
|
106
|
+
const e = M.length;
|
|
107
|
+
j = e > 0 ? M[e - 1] : void 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
stop() {
|
|
111
|
+
this.active && (vt(this), this.onStop && this.onStop(), this.active = !1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function vt(t) {
|
|
115
|
+
const { deps: e } = t;
|
|
116
|
+
if (e.length) {
|
|
117
|
+
for (let o = 0; o < e.length; o++) e[o].delete(t);
|
|
118
|
+
e.length = 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function Te(t, e) {
|
|
122
|
+
t.effect && (t = t.effect.fn);
|
|
123
|
+
const o = new ke(t);
|
|
124
|
+
e && (pe(o, e), e.scope && Dt(o, e.scope)), (!e || !e.lazy) && o.run();
|
|
125
|
+
const n = o.run.bind(o);
|
|
126
|
+
return n.effect = o, n;
|
|
127
|
+
}
|
|
128
|
+
function $e(t) {
|
|
129
|
+
t.effect.stop();
|
|
130
|
+
}
|
|
131
|
+
let D = !0;
|
|
132
|
+
const pt = [];
|
|
133
|
+
function Ee() {
|
|
134
|
+
pt.push(D), D = !1;
|
|
135
|
+
}
|
|
136
|
+
function Se() {
|
|
137
|
+
pt.push(D), D = !0;
|
|
138
|
+
}
|
|
139
|
+
function Ht() {
|
|
140
|
+
const t = pt.pop();
|
|
141
|
+
D = t === void 0 ? !0 : t;
|
|
142
|
+
}
|
|
143
|
+
function K(t, e, o) {
|
|
144
|
+
if (!Ce()) return;
|
|
145
|
+
let n = X.get(t);
|
|
146
|
+
n || X.set(t, n = /* @__PURE__ */ new Map());
|
|
147
|
+
let i = n.get(o);
|
|
148
|
+
i || n.set(o, i = Mt()), Oe(i);
|
|
149
|
+
}
|
|
150
|
+
function Ce() {
|
|
151
|
+
return D && j !== void 0;
|
|
152
|
+
}
|
|
153
|
+
function Oe(t, e) {
|
|
154
|
+
let o = !1;
|
|
155
|
+
z <= tt ? Bt(t) || (t.n |= C, o = !zt(t)) : o = !t.has(j), o && (t.add(j), j.deps.push(t));
|
|
156
|
+
}
|
|
157
|
+
function et(t, e, o, n, i, s) {
|
|
158
|
+
const r = X.get(t);
|
|
159
|
+
if (!r) return;
|
|
160
|
+
let l = [];
|
|
161
|
+
if (e === "clear") l = [...r.values()];
|
|
162
|
+
else if (o === "length" && b(t)) r.forEach((a, c) => {
|
|
163
|
+
(c === "length" || c >= n) && l.push(a);
|
|
164
|
+
});
|
|
165
|
+
else switch (o !== void 0 && l.push(r.get(o)), e) {
|
|
166
|
+
case "add":
|
|
167
|
+
b(t) ? dt(o) && l.push(r.get("length")) : (l.push(r.get(W)), U(t) && l.push(r.get(bt)));
|
|
168
|
+
break;
|
|
169
|
+
case "delete":
|
|
170
|
+
b(t) || (l.push(r.get(W)), U(t) && l.push(r.get(bt)));
|
|
171
|
+
break;
|
|
172
|
+
case "set":
|
|
173
|
+
U(t) && l.push(r.get(W));
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
if (l.length === 1) l[0] && xt(l[0]);
|
|
177
|
+
else {
|
|
178
|
+
const a = [];
|
|
179
|
+
for (const c of l) c && a.push(...c);
|
|
180
|
+
xt(Mt(a));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function xt(t, e) {
|
|
184
|
+
for (const o of b(t) ? t : [...t]) (o !== j || o.allowRecurse) && (o.scheduler ? o.scheduler() : o.run());
|
|
185
|
+
}
|
|
186
|
+
const Ae = re("__proto__,__v_isRef,__isVue"), Vt = new Set(Object.getOwnPropertyNames(Symbol).map((t) => Symbol[t]).filter(at)), Le = Wt(), je = Wt(!0), yt = Pe();
|
|
187
|
+
function Pe() {
|
|
188
|
+
const t = {};
|
|
189
|
+
return ["includes", "indexOf", "lastIndexOf"].forEach((e) => {
|
|
190
|
+
t[e] = function(...o) {
|
|
191
|
+
const n = P(this);
|
|
192
|
+
for (let s = 0, r = this.length; s < r; s++) K(n, "get", s + "");
|
|
193
|
+
const i = n[e](...o);
|
|
194
|
+
return i === -1 || i === !1 ? n[e](...o.map(P)) : i;
|
|
195
|
+
};
|
|
196
|
+
}), ["push", "pop", "shift", "unshift", "splice"].forEach((e) => {
|
|
197
|
+
t[e] = function(...o) {
|
|
198
|
+
Ee();
|
|
199
|
+
const n = P(this)[e].apply(this, o);
|
|
200
|
+
return Ht(), n;
|
|
201
|
+
};
|
|
202
|
+
}), t;
|
|
203
|
+
}
|
|
204
|
+
function Wt(t = !1, e = !1) {
|
|
205
|
+
return function(o, n, i) {
|
|
206
|
+
if (n === "__v_isReactive") return !t;
|
|
207
|
+
if (n === "__v_isReadonly") return t;
|
|
208
|
+
if (n === "__v_raw" && i === (t ? e ? Ve : Kt : e ? He : Ft).get(o)) return o;
|
|
209
|
+
const s = b(o);
|
|
210
|
+
if (!t && s && ct(yt, n)) return Reflect.get(yt, n, i);
|
|
211
|
+
const r = Reflect.get(o, n, i);
|
|
212
|
+
return (at(n) ? Vt.has(n) : Ae(n)) || (t || K(o, "get", n), e) ? r : ot(r) ? !s || !dt(n) ? r.value : r : S(r) ? t ? Ke(r) : H(r) : r;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const Ie = Re();
|
|
216
|
+
function Re(t = !1) {
|
|
217
|
+
return function(e, o, n, i) {
|
|
218
|
+
let s = e[o];
|
|
219
|
+
if (!t && !Je(n) && (n = P(n), s = P(s), !b(e) && ot(s) && !ot(n))) return s.value = n, !0;
|
|
220
|
+
const r = b(e) && dt(o) ? Number(o) < e.length : ct(e, o), l = Reflect.set(e, o, n, i);
|
|
221
|
+
return e === P(i) && (r ? xe(n, s) && et(e, "set", o, n) : et(e, "add", o, n)), l;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function Ne(t, e) {
|
|
225
|
+
const o = ct(t, e);
|
|
226
|
+
t[e];
|
|
227
|
+
const n = Reflect.deleteProperty(t, e);
|
|
228
|
+
return n && o && et(t, "delete", e, void 0), n;
|
|
229
|
+
}
|
|
230
|
+
function De(t, e) {
|
|
231
|
+
const o = Reflect.has(t, e);
|
|
232
|
+
return (!at(e) || !Vt.has(e)) && K(t, "has", e), o;
|
|
233
|
+
}
|
|
234
|
+
function Me(t) {
|
|
235
|
+
return K(t, "iterate", b(t) ? "length" : W), Reflect.ownKeys(t);
|
|
236
|
+
}
|
|
237
|
+
const ze = { get: Le, set: Ie, deleteProperty: Ne, has: De, ownKeys: Me }, Be = { get: je, set(t, e) {
|
|
238
|
+
return !0;
|
|
239
|
+
}, deleteProperty(t, e) {
|
|
240
|
+
return !0;
|
|
241
|
+
} }, Ft = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), Kt = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap();
|
|
242
|
+
function We(t) {
|
|
243
|
+
switch (t) {
|
|
244
|
+
case "Object":
|
|
245
|
+
case "Array":
|
|
246
|
+
return 1;
|
|
247
|
+
case "Map":
|
|
248
|
+
case "Set":
|
|
249
|
+
case "WeakMap":
|
|
250
|
+
case "WeakSet":
|
|
251
|
+
return 2;
|
|
252
|
+
default:
|
|
253
|
+
return 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function Fe(t) {
|
|
257
|
+
return t.__v_skip || !Object.isExtensible(t) ? 0 : We(ge(t));
|
|
258
|
+
}
|
|
259
|
+
function H(t) {
|
|
260
|
+
return t && t.__v_isReadonly ? t : Jt(t, !1, ze, null, Ft);
|
|
261
|
+
}
|
|
262
|
+
function Ke(t) {
|
|
263
|
+
return Jt(t, !0, Be, null, Kt);
|
|
264
|
+
}
|
|
265
|
+
function Jt(t, e, o, n, i) {
|
|
266
|
+
if (!S(t) || t.__v_raw && !(e && t.__v_isReactive)) return t;
|
|
267
|
+
const s = i.get(t);
|
|
268
|
+
if (s) return s;
|
|
269
|
+
const r = Fe(t);
|
|
270
|
+
if (r === 0) return t;
|
|
271
|
+
const l = new Proxy(t, r === 2 ? n : o);
|
|
272
|
+
return i.set(t, l), l;
|
|
273
|
+
}
|
|
274
|
+
function Je(t) {
|
|
275
|
+
return !!(t && t.__v_isReadonly);
|
|
276
|
+
}
|
|
277
|
+
function P(t) {
|
|
278
|
+
const e = t && t.__v_raw;
|
|
279
|
+
return e ? P(e) : t;
|
|
280
|
+
}
|
|
281
|
+
function ot(t) {
|
|
282
|
+
return !!(t && t.__v_isRef === !0);
|
|
283
|
+
}
|
|
284
|
+
Promise.resolve();
|
|
285
|
+
let nt = !1;
|
|
286
|
+
const F = [], qe = Promise.resolve(), J = (t) => qe.then(t), _t = (t) => {
|
|
287
|
+
F.includes(t) || F.push(t), nt || (nt = !0, J(Ze));
|
|
288
|
+
}, Ze = () => {
|
|
289
|
+
for (const t of F) t();
|
|
290
|
+
F.length = 0, nt = !1;
|
|
291
|
+
}, Ge = /^(spellcheck|draggable|form|list|type)$/, it = ({ el: t, get: e, effect: o, arg: n, modifiers: i }) => {
|
|
292
|
+
let s;
|
|
293
|
+
n === "class" && (t._class = t.className), o(() => {
|
|
294
|
+
let r = e();
|
|
295
|
+
if (n) i?.camel && (n = be(n)), Y(t, n, r, s);
|
|
296
|
+
else {
|
|
297
|
+
for (const l in r) Y(t, l, r[l], s && s[l]);
|
|
298
|
+
for (const l in s) (!r || !(l in r)) && Y(t, l, null);
|
|
299
|
+
}
|
|
300
|
+
s = r;
|
|
301
|
+
});
|
|
302
|
+
}, Y = (t, e, o, n) => {
|
|
303
|
+
if (e === "class") t.setAttribute("class", Pt(t._class ? [t._class, o] : o) || "");
|
|
304
|
+
else if (e === "style") {
|
|
305
|
+
o = jt(o);
|
|
306
|
+
const { style: i } = t;
|
|
307
|
+
if (!o) t.removeAttribute("style");
|
|
308
|
+
else if (N(o)) o !== n && (i.cssText = o);
|
|
309
|
+
else {
|
|
310
|
+
for (const s in o) st(i, s, o[s]);
|
|
311
|
+
if (n && !N(n)) for (const s in n) o[s] == null && st(i, s, "");
|
|
312
|
+
}
|
|
313
|
+
} else !(t instanceof SVGElement) && e in t && !Ge.test(e) ? (t[e] = o, e === "value" && (t._value = o)) : e === "true-value" ? t._trueValue = o : e === "false-value" ? t._falseValue = o : o != null ? t.setAttribute(e, o) : t.removeAttribute(e);
|
|
314
|
+
}, wt = /\s*!important$/, st = (t, e, o) => {
|
|
315
|
+
b(o) ? o.forEach((n) => st(t, e, n)) : e.startsWith("--") ? t.setProperty(e, o) : wt.test(o) ? t.setProperty(Nt(e), o.replace(wt, ""), "important") : t[e] = o;
|
|
316
|
+
}, E = (t, e) => {
|
|
317
|
+
const o = t.getAttribute(e);
|
|
318
|
+
return o != null && t.removeAttribute(e), o;
|
|
319
|
+
}, $ = (t, e, o, n) => {
|
|
320
|
+
t.addEventListener(e, o, n);
|
|
321
|
+
}, Ue = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/, Ye = ["ctrl", "shift", "alt", "meta"], Qe = { stop: (t) => t.stopPropagation(), prevent: (t) => t.preventDefault(), self: (t) => t.target !== t.currentTarget, ctrl: (t) => !t.ctrlKey, shift: (t) => !t.shiftKey, alt: (t) => !t.altKey, meta: (t) => !t.metaKey, left: (t) => "button" in t && t.button !== 0, middle: (t) => "button" in t && t.button !== 1, right: (t) => "button" in t && t.button !== 2, exact: (t, e) => Ye.some((o) => t[`${o}Key`] && !e[o]) }, qt = ({ el: t, get: e, exp: o, arg: n, modifiers: i }) => {
|
|
322
|
+
if (!n) return;
|
|
323
|
+
let s = Ue.test(o) ? e(`(e => ${o}(e))`) : e(`($event => { ${o} })`);
|
|
324
|
+
if (n === "vue:mounted") {
|
|
325
|
+
J(s);
|
|
326
|
+
return;
|
|
327
|
+
} else if (n === "vue:unmounted") return () => s();
|
|
328
|
+
if (i) {
|
|
329
|
+
n === "click" && (i.right && (n = "contextmenu"), i.middle && (n = "mouseup"));
|
|
330
|
+
const r = s;
|
|
331
|
+
s = (l) => {
|
|
332
|
+
if (!("key" in l && !(Nt(l.key) in i))) {
|
|
333
|
+
for (const a in i) {
|
|
334
|
+
const c = Qe[a];
|
|
335
|
+
if (c && c(l, i)) return;
|
|
336
|
+
}
|
|
337
|
+
return r(l);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
$(t, n, s, i);
|
|
342
|
+
}, Xe = ({ el: t, get: e, effect: o }) => {
|
|
343
|
+
const n = t.style.display;
|
|
344
|
+
o(() => {
|
|
345
|
+
t.style.display = e() ? n : "none";
|
|
346
|
+
});
|
|
347
|
+
}, Zt = ({ el: t, get: e, effect: o }) => {
|
|
348
|
+
o(() => {
|
|
349
|
+
t.textContent = Gt(e());
|
|
350
|
+
});
|
|
351
|
+
}, Gt = (t) => t == null ? "" : S(t) ? JSON.stringify(t, null, 2) : String(t), to = ({ el: t, get: e, effect: o }) => {
|
|
352
|
+
o(() => {
|
|
353
|
+
t.innerHTML = e();
|
|
354
|
+
});
|
|
355
|
+
}, eo = ({ el: t, exp: e, get: o, effect: n, modifiers: i }) => {
|
|
356
|
+
const s = t.type, r = o(`(val) => { ${e} = val }`), { trim: l, number: a = s === "number" } = i || {};
|
|
357
|
+
if (t.tagName === "SELECT") {
|
|
358
|
+
const c = t;
|
|
359
|
+
$(t, "change", () => {
|
|
360
|
+
const d = Array.prototype.filter.call(c.options, (p) => p.selected).map((p) => a ? mt(T(p)) : T(p));
|
|
361
|
+
r(c.multiple ? d : d[0]);
|
|
362
|
+
}), n(() => {
|
|
363
|
+
const d = o(), p = c.multiple;
|
|
364
|
+
for (let u = 0, x = c.options.length; u < x; u++) {
|
|
365
|
+
const v = c.options[u], y = T(v);
|
|
366
|
+
if (p) b(d) ? v.selected = G(d, y) > -1 : v.selected = d.has(y);
|
|
367
|
+
else if (R(T(v), d)) {
|
|
368
|
+
c.selectedIndex !== u && (c.selectedIndex = u);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
!p && c.selectedIndex !== -1 && (c.selectedIndex = -1);
|
|
373
|
+
});
|
|
374
|
+
} else if (s === "checkbox") {
|
|
375
|
+
$(t, "change", () => {
|
|
376
|
+
const d = o(), p = t.checked;
|
|
377
|
+
if (b(d)) {
|
|
378
|
+
const u = T(t), x = G(d, u), v = x !== -1;
|
|
379
|
+
if (p && !v) r(d.concat(u));
|
|
380
|
+
else if (!p && v) {
|
|
381
|
+
const y = [...d];
|
|
382
|
+
y.splice(x, 1), r(y);
|
|
383
|
+
}
|
|
384
|
+
} else r(kt(t, p));
|
|
385
|
+
});
|
|
386
|
+
let c;
|
|
387
|
+
n(() => {
|
|
388
|
+
const d = o();
|
|
389
|
+
b(d) ? t.checked = G(d, T(t)) > -1 : d !== c && (t.checked = R(d, kt(t, !0))), c = d;
|
|
390
|
+
});
|
|
391
|
+
} else if (s === "radio") {
|
|
392
|
+
$(t, "change", () => {
|
|
393
|
+
r(T(t));
|
|
394
|
+
});
|
|
395
|
+
let c;
|
|
396
|
+
n(() => {
|
|
397
|
+
const d = o();
|
|
398
|
+
d !== c && (t.checked = R(d, T(t)));
|
|
399
|
+
});
|
|
400
|
+
} else {
|
|
401
|
+
const c = (d) => l ? d.trim() : a ? mt(d) : d;
|
|
402
|
+
$(t, "compositionstart", oo), $(t, "compositionend", no), $(t, i?.lazy ? "change" : "input", () => {
|
|
403
|
+
t.composing || r(c(t.value));
|
|
404
|
+
}), l && $(t, "change", () => {
|
|
405
|
+
t.value = t.value.trim();
|
|
406
|
+
}), n(() => {
|
|
407
|
+
if (t.composing) return;
|
|
408
|
+
const d = t.value, p = o();
|
|
409
|
+
document.activeElement === t && c(d) === p || d !== p && (t.value = p);
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}, T = (t) => "_value" in t ? t._value : t.value, kt = (t, e) => {
|
|
413
|
+
const o = e ? "_trueValue" : "_falseValue";
|
|
414
|
+
return o in t ? t[o] : e;
|
|
415
|
+
}, oo = (t) => {
|
|
416
|
+
t.target.composing = !0;
|
|
417
|
+
}, no = (t) => {
|
|
418
|
+
const e = t.target;
|
|
419
|
+
e.composing && (e.composing = !1, io(e, "input"));
|
|
420
|
+
}, io = (t, e) => {
|
|
421
|
+
const o = document.createEvent("HTMLEvents");
|
|
422
|
+
o.initEvent(e, !0, !0), t.dispatchEvent(o);
|
|
423
|
+
}, Tt = /* @__PURE__ */ Object.create(null), B = (t, e, o) => Ut(t, `return(${e})`, o), Ut = (t, e, o) => {
|
|
424
|
+
const n = Tt[e] || (Tt[e] = so(e));
|
|
425
|
+
try {
|
|
426
|
+
return n(t, o);
|
|
427
|
+
} catch (i) {
|
|
428
|
+
console.error(i);
|
|
429
|
+
}
|
|
430
|
+
}, so = (t) => {
|
|
431
|
+
try {
|
|
432
|
+
return new Function("$data", "$el", `with($data){${t}}`);
|
|
433
|
+
} catch (e) {
|
|
434
|
+
return console.error(`${e.message} in expression: ${t}`), () => {
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
}, ro = ({ el: t, ctx: e, exp: o, effect: n }) => {
|
|
438
|
+
J(() => n(() => Ut(e.scope, o, t)));
|
|
439
|
+
}, lo = { bind: it, on: qt, show: Xe, text: Zt, html: to, model: eo, effect: ro }, co = (t, e, o) => {
|
|
440
|
+
const n = t.parentElement, i = new Comment("v-if");
|
|
441
|
+
n.insertBefore(i, t);
|
|
442
|
+
const s = [{ exp: e, el: t }];
|
|
443
|
+
let r, l;
|
|
444
|
+
for (; (r = t.nextElementSibling) && (l = null, E(r, "v-else") === "" || (l = E(r, "v-else-if"))); ) n.removeChild(r), s.push({ exp: l, el: r });
|
|
445
|
+
const a = t.nextSibling;
|
|
446
|
+
n.removeChild(t);
|
|
447
|
+
let c, d = -1;
|
|
448
|
+
const p = () => {
|
|
449
|
+
c && (n.insertBefore(i, c.el), c.remove(), c = void 0);
|
|
450
|
+
};
|
|
451
|
+
return o.effect(() => {
|
|
452
|
+
for (let u = 0; u < s.length; u++) {
|
|
453
|
+
const { exp: x, el: v } = s[u];
|
|
454
|
+
if (!x || B(o.scope, x)) {
|
|
455
|
+
u !== d && (p(), c = new ut(v, o), c.insert(n, i), n.removeChild(i), d = u);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
d = -1, p();
|
|
460
|
+
}), a;
|
|
461
|
+
}, ao = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/, $t = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/, po = /^\(|\)$/g, uo = /^[{[]\s*((?:[\w_$]+\s*,?\s*)+)[\]}]$/, fo = (t, e, o) => {
|
|
462
|
+
const n = e.match(ao);
|
|
463
|
+
if (!n) return;
|
|
464
|
+
const i = t.nextSibling, s = t.parentElement, r = new Text("");
|
|
465
|
+
s.insertBefore(r, t), s.removeChild(t);
|
|
466
|
+
const l = n[2].trim();
|
|
467
|
+
let a = n[1].trim().replace(po, "").trim(), c, d = !1, p, u, x = "key", v = t.getAttribute(x) || t.getAttribute(x = ":key") || t.getAttribute(x = "v-bind:key");
|
|
468
|
+
v && (t.removeAttribute(x), x === "key" && (v = JSON.stringify(v)));
|
|
469
|
+
let y;
|
|
470
|
+
(y = a.match($t)) && (a = a.replace($t, "").trim(), p = y[1].trim(), y[2] && (u = y[2].trim())), (y = a.match(uo)) && (c = y[1].split(",").map((g) => g.trim()), d = a[0] === "[");
|
|
471
|
+
let ft = !1, O, V, q;
|
|
472
|
+
const ne = (g) => {
|
|
473
|
+
const _ = /* @__PURE__ */ new Map(), f = [];
|
|
474
|
+
if (b(g)) for (let h = 0; h < g.length; h++) f.push(Z(_, g[h], h));
|
|
475
|
+
else if (typeof g == "number") for (let h = 0; h < g; h++) f.push(Z(_, h + 1, h));
|
|
476
|
+
else if (S(g)) {
|
|
477
|
+
let h = 0;
|
|
478
|
+
for (const m in g) f.push(Z(_, g[m], h++, m));
|
|
479
|
+
}
|
|
480
|
+
return [f, _];
|
|
481
|
+
}, Z = (g, _, f, h) => {
|
|
482
|
+
const m = {};
|
|
483
|
+
c ? c.forEach((A, k) => m[A] = _[d ? k : A]) : m[a] = _, h ? (p && (m[p] = h), u && (m[u] = f)) : p && (m[p] = f);
|
|
484
|
+
const I = te(o, m), w = v ? B(I.scope, v) : f;
|
|
485
|
+
return g.set(w, f), I.key = w, I;
|
|
486
|
+
}, ht = (g, _) => {
|
|
487
|
+
const f = new ut(t, g);
|
|
488
|
+
return f.key = g.key, f.insert(s, _), f;
|
|
489
|
+
};
|
|
490
|
+
return o.effect(() => {
|
|
491
|
+
const g = B(o.scope, l), _ = q;
|
|
492
|
+
if ([V, q] = ne(g), !ft) O = V.map((f) => ht(f, r)), ft = !0;
|
|
493
|
+
else {
|
|
494
|
+
for (let w = 0; w < O.length; w++) q.has(O[w].key) || O[w].remove();
|
|
495
|
+
const f = [];
|
|
496
|
+
let h = V.length, m, I;
|
|
497
|
+
for (; h--; ) {
|
|
498
|
+
const w = V[h], A = _.get(w.key);
|
|
499
|
+
let k;
|
|
500
|
+
A == null ? k = ht(w, m ? m.el : r) : (k = O[A], Object.assign(k.ctx.scope, w.scope), A !== h && (O[A + 1] !== m || I === m) && (I = k, k.insert(s, m ? m.el : r))), f.unshift(m = k);
|
|
501
|
+
}
|
|
502
|
+
O = f;
|
|
503
|
+
}
|
|
504
|
+
}), i;
|
|
505
|
+
}, Yt = ({ el: t, ctx: { scope: { $refs: e } }, get: o, effect: n }) => {
|
|
506
|
+
let i;
|
|
507
|
+
return n(() => {
|
|
508
|
+
const s = o();
|
|
509
|
+
e[s] = t, i && s !== i && delete e[i], i = s;
|
|
510
|
+
}), () => {
|
|
511
|
+
i && delete e[i];
|
|
512
|
+
};
|
|
513
|
+
}, ho = /^(?:v-|:|@)/, go = /\.([\w-]+)/g;
|
|
514
|
+
let rt = !1;
|
|
515
|
+
const Qt = (t, e) => {
|
|
516
|
+
const o = t.nodeType;
|
|
517
|
+
if (o === 1) {
|
|
518
|
+
const n = t;
|
|
519
|
+
if (n.hasAttribute("v-pre")) return;
|
|
520
|
+
E(n, "v-cloak");
|
|
521
|
+
let i;
|
|
522
|
+
if (i = E(n, "v-if")) return co(n, i, e);
|
|
523
|
+
if (i = E(n, "v-for")) return fo(n, i, e);
|
|
524
|
+
if ((i = E(n, "v-scope")) || i === "") {
|
|
525
|
+
const l = i ? B(e.scope, i) : {};
|
|
526
|
+
e = te(e, l), l.$template && mo(n, l.$template);
|
|
527
|
+
}
|
|
528
|
+
const s = E(n, "v-once") != null;
|
|
529
|
+
s && (rt = !0), (i = E(n, "ref")) && lt(n, Yt, `"${i}"`, e), Et(n, e);
|
|
530
|
+
const r = [];
|
|
531
|
+
for (const { name: l, value: a } of [...n.attributes]) ho.test(l) && l !== "v-cloak" && (l === "v-model" ? r.unshift([l, a]) : l[0] === "@" || /^v-on\b/.test(l) ? r.push([l, a]) : St(n, l, a, e));
|
|
532
|
+
for (const [l, a] of r) St(n, l, a, e);
|
|
533
|
+
s && (rt = !1);
|
|
534
|
+
} else if (o === 3) {
|
|
535
|
+
const n = t.data;
|
|
536
|
+
if (n.includes(e.delimiters[0])) {
|
|
537
|
+
let i = [], s = 0, r;
|
|
538
|
+
for (; r = e.delimitersRE.exec(n); ) {
|
|
539
|
+
const l = n.slice(s, r.index);
|
|
540
|
+
l && i.push(JSON.stringify(l)), i.push(`$s(${r[1]})`), s = r.index + r[0].length;
|
|
541
|
+
}
|
|
542
|
+
s < n.length && i.push(JSON.stringify(n.slice(s))), lt(t, Zt, i.join("+"), e);
|
|
543
|
+
}
|
|
544
|
+
} else o === 11 && Et(t, e);
|
|
545
|
+
}, Et = (t, e) => {
|
|
546
|
+
let o = t.firstChild;
|
|
547
|
+
for (; o; ) o = Qt(o, e) || o.nextSibling;
|
|
548
|
+
}, St = (t, e, o, n) => {
|
|
549
|
+
let i, s, r;
|
|
550
|
+
if (e = e.replace(go, (l, a) => ((r || (r = {}))[a] = !0, "")), e[0] === ":") i = it, s = e.slice(1);
|
|
551
|
+
else if (e[0] === "@") i = qt, s = e.slice(1);
|
|
552
|
+
else {
|
|
553
|
+
const l = e.indexOf(":"), a = l > 0 ? e.slice(2, l) : e.slice(2);
|
|
554
|
+
i = lo[a] || n.dirs[a], s = l > 0 ? e.slice(l + 1) : void 0;
|
|
555
|
+
}
|
|
556
|
+
i && (i === it && s === "ref" && (i = Yt), lt(t, i, o, n, s, r), t.removeAttribute(e));
|
|
557
|
+
}, lt = (t, e, o, n, i, s) => {
|
|
558
|
+
const r = e({ el: t, get: (l = o) => B(n.scope, l, t), effect: n.effect, ctx: n, exp: o, arg: i, modifiers: s });
|
|
559
|
+
r && n.cleanups.push(r);
|
|
560
|
+
}, mo = (t, e) => {
|
|
561
|
+
if (e[0] === "#") {
|
|
562
|
+
const o = document.querySelector(e);
|
|
563
|
+
t.appendChild(o.content.cloneNode(!0));
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
t.innerHTML = e;
|
|
567
|
+
}, Xt = (t) => {
|
|
568
|
+
const e = { delimiters: ["{{", "}}"], delimitersRE: /\{\{([^]+?)\}\}/g, ...t, scope: t ? t.scope : H({}), dirs: t ? t.dirs : {}, effects: [], blocks: [], cleanups: [], effect: (o) => {
|
|
569
|
+
if (rt) return _t(o), o;
|
|
570
|
+
const n = Te(o, { scheduler: () => _t(n) });
|
|
571
|
+
return e.effects.push(n), n;
|
|
572
|
+
} };
|
|
573
|
+
return e;
|
|
574
|
+
}, te = (t, e = {}) => {
|
|
575
|
+
const o = t.scope, n = Object.create(o);
|
|
576
|
+
Object.defineProperties(n, Object.getOwnPropertyDescriptors(e)), n.$refs = Object.create(o.$refs);
|
|
577
|
+
const i = H(new Proxy(n, { set(s, r, l, a) {
|
|
578
|
+
return a === i && !s.hasOwnProperty(r) ? Reflect.set(o, r, l) : Reflect.set(s, r, l, a);
|
|
579
|
+
} }));
|
|
580
|
+
return ee(i), { ...t, scope: i };
|
|
581
|
+
}, ee = (t) => {
|
|
582
|
+
for (const e of Object.keys(t)) typeof t[e] == "function" && (t[e] = t[e].bind(t));
|
|
583
|
+
};
|
|
584
|
+
class ut {
|
|
585
|
+
constructor(e, o, n = !1) {
|
|
586
|
+
L(this, "template"), L(this, "ctx"), L(this, "key"), L(this, "parentCtx"), L(this, "isFragment"), L(this, "start"), L(this, "end"), this.isFragment = e instanceof HTMLTemplateElement, n ? this.template = e : this.isFragment ? this.template = e.content.cloneNode(!0) : this.template = e.cloneNode(!0), n ? this.ctx = o : (this.parentCtx = o, o.blocks.push(this), this.ctx = Xt(o)), Qt(this.template, this.ctx);
|
|
587
|
+
}
|
|
588
|
+
get el() {
|
|
589
|
+
return this.start || this.template;
|
|
590
|
+
}
|
|
591
|
+
insert(e, o = null) {
|
|
592
|
+
if (this.isFragment) if (this.start) {
|
|
593
|
+
let n = this.start, i;
|
|
594
|
+
for (; n && (i = n.nextSibling, e.insertBefore(n, o), n !== this.end); ) n = i;
|
|
595
|
+
} else this.start = new Text(""), this.end = new Text(""), e.insertBefore(this.end, o), e.insertBefore(this.start, this.end), e.insertBefore(this.template, this.end);
|
|
596
|
+
else e.insertBefore(this.template, o);
|
|
597
|
+
}
|
|
598
|
+
remove() {
|
|
599
|
+
if (this.parentCtx && ue(this.parentCtx.blocks, this), this.start) {
|
|
600
|
+
const e = this.start.parentNode;
|
|
601
|
+
let o = this.start, n;
|
|
602
|
+
for (; o && (n = o.nextSibling, e.removeChild(o), o !== this.end); ) o = n;
|
|
603
|
+
} else this.template.parentNode.removeChild(this.template);
|
|
604
|
+
this.teardown();
|
|
605
|
+
}
|
|
606
|
+
teardown() {
|
|
607
|
+
this.ctx.blocks.forEach((e) => {
|
|
608
|
+
e.teardown();
|
|
609
|
+
}), this.ctx.effects.forEach($e), this.ctx.cleanups.forEach((e) => e());
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const Ct = (t) => t.replace(/[-.*+?^${}()|[\]\/\\]/g, "\\$&"), oe = (t) => {
|
|
613
|
+
const e = Xt();
|
|
614
|
+
if (t && (e.scope = H(t), ee(e.scope), t.$delimiters)) {
|
|
615
|
+
const [n, i] = e.delimiters = t.$delimiters;
|
|
616
|
+
e.delimitersRE = new RegExp(Ct(n) + "([^]+?)" + Ct(i), "g");
|
|
617
|
+
}
|
|
618
|
+
e.scope.$s = Gt, e.scope.$nextTick = J, e.scope.$refs = /* @__PURE__ */ Object.create(null);
|
|
619
|
+
let o;
|
|
620
|
+
return { directive(n, i) {
|
|
621
|
+
return i ? (e.dirs[n] = i, this) : e.dirs[n];
|
|
622
|
+
}, mount(n) {
|
|
623
|
+
if (typeof n == "string" && (n = document.querySelector(n), !n)) return;
|
|
624
|
+
n = n || document.documentElement;
|
|
625
|
+
let i;
|
|
626
|
+
return n.hasAttribute("v-scope") ? i = [n] : i = [...n.querySelectorAll("[v-scope]")].filter((s) => !s.matches("[v-scope] [v-scope]")), i.length || (i = [n]), o = i.map((s) => new ut(s, e, !0)), this;
|
|
627
|
+
}, unmount() {
|
|
628
|
+
o.forEach((n) => n.teardown());
|
|
629
|
+
} };
|
|
630
|
+
}, Ot = document.currentScript;
|
|
631
|
+
Ot && Ot.hasAttribute("init") && oe().mount();
|
|
632
|
+
const At = function(t) {
|
|
633
|
+
return !t || !t.tagName ? !1 : [
|
|
634
|
+
// 检查1:是否是自定义元素标签(包含短横线)
|
|
635
|
+
() => t.tagName.includes("-"),
|
|
636
|
+
// 检查2:是否有 shadowRoot
|
|
637
|
+
() => !!t.shadowRoot,
|
|
638
|
+
// 检查3:检查是否注册为自定义元素
|
|
639
|
+
() => {
|
|
640
|
+
try {
|
|
641
|
+
return customElements.get(t.tagName.toLowerCase()) !== void 0;
|
|
642
|
+
} catch {
|
|
643
|
+
return !1;
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
// 检查4:检查是否有常见的 Web Component 特征
|
|
647
|
+
() => ["__isDarkchest", "__componentId"].some((n) => n in t)
|
|
648
|
+
].some((o) => o());
|
|
649
|
+
}, Q = "[@DARKCHEST/LIT]", Lt = {
|
|
650
|
+
log: (...t) => console.log(`${Q} `, ...t),
|
|
651
|
+
warn: (...t) => console.warn(`${Q} `, ...t),
|
|
652
|
+
error: (...t) => console.error(`${Q} `, ...t)
|
|
653
|
+
};
|
|
654
|
+
class bo extends HTMLElement {
|
|
655
|
+
static observedAttributes = ["initialtodos", "apptitle", "enablelocalstorage", "initial-todos", "app-title", "enable-local-storage"];
|
|
656
|
+
constructor() {
|
|
657
|
+
super(), this._isDarkchest = !0, this._componentId = Math.random().toString(36).substring(2), this._types = { initialTodos: { type: ["Array", "Object"], attr: "initialTodos" }, initialtodos: { type: ["Array", "Object"], attr: "initialTodos" }, "initial-todos": { type: ["Array", "Object"], attr: "initialTodos" }, appTitle: { type: ["String"], attr: "appTitle" }, apptitle: { type: ["String"], attr: "appTitle" }, "app-title": { type: ["String"], attr: "appTitle" }, enableLocalStorage: { type: ["Boolean"], attr: "enableLocalStorage" }, enablelocalstorage: { type: ["Boolean"], attr: "enableLocalStorage" }, "enable-local-storage": { type: ["Boolean"], attr: "enableLocalStorage" } }, this._watchers = {}, this._listeners = [], this._el = null, this._parent = null, this._children = [], this._eventPrefix = "@", this.attachShadow({ mode: "open" });
|
|
658
|
+
const e = document.createElement("style");
|
|
659
|
+
e.textContent = `
|
|
660
|
+
*, *::before, *::after {
|
|
661
|
+
padding: 0;
|
|
662
|
+
margin: 0;
|
|
663
|
+
box-sizing: border-box;
|
|
664
|
+
}
|
|
665
|
+
#app {
|
|
666
|
+
font-family: "Avenir", Helvetica, Arial, sans-serif;
|
|
667
|
+
-webkit-font-smoothing: antialiased;
|
|
668
|
+
-moz-osx-font-smoothing: grayscale;
|
|
669
|
+
color: #2c3e50;
|
|
670
|
+
max-width: 800px;
|
|
671
|
+
margin: 0 auto;
|
|
672
|
+
padding: 20px;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
.todo-container {
|
|
676
|
+
background: white;
|
|
677
|
+
border-radius: 10px;
|
|
678
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
|
679
|
+
padding: 30px;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
header {
|
|
683
|
+
text-align: center;
|
|
684
|
+
margin-bottom: 30px;
|
|
685
|
+
border-bottom: 1px solid #eee;
|
|
686
|
+
padding-bottom: 20px;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.app-title {
|
|
690
|
+
color: #42b983;
|
|
691
|
+
font-size: 2.5rem;
|
|
692
|
+
margin-bottom: 10px;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.app-description {
|
|
696
|
+
color: #7f8c8d;
|
|
697
|
+
font-size: 1rem;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.add-todo {
|
|
701
|
+
display: flex;
|
|
702
|
+
gap: 10px;
|
|
703
|
+
margin-bottom: 20px;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.todo-input {
|
|
707
|
+
flex: 1;
|
|
708
|
+
padding: 12px 15px;
|
|
709
|
+
border: 2px solid #e0e0e0;
|
|
710
|
+
border-radius: 6px;
|
|
711
|
+
font-size: 16px;
|
|
712
|
+
transition: border-color 0.3s;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.todo-input:focus {
|
|
716
|
+
border-color: #42b983;
|
|
717
|
+
outline: none;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.add-btn, .clear-btn {
|
|
721
|
+
padding: 12px 20px;
|
|
722
|
+
border: none;
|
|
723
|
+
border-radius: 6px;
|
|
724
|
+
font-weight: bold;
|
|
725
|
+
cursor: pointer;
|
|
726
|
+
transition: all 0.3s;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.add-btn {
|
|
730
|
+
background-color: #42b983;
|
|
731
|
+
color: white;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.add-btn:hover {
|
|
735
|
+
background-color: #3aa876;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
.clear-btn {
|
|
739
|
+
background-color: #f0f0f0;
|
|
740
|
+
color: #333;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.clear-btn:hover {
|
|
744
|
+
background-color: #e0e0e0;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.filter-controls {
|
|
748
|
+
display: flex;
|
|
749
|
+
gap: 10px;
|
|
750
|
+
margin-bottom: 25px;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.filter-btn {
|
|
754
|
+
flex: 1;
|
|
755
|
+
padding: 10px;
|
|
756
|
+
background-color: #f8f9fa;
|
|
757
|
+
border: 1px solid #dee2e6;
|
|
758
|
+
border-radius: 6px;
|
|
759
|
+
cursor: pointer;
|
|
760
|
+
transition: all 0.3s;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.filter-btn.active {
|
|
764
|
+
background-color: #42b983;
|
|
765
|
+
color: white;
|
|
766
|
+
border-color: #42b983;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.filter-btn:hover:not(.active) {
|
|
770
|
+
background-color: #e9ecef;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.todo-list {
|
|
774
|
+
margin-bottom: 25px;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
.empty-state {
|
|
778
|
+
text-align: center;
|
|
779
|
+
padding: 40px 20px;
|
|
780
|
+
color: #95a5a6;
|
|
781
|
+
font-style: italic;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
.todo-item {
|
|
785
|
+
display: flex;
|
|
786
|
+
justify-content: space-between;
|
|
787
|
+
align-items: center;
|
|
788
|
+
padding: 15px;
|
|
789
|
+
border-bottom: 1px solid #f0f0f0;
|
|
790
|
+
transition: all 0.3s;
|
|
791
|
+
border-radius: 6px;
|
|
792
|
+
margin-bottom: 8px;
|
|
793
|
+
background-color: #f9f9f9;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.todo-item:hover {
|
|
797
|
+
background-color: #f0f0f0;
|
|
798
|
+
transform: translateY(-2px);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.todo-item.completed {
|
|
802
|
+
opacity: 0.8;
|
|
803
|
+
background-color: #f0f9f0;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
.todo-content {
|
|
807
|
+
display: flex;
|
|
808
|
+
align-items: center;
|
|
809
|
+
gap: 15px;
|
|
810
|
+
flex: 1;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.todo-checkbox {
|
|
814
|
+
width: 20px;
|
|
815
|
+
height: 20px;
|
|
816
|
+
cursor: pointer;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
.todo-text {
|
|
820
|
+
flex: 1;
|
|
821
|
+
cursor: pointer;
|
|
822
|
+
display: flex;
|
|
823
|
+
justify-content: space-between;
|
|
824
|
+
align-items: center;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.todo-item.completed .todo-text span:first-child {
|
|
828
|
+
text-decoration: line-through;
|
|
829
|
+
color: #95a5a6;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.todo-date {
|
|
833
|
+
font-size: 0.8rem;
|
|
834
|
+
color: #95a5a6;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.todo-actions {
|
|
838
|
+
display: flex;
|
|
839
|
+
gap: 8px;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
.edit-btn, .delete-btn {
|
|
843
|
+
padding: 6px 12px;
|
|
844
|
+
border: none;
|
|
845
|
+
border-radius: 4px;
|
|
846
|
+
font-size: 0.9rem;
|
|
847
|
+
cursor: pointer;
|
|
848
|
+
transition: all 0.2s;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.edit-btn {
|
|
852
|
+
background-color: #f0f0f0;
|
|
853
|
+
color: #333;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
.edit-btn:hover {
|
|
857
|
+
background-color: #e0e0e0;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
.delete-btn {
|
|
861
|
+
background-color: #ff6b6b;
|
|
862
|
+
color: white;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.delete-btn:hover {
|
|
866
|
+
background-color: #ff5252;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.stats {
|
|
870
|
+
margin-top: 25px;
|
|
871
|
+
padding-top: 20px;
|
|
872
|
+
border-top: 1px solid #eee;
|
|
873
|
+
color: #7f8c8d;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.completion-rate {
|
|
877
|
+
color: #42b983;
|
|
878
|
+
font-weight: bold;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
.progress-container {
|
|
882
|
+
height: 10px;
|
|
883
|
+
background-color: #f0f0f0;
|
|
884
|
+
border-radius: 5px;
|
|
885
|
+
margin-top: 10px;
|
|
886
|
+
overflow: hidden;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.progress-bar {
|
|
890
|
+
height: 100%;
|
|
891
|
+
background-color: #42b983;
|
|
892
|
+
border-radius: 5px;
|
|
893
|
+
transition: width 0.5s ease;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
footer {
|
|
897
|
+
margin-top: 30px;
|
|
898
|
+
padding-top: 20px;
|
|
899
|
+
border-top: 1px solid #eee;
|
|
900
|
+
text-align: center;
|
|
901
|
+
color: #95a5a6;
|
|
902
|
+
font-size: 0.9rem;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.footer-text {
|
|
906
|
+
margin: 5px 0;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/* 编辑模态框样式 */
|
|
910
|
+
.modal-overlay {
|
|
911
|
+
position: fixed;
|
|
912
|
+
top: 0;
|
|
913
|
+
left: 0;
|
|
914
|
+
right: 0;
|
|
915
|
+
bottom: 0;
|
|
916
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
917
|
+
display: flex;
|
|
918
|
+
justify-content: center;
|
|
919
|
+
align-items: center;
|
|
920
|
+
z-index: 1000;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
.modal {
|
|
924
|
+
background-color: white;
|
|
925
|
+
padding: 30px;
|
|
926
|
+
border-radius: 10px;
|
|
927
|
+
width: 90%;
|
|
928
|
+
max-width: 500px;
|
|
929
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.modal h3 {
|
|
933
|
+
margin-top: 0;
|
|
934
|
+
margin-bottom: 20px;
|
|
935
|
+
color: #2c3e50;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
.edit-input {
|
|
939
|
+
width: 100%;
|
|
940
|
+
padding: 12px 15px;
|
|
941
|
+
border: 2px solid #42b983;
|
|
942
|
+
border-radius: 6px;
|
|
943
|
+
font-size: 16px;
|
|
944
|
+
margin-bottom: 20px;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
.modal-actions {
|
|
948
|
+
display: flex;
|
|
949
|
+
gap: 10px;
|
|
950
|
+
justify-content: flex-end;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.save-btn, .cancel-btn {
|
|
954
|
+
padding: 10px 20px;
|
|
955
|
+
border: none;
|
|
956
|
+
border-radius: 6px;
|
|
957
|
+
font-weight: bold;
|
|
958
|
+
cursor: pointer;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
.save-btn {
|
|
962
|
+
background-color: #42b983;
|
|
963
|
+
color: white;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
.save-btn:hover {
|
|
967
|
+
background-color: #3aa876;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
.cancel-btn {
|
|
971
|
+
background-color: #f0f0f0;
|
|
972
|
+
color: #333;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
.cancel-btn:hover {
|
|
976
|
+
background-color: #e0e0e0;
|
|
977
|
+
}
|
|
978
|
+
`;
|
|
979
|
+
const o = document.createElement("div");
|
|
980
|
+
o.innerHTML = `<div :data-watch-todos="$todos" :data-watch-filter="$filter">
|
|
981
|
+
<div id="app">
|
|
982
|
+
<div class="todo-container">
|
|
983
|
+
<!-- Header Slot -->
|
|
984
|
+
<header>
|
|
985
|
+
<slot name="header">
|
|
986
|
+
<h1 class="app-title">{{ appTitle }}</h1>
|
|
987
|
+
<p class="app-description">使用 Vue2 实现的 Todo List 应用</p>
|
|
988
|
+
</slot>
|
|
989
|
+
</header>
|
|
990
|
+
|
|
991
|
+
<!-- Add Todo Form -->
|
|
992
|
+
<div class="add-todo">
|
|
993
|
+
<input
|
|
994
|
+
type="text"
|
|
995
|
+
v-model="newTodo"
|
|
996
|
+
placeholder="请输入待办事项..."
|
|
997
|
+
@keyup.enter="addTodo"
|
|
998
|
+
class="todo-input"
|
|
999
|
+
/>
|
|
1000
|
+
<button @click="addTodo" class="add-btn">添加</button>
|
|
1001
|
+
<button @click="clearCompleted" class="clear-btn">清除已完成</button>
|
|
1002
|
+
</div>
|
|
1003
|
+
|
|
1004
|
+
<!-- Filter Controls -->
|
|
1005
|
+
<div class="filter-controls">
|
|
1006
|
+
<button
|
|
1007
|
+
@click="filter = 'all'"
|
|
1008
|
+
:class="{ active: filter === 'all' }"
|
|
1009
|
+
class="filter-btn"
|
|
1010
|
+
>
|
|
1011
|
+
全部 ({{ totalTodos }})
|
|
1012
|
+
</button>
|
|
1013
|
+
<button
|
|
1014
|
+
@click="filter = 'active'"
|
|
1015
|
+
:class="{ active: filter === 'active' }"
|
|
1016
|
+
class="filter-btn"
|
|
1017
|
+
>
|
|
1018
|
+
未完成 ({{ activeTodosCount }})
|
|
1019
|
+
</button>
|
|
1020
|
+
<button
|
|
1021
|
+
@click="filter = 'completed'"
|
|
1022
|
+
:class="{ active: filter === 'completed' }"
|
|
1023
|
+
class="filter-btn"
|
|
1024
|
+
>
|
|
1025
|
+
已完成 ({{ completedTodosCount }})
|
|
1026
|
+
</button>
|
|
1027
|
+
</div>
|
|
1028
|
+
|
|
1029
|
+
<!-- Todo List -->
|
|
1030
|
+
<div class="todo-list">
|
|
1031
|
+
<div v-if="filteredTodos.length === 0" class="empty-state">
|
|
1032
|
+
<p v-if="todos.length === 0">暂无待办事项,请添加一个吧!</p>
|
|
1033
|
+
<p v-else>没有{{ filter === 'active' ? '未完成' : '已完成' }}的事项</p>
|
|
1034
|
+
</div>
|
|
1035
|
+
|
|
1036
|
+
<div
|
|
1037
|
+
v-for="todo in filteredTodos"
|
|
1038
|
+
:key="todo.id"
|
|
1039
|
+
class="todo-item"
|
|
1040
|
+
:class="{ completed: todo.completed }"
|
|
1041
|
+
>
|
|
1042
|
+
<div class="todo-content">
|
|
1043
|
+
<input
|
|
1044
|
+
type="checkbox"
|
|
1045
|
+
v-model="todo.completed"
|
|
1046
|
+
class="todo-checkbox"
|
|
1047
|
+
:id="'todo-' + todo.id"
|
|
1048
|
+
/>
|
|
1049
|
+
<label :for="'todo-' + todo.id" class="todo-text">
|
|
1050
|
+
<span>{{ todo.text }}</span>
|
|
1051
|
+
<span class="todo-date">{{ formatDate(todo.createdAt) }}</span>
|
|
1052
|
+
</label>
|
|
1053
|
+
</div>
|
|
1054
|
+
<div class="todo-actions">
|
|
1055
|
+
<button @click="editTodo(todo)" class="edit-btn">编辑</button>
|
|
1056
|
+
<button @click="deleteTodo(todo.id)" class="delete-btn">删除</button>
|
|
1057
|
+
</div>
|
|
1058
|
+
</div>
|
|
1059
|
+
</div>
|
|
1060
|
+
|
|
1061
|
+
<!-- Stats -->
|
|
1062
|
+
<div class="stats">
|
|
1063
|
+
<p v-if="todos.length > 0">
|
|
1064
|
+
已完成 {{ completedTodosCount }} / 总共 {{ totalTodos }} 个待办事项
|
|
1065
|
+
<span v-if="hasCompletedTodos" class="completion-rate">
|
|
1066
|
+
(完成率: {{ completionRate }}%)
|
|
1067
|
+
</span>
|
|
1068
|
+
</p>
|
|
1069
|
+
|
|
1070
|
+
<!-- Progress Bar Slot -->
|
|
1071
|
+
<slot name="progress">
|
|
1072
|
+
<div class="progress-container">
|
|
1073
|
+
<div class="progress-bar" :style="{ width: completionRate + '%' }"></div>
|
|
1074
|
+
</div>
|
|
1075
|
+
</slot>
|
|
1076
|
+
</div>
|
|
1077
|
+
|
|
1078
|
+
<!-- Footer Slot -->
|
|
1079
|
+
<footer>
|
|
1080
|
+
<slot name="footer">
|
|
1081
|
+
<p class="footer-text">双击事项可标记为完成/未完成</p>
|
|
1082
|
+
<p class="footer-text">使用 Vue2 实现 - 包含 Props, Data, Methods, Slots, Watch, Computed, 生命周期</p>
|
|
1083
|
+
</slot>
|
|
1084
|
+
</footer>
|
|
1085
|
+
</div>
|
|
1086
|
+
|
|
1087
|
+
<!-- Edit Modal -->
|
|
1088
|
+
<div v-if="editingTodo" class="modal-overlay" @click="cancelEdit">
|
|
1089
|
+
<div class="modal" @click.stop>
|
|
1090
|
+
<h3>编辑待办事项</h3>
|
|
1091
|
+
<input
|
|
1092
|
+
type="text"
|
|
1093
|
+
v-model="editingTodo.text"
|
|
1094
|
+
@keyup.enter="saveEdit"
|
|
1095
|
+
class="edit-input"
|
|
1096
|
+
/>
|
|
1097
|
+
<div class="modal-actions">
|
|
1098
|
+
<button @click="saveEdit" class="save-btn">保存</button>
|
|
1099
|
+
<button @click="cancelEdit" class="cancel-btn">取消</button>
|
|
1100
|
+
</div>
|
|
1101
|
+
</div>
|
|
1102
|
+
</div>
|
|
1103
|
+
</div>
|
|
1104
|
+
</div>`, this._el = o.firstElementChild, this.shadowRoot.appendChild(e), this.shadowRoot.appendChild(this._el), this.app = null;
|
|
1105
|
+
}
|
|
1106
|
+
connectedCallback() {
|
|
1107
|
+
const e = this;
|
|
1108
|
+
this.app = H({
|
|
1109
|
+
initialTodos: function() {
|
|
1110
|
+
return [];
|
|
1111
|
+
},
|
|
1112
|
+
appTitle: "我的待办清单",
|
|
1113
|
+
enableLocalStorage: !0,
|
|
1114
|
+
newTodo: "",
|
|
1115
|
+
todos: [],
|
|
1116
|
+
filter: "all",
|
|
1117
|
+
editingTodo: null,
|
|
1118
|
+
lastTodoId: 0,
|
|
1119
|
+
get filteredTodos() {
|
|
1120
|
+
switch (this.filter) {
|
|
1121
|
+
case "active":
|
|
1122
|
+
return this.todos.filter((n) => !n.completed);
|
|
1123
|
+
case "completed":
|
|
1124
|
+
return this.todos.filter((n) => n.completed);
|
|
1125
|
+
default:
|
|
1126
|
+
return this.todos;
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
get activeTodosCount() {
|
|
1130
|
+
return this.todos.filter((n) => !n.completed).length;
|
|
1131
|
+
},
|
|
1132
|
+
get completedTodosCount() {
|
|
1133
|
+
return this.todos.filter((n) => n.completed).length;
|
|
1134
|
+
},
|
|
1135
|
+
get totalTodos() {
|
|
1136
|
+
return this.todos.length;
|
|
1137
|
+
},
|
|
1138
|
+
get completionRate() {
|
|
1139
|
+
return this.totalTodos === 0 ? 0 : Math.round(this.completedTodosCount / this.totalTodos * 100);
|
|
1140
|
+
},
|
|
1141
|
+
get hasCompletedTodos() {
|
|
1142
|
+
return this.completedTodosCount > 0;
|
|
1143
|
+
},
|
|
1144
|
+
$todos_handler(n, i) {
|
|
1145
|
+
e._watchers.$todos = n, i?.split?.(",")?.shift?.()?.trim?.(), this.enableLocalStorage && localStorage.setItem("vue-todos", JSON.stringify(n)), this.$emit("todos-updated", n);
|
|
1146
|
+
},
|
|
1147
|
+
get $todos() {
|
|
1148
|
+
const n = this.todos;
|
|
1149
|
+
return e._watchers.$todos !== n && this.$todos_handler(n, e._watchers.$todos), n;
|
|
1150
|
+
},
|
|
1151
|
+
$filter_handler(n, i) {
|
|
1152
|
+
e._watchers.$filter = n, i?.split?.(",")?.shift?.()?.trim?.(), console.log("过滤器已更改为: " + n);
|
|
1153
|
+
},
|
|
1154
|
+
get $filter() {
|
|
1155
|
+
const n = this.filter;
|
|
1156
|
+
return e._watchers.$filter !== n && this.$filter_handler(n, e._watchers.$filter), n;
|
|
1157
|
+
},
|
|
1158
|
+
addTodo() {
|
|
1159
|
+
this.newTodo.trim() !== "" && (this.todos.push({
|
|
1160
|
+
id: ++this.lastTodoId,
|
|
1161
|
+
text: this.newTodo.trim(),
|
|
1162
|
+
completed: !1,
|
|
1163
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1164
|
+
}), this.newTodo = "", console.log("已添加新的待办事项"));
|
|
1165
|
+
},
|
|
1166
|
+
deleteTodo(n) {
|
|
1167
|
+
const i = this.todos.findIndex((s) => s.id === n);
|
|
1168
|
+
i !== -1 && (this.todos.splice(i, 1), console.log("已删除待办事项 ID: " + n));
|
|
1169
|
+
},
|
|
1170
|
+
editTodo(n) {
|
|
1171
|
+
this.editingTodo = {
|
|
1172
|
+
...n
|
|
1173
|
+
};
|
|
1174
|
+
},
|
|
1175
|
+
saveEdit() {
|
|
1176
|
+
if (this.editingTodo && this.editingTodo.text.trim() !== "") {
|
|
1177
|
+
const n = this.todos.findIndex((i) => i.id === this.editingTodo.id);
|
|
1178
|
+
n !== -1 && (this.$set(this.todos, n, {
|
|
1179
|
+
...this.editingTodo
|
|
1180
|
+
}), console.log("已更新待办事项 ID: " + this.editingTodo.id));
|
|
1181
|
+
}
|
|
1182
|
+
this.editingTodo = null;
|
|
1183
|
+
},
|
|
1184
|
+
cancelEdit() {
|
|
1185
|
+
this.editingTodo = null;
|
|
1186
|
+
},
|
|
1187
|
+
clearCompleted() {
|
|
1188
|
+
const n = this.todos.length;
|
|
1189
|
+
this.todos = this.todos.filter((s) => !s.completed);
|
|
1190
|
+
const i = n - this.todos.length;
|
|
1191
|
+
console.log("已清除 " + i + " 个已完成事项");
|
|
1192
|
+
},
|
|
1193
|
+
formatDate(n) {
|
|
1194
|
+
return new Date(n).toLocaleDateString("zh-CN", {
|
|
1195
|
+
month: "short",
|
|
1196
|
+
day: "numeric",
|
|
1197
|
+
hour: "2-digit",
|
|
1198
|
+
minute: "2-digit"
|
|
1199
|
+
});
|
|
1200
|
+
},
|
|
1201
|
+
$lifecycle_mounted() {
|
|
1202
|
+
console.log("TodoApp 组件已挂载到 DOM"), this.$nextTick(() => {
|
|
1203
|
+
document.querySelectorAll(".todo-item").forEach((i) => {
|
|
1204
|
+
i.addEventListener("dblclick", () => {
|
|
1205
|
+
const s = parseInt(i.dataset.id), r = this.todos.findIndex((l) => l.id === s);
|
|
1206
|
+
r !== -1 && (this.todos[r].completed = !this.todos[r].completed, console.log("双击切换待办事项状态 ID: " + s));
|
|
1207
|
+
});
|
|
1208
|
+
});
|
|
1209
|
+
});
|
|
1210
|
+
},
|
|
1211
|
+
$lifecycle_unmounted() {
|
|
1212
|
+
console.log("TodoApp 组件已销毁");
|
|
1213
|
+
},
|
|
1214
|
+
get $el() {
|
|
1215
|
+
return e.$el;
|
|
1216
|
+
},
|
|
1217
|
+
get $parent() {
|
|
1218
|
+
return e.$parent;
|
|
1219
|
+
},
|
|
1220
|
+
get $children() {
|
|
1221
|
+
return e.$children;
|
|
1222
|
+
},
|
|
1223
|
+
get $root() {
|
|
1224
|
+
return e.$root;
|
|
1225
|
+
},
|
|
1226
|
+
$emit(n, i) {
|
|
1227
|
+
e.dispatchEvent(new CustomEvent(e._eventPrefix + n, { detail: i }));
|
|
1228
|
+
}
|
|
1229
|
+
}), this.$app = oe(this.app).mount(this._el);
|
|
1230
|
+
let o = this.parentElement;
|
|
1231
|
+
for (; o && !At(o); )
|
|
1232
|
+
o = o.parentElement;
|
|
1233
|
+
o && (this._parent = o, o._children.push(this)), this.dispatchEvent(new CustomEvent("mounted")), this.app?.$lifecycle_mounted?.(), (function() {
|
|
1234
|
+
const n = /* @__PURE__ */ (function() {
|
|
1235
|
+
return {
|
|
1236
|
+
newTodo: "",
|
|
1237
|
+
todos: [],
|
|
1238
|
+
filter: "all",
|
|
1239
|
+
editingTodo: null,
|
|
1240
|
+
lastTodoId: 0
|
|
1241
|
+
};
|
|
1242
|
+
})();
|
|
1243
|
+
Object.keys(n).forEach((i) => {
|
|
1244
|
+
(e?.constructor?.observedAttributes ?? []).indexOf?.(i) >= 0 ? Lt.info("当前属性 " + i + " 已定义为 prop 属性, 无法初始化.") : e.app[i] = n[i];
|
|
1245
|
+
});
|
|
1246
|
+
})();
|
|
1247
|
+
}
|
|
1248
|
+
attributeChangedCallback(e, o, n) {
|
|
1249
|
+
if (!this.app) {
|
|
1250
|
+
var i = this;
|
|
1251
|
+
setTimeout(function() {
|
|
1252
|
+
i.attributeChangedCallback(e, o, n);
|
|
1253
|
+
}, 10);
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
if ((this?.constructor?.observedAttributes ?? []).indexOf?.(e) >= 0) {
|
|
1257
|
+
const s = this._types[e];
|
|
1258
|
+
s && (this.app[s.attr] = this._typeChcker(n, s.type));
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
disconnectedCallback() {
|
|
1262
|
+
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;
|
|
1263
|
+
}
|
|
1264
|
+
get __isDarkchest() {
|
|
1265
|
+
return this._isDarkchest;
|
|
1266
|
+
}
|
|
1267
|
+
get __componentId() {
|
|
1268
|
+
return this._componentId;
|
|
1269
|
+
}
|
|
1270
|
+
get $el() {
|
|
1271
|
+
return this._el || null;
|
|
1272
|
+
}
|
|
1273
|
+
get $parent() {
|
|
1274
|
+
return this._parent || null;
|
|
1275
|
+
}
|
|
1276
|
+
get $children() {
|
|
1277
|
+
return this._children || [];
|
|
1278
|
+
}
|
|
1279
|
+
get $root() {
|
|
1280
|
+
let e = this;
|
|
1281
|
+
for (; e.$parent && At(e.$parent); )
|
|
1282
|
+
e = e.$parent;
|
|
1283
|
+
return e;
|
|
1284
|
+
}
|
|
1285
|
+
_typeChcker(e, o) {
|
|
1286
|
+
return e;
|
|
1287
|
+
}
|
|
1288
|
+
prop(e, o) {
|
|
1289
|
+
if ((this?.constructor?.observedAttributes ?? []).indexOf?.(e) >= 0) {
|
|
1290
|
+
if (o === void 0) return this.getAttribute(e);
|
|
1291
|
+
this.setAttribute(e, o);
|
|
1292
|
+
} else
|
|
1293
|
+
Lt.info(`未定义的prop [${e}]`);
|
|
1294
|
+
}
|
|
1295
|
+
get initialTodos() {
|
|
1296
|
+
return this?.app?.initialTodos;
|
|
1297
|
+
}
|
|
1298
|
+
set initialTodos(e) {
|
|
1299
|
+
this.app.initialTodos = this?._typeChcker?.(e, "Array", "Object");
|
|
1300
|
+
}
|
|
1301
|
+
get appTitle() {
|
|
1302
|
+
return this?.app?.appTitle;
|
|
1303
|
+
}
|
|
1304
|
+
set appTitle(e) {
|
|
1305
|
+
this.app.appTitle = this?._typeChcker?.(e, "String");
|
|
1306
|
+
}
|
|
1307
|
+
get enableLocalStorage() {
|
|
1308
|
+
return this?.app?.enableLocalStorage;
|
|
1309
|
+
}
|
|
1310
|
+
set enableLocalStorage(e) {
|
|
1311
|
+
this.app.enableLocalStorage = this?._typeChcker?.(e, "Boolean");
|
|
1312
|
+
}
|
|
1313
|
+
on(e, o, n) {
|
|
1314
|
+
const i = this._eventPrefix + e;
|
|
1315
|
+
return this._listeners[i] = o, this.addEventListener(i, o, n), this;
|
|
1316
|
+
}
|
|
1317
|
+
off(e, o) {
|
|
1318
|
+
if (e) {
|
|
1319
|
+
const n = this._eventPrefix + e;
|
|
1320
|
+
if (o)
|
|
1321
|
+
this.removeEventListener(n, o), delete this._listeners[n];
|
|
1322
|
+
else {
|
|
1323
|
+
const i = this._listeners[n];
|
|
1324
|
+
i && (this.removeEventListener(n, i), delete this._listeners[n]);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
return this;
|
|
1328
|
+
}
|
|
1329
|
+
once(e, o, n) {
|
|
1330
|
+
const i = this._eventPrefix + e, s = (...r) => {
|
|
1331
|
+
this.removeEventListener(i, s), o(...r);
|
|
1332
|
+
};
|
|
1333
|
+
return this.addEventListener(i, s, n), this;
|
|
1334
|
+
}
|
|
1335
|
+
addTodo() {
|
|
1336
|
+
return this.app.addTodo();
|
|
1337
|
+
}
|
|
1338
|
+
deleteTodo(e) {
|
|
1339
|
+
return this.app.deleteTodo(e);
|
|
1340
|
+
}
|
|
1341
|
+
editTodo(e) {
|
|
1342
|
+
return this.app.editTodo(e);
|
|
1343
|
+
}
|
|
1344
|
+
saveEdit() {
|
|
1345
|
+
return this.app.saveEdit();
|
|
1346
|
+
}
|
|
1347
|
+
cancelEdit() {
|
|
1348
|
+
return this.app.cancelEdit();
|
|
1349
|
+
}
|
|
1350
|
+
clearCompleted() {
|
|
1351
|
+
return this.app.clearCompleted();
|
|
1352
|
+
}
|
|
1353
|
+
formatDate(e) {
|
|
1354
|
+
return this.app.formatDate(e);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
customElements.define("todo-list", bo);
|