ddd-react 1.10.16 → 1.11.0
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 +4 -3
- package/dist/{h-BbaMkkC7.mjs → h-edTp7-8E.mjs} +2 -2
- package/dist/index.mjs +179 -122
- package/dist/jsx-runtime.mjs +17 -13
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -24,13 +24,13 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
24
24
|
}): void;
|
|
25
25
|
notify(): void;
|
|
26
26
|
didMount(): void | Promise<void>;
|
|
27
|
-
willUpdate(
|
|
28
|
-
didUpdate(
|
|
27
|
+
willUpdate(_nextProps: P, _nextState: S): void | Promise<void>;
|
|
28
|
+
didUpdate(_prevProps: P, _prevState: S): void | Promise<void>;
|
|
29
29
|
willUnmount(): void | Promise<void>;
|
|
30
30
|
didUnmount(): void | Promise<void>;
|
|
31
31
|
didCatch(error: Error, errorInfo: any): void | Promise<void>;
|
|
32
32
|
shouldComponentUpdate(prevProps: P, nextProps: P): boolean;
|
|
33
|
-
abstract render(): VDOMNode;
|
|
33
|
+
abstract render(): VDOMNode[] | VDOMNode | Function | null | undefined;
|
|
34
34
|
get elements(): HTMLElement[];
|
|
35
35
|
get firstElement(): HTMLElement | undefined;
|
|
36
36
|
get offset(): number;
|
|
@@ -46,4 +46,5 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
46
46
|
private getComponentStack;
|
|
47
47
|
private findClosestErrorBoundary;
|
|
48
48
|
isErrorBoundary(): boolean;
|
|
49
|
+
private normalizeRenderResult;
|
|
49
50
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as u, e as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
1
|
+
import { D as u, e as g, a as F, A as v, b as U, h as N, c as B, d as I } from "./h-edTp7-8E.mjs";
|
|
2
|
+
import { f as Ot } from "./h-edTp7-8E.mjs";
|
|
3
|
+
function b(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 m(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 (!b(e[n], t[n]))
|
|
18
18
|
return !1;
|
|
19
19
|
return !0;
|
|
20
20
|
}
|
|
@@ -32,24 +32,24 @@ function m(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) && !b(e[s], t[s]))
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
38
|
return !0;
|
|
39
39
|
}
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function M(e, t, r, n = null) {
|
|
43
43
|
function s(i) {
|
|
44
44
|
const o = i;
|
|
45
45
|
n ? t.call(n, o) : t(o);
|
|
46
46
|
}
|
|
47
47
|
return r.addEventListener(e, s), s;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function _(e = {}, t, r = null) {
|
|
50
50
|
const n = {};
|
|
51
51
|
return Object.entries(e).forEach(([s, i]) => {
|
|
52
|
-
n[s] =
|
|
52
|
+
n[s] = M(
|
|
53
53
|
s,
|
|
54
54
|
i,
|
|
55
55
|
t,
|
|
@@ -74,7 +74,7 @@ function p(e) {
|
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
case u.FRAGMENT: {
|
|
77
|
-
|
|
77
|
+
z(e);
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
case u.COMPONENT: {
|
|
@@ -98,7 +98,7 @@ function G(e) {
|
|
|
98
98
|
const { el: t, children: r, listeners: n, props: s } = e;
|
|
99
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
|
-
function
|
|
101
|
+
function z(e) {
|
|
102
102
|
const { children: t } = e;
|
|
103
103
|
t && t.forEach(p);
|
|
104
104
|
}
|
|
@@ -106,7 +106,7 @@ function X(e) {
|
|
|
106
106
|
const { children: t } = e;
|
|
107
107
|
t && t.forEach(p);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function w(e, t, r) {
|
|
110
110
|
e.style[t] = r.toString();
|
|
111
111
|
}
|
|
112
112
|
function J(e, t) {
|
|
@@ -115,10 +115,10 @@ function J(e, t) {
|
|
|
115
115
|
function K(e, t) {
|
|
116
116
|
const { class: r, style: n, ...s } = t;
|
|
117
117
|
r && W(e, r), n && Object.entries(n).forEach(([i, o]) => {
|
|
118
|
-
|
|
118
|
+
w(e, i, o);
|
|
119
119
|
});
|
|
120
120
|
for (const [i, o] of Object.entries(s))
|
|
121
|
-
|
|
121
|
+
D(e, i, o);
|
|
122
122
|
}
|
|
123
123
|
function W(e, t) {
|
|
124
124
|
if (e instanceof SVGElement) {
|
|
@@ -127,15 +127,15 @@ function W(e, t) {
|
|
|
127
127
|
}
|
|
128
128
|
e.className = "", typeof t == "string" ? e.className = t : Array.isArray(t) && e.classList.add(...t);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
r == null ?
|
|
130
|
+
function D(e, t, r) {
|
|
131
|
+
r == null ? j(e, t) : e.setAttribute(t, String(r));
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function j(e, t) {
|
|
134
134
|
e[t] = null, e.removeAttribute(t);
|
|
135
135
|
}
|
|
136
136
|
let P = !1;
|
|
137
137
|
const O = [];
|
|
138
|
-
function
|
|
138
|
+
function d(e) {
|
|
139
139
|
O.push(e), Y();
|
|
140
140
|
}
|
|
141
141
|
function Y() {
|
|
@@ -165,59 +165,74 @@ function A(e) {
|
|
|
165
165
|
const { on: t = {}, ...r } = e.props;
|
|
166
166
|
return delete r.key, { props: r, events: t };
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function h(e, t, r = null, n = null) {
|
|
169
169
|
switch (e.type) {
|
|
170
170
|
case u.TEXT: {
|
|
171
|
-
|
|
171
|
+
Q(e, t, r);
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
case u.ELEMENT: {
|
|
175
|
-
|
|
175
|
+
V(
|
|
176
|
+
e,
|
|
177
|
+
t,
|
|
178
|
+
r,
|
|
179
|
+
n
|
|
180
|
+
);
|
|
176
181
|
break;
|
|
177
182
|
}
|
|
178
183
|
case u.FRAGMENT: {
|
|
179
|
-
|
|
184
|
+
Z(
|
|
185
|
+
e,
|
|
186
|
+
t,
|
|
187
|
+
r,
|
|
188
|
+
n
|
|
189
|
+
);
|
|
180
190
|
break;
|
|
181
191
|
}
|
|
182
192
|
case u.COMPONENT: {
|
|
183
|
-
|
|
193
|
+
et(
|
|
194
|
+
e,
|
|
195
|
+
t,
|
|
196
|
+
r,
|
|
197
|
+
n
|
|
198
|
+
);
|
|
184
199
|
const s = e.component;
|
|
185
|
-
s &&
|
|
200
|
+
s && d(() => s.didMount());
|
|
186
201
|
break;
|
|
187
202
|
}
|
|
188
203
|
case u.PORTAL: {
|
|
189
|
-
|
|
204
|
+
rt(e, n);
|
|
190
205
|
break;
|
|
191
206
|
}
|
|
192
207
|
default:
|
|
193
208
|
throw new Error(`Can't mount DOM of type: ${e.type}`);
|
|
194
209
|
}
|
|
195
210
|
}
|
|
196
|
-
function
|
|
211
|
+
function Q(e, t, r) {
|
|
197
212
|
const { value: n } = e, s = document.createTextNode(n);
|
|
198
|
-
e.el = s,
|
|
213
|
+
e.el = s, L(s, t, r);
|
|
199
214
|
}
|
|
200
|
-
function
|
|
215
|
+
function Z(e, t, r, n) {
|
|
201
216
|
const { children: s } = e;
|
|
202
217
|
e.el = t, s?.forEach((i, o) => {
|
|
203
|
-
|
|
218
|
+
h(i, t, r != null ? r + o : null, n);
|
|
204
219
|
});
|
|
205
220
|
}
|
|
206
|
-
function
|
|
207
|
-
const { tag: s, children: i } = e,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}),
|
|
221
|
+
function V(e, t, r, n) {
|
|
222
|
+
const { tag: s, children: i } = e, l = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
223
|
+
tt(l, e, n), e.el = l, i?.forEach((f) => {
|
|
224
|
+
h(f, l, null, n);
|
|
225
|
+
}), L(l, t, r);
|
|
211
226
|
}
|
|
212
|
-
function
|
|
227
|
+
function tt(e, t, r) {
|
|
213
228
|
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 =
|
|
229
|
+
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = _(s, e, r), K(e, n);
|
|
215
230
|
}
|
|
216
|
-
function
|
|
231
|
+
function et(e, t, r, n) {
|
|
217
232
|
const s = e.tag, { props: i } = A(e), o = new s(i, n);
|
|
218
233
|
o.mount(t, r), e.component = o, e.el = o.firstElement || null;
|
|
219
234
|
}
|
|
220
|
-
function
|
|
235
|
+
function L(e, t, r) {
|
|
221
236
|
if (r == null) {
|
|
222
237
|
t.append(e);
|
|
223
238
|
return;
|
|
@@ -227,13 +242,13 @@ function j(e, t, r) {
|
|
|
227
242
|
const n = t.childNodes;
|
|
228
243
|
r >= n.length ? t.append(e) : t.insertBefore(e, n[r]);
|
|
229
244
|
}
|
|
230
|
-
function
|
|
245
|
+
function rt(e, t) {
|
|
231
246
|
const { children: r, container: n } = e;
|
|
232
247
|
r?.forEach((s) => {
|
|
233
|
-
|
|
248
|
+
h(s, n, null, t);
|
|
234
249
|
});
|
|
235
250
|
}
|
|
236
|
-
function
|
|
251
|
+
function R(e, t) {
|
|
237
252
|
if (e.type !== t.type)
|
|
238
253
|
return !1;
|
|
239
254
|
if (e.type === u.ELEMENT) {
|
|
@@ -242,9 +257,9 @@ function L(e, t) {
|
|
|
242
257
|
props: { key: i }
|
|
243
258
|
} = r, {
|
|
244
259
|
tag: o,
|
|
245
|
-
props: { key:
|
|
260
|
+
props: { key: l }
|
|
246
261
|
} = n;
|
|
247
|
-
return s === o && i ===
|
|
262
|
+
return s === o && i === l;
|
|
248
263
|
}
|
|
249
264
|
if (e.type === u.COMPONENT) {
|
|
250
265
|
const r = e, n = t, { tag: s } = r, { tag: i } = n;
|
|
@@ -266,101 +281,115 @@ function S(e, t) {
|
|
|
266
281
|
updated: i
|
|
267
282
|
};
|
|
268
283
|
}
|
|
269
|
-
function
|
|
284
|
+
function nt(e) {
|
|
270
285
|
return e !== "";
|
|
271
286
|
}
|
|
272
287
|
function T(e) {
|
|
273
|
-
return
|
|
288
|
+
return nt(e.trim());
|
|
274
289
|
}
|
|
275
290
|
function y(e, t, r, n = null) {
|
|
276
|
-
if (!
|
|
277
|
-
const s =
|
|
278
|
-
return p(e),
|
|
291
|
+
if (!R(e, t)) {
|
|
292
|
+
const s = st(r, e.el);
|
|
293
|
+
return p(e), h(t, r, s, n), t;
|
|
279
294
|
}
|
|
280
295
|
switch (t.el = e.el, t.type) {
|
|
281
296
|
case u.TEXT:
|
|
282
|
-
return
|
|
297
|
+
return ot(e, t), t;
|
|
283
298
|
case u.ELEMENT: {
|
|
284
|
-
|
|
299
|
+
it(
|
|
300
|
+
e,
|
|
301
|
+
t,
|
|
302
|
+
n
|
|
303
|
+
);
|
|
285
304
|
break;
|
|
286
305
|
}
|
|
287
306
|
case u.COMPONENT: {
|
|
288
|
-
|
|
307
|
+
at(
|
|
308
|
+
e,
|
|
309
|
+
t
|
|
310
|
+
);
|
|
289
311
|
break;
|
|
290
312
|
}
|
|
291
313
|
case u.PORTAL: {
|
|
292
|
-
|
|
314
|
+
ht(
|
|
315
|
+
e,
|
|
316
|
+
t,
|
|
317
|
+
n
|
|
318
|
+
);
|
|
293
319
|
break;
|
|
294
320
|
}
|
|
295
321
|
}
|
|
296
|
-
return
|
|
322
|
+
return x(e, t, n), t;
|
|
297
323
|
}
|
|
298
|
-
function
|
|
324
|
+
function st(e, t) {
|
|
299
325
|
if (!t) return null;
|
|
300
326
|
const r = Array.from(e.childNodes).indexOf(t);
|
|
301
327
|
return r < 0 ? null : r;
|
|
302
328
|
}
|
|
303
|
-
function
|
|
329
|
+
function ot(e, t) {
|
|
304
330
|
const r = e.el, { value: n } = e, { value: s } = t;
|
|
305
331
|
n !== s && r && (r.nodeValue = s);
|
|
306
332
|
}
|
|
307
|
-
function
|
|
333
|
+
function it(e, t, r) {
|
|
308
334
|
const n = e.el, {
|
|
309
335
|
class: s,
|
|
310
336
|
style: i,
|
|
311
337
|
on: o,
|
|
312
|
-
...
|
|
338
|
+
...l
|
|
313
339
|
} = e.props ?? {}, {
|
|
314
340
|
class: f,
|
|
315
341
|
style: c,
|
|
316
|
-
on:
|
|
342
|
+
on: a,
|
|
317
343
|
...E
|
|
318
|
-
} = t.props ?? {}, { listeners:
|
|
319
|
-
|
|
344
|
+
} = t.props ?? {}, { listeners: m } = e;
|
|
345
|
+
ct(n, l, E), ut(n, s, f), lt(
|
|
320
346
|
n,
|
|
321
347
|
i,
|
|
322
348
|
c
|
|
323
|
-
), t.listeners =
|
|
349
|
+
), t.listeners = ft(
|
|
324
350
|
n,
|
|
325
|
-
|
|
351
|
+
m,
|
|
326
352
|
o ?? {},
|
|
327
|
-
|
|
353
|
+
a ?? {},
|
|
328
354
|
r
|
|
329
355
|
);
|
|
330
356
|
}
|
|
331
|
-
function
|
|
357
|
+
function ct(e, t = {}, r = {}) {
|
|
332
358
|
const n = t.ref, s = r.ref;
|
|
333
359
|
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
334
360
|
const i = { ...t }, o = { ...r };
|
|
335
361
|
delete i.ref, delete o.ref;
|
|
336
|
-
const { added:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
362
|
+
const { added: l, removed: f, updated: c } = S(
|
|
363
|
+
i,
|
|
364
|
+
o
|
|
365
|
+
);
|
|
366
|
+
for (const a of f)
|
|
367
|
+
j(e, a);
|
|
368
|
+
for (const a of l.concat(c))
|
|
369
|
+
D(e, a, o[a]);
|
|
370
|
+
}
|
|
371
|
+
function ut(e, t, r) {
|
|
372
|
+
const n = k(t), s = k(r), { added: i, removed: o } = U(n, s);
|
|
344
373
|
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
345
374
|
}
|
|
346
375
|
function k(e = "") {
|
|
347
376
|
return Array.isArray(e) ? e.filter(T) : String(e).split(/(\s+)/).filter(T);
|
|
348
377
|
}
|
|
349
|
-
function
|
|
378
|
+
function lt(e, t = {}, r = {}) {
|
|
350
379
|
const { added: n, removed: s, updated: i } = S(t, r);
|
|
351
380
|
for (const o of s)
|
|
352
381
|
J(e, o);
|
|
353
382
|
for (const o of n.concat(i))
|
|
354
|
-
|
|
383
|
+
w(e, o, r[o]);
|
|
355
384
|
}
|
|
356
|
-
function
|
|
357
|
-
const { removed: i, added: o, updated:
|
|
358
|
-
for (const c of i.concat(
|
|
359
|
-
const
|
|
360
|
-
|
|
385
|
+
function ft(e, t = {}, r = {}, n = {}, s = null) {
|
|
386
|
+
const { removed: i, added: o, updated: l } = S(r, n), f = { ...t };
|
|
387
|
+
for (const c of i.concat(l)) {
|
|
388
|
+
const a = t?.[c];
|
|
389
|
+
a && (e.removeEventListener(c, a), delete f[c]);
|
|
361
390
|
}
|
|
362
|
-
for (const c of o.concat(
|
|
363
|
-
f[c] =
|
|
391
|
+
for (const c of o.concat(l))
|
|
392
|
+
f[c] = M(
|
|
364
393
|
c,
|
|
365
394
|
n[c],
|
|
366
395
|
e,
|
|
@@ -368,18 +397,32 @@ function at(e, t = {}, r = {}, n = {}, s = null) {
|
|
|
368
397
|
);
|
|
369
398
|
return f;
|
|
370
399
|
}
|
|
371
|
-
function
|
|
372
|
-
const n =
|
|
400
|
+
function x(e, t, r) {
|
|
401
|
+
const n = g(e), s = g(t), i = e.el, o = F(
|
|
402
|
+
n,
|
|
403
|
+
s,
|
|
404
|
+
R
|
|
405
|
+
), l = r?.offset ?? 0;
|
|
373
406
|
for (const f of o)
|
|
374
407
|
if (f.op === v.NOOP) {
|
|
375
|
-
const { originalIndex: c, index:
|
|
376
|
-
y(
|
|
408
|
+
const { originalIndex: c, index: a } = f;
|
|
409
|
+
y(
|
|
410
|
+
n[c],
|
|
411
|
+
s[a],
|
|
412
|
+
i,
|
|
413
|
+
r
|
|
414
|
+
);
|
|
377
415
|
}
|
|
378
416
|
for (const f of o)
|
|
379
417
|
switch (f.op) {
|
|
380
418
|
case v.MOVE: {
|
|
381
|
-
const { from: c, index:
|
|
382
|
-
E && (i.insertBefore(E,
|
|
419
|
+
const { from: c, index: a } = f, E = n[c].el, m = i.childNodes[a + l];
|
|
420
|
+
E && (i.insertBefore(E, m), y(
|
|
421
|
+
n[c],
|
|
422
|
+
s[a],
|
|
423
|
+
i,
|
|
424
|
+
r
|
|
425
|
+
));
|
|
383
426
|
break;
|
|
384
427
|
}
|
|
385
428
|
case v.REMOVE: {
|
|
@@ -388,24 +431,24 @@ function R(e, t, r) {
|
|
|
388
431
|
break;
|
|
389
432
|
}
|
|
390
433
|
case v.ADD: {
|
|
391
|
-
const { index: c, item:
|
|
392
|
-
|
|
434
|
+
const { index: c, item: a } = f;
|
|
435
|
+
h(a, i, c + l, r);
|
|
393
436
|
break;
|
|
394
437
|
}
|
|
395
438
|
}
|
|
396
439
|
}
|
|
397
|
-
function
|
|
440
|
+
function at(e, t) {
|
|
398
441
|
const { component: r } = e, { props: n } = A(t);
|
|
399
442
|
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
400
443
|
}
|
|
401
|
-
function
|
|
444
|
+
function ht(e, t, r) {
|
|
402
445
|
if (e.container !== t.container) {
|
|
403
|
-
p(e),
|
|
446
|
+
p(e), h(t, document.body, null, r);
|
|
404
447
|
return;
|
|
405
448
|
}
|
|
406
|
-
|
|
449
|
+
x(e, t, r);
|
|
407
450
|
}
|
|
408
|
-
const
|
|
451
|
+
const dt = (e) => e.isProvider, pt = (e) => e.isConsumer;
|
|
409
452
|
class C {
|
|
410
453
|
isMounted = !1;
|
|
411
454
|
vdom = null;
|
|
@@ -427,11 +470,13 @@ class C {
|
|
|
427
470
|
this.dependencies.some((r) => r.consumer === t) || (this.dependencies.push({ consumer: t }), t.subscribedProvider = this);
|
|
428
471
|
}
|
|
429
472
|
removeDependency({ consumer: t }) {
|
|
430
|
-
const r = this.dependencies.findIndex(
|
|
473
|
+
const r = this.dependencies.findIndex(
|
|
474
|
+
(n) => n.consumer === t
|
|
475
|
+
);
|
|
431
476
|
r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
|
|
432
477
|
}
|
|
433
478
|
notify() {
|
|
434
|
-
|
|
479
|
+
d(() => {
|
|
435
480
|
this.dependencies.forEach(({ consumer: t }) => {
|
|
436
481
|
t.isMounted && t.updateContext() && t.patch(t.props, t.state);
|
|
437
482
|
});
|
|
@@ -456,10 +501,10 @@ class C {
|
|
|
456
501
|
return console.error("Uncaught error:", t, r), Promise.resolve();
|
|
457
502
|
}
|
|
458
503
|
shouldComponentUpdate(t, r) {
|
|
459
|
-
return
|
|
504
|
+
return b(t, r);
|
|
460
505
|
}
|
|
461
506
|
get elements() {
|
|
462
|
-
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ?
|
|
507
|
+
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ? g(this.vdom).flatMap((t) => t.type === u.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
|
|
463
508
|
}
|
|
464
509
|
get firstElement() {
|
|
465
510
|
return this.elements[0];
|
|
@@ -469,36 +514,40 @@ class C {
|
|
|
469
514
|
}
|
|
470
515
|
updateProps(t) {
|
|
471
516
|
const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
|
|
472
|
-
this.props = n, !this.shouldComponentUpdate(s, n) && (
|
|
517
|
+
this.props = n, !this.shouldComponentUpdate(s, n) && (dt(this) && this.notify(), this.patch(s, this.state));
|
|
473
518
|
}
|
|
474
519
|
setState(t) {
|
|
475
520
|
const r = this.state;
|
|
476
521
|
typeof t == "function" ? this.state = {
|
|
477
522
|
...this.state,
|
|
478
|
-
...t(
|
|
523
|
+
...t(
|
|
524
|
+
this.state,
|
|
525
|
+
this.props
|
|
526
|
+
)
|
|
479
527
|
} : this.state = { ...this.state, ...t }, this.patch(this.props, r);
|
|
480
528
|
}
|
|
481
529
|
mount(t, r = null) {
|
|
482
530
|
if (this.isMounted)
|
|
483
531
|
throw new Error("Component is already mounted");
|
|
484
|
-
|
|
532
|
+
pt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
|
|
485
533
|
try {
|
|
486
|
-
|
|
534
|
+
const n = this.render(), s = this.normalizeRenderResult(n);
|
|
535
|
+
this.hostEl = t, this.isMounted = !0, s !== null ? (h(s, t, r, this), this.vdom = s) : this.vdom = null;
|
|
487
536
|
} catch (n) {
|
|
488
537
|
this.handleError(n, "mount");
|
|
489
538
|
}
|
|
490
539
|
}
|
|
491
540
|
unmount() {
|
|
492
|
-
this.isMounted && (
|
|
541
|
+
this.isMounted && (d(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
493
542
|
t.subscribedProvider = null;
|
|
494
|
-
}), this.dependencies = [], this.vdom && p(this.vdom),
|
|
543
|
+
}), this.dependencies = [], this.vdom && p(this.vdom), d(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
|
|
495
544
|
}
|
|
496
545
|
patch(t, r) {
|
|
497
|
-
if (!(!this.isMounted || !this.hostEl
|
|
498
|
-
|
|
546
|
+
if (!(!this.isMounted || !this.hostEl)) {
|
|
547
|
+
d(() => this.willUpdate(this.props, this.state));
|
|
499
548
|
try {
|
|
500
|
-
const n = this.render();
|
|
501
|
-
this.vdom = y(this.vdom,
|
|
549
|
+
const n = this.render(), s = this.normalizeRenderResult(n);
|
|
550
|
+
this.vdom === null && s !== null ? (h(s, this.hostEl, null, this), this.vdom = s) : this.vdom !== null && s === null ? (p(this.vdom), this.vdom = null) : this.vdom !== null && s !== null && (this.vdom = y(this.vdom, s, this.hostEl, this)), d(() => this.didUpdate(t, r));
|
|
502
551
|
} catch (n) {
|
|
503
552
|
this.handleError(n, "patch");
|
|
504
553
|
}
|
|
@@ -544,13 +593,18 @@ class C {
|
|
|
544
593
|
if (n.hostEl && n.isMounted)
|
|
545
594
|
try {
|
|
546
595
|
const o = n.render();
|
|
547
|
-
o && (n.vdom = y(
|
|
548
|
-
|
|
596
|
+
o && (n.vdom = y(
|
|
597
|
+
n.vdom,
|
|
598
|
+
o,
|
|
599
|
+
n.hostEl,
|
|
600
|
+
n
|
|
601
|
+
), d(() => {
|
|
602
|
+
const l = {
|
|
549
603
|
phase: r,
|
|
550
604
|
failedComponent: this.constructor.name,
|
|
551
605
|
componentStack: this.getComponentStack()
|
|
552
606
|
};
|
|
553
|
-
console.error("error", t,
|
|
607
|
+
console.error("error", t, l), n.didCatch(t, l);
|
|
554
608
|
}));
|
|
555
609
|
} catch (o) {
|
|
556
610
|
n.parent && n.parent.handleError(o, r);
|
|
@@ -562,7 +616,7 @@ class C {
|
|
|
562
616
|
const i = s.getDerivedStateFromError(t);
|
|
563
617
|
this.state = { ...this.state, ...i };
|
|
564
618
|
}
|
|
565
|
-
|
|
619
|
+
d(() => {
|
|
566
620
|
if (this.didCatch(t, {
|
|
567
621
|
phase: r,
|
|
568
622
|
componentStack: this.getComponentStack()
|
|
@@ -594,13 +648,16 @@ class C {
|
|
|
594
648
|
isErrorBoundary() {
|
|
595
649
|
return this.constructor.getDerivedStateFromError !== void 0;
|
|
596
650
|
}
|
|
651
|
+
normalizeRenderResult(t) {
|
|
652
|
+
return t == null ? null : Array.isArray(t) ? t.length > 0 ? N(t) : null : typeof t == "function" ? B(t, {}) : t;
|
|
653
|
+
}
|
|
597
654
|
}
|
|
598
|
-
function
|
|
655
|
+
function Et(e) {
|
|
599
656
|
class t extends C {
|
|
600
657
|
isProvider = !0;
|
|
601
658
|
render() {
|
|
602
659
|
let s = [];
|
|
603
|
-
return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [],
|
|
660
|
+
return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [], N(s);
|
|
604
661
|
}
|
|
605
662
|
}
|
|
606
663
|
class r extends C {
|
|
@@ -629,27 +686,27 @@ function yt(e) {
|
|
|
629
686
|
defaultValue: e
|
|
630
687
|
};
|
|
631
688
|
}
|
|
632
|
-
function
|
|
689
|
+
function vt(e, t) {
|
|
633
690
|
if (!t)
|
|
634
691
|
throw new Error("Container element is not provided for rendering.");
|
|
635
|
-
|
|
692
|
+
h(e, t);
|
|
636
693
|
}
|
|
637
|
-
function
|
|
694
|
+
function mt(e = null) {
|
|
638
695
|
return {
|
|
639
696
|
current: e
|
|
640
697
|
};
|
|
641
698
|
}
|
|
642
699
|
function gt(e, t) {
|
|
643
700
|
const r = Array.isArray(e) ? e : [e];
|
|
644
|
-
return
|
|
701
|
+
return I(r, t);
|
|
645
702
|
}
|
|
646
703
|
export {
|
|
647
704
|
C as Component,
|
|
648
|
-
|
|
705
|
+
Et as createContext,
|
|
649
706
|
gt as createPortal,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
707
|
+
mt as createRef,
|
|
708
|
+
B as h,
|
|
709
|
+
N as hFragment,
|
|
653
710
|
Ot as hString,
|
|
654
|
-
|
|
711
|
+
vt as render
|
|
655
712
|
};
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { h as p,
|
|
2
|
-
const
|
|
1
|
+
import { h as p, c, f as a } from "./h-edTp7-8E.mjs";
|
|
2
|
+
const h = /* @__PURE__ */ Symbol("Fragment");
|
|
3
3
|
function l(n) {
|
|
4
4
|
return n == null || n === !1 ? null : typeof n == "string" || typeof n == "number" || typeof n == "boolean" ? a(String(n)) : n;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (n ===
|
|
8
|
-
const t =
|
|
6
|
+
function d(n, o, ...s) {
|
|
7
|
+
if (n === h) {
|
|
8
|
+
const t = s.flat().map(l).filter((e) => e != null);
|
|
9
9
|
return p(t);
|
|
10
10
|
}
|
|
11
11
|
let f = {}, i = {};
|
|
12
12
|
if (o && Object.entries(o).forEach(([t, e]) => {
|
|
13
13
|
if (t.startsWith("on") && typeof e == "function") {
|
|
14
|
-
const
|
|
15
|
-
f[
|
|
14
|
+
const r = t.slice(2).toLowerCase();
|
|
15
|
+
f[r] = e;
|
|
16
16
|
} else t === "ref" ? i.ref = e : t === "className" ? i.class = e : t === "style" && typeof e == "object" ? i.style = e : t === "colorInterpolationFilters" ? i["color-interpolation-filters"] = e : t === "viewbox" ? i.viewBox = e : t !== "children" && t !== "key" && (i[t] = e);
|
|
17
17
|
}), typeof n == "function")
|
|
18
18
|
try {
|
|
@@ -21,18 +21,22 @@ function j(n, o, ...r) {
|
|
|
21
21
|
}
|
|
22
22
|
if (typeof n == "function" || typeof n == "object" && n != null && "render" in n) {
|
|
23
23
|
const t = { ...o ?? {} };
|
|
24
|
-
|
|
24
|
+
if (s.length > 0) {
|
|
25
|
+
const e = s.flat().map(l).filter((r) => r != null);
|
|
26
|
+
e.length === 1 ? t.children = e[0] : t.children = e;
|
|
27
|
+
}
|
|
28
|
+
return c(n, t);
|
|
25
29
|
}
|
|
26
30
|
f = {}, i = {}, o && Object.entries(o).forEach(([t, e]) => {
|
|
27
31
|
if (t.startsWith("on") && typeof e == "function") {
|
|
28
|
-
const
|
|
29
|
-
f[
|
|
32
|
+
const r = t.slice(2).toLowerCase();
|
|
33
|
+
f[r] = e;
|
|
30
34
|
} else t === "ref" ? i.ref = e : t === "className" ? i.class = e : t === "style" && typeof e == "object" ? i.style = e : t === "colorInterpolationFilters" ? i["color-interpolation-filters"] = e : t === "filterUnits" ? i.filterUnits = e : t === "clipPath" ? i["clip-path"] = e : t === "floodOpacity" ? i["flood-opacity"] = e : t === "stdDeviation" ? i.stdDeviation = e : t === "viewbox" ? i.viewBox = e : t !== "children" && t !== "key" && (i[t] = e);
|
|
31
35
|
});
|
|
32
|
-
const m =
|
|
36
|
+
const m = s.flat().map(l).filter((t) => t != null);
|
|
33
37
|
return c(n, { ...i, on: f }, m);
|
|
34
38
|
}
|
|
35
39
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
h as Fragment,
|
|
41
|
+
d as jsx
|
|
38
42
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface Context<T> {
|
|
|
40
40
|
defaultValue: T;
|
|
41
41
|
}
|
|
42
42
|
export interface WithChildrenProps {
|
|
43
|
-
children?: VDOMNode[] | VDOMNode |
|
|
43
|
+
children?: VDOMNode[] | VDOMNode | Function;
|
|
44
44
|
}
|
|
45
45
|
export type ComponentType<Props = any, ComponentState = any, Context = any> = new (props: Props, parentComponent: Component<{}, any, null> | null) => Component<Props, ComponentState, Context>;
|
|
46
46
|
export type Consumer<T> = Component<{}, {}, T>;
|