ddd-react 1.3.6 → 1.3.7
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/index.mjs +64 -62
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -39,7 +39,7 @@ function E(t, e) {
|
|
|
39
39
|
}
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function S(t, e, n, r = null) {
|
|
43
43
|
function s(o) {
|
|
44
44
|
const i = o;
|
|
45
45
|
r ? e.call(r, i) : e(i);
|
|
@@ -49,7 +49,7 @@ function C(t, e, n, r = null) {
|
|
|
49
49
|
function $(t = {}, e, n = null) {
|
|
50
50
|
const r = {};
|
|
51
51
|
return Object.entries(t).forEach(([s, o]) => {
|
|
52
|
-
r[s] =
|
|
52
|
+
r[s] = S(
|
|
53
53
|
s,
|
|
54
54
|
o,
|
|
55
55
|
e,
|
|
@@ -195,7 +195,7 @@ function h(t, e, n = null, r = null) {
|
|
|
195
195
|
}
|
|
196
196
|
function Q(t, e, n) {
|
|
197
197
|
const { value: r } = t, s = document.createTextNode(r);
|
|
198
|
-
t.el = s,
|
|
198
|
+
t.el = s, x(s, e, n);
|
|
199
199
|
}
|
|
200
200
|
function Z(t, e, n, r) {
|
|
201
201
|
const { children: s } = t;
|
|
@@ -204,10 +204,10 @@ function Z(t, e, n, r) {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
function V(t, e, n, r) {
|
|
207
|
-
const { tag: s, children: o } = t,
|
|
208
|
-
ee(
|
|
209
|
-
h(
|
|
210
|
-
}),
|
|
207
|
+
const { tag: s, children: o } = t, u = s === "svg" || e instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
+
ee(u, t, r), t.el = u, o?.forEach((f) => {
|
|
209
|
+
h(f, u, null, r);
|
|
210
|
+
}), x(u, e, n);
|
|
211
211
|
}
|
|
212
212
|
function ee(t, e, n) {
|
|
213
213
|
const { props: r, events: s } = A(e);
|
|
@@ -217,7 +217,7 @@ function te(t, e, n, r) {
|
|
|
217
217
|
const s = t.tag, { props: o } = A(t), i = new s(o, r);
|
|
218
218
|
i.mount(e, n), t.component = i, t.el = i.firstElement || null;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function x(t, e, n) {
|
|
221
221
|
if (n == null) {
|
|
222
222
|
e.append(t);
|
|
223
223
|
return;
|
|
@@ -233,7 +233,7 @@ function ne(t, e) {
|
|
|
233
233
|
h(s, r, null, e);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function D(t, e) {
|
|
237
237
|
if (t.type !== e.type)
|
|
238
238
|
return !1;
|
|
239
239
|
if (t.type === c.ELEMENT) {
|
|
@@ -242,9 +242,9 @@ function R(t, e) {
|
|
|
242
242
|
props: { key: o }
|
|
243
243
|
} = n, {
|
|
244
244
|
tag: i,
|
|
245
|
-
props: { key:
|
|
245
|
+
props: { key: u }
|
|
246
246
|
} = r;
|
|
247
|
-
return s === i && o ===
|
|
247
|
+
return s === i && o === u;
|
|
248
248
|
}
|
|
249
249
|
if (t.type === c.COMPONENT) {
|
|
250
250
|
const n = t, r = e, { tag: s } = n, { tag: o } = r;
|
|
@@ -273,7 +273,7 @@ function N(t) {
|
|
|
273
273
|
return re(t.trim());
|
|
274
274
|
}
|
|
275
275
|
function m(t, e, n, r = null) {
|
|
276
|
-
if (!
|
|
276
|
+
if (!D(t, e)) {
|
|
277
277
|
const s = se(n, t.el);
|
|
278
278
|
return p(t), h(e, n, s, r), e;
|
|
279
279
|
}
|
|
@@ -293,7 +293,7 @@ function m(t, e, n, r = null) {
|
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
return
|
|
296
|
+
return R(t, e, r), e;
|
|
297
297
|
}
|
|
298
298
|
function se(t, e) {
|
|
299
299
|
if (!e) return null;
|
|
@@ -309,18 +309,18 @@ function ie(t, e, n) {
|
|
|
309
309
|
class: s,
|
|
310
310
|
style: o,
|
|
311
311
|
on: i,
|
|
312
|
-
...
|
|
312
|
+
...u
|
|
313
313
|
} = t.props ?? {}, {
|
|
314
|
-
class:
|
|
315
|
-
style:
|
|
314
|
+
class: f,
|
|
315
|
+
style: l,
|
|
316
316
|
on: a,
|
|
317
317
|
...d
|
|
318
318
|
} = e.props ?? {}, { listeners: b } = t;
|
|
319
|
-
ce(r,
|
|
319
|
+
ce(r, u, d), le(r, s, f), ue(
|
|
320
320
|
r,
|
|
321
321
|
o,
|
|
322
|
-
|
|
323
|
-
), e.listeners =
|
|
322
|
+
l
|
|
323
|
+
), e.listeners = fe(
|
|
324
324
|
r,
|
|
325
325
|
b,
|
|
326
326
|
i ?? {},
|
|
@@ -333,64 +333,64 @@ function ce(t, e = {}, n = {}) {
|
|
|
333
333
|
r !== s && (r && typeof r == "object" && "current" in r && (r.current = null), s && typeof s == "object" && "current" in s && (s.current = t));
|
|
334
334
|
const o = { ...e }, i = { ...n };
|
|
335
335
|
delete o.ref, delete i.ref;
|
|
336
|
-
const { added:
|
|
337
|
-
for (const a of
|
|
336
|
+
const { added: u, removed: f, updated: l } = T(o, i);
|
|
337
|
+
for (const a of f)
|
|
338
338
|
j(t, a);
|
|
339
|
-
for (const a of
|
|
339
|
+
for (const a of u.concat(l))
|
|
340
340
|
L(t, a, i[a]);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function le(t, e, n) {
|
|
343
343
|
const r = M(e), s = M(n), { added: o, removed: i } = U(r, s);
|
|
344
344
|
i.length > 0 && t.classList.remove(...i), o.length > 0 && t.classList.add(...o);
|
|
345
345
|
}
|
|
346
346
|
function M(t = "") {
|
|
347
347
|
return Array.isArray(t) ? t.filter(N) : String(t).split(/(\s+)/).filter(N);
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function ue(t, e = {}, n = {}) {
|
|
350
350
|
const { added: r, removed: s, updated: o } = T(e, n);
|
|
351
351
|
for (const i of s)
|
|
352
352
|
J(t, i);
|
|
353
353
|
for (const i of r.concat(o))
|
|
354
354
|
w(t, i, n[i]);
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
const { removed: o, added: i, updated:
|
|
358
|
-
for (const
|
|
359
|
-
const a = e?.[
|
|
360
|
-
a && t.removeEventListener(
|
|
361
|
-
}
|
|
362
|
-
const
|
|
363
|
-
for (const
|
|
364
|
-
l
|
|
365
|
-
|
|
366
|
-
r[
|
|
356
|
+
function fe(t, e = {}, n = {}, r = {}, s = null) {
|
|
357
|
+
const { removed: o, added: i, updated: u } = T(n, r);
|
|
358
|
+
for (const l of o.concat(u)) {
|
|
359
|
+
const a = e?.[l];
|
|
360
|
+
a && t.removeEventListener(l, a);
|
|
361
|
+
}
|
|
362
|
+
const f = {};
|
|
363
|
+
for (const l of i.concat(u))
|
|
364
|
+
f[l] = S(
|
|
365
|
+
l,
|
|
366
|
+
r[l],
|
|
367
367
|
t,
|
|
368
368
|
s
|
|
369
369
|
);
|
|
370
|
-
return
|
|
371
|
-
}
|
|
372
|
-
function
|
|
373
|
-
const r = v(t), s = v(e), o = t.el, i = F(r, s,
|
|
374
|
-
for (const
|
|
375
|
-
if (
|
|
376
|
-
const { originalIndex:
|
|
377
|
-
m(r[
|
|
370
|
+
return f;
|
|
371
|
+
}
|
|
372
|
+
function R(t, e, n) {
|
|
373
|
+
const r = v(t), s = v(e), o = t.el, i = F(r, s, D), u = n?.offset ?? 0;
|
|
374
|
+
for (const f of i)
|
|
375
|
+
if (f.op === y.NOOP) {
|
|
376
|
+
const { originalIndex: l, index: a } = f;
|
|
377
|
+
m(r[l], s[a], o, n);
|
|
378
378
|
}
|
|
379
|
-
for (const
|
|
380
|
-
switch (
|
|
379
|
+
for (const f of i)
|
|
380
|
+
switch (f.op) {
|
|
381
381
|
case y.MOVE: {
|
|
382
|
-
const { from:
|
|
383
|
-
d && (o.insertBefore(d, b), m(r[
|
|
382
|
+
const { from: l, index: a } = f, d = r[l].el, b = o.childNodes[a + u];
|
|
383
|
+
d && (o.insertBefore(d, b), m(r[l], s[a], o, n));
|
|
384
384
|
break;
|
|
385
385
|
}
|
|
386
386
|
case y.REMOVE: {
|
|
387
|
-
const { item:
|
|
388
|
-
p(
|
|
387
|
+
const { item: l } = f;
|
|
388
|
+
p(l);
|
|
389
389
|
break;
|
|
390
390
|
}
|
|
391
391
|
case y.ADD: {
|
|
392
|
-
const { index:
|
|
393
|
-
h(a, o,
|
|
392
|
+
const { index: l, item: a } = f;
|
|
393
|
+
h(a, o, l + u, n);
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
@@ -404,10 +404,10 @@ function he(t, e, n) {
|
|
|
404
404
|
p(t), h(e, document.body, null, n);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
|
|
407
|
+
R(t, e, n);
|
|
408
408
|
}
|
|
409
409
|
const k = (t) => t.constructor.name.includes("Provider"), pe = (t) => t.constructor.name.includes("Consumer");
|
|
410
|
-
class
|
|
410
|
+
class C {
|
|
411
411
|
constructor(e = {}, n) {
|
|
412
412
|
this.isMounted = !1, this.vdom = null, this.hostEl = null, this.parent = null, this.state = {}, this.context = null, this.dependencies = [], this.subscribedProvider = null, this.props = e, this.parent = n;
|
|
413
413
|
}
|
|
@@ -448,7 +448,7 @@ class S {
|
|
|
448
448
|
return this.vdom?.type === c.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
|
|
449
449
|
}
|
|
450
450
|
updateProps(e) {
|
|
451
|
-
console.log("updateProps");
|
|
451
|
+
console.log("updateProps", this);
|
|
452
452
|
const n = { ...this.props, ...e }, r = this.props;
|
|
453
453
|
this.props = n;
|
|
454
454
|
let s = this.updateContext();
|
|
@@ -481,17 +481,19 @@ class S {
|
|
|
481
481
|
this.vdom = m(this.vdom, e, this.hostEl, this), g(() => this.onUpdate());
|
|
482
482
|
}
|
|
483
483
|
updateContext() {
|
|
484
|
+
console.log("updateContext");
|
|
484
485
|
const e = Object.getPrototypeOf(this).constructor.contextType;
|
|
486
|
+
console.log("context", e);
|
|
485
487
|
let n = this.parent;
|
|
486
488
|
if (e != null) {
|
|
487
|
-
for (; n; ) {
|
|
488
|
-
if (Object.getPrototypeOf(n).constructor === e.Provider)
|
|
489
|
-
return this.context = n.props.value, !0;
|
|
489
|
+
for (console.log(1); n; ) {
|
|
490
|
+
if (console.log(2), Object.getPrototypeOf(n).constructor === e.Provider)
|
|
491
|
+
return this.context = n.props.value, console.log("this.context", this.context), console.log(3), !0;
|
|
490
492
|
n = n.parent;
|
|
491
493
|
}
|
|
492
|
-
n == null && (this.context = e.defaultValue);
|
|
494
|
+
n == null && (console.log(4), this.context = e.defaultValue);
|
|
493
495
|
}
|
|
494
|
-
return !1;
|
|
496
|
+
return console.log(5), !1;
|
|
495
497
|
}
|
|
496
498
|
subscribeToProvider() {
|
|
497
499
|
const e = Object.getPrototypeOf(this).constructor.contextType;
|
|
@@ -508,13 +510,13 @@ class S {
|
|
|
508
510
|
}
|
|
509
511
|
}
|
|
510
512
|
function ye(t) {
|
|
511
|
-
class e extends
|
|
513
|
+
class e extends C {
|
|
512
514
|
render() {
|
|
513
515
|
let o = [];
|
|
514
516
|
return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], q(o);
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
|
-
const r = class r extends
|
|
519
|
+
const r = class r extends C {
|
|
518
520
|
render() {
|
|
519
521
|
let o = this.props.children;
|
|
520
522
|
if (Array.isArray(o))
|
|
@@ -555,7 +557,7 @@ function be(t, e) {
|
|
|
555
557
|
return I(n, e);
|
|
556
558
|
}
|
|
557
559
|
export {
|
|
558
|
-
|
|
560
|
+
C as Component,
|
|
559
561
|
ye as createContext,
|
|
560
562
|
be as createPortal,
|
|
561
563
|
Ee as createRef,
|