ddd-react 1.10.15 → 1.10.16
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/component.d.ts +0 -1
- package/dist/index.mjs +48 -48
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
4
4
|
vdom: VDOMNode | null;
|
|
5
5
|
private hostEl;
|
|
6
6
|
parent: Component | null;
|
|
7
|
-
private error;
|
|
8
7
|
static defaultProps: any;
|
|
9
8
|
static getDerivedStateFromError?(error: Error): any;
|
|
10
9
|
props: P & WithChildrenProps;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as u, e as
|
|
1
|
+
import { D as u, e as b, a as x, A as v, b as F, h as U, c as B } from "./h-BbaMkkC7.mjs";
|
|
2
2
|
import { d as Pt, f as Ot } from "./h-BbaMkkC7.mjs";
|
|
3
|
-
function
|
|
3
|
+
function m(e, t) {
|
|
4
4
|
if (e === null || t === null || e === void 0 || t === void 0)
|
|
5
5
|
return e === t;
|
|
6
6
|
if (typeof e != typeof t)
|
|
@@ -14,7 +14,7 @@ function b(e, t) {
|
|
|
14
14
|
if (e.length !== t.length)
|
|
15
15
|
return !1;
|
|
16
16
|
for (let n = 0; n < e.length; ++n)
|
|
17
|
-
if (!
|
|
17
|
+
if (!m(e[n], t[n]))
|
|
18
18
|
return !1;
|
|
19
19
|
return !0;
|
|
20
20
|
}
|
|
@@ -32,7 +32,7 @@ function b(e, t) {
|
|
|
32
32
|
return !1;
|
|
33
33
|
for (let n = 0; n < r.length; ++n) {
|
|
34
34
|
const s = r[n];
|
|
35
|
-
if (!(s === "_owner" && e.$$typeof) && !
|
|
35
|
+
if (!(s === "_owner" && e.$$typeof) && !m(e[s], t[s]))
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
38
|
return !0;
|
|
@@ -204,10 +204,10 @@ function Q(e, t, r, n) {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
function Z(e, t, r, n) {
|
|
207
|
-
const { tag: s, children: i } = e,
|
|
208
|
-
V(
|
|
209
|
-
d(
|
|
210
|
-
}), j(
|
|
207
|
+
const { tag: s, children: i } = e, a = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
+
V(a, e, n), e.el = a, i?.forEach((f) => {
|
|
209
|
+
d(f, a, null, n);
|
|
210
|
+
}), j(a, t, r);
|
|
211
211
|
}
|
|
212
212
|
function V(e, t, r) {
|
|
213
213
|
const { props: n, events: s } = A(t);
|
|
@@ -242,9 +242,9 @@ function L(e, t) {
|
|
|
242
242
|
props: { key: i }
|
|
243
243
|
} = r, {
|
|
244
244
|
tag: o,
|
|
245
|
-
props: { key:
|
|
245
|
+
props: { key: a }
|
|
246
246
|
} = n;
|
|
247
|
-
return s === o && i ===
|
|
247
|
+
return s === o && i === a;
|
|
248
248
|
}
|
|
249
249
|
if (e.type === u.COMPONENT) {
|
|
250
250
|
const r = e, n = t, { tag: s } = r, { tag: i } = n;
|
|
@@ -269,7 +269,7 @@ function S(e, t) {
|
|
|
269
269
|
function rt(e) {
|
|
270
270
|
return e !== "";
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function T(e) {
|
|
273
273
|
return rt(e.trim());
|
|
274
274
|
}
|
|
275
275
|
function y(e, t, r, n = null) {
|
|
@@ -309,14 +309,14 @@ function ot(e, t, r) {
|
|
|
309
309
|
class: s,
|
|
310
310
|
style: i,
|
|
311
311
|
on: o,
|
|
312
|
-
...
|
|
312
|
+
...a
|
|
313
313
|
} = e.props ?? {}, {
|
|
314
|
-
class:
|
|
314
|
+
class: f,
|
|
315
315
|
style: c,
|
|
316
316
|
on: l,
|
|
317
317
|
...E
|
|
318
318
|
} = t.props ?? {}, { listeners: g } = e;
|
|
319
|
-
it(n,
|
|
319
|
+
it(n, a, E), ct(n, s, f), ut(
|
|
320
320
|
n,
|
|
321
321
|
i,
|
|
322
322
|
c
|
|
@@ -333,18 +333,18 @@ function it(e, t = {}, r = {}) {
|
|
|
333
333
|
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
334
334
|
const i = { ...t }, o = { ...r };
|
|
335
335
|
delete i.ref, delete o.ref;
|
|
336
|
-
const { added:
|
|
337
|
-
for (const l of
|
|
336
|
+
const { added: a, removed: f, updated: c } = S(i, o);
|
|
337
|
+
for (const l of f)
|
|
338
338
|
D(e, l);
|
|
339
|
-
for (const l of
|
|
339
|
+
for (const l of a.concat(c))
|
|
340
340
|
w(e, l, o[l]);
|
|
341
341
|
}
|
|
342
342
|
function ct(e, t, r) {
|
|
343
|
-
const n =
|
|
343
|
+
const n = k(t), s = k(r), { added: i, removed: o } = F(n, s);
|
|
344
344
|
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
return Array.isArray(e) ? e.filter(
|
|
346
|
+
function k(e = "") {
|
|
347
|
+
return Array.isArray(e) ? e.filter(T) : String(e).split(/(\s+)/).filter(T);
|
|
348
348
|
}
|
|
349
349
|
function ut(e, t = {}, r = {}) {
|
|
350
350
|
const { added: n, removed: s, updated: i } = S(t, r);
|
|
@@ -354,42 +354,42 @@ function ut(e, t = {}, r = {}) {
|
|
|
354
354
|
M(e, o, r[o]);
|
|
355
355
|
}
|
|
356
356
|
function at(e, t = {}, r = {}, n = {}, s = null) {
|
|
357
|
-
const { removed: i, added: o, updated:
|
|
358
|
-
for (const c of i.concat(
|
|
357
|
+
const { removed: i, added: o, updated: a } = S(r, n), f = { ...t };
|
|
358
|
+
for (const c of i.concat(a)) {
|
|
359
359
|
const l = t?.[c];
|
|
360
|
-
l && (e.removeEventListener(c, l), delete
|
|
360
|
+
l && (e.removeEventListener(c, l), delete f[c]);
|
|
361
361
|
}
|
|
362
|
-
for (const c of o.concat(
|
|
363
|
-
|
|
362
|
+
for (const c of o.concat(a))
|
|
363
|
+
f[c] = N(
|
|
364
364
|
c,
|
|
365
365
|
n[c],
|
|
366
366
|
e,
|
|
367
367
|
s
|
|
368
368
|
);
|
|
369
|
-
return
|
|
369
|
+
return f;
|
|
370
370
|
}
|
|
371
371
|
function R(e, t, r) {
|
|
372
|
-
const n =
|
|
373
|
-
for (const
|
|
374
|
-
if (
|
|
375
|
-
const { originalIndex: c, index: l } =
|
|
372
|
+
const n = b(e), s = b(t), i = e.el, o = x(n, s, L), a = r?.offset ?? 0;
|
|
373
|
+
for (const f of o)
|
|
374
|
+
if (f.op === v.NOOP) {
|
|
375
|
+
const { originalIndex: c, index: l } = f;
|
|
376
376
|
y(n[c], s[l], i, r);
|
|
377
377
|
}
|
|
378
|
-
for (const
|
|
379
|
-
switch (
|
|
378
|
+
for (const f of o)
|
|
379
|
+
switch (f.op) {
|
|
380
380
|
case v.MOVE: {
|
|
381
|
-
const { from: c, index: l } =
|
|
381
|
+
const { from: c, index: l } = f, E = n[c].el, g = i.childNodes[l + a];
|
|
382
382
|
E && (i.insertBefore(E, g), y(n[c], s[l], i, r));
|
|
383
383
|
break;
|
|
384
384
|
}
|
|
385
385
|
case v.REMOVE: {
|
|
386
|
-
const { item: c } =
|
|
386
|
+
const { item: c } = f;
|
|
387
387
|
p(c);
|
|
388
388
|
break;
|
|
389
389
|
}
|
|
390
390
|
case v.ADD: {
|
|
391
|
-
const { index: c, item: l } =
|
|
392
|
-
d(l, i, c +
|
|
391
|
+
const { index: c, item: l } = f;
|
|
392
|
+
d(l, i, c + a, r);
|
|
393
393
|
break;
|
|
394
394
|
}
|
|
395
395
|
}
|
|
@@ -406,12 +406,11 @@ function lt(e, t, r) {
|
|
|
406
406
|
R(e, t, r);
|
|
407
407
|
}
|
|
408
408
|
const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
|
|
409
|
-
class
|
|
409
|
+
class C {
|
|
410
410
|
isMounted = !1;
|
|
411
411
|
vdom = null;
|
|
412
412
|
hostEl = null;
|
|
413
413
|
parent = null;
|
|
414
|
-
error = null;
|
|
415
414
|
static defaultProps = {};
|
|
416
415
|
props;
|
|
417
416
|
state = {};
|
|
@@ -454,13 +453,13 @@ class k {
|
|
|
454
453
|
return Promise.resolve();
|
|
455
454
|
}
|
|
456
455
|
didCatch(t, r) {
|
|
457
|
-
return console.error("Uncaught error:", t, r),
|
|
456
|
+
return console.error("Uncaught error:", t, r), Promise.resolve();
|
|
458
457
|
}
|
|
459
458
|
shouldComponentUpdate(t, r) {
|
|
460
|
-
return
|
|
459
|
+
return m(t, r);
|
|
461
460
|
}
|
|
462
461
|
get elements() {
|
|
463
|
-
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ?
|
|
462
|
+
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ? b(this.vdom).flatMap((t) => t.type === u.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
|
|
464
463
|
}
|
|
465
464
|
get firstElement() {
|
|
466
465
|
return this.elements[0];
|
|
@@ -492,7 +491,7 @@ class k {
|
|
|
492
491
|
unmount() {
|
|
493
492
|
this.isMounted && (h(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
494
493
|
t.subscribedProvider = null;
|
|
495
|
-
}), this.dependencies = [], this.vdom && p(this.vdom), h(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1
|
|
494
|
+
}), this.dependencies = [], this.vdom && p(this.vdom), h(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
|
|
496
495
|
}
|
|
497
496
|
patch(t, r) {
|
|
498
497
|
if (!(!this.isMounted || !this.hostEl || !this.vdom)) {
|
|
@@ -546,11 +545,12 @@ class k {
|
|
|
546
545
|
try {
|
|
547
546
|
const o = n.render();
|
|
548
547
|
o && (n.vdom = y(n.vdom, o, n.hostEl, n), h(() => {
|
|
549
|
-
|
|
548
|
+
const a = {
|
|
550
549
|
phase: r,
|
|
551
550
|
failedComponent: this.constructor.name,
|
|
552
551
|
componentStack: this.getComponentStack()
|
|
553
|
-
}
|
|
552
|
+
};
|
|
553
|
+
console.error("error", t, a), n.didCatch(t, a);
|
|
554
554
|
}));
|
|
555
555
|
} catch (o) {
|
|
556
556
|
n.parent && n.parent.handleError(o, r);
|
|
@@ -592,18 +592,18 @@ class k {
|
|
|
592
592
|
return null;
|
|
593
593
|
}
|
|
594
594
|
isErrorBoundary() {
|
|
595
|
-
return
|
|
595
|
+
return this.constructor.getDerivedStateFromError !== void 0;
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
function yt(e) {
|
|
599
|
-
class t extends
|
|
599
|
+
class t extends C {
|
|
600
600
|
isProvider = !0;
|
|
601
601
|
render() {
|
|
602
602
|
let s = [];
|
|
603
603
|
return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [], U(s);
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
class r extends
|
|
606
|
+
class r extends C {
|
|
607
607
|
static contextType = {
|
|
608
608
|
Provider: t,
|
|
609
609
|
defaultValue: e
|
|
@@ -644,7 +644,7 @@ function gt(e, t) {
|
|
|
644
644
|
return B(r, t);
|
|
645
645
|
}
|
|
646
646
|
export {
|
|
647
|
-
|
|
647
|
+
C as Component,
|
|
648
648
|
yt as createContext,
|
|
649
649
|
gt as createPortal,
|
|
650
650
|
vt as createRef,
|