ddd-react 1.6.0 → 1.6.2
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 +1 -1
- package/dist/index.mjs +49 -43
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function w(e, t) {
|
|
|
135
135
|
}
|
|
136
136
|
let P = !1;
|
|
137
137
|
const O = [];
|
|
138
|
-
function
|
|
138
|
+
function b(e) {
|
|
139
139
|
O.push(e), Y();
|
|
140
140
|
}
|
|
141
141
|
function Y() {
|
|
@@ -182,7 +182,7 @@ function h(e, t, r = null, n = null) {
|
|
|
182
182
|
case c.COMPONENT: {
|
|
183
183
|
tt(e, t, r, n);
|
|
184
184
|
const s = e.component;
|
|
185
|
-
s &&
|
|
185
|
+
s && b(() => s.onMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
188
|
case c.PORTAL: {
|
|
@@ -205,8 +205,8 @@ function Q(e, t, r, n) {
|
|
|
205
205
|
}
|
|
206
206
|
function Z(e, t, r, n) {
|
|
207
207
|
const { tag: s, children: i } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
-
V(f, e, n), e.el = f, i?.forEach((
|
|
209
|
-
h(
|
|
208
|
+
V(f, e, n), e.el = f, i?.forEach((l) => {
|
|
209
|
+
h(l, f, null, n);
|
|
210
210
|
}), j(f, t, r);
|
|
211
211
|
}
|
|
212
212
|
function V(e, t, r) {
|
|
@@ -285,11 +285,11 @@ function m(e, t, r, n = null) {
|
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case c.COMPONENT: {
|
|
288
|
-
|
|
288
|
+
lt(e, t);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case c.PORTAL: {
|
|
292
|
-
|
|
292
|
+
at(e, t, n);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
@@ -311,20 +311,20 @@ function it(e, t, r) {
|
|
|
311
311
|
on: o,
|
|
312
312
|
...f
|
|
313
313
|
} = e.props ?? {}, {
|
|
314
|
-
class:
|
|
314
|
+
class: l,
|
|
315
315
|
style: u,
|
|
316
|
-
on:
|
|
316
|
+
on: a,
|
|
317
317
|
...d
|
|
318
|
-
} = t.props ?? {}, { listeners:
|
|
319
|
-
ot(n, f, d), ct(n, s,
|
|
318
|
+
} = t.props ?? {}, { listeners: E } = e;
|
|
319
|
+
ot(n, f, d), ct(n, s, l), ut(
|
|
320
320
|
n,
|
|
321
321
|
i,
|
|
322
322
|
u
|
|
323
323
|
), t.listeners = ft(
|
|
324
324
|
n,
|
|
325
|
-
|
|
325
|
+
E,
|
|
326
326
|
o ?? {},
|
|
327
|
-
|
|
327
|
+
a ?? {},
|
|
328
328
|
r
|
|
329
329
|
);
|
|
330
330
|
}
|
|
@@ -333,11 +333,11 @@ function ot(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: f, removed:
|
|
337
|
-
for (const
|
|
338
|
-
w(e,
|
|
339
|
-
for (const
|
|
340
|
-
L(e,
|
|
336
|
+
const { added: f, removed: l, updated: u } = T(i, o);
|
|
337
|
+
for (const a of l)
|
|
338
|
+
w(e, a);
|
|
339
|
+
for (const a of f.concat(u))
|
|
340
|
+
L(e, a, o[a]);
|
|
341
341
|
}
|
|
342
342
|
function ct(e, t, r) {
|
|
343
343
|
const n = M(t), s = M(r), { added: i, removed: o } = F(n, s);
|
|
@@ -356,50 +356,50 @@ function ut(e, t = {}, r = {}) {
|
|
|
356
356
|
function ft(e, t = {}, r = {}, n = {}, s = null) {
|
|
357
357
|
const { removed: i, added: o, updated: f } = T(r, n);
|
|
358
358
|
for (const u of i.concat(f)) {
|
|
359
|
-
const
|
|
360
|
-
|
|
359
|
+
const a = t?.[u];
|
|
360
|
+
a && e.removeEventListener(u, a);
|
|
361
361
|
}
|
|
362
|
-
const
|
|
362
|
+
const l = {};
|
|
363
363
|
for (const u of o.concat(f))
|
|
364
|
-
|
|
364
|
+
l[u] = S(
|
|
365
365
|
u,
|
|
366
366
|
n[u],
|
|
367
367
|
e,
|
|
368
368
|
s
|
|
369
369
|
);
|
|
370
|
-
return
|
|
370
|
+
return l;
|
|
371
371
|
}
|
|
372
372
|
function R(e, t, r) {
|
|
373
373
|
const n = v(e), s = v(t), i = e.el, o = x(n, s, D), f = r?.offset ?? 0;
|
|
374
|
-
for (const
|
|
375
|
-
if (
|
|
376
|
-
const { originalIndex: u, index:
|
|
377
|
-
m(n[u], s[
|
|
374
|
+
for (const l of o)
|
|
375
|
+
if (l.op === y.NOOP) {
|
|
376
|
+
const { originalIndex: u, index: a } = l;
|
|
377
|
+
m(n[u], s[a], i, r);
|
|
378
378
|
}
|
|
379
|
-
for (const
|
|
380
|
-
switch (
|
|
379
|
+
for (const l of o)
|
|
380
|
+
switch (l.op) {
|
|
381
381
|
case y.MOVE: {
|
|
382
|
-
const { from: u, index:
|
|
383
|
-
d && (i.insertBefore(d,
|
|
382
|
+
const { from: u, index: a } = l, d = n[u].el, E = i.childNodes[a + f];
|
|
383
|
+
d && (i.insertBefore(d, E), m(n[u], s[a], i, r));
|
|
384
384
|
break;
|
|
385
385
|
}
|
|
386
386
|
case y.REMOVE: {
|
|
387
|
-
const { item: u } =
|
|
387
|
+
const { item: u } = l;
|
|
388
388
|
p(u);
|
|
389
389
|
break;
|
|
390
390
|
}
|
|
391
391
|
case y.ADD: {
|
|
392
|
-
const { index: u, item:
|
|
393
|
-
h(
|
|
392
|
+
const { index: u, item: a } = l;
|
|
393
|
+
h(a, i, u + f, r);
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function lt(e, t) {
|
|
399
399
|
const { component: r } = e, { props: n } = A(t);
|
|
400
400
|
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function at(e, t, r) {
|
|
403
403
|
if (e.container !== t.container) {
|
|
404
404
|
p(e), h(t, document.body, null, r);
|
|
405
405
|
return;
|
|
@@ -463,18 +463,24 @@ class k {
|
|
|
463
463
|
pt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), h(this.vdom, t, r, this), this.hostEl = t, this.isMounted = !0;
|
|
464
464
|
}
|
|
465
465
|
unmount() {
|
|
466
|
-
this.isMounted && (
|
|
466
|
+
this.isMounted && (b(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
467
467
|
t.subscribedProvider = null;
|
|
468
|
-
}), this.dependencies = [], this.vdom && p(this.vdom),
|
|
468
|
+
}), this.dependencies = [], this.vdom && p(this.vdom), b(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
|
|
469
469
|
}
|
|
470
470
|
patch(t, r) {
|
|
471
471
|
if (!this.isMounted || !this.hostEl || !this.vdom)
|
|
472
472
|
return;
|
|
473
473
|
const n = this.render();
|
|
474
|
-
this.vdom = m(this.vdom, n, this.hostEl, this),
|
|
474
|
+
this.vdom = m(this.vdom, n, this.hostEl, this), b(() => this.onUpdate(t, r));
|
|
475
475
|
}
|
|
476
476
|
updateContext() {
|
|
477
|
-
|
|
477
|
+
const t = Object.getPrototypeOf(this).constructor.contextType;
|
|
478
|
+
if (t != null) {
|
|
479
|
+
if (this.subscribedProvider)
|
|
480
|
+
return console.log("this.subscribedProvider", this.subscribedProvider), this.context = this.subscribedProvider.props.value, !0;
|
|
481
|
+
this.context = t.defaultValue;
|
|
482
|
+
}
|
|
483
|
+
return !1;
|
|
478
484
|
}
|
|
479
485
|
subscribeToProvider() {
|
|
480
486
|
const t = Object.getPrototypeOf(this).constructor.contextType;
|
|
@@ -529,12 +535,12 @@ function yt(e) {
|
|
|
529
535
|
defaultValue: e
|
|
530
536
|
};
|
|
531
537
|
}
|
|
532
|
-
function
|
|
538
|
+
function bt(e, t) {
|
|
533
539
|
if (!t)
|
|
534
540
|
throw new Error("Container element is not provided for rendering.");
|
|
535
541
|
h(e, t);
|
|
536
542
|
}
|
|
537
|
-
function
|
|
543
|
+
function Et(e = null) {
|
|
538
544
|
return {
|
|
539
545
|
current: e
|
|
540
546
|
};
|
|
@@ -547,9 +553,9 @@ export {
|
|
|
547
553
|
k as Component,
|
|
548
554
|
yt as createContext,
|
|
549
555
|
vt as createPortal,
|
|
550
|
-
|
|
556
|
+
Et as createRef,
|
|
551
557
|
Ot as h,
|
|
552
558
|
U as hFragment,
|
|
553
559
|
mt as hString,
|
|
554
|
-
|
|
560
|
+
bt as render
|
|
555
561
|
};
|