ddd-react 1.10.14 → 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 +198 -206
- 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
|
|
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
|
}
|
|
@@ -31,8 +31,8 @@ function b(e, t) {
|
|
|
31
31
|
if (!Object.prototype.hasOwnProperty.call(t, r[n]))
|
|
32
32
|
return !1;
|
|
33
33
|
for (let n = 0; n < r.length; ++n) {
|
|
34
|
-
const
|
|
35
|
-
if (!(
|
|
34
|
+
const s = r[n];
|
|
35
|
+
if (!(s === "_owner" && e.$$typeof) && !m(e[s], t[s]))
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
38
|
return !0;
|
|
@@ -40,17 +40,17 @@ function b(e, t) {
|
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
42
|
function N(e, t, r, n = null) {
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
n ? t.call(n,
|
|
43
|
+
function s(i) {
|
|
44
|
+
const o = i;
|
|
45
|
+
n ? t.call(n, o) : t(o);
|
|
46
46
|
}
|
|
47
|
-
return r.addEventListener(e,
|
|
47
|
+
return r.addEventListener(e, s), s;
|
|
48
48
|
}
|
|
49
49
|
function I(e = {}, t, r = null) {
|
|
50
50
|
const n = {};
|
|
51
|
-
return Object.entries(e).forEach(([
|
|
52
|
-
n[
|
|
53
|
-
|
|
51
|
+
return Object.entries(e).forEach(([s, i]) => {
|
|
52
|
+
n[s] = N(
|
|
53
|
+
s,
|
|
54
54
|
i,
|
|
55
55
|
t,
|
|
56
56
|
r
|
|
@@ -65,23 +65,23 @@ function $(e = {}, t) {
|
|
|
65
65
|
function p(e) {
|
|
66
66
|
const { type: t } = e;
|
|
67
67
|
switch (t) {
|
|
68
|
-
case
|
|
68
|
+
case u.TEXT: {
|
|
69
69
|
q(e);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
case
|
|
72
|
+
case u.ELEMENT: {
|
|
73
73
|
G(e);
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
|
-
case
|
|
76
|
+
case u.FRAGMENT: {
|
|
77
77
|
_(e);
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
|
-
case
|
|
80
|
+
case u.COMPONENT: {
|
|
81
81
|
e.component?.unmount();
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
|
-
case
|
|
84
|
+
case u.PORTAL: {
|
|
85
85
|
X(e);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
@@ -95,8 +95,8 @@ function q(e) {
|
|
|
95
95
|
t && t.remove();
|
|
96
96
|
}
|
|
97
97
|
function G(e) {
|
|
98
|
-
const { el: t, children: r, listeners: n, props:
|
|
99
|
-
|
|
98
|
+
const { el: t, children: r, listeners: n, props: s } = e;
|
|
99
|
+
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), r && r.forEach(p), n && t && ($(n, t), delete e.listeners);
|
|
100
100
|
}
|
|
101
101
|
function _(e) {
|
|
102
102
|
const { children: t } = e;
|
|
@@ -113,12 +113,12 @@ function J(e, t) {
|
|
|
113
113
|
e.style[t] = null;
|
|
114
114
|
}
|
|
115
115
|
function K(e, t) {
|
|
116
|
-
const { class: r, style: n, ...
|
|
117
|
-
r && W(e, r), n && Object.entries(n).forEach(([i,
|
|
118
|
-
M(e, i,
|
|
116
|
+
const { class: r, style: n, ...s } = t;
|
|
117
|
+
r && W(e, r), n && Object.entries(n).forEach(([i, o]) => {
|
|
118
|
+
M(e, i, o);
|
|
119
119
|
});
|
|
120
|
-
for (const [i,
|
|
121
|
-
w(e, i,
|
|
120
|
+
for (const [i, o] of Object.entries(s))
|
|
121
|
+
w(e, i, o);
|
|
122
122
|
}
|
|
123
123
|
function W(e, t) {
|
|
124
124
|
if (e instanceof SVGElement) {
|
|
@@ -161,31 +161,31 @@ function H() {
|
|
|
161
161
|
}
|
|
162
162
|
P = !1;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function A(e) {
|
|
165
165
|
const { on: t = {}, ...r } = e.props;
|
|
166
166
|
return delete r.key, { props: r, events: t };
|
|
167
167
|
}
|
|
168
168
|
function d(e, t, r = null, n = null) {
|
|
169
169
|
switch (e.type) {
|
|
170
|
-
case
|
|
170
|
+
case u.TEXT: {
|
|
171
171
|
z(e, t, r);
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
|
-
case
|
|
174
|
+
case u.ELEMENT: {
|
|
175
175
|
Z(e, t, r, n);
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
|
-
case
|
|
178
|
+
case u.FRAGMENT: {
|
|
179
179
|
Q(e, t, r, n);
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
|
-
case
|
|
182
|
+
case u.COMPONENT: {
|
|
183
183
|
tt(e, t, r, n);
|
|
184
|
-
const
|
|
185
|
-
|
|
184
|
+
const s = e.component;
|
|
185
|
+
s && h(() => s.didMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
|
-
case
|
|
188
|
+
case u.PORTAL: {
|
|
189
189
|
et(e, n);
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
@@ -194,30 +194,30 @@ function d(e, t, r = null, n = null) {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
function z(e, t, r) {
|
|
197
|
-
const { value: n } = e,
|
|
198
|
-
e.el =
|
|
197
|
+
const { value: n } = e, s = document.createTextNode(n);
|
|
198
|
+
e.el = s, j(s, t, r);
|
|
199
199
|
}
|
|
200
200
|
function Q(e, t, r, n) {
|
|
201
|
-
const { children:
|
|
202
|
-
e.el = t,
|
|
203
|
-
d(i, t, r != null ? r +
|
|
201
|
+
const { children: s } = e;
|
|
202
|
+
e.el = t, s?.forEach((i, o) => {
|
|
203
|
+
d(i, t, r != null ? r + o : null, n);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
function Z(e, t, r, n) {
|
|
207
|
-
const { tag:
|
|
208
|
-
V(
|
|
209
|
-
d(
|
|
210
|
-
}),
|
|
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
|
-
const { props: n, events:
|
|
214
|
-
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = I(
|
|
213
|
+
const { props: n, events: s } = A(t);
|
|
214
|
+
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = I(s, e, r), K(e, n);
|
|
215
215
|
}
|
|
216
216
|
function tt(e, t, r, n) {
|
|
217
|
-
const
|
|
218
|
-
|
|
217
|
+
const s = e.tag, { props: i } = A(e), o = new s(i, n);
|
|
218
|
+
o.mount(t, r), e.component = o, e.el = o.firstElement || null;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function j(e, t, r) {
|
|
221
221
|
if (r == null) {
|
|
222
222
|
t.append(e);
|
|
223
223
|
return;
|
|
@@ -229,190 +229,188 @@ function L(e, t, r) {
|
|
|
229
229
|
}
|
|
230
230
|
function et(e, t) {
|
|
231
231
|
const { children: r, container: n } = e;
|
|
232
|
-
r?.forEach((
|
|
233
|
-
d(
|
|
232
|
+
r?.forEach((s) => {
|
|
233
|
+
d(s, n, null, t);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function L(e, t) {
|
|
237
237
|
if (e.type !== t.type)
|
|
238
238
|
return !1;
|
|
239
|
-
if (e.type ===
|
|
239
|
+
if (e.type === u.ELEMENT) {
|
|
240
240
|
const r = e, n = t, {
|
|
241
|
-
tag:
|
|
241
|
+
tag: s,
|
|
242
242
|
props: { key: i }
|
|
243
243
|
} = r, {
|
|
244
|
-
tag:
|
|
245
|
-
props: { key:
|
|
244
|
+
tag: o,
|
|
245
|
+
props: { key: a }
|
|
246
246
|
} = n;
|
|
247
|
-
return
|
|
247
|
+
return s === o && i === a;
|
|
248
248
|
}
|
|
249
|
-
if (e.type ===
|
|
250
|
-
const r = e, n = t, { tag:
|
|
251
|
-
return
|
|
249
|
+
if (e.type === u.COMPONENT) {
|
|
250
|
+
const r = e, n = t, { tag: s } = r, { tag: i } = n;
|
|
251
|
+
return s === i;
|
|
252
252
|
}
|
|
253
|
-
if (e.type ===
|
|
253
|
+
if (e.type === u.PORTAL) {
|
|
254
254
|
const r = e, n = t;
|
|
255
255
|
return r.container === n.container;
|
|
256
256
|
}
|
|
257
257
|
return !0;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
const r = Object.keys(e), n = Object.keys(t),
|
|
261
|
-
for (const
|
|
262
|
-
|
|
259
|
+
function S(e, t) {
|
|
260
|
+
const r = Object.keys(e), n = Object.keys(t), s = [], i = [];
|
|
261
|
+
for (const o of n)
|
|
262
|
+
o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
|
|
263
263
|
return {
|
|
264
|
-
added:
|
|
265
|
-
removed: r.filter((
|
|
264
|
+
added: s,
|
|
265
|
+
removed: r.filter((o) => !(o in t)),
|
|
266
266
|
updated: i
|
|
267
267
|
};
|
|
268
268
|
}
|
|
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
|
-
function
|
|
276
|
-
if (!
|
|
277
|
-
const
|
|
278
|
-
return p(e), d(t, r,
|
|
275
|
+
function y(e, t, r, n = null) {
|
|
276
|
+
if (!L(e, t)) {
|
|
277
|
+
const s = nt(r, e.el);
|
|
278
|
+
return p(e), d(t, r, s, n), t;
|
|
279
279
|
}
|
|
280
280
|
switch (t.el = e.el, t.type) {
|
|
281
|
-
case
|
|
282
|
-
return
|
|
283
|
-
case
|
|
284
|
-
|
|
281
|
+
case u.TEXT:
|
|
282
|
+
return st(e, t), t;
|
|
283
|
+
case u.ELEMENT: {
|
|
284
|
+
ot(e, t, n);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
case
|
|
288
|
-
|
|
287
|
+
case u.COMPONENT: {
|
|
288
|
+
ft(e, t);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
|
-
case
|
|
292
|
-
|
|
291
|
+
case u.PORTAL: {
|
|
292
|
+
lt(e, t, n);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
return
|
|
296
|
+
return R(e, t, n), t;
|
|
297
297
|
}
|
|
298
298
|
function nt(e, t) {
|
|
299
299
|
if (!t) return null;
|
|
300
300
|
const r = Array.from(e.childNodes).indexOf(t);
|
|
301
301
|
return r < 0 ? null : r;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
const r = e.el, { value: n } = e, { value:
|
|
305
|
-
n !==
|
|
303
|
+
function st(e, t) {
|
|
304
|
+
const r = e.el, { value: n } = e, { value: s } = t;
|
|
305
|
+
n !== s && r && (r.nodeValue = s);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function ot(e, t, r) {
|
|
308
308
|
const n = e.el, {
|
|
309
|
-
class:
|
|
309
|
+
class: s,
|
|
310
310
|
style: i,
|
|
311
|
-
on:
|
|
312
|
-
...
|
|
311
|
+
on: o,
|
|
312
|
+
...a
|
|
313
313
|
} = e.props ?? {}, {
|
|
314
|
-
class:
|
|
315
|
-
style:
|
|
316
|
-
on:
|
|
317
|
-
...
|
|
318
|
-
} = t.props ?? {}, { listeners:
|
|
319
|
-
it(n,
|
|
314
|
+
class: f,
|
|
315
|
+
style: c,
|
|
316
|
+
on: l,
|
|
317
|
+
...E
|
|
318
|
+
} = t.props ?? {}, { listeners: g } = e;
|
|
319
|
+
it(n, a, E), ct(n, s, f), ut(
|
|
320
320
|
n,
|
|
321
321
|
i,
|
|
322
|
-
|
|
323
|
-
), t.listeners =
|
|
322
|
+
c
|
|
323
|
+
), t.listeners = at(
|
|
324
324
|
n,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
g,
|
|
326
|
+
o ?? {},
|
|
327
|
+
l ?? {},
|
|
328
328
|
r
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
331
|
function it(e, t = {}, r = {}) {
|
|
332
|
-
const n = t.ref,
|
|
333
|
-
n !==
|
|
334
|
-
const i = { ...t },
|
|
335
|
-
delete i.ref, delete
|
|
336
|
-
const { added:
|
|
337
|
-
for (const
|
|
338
|
-
D(e,
|
|
339
|
-
for (const
|
|
340
|
-
w(e,
|
|
332
|
+
const n = t.ref, s = r.ref;
|
|
333
|
+
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
334
|
+
const i = { ...t }, o = { ...r };
|
|
335
|
+
delete i.ref, delete o.ref;
|
|
336
|
+
const { added: a, removed: f, updated: c } = S(i, o);
|
|
337
|
+
for (const l of f)
|
|
338
|
+
D(e, l);
|
|
339
|
+
for (const l of a.concat(c))
|
|
340
|
+
w(e, l, o[l]);
|
|
341
341
|
}
|
|
342
342
|
function ct(e, t, r) {
|
|
343
|
-
const n =
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
function
|
|
347
|
-
return Array.isArray(e) ? e.filter(
|
|
348
|
-
}
|
|
349
|
-
function
|
|
350
|
-
const { added: n, removed:
|
|
351
|
-
for (const
|
|
352
|
-
J(e,
|
|
353
|
-
for (const
|
|
354
|
-
M(e,
|
|
355
|
-
}
|
|
356
|
-
function
|
|
357
|
-
const { removed: i, added:
|
|
358
|
-
for (const
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
n[l],
|
|
343
|
+
const n = k(t), s = k(r), { added: i, removed: o } = F(n, s);
|
|
344
|
+
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
345
|
+
}
|
|
346
|
+
function k(e = "") {
|
|
347
|
+
return Array.isArray(e) ? e.filter(T) : String(e).split(/(\s+)/).filter(T);
|
|
348
|
+
}
|
|
349
|
+
function ut(e, t = {}, r = {}) {
|
|
350
|
+
const { added: n, removed: s, updated: i } = S(t, r);
|
|
351
|
+
for (const o of s)
|
|
352
|
+
J(e, o);
|
|
353
|
+
for (const o of n.concat(i))
|
|
354
|
+
M(e, o, r[o]);
|
|
355
|
+
}
|
|
356
|
+
function at(e, t = {}, r = {}, n = {}, s = null) {
|
|
357
|
+
const { removed: i, added: o, updated: a } = S(r, n), f = { ...t };
|
|
358
|
+
for (const c of i.concat(a)) {
|
|
359
|
+
const l = t?.[c];
|
|
360
|
+
l && (e.removeEventListener(c, l), delete f[c]);
|
|
361
|
+
}
|
|
362
|
+
for (const c of o.concat(a))
|
|
363
|
+
f[c] = N(
|
|
364
|
+
c,
|
|
365
|
+
n[c],
|
|
367
366
|
e,
|
|
368
|
-
|
|
367
|
+
s
|
|
369
368
|
);
|
|
370
|
-
return
|
|
371
|
-
}
|
|
372
|
-
function
|
|
373
|
-
const n =
|
|
374
|
-
for (const
|
|
375
|
-
if (
|
|
376
|
-
const { originalIndex:
|
|
377
|
-
|
|
369
|
+
return f;
|
|
370
|
+
}
|
|
371
|
+
function R(e, t, r) {
|
|
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
|
+
y(n[c], s[l], i, r);
|
|
378
377
|
}
|
|
379
|
-
for (const
|
|
380
|
-
switch (
|
|
381
|
-
case
|
|
382
|
-
const { from:
|
|
383
|
-
|
|
378
|
+
for (const f of o)
|
|
379
|
+
switch (f.op) {
|
|
380
|
+
case v.MOVE: {
|
|
381
|
+
const { from: c, index: l } = f, E = n[c].el, g = i.childNodes[l + a];
|
|
382
|
+
E && (i.insertBefore(E, g), y(n[c], s[l], i, r));
|
|
384
383
|
break;
|
|
385
384
|
}
|
|
386
|
-
case
|
|
387
|
-
const { item:
|
|
388
|
-
p(
|
|
385
|
+
case v.REMOVE: {
|
|
386
|
+
const { item: c } = f;
|
|
387
|
+
p(c);
|
|
389
388
|
break;
|
|
390
389
|
}
|
|
391
|
-
case
|
|
392
|
-
const { index:
|
|
393
|
-
d(
|
|
390
|
+
case v.ADD: {
|
|
391
|
+
const { index: c, item: l } = f;
|
|
392
|
+
d(l, i, c + a, r);
|
|
394
393
|
break;
|
|
395
394
|
}
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
|
-
function
|
|
399
|
-
const { component: r } = e, { props: n } =
|
|
397
|
+
function ft(e, t) {
|
|
398
|
+
const { component: r } = e, { props: n } = A(t);
|
|
400
399
|
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
401
400
|
}
|
|
402
|
-
function
|
|
401
|
+
function lt(e, t, r) {
|
|
403
402
|
if (e.container !== t.container) {
|
|
404
403
|
p(e), d(t, document.body, null, r);
|
|
405
404
|
return;
|
|
406
405
|
}
|
|
407
|
-
|
|
406
|
+
R(e, t, r);
|
|
408
407
|
}
|
|
409
408
|
const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
|
|
410
|
-
class
|
|
409
|
+
class C {
|
|
411
410
|
isMounted = !1;
|
|
412
411
|
vdom = null;
|
|
413
412
|
hostEl = null;
|
|
414
413
|
parent = null;
|
|
415
|
-
error = null;
|
|
416
414
|
static defaultProps = {};
|
|
417
415
|
props;
|
|
418
416
|
state = {};
|
|
@@ -455,23 +453,23 @@ class k {
|
|
|
455
453
|
return Promise.resolve();
|
|
456
454
|
}
|
|
457
455
|
didCatch(t, r) {
|
|
458
|
-
return console.error("Uncaught error:", t, r),
|
|
456
|
+
return console.error("Uncaught error:", t, r), Promise.resolve();
|
|
459
457
|
}
|
|
460
458
|
shouldComponentUpdate(t, r) {
|
|
461
|
-
return
|
|
459
|
+
return m(t, r);
|
|
462
460
|
}
|
|
463
461
|
get elements() {
|
|
464
|
-
return this.vdom == null ? [] : this.vdom.type ===
|
|
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] : [];
|
|
465
463
|
}
|
|
466
464
|
get firstElement() {
|
|
467
465
|
return this.elements[0];
|
|
468
466
|
}
|
|
469
467
|
get offset() {
|
|
470
|
-
return this.vdom?.type ===
|
|
468
|
+
return this.vdom?.type === u.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
|
|
471
469
|
}
|
|
472
470
|
updateProps(t) {
|
|
473
|
-
const n = { ...this.getDefaultProps(), ...this.props, ...t },
|
|
474
|
-
this.props = n, !this.shouldComponentUpdate(
|
|
471
|
+
const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
|
|
472
|
+
this.props = n, !this.shouldComponentUpdate(s, n) && (ht(this) && this.notify(), this.patch(s, this.state));
|
|
475
473
|
}
|
|
476
474
|
setState(t) {
|
|
477
475
|
const r = this.state;
|
|
@@ -493,14 +491,14 @@ class k {
|
|
|
493
491
|
unmount() {
|
|
494
492
|
this.isMounted && (h(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
495
493
|
t.subscribedProvider = null;
|
|
496
|
-
}), 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);
|
|
497
495
|
}
|
|
498
496
|
patch(t, r) {
|
|
499
|
-
if (!(!this.isMounted || !this.hostEl || !this.vdom)
|
|
497
|
+
if (!(!this.isMounted || !this.hostEl || !this.vdom)) {
|
|
500
498
|
h(() => this.willUpdate(this.props, this.state));
|
|
501
499
|
try {
|
|
502
500
|
const n = this.render();
|
|
503
|
-
this.vdom =
|
|
501
|
+
this.vdom = y(this.vdom, n, this.hostEl, this), h(() => this.didUpdate(t, r));
|
|
504
502
|
} catch (n) {
|
|
505
503
|
this.handleError(n, "patch");
|
|
506
504
|
}
|
|
@@ -536,38 +534,32 @@ class k {
|
|
|
536
534
|
return this.constructor.defaultProps || {};
|
|
537
535
|
}
|
|
538
536
|
handleError(t, r) {
|
|
539
|
-
console.log("handleError");
|
|
540
537
|
const n = this.findClosestErrorBoundary();
|
|
541
|
-
if (
|
|
542
|
-
console.log("Found error boundary");
|
|
538
|
+
if (n) {
|
|
543
539
|
const i = n.constructor;
|
|
544
540
|
if (i.getDerivedStateFromError) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
n.state = { ...n.state, ...s };
|
|
541
|
+
const o = i.getDerivedStateFromError(t);
|
|
542
|
+
n.state = { ...n.state, ...o };
|
|
548
543
|
}
|
|
549
|
-
if (n.hostEl)
|
|
550
|
-
for (console.log("Cleaning up ErrorBoundary hostEl"); n.hostEl.firstChild; )
|
|
551
|
-
console.log("errorBoundary.hostEl.firstChild", n.hostEl.firstChild), console.log("errorBoundary.hostEl.removeChild"), n.hostEl.removeChild(n.hostEl.firstChild);
|
|
552
544
|
if (n.hostEl && n.isMounted)
|
|
553
545
|
try {
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
546
|
+
const o = n.render();
|
|
547
|
+
o && (n.vdom = y(n.vdom, o, n.hostEl, n), h(() => {
|
|
548
|
+
const a = {
|
|
557
549
|
phase: r,
|
|
558
550
|
failedComponent: this.constructor.name,
|
|
559
551
|
componentStack: this.getComponentStack()
|
|
560
|
-
}
|
|
552
|
+
};
|
|
553
|
+
console.error("error", t, a), n.didCatch(t, a);
|
|
561
554
|
}));
|
|
562
|
-
} catch (
|
|
563
|
-
|
|
555
|
+
} catch (o) {
|
|
556
|
+
n.parent && n.parent.handleError(o, r);
|
|
564
557
|
}
|
|
565
558
|
return;
|
|
566
559
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const i = o.getDerivedStateFromError(t);
|
|
560
|
+
const s = this.constructor;
|
|
561
|
+
if (s.getDerivedStateFromError) {
|
|
562
|
+
const i = s.getDerivedStateFromError(t);
|
|
571
563
|
this.state = { ...this.state, ...i };
|
|
572
564
|
}
|
|
573
565
|
h(() => {
|
|
@@ -577,7 +569,7 @@ class k {
|
|
|
577
569
|
}), this.hostEl && this.isMounted)
|
|
578
570
|
try {
|
|
579
571
|
const i = this.render();
|
|
580
|
-
i &&
|
|
572
|
+
i && y(this.vdom, i, this.hostEl, this);
|
|
581
573
|
} catch (i) {
|
|
582
574
|
console.error("Error during error recovery render:", i);
|
|
583
575
|
}
|
|
@@ -600,35 +592,35 @@ class k {
|
|
|
600
592
|
return null;
|
|
601
593
|
}
|
|
602
594
|
isErrorBoundary() {
|
|
603
|
-
return
|
|
595
|
+
return this.constructor.getDerivedStateFromError !== void 0;
|
|
604
596
|
}
|
|
605
597
|
}
|
|
606
|
-
function
|
|
607
|
-
class t extends
|
|
598
|
+
function yt(e) {
|
|
599
|
+
class t extends C {
|
|
608
600
|
isProvider = !0;
|
|
609
601
|
render() {
|
|
610
|
-
let
|
|
611
|
-
return Array.isArray(this.props.children) ?
|
|
602
|
+
let s = [];
|
|
603
|
+
return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [], U(s);
|
|
612
604
|
}
|
|
613
605
|
}
|
|
614
|
-
class r extends
|
|
606
|
+
class r extends C {
|
|
615
607
|
static contextType = {
|
|
616
608
|
Provider: t,
|
|
617
609
|
defaultValue: e
|
|
618
610
|
};
|
|
619
611
|
isConsumer = !0;
|
|
620
612
|
render() {
|
|
621
|
-
let
|
|
622
|
-
if (Array.isArray(
|
|
623
|
-
if (
|
|
624
|
-
|
|
613
|
+
let s = this.props.children;
|
|
614
|
+
if (Array.isArray(s))
|
|
615
|
+
if (s.length === 1 && typeof s[0] == "function")
|
|
616
|
+
s = s[0];
|
|
625
617
|
else
|
|
626
618
|
throw new Error(
|
|
627
619
|
"Consumer: expected single function child, got array"
|
|
628
620
|
);
|
|
629
|
-
if (typeof
|
|
621
|
+
if (typeof s != "function")
|
|
630
622
|
throw new Error("Consumer: children is not a function");
|
|
631
|
-
return
|
|
623
|
+
return s(this.context);
|
|
632
624
|
}
|
|
633
625
|
}
|
|
634
626
|
return {
|
|
@@ -637,27 +629,27 @@ function Et(e) {
|
|
|
637
629
|
defaultValue: e
|
|
638
630
|
};
|
|
639
631
|
}
|
|
640
|
-
function
|
|
632
|
+
function Et(e, t) {
|
|
641
633
|
if (!t)
|
|
642
634
|
throw new Error("Container element is not provided for rendering.");
|
|
643
635
|
d(e, t);
|
|
644
636
|
}
|
|
645
|
-
function
|
|
637
|
+
function vt(e = null) {
|
|
646
638
|
return {
|
|
647
639
|
current: e
|
|
648
640
|
};
|
|
649
641
|
}
|
|
650
|
-
function
|
|
642
|
+
function gt(e, t) {
|
|
651
643
|
const r = Array.isArray(e) ? e : [e];
|
|
652
|
-
return
|
|
644
|
+
return B(r, t);
|
|
653
645
|
}
|
|
654
646
|
export {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
647
|
+
C as Component,
|
|
648
|
+
yt as createContext,
|
|
649
|
+
gt as createPortal,
|
|
650
|
+
vt as createRef,
|
|
659
651
|
Pt as h,
|
|
660
|
-
|
|
652
|
+
U as hFragment,
|
|
661
653
|
Ot as hString,
|
|
662
|
-
|
|
654
|
+
Et as render
|
|
663
655
|
};
|