ddd-react 1.11.0 → 1.12.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 +1 -1
- package/dist/{h-edTp7-8E.mjs → h-DE267foy.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +73 -74
- package/dist/jsx-runtime.mjs +1 -1
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
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 | string | null | undefined;
|
|
34
34
|
get elements(): HTMLElement[];
|
|
35
35
|
get firstElement(): HTMLElement | undefined;
|
|
36
36
|
get offset(): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { h, hFragment, hString } from './h';
|
|
|
4
4
|
import { render } from './render';
|
|
5
5
|
import { createRef } from './ref';
|
|
6
6
|
import type { Ref } from './ref';
|
|
7
|
-
import type { ComponentType } from './types
|
|
7
|
+
import type { ComponentType } from './types';
|
|
8
8
|
import { createPortal } from './portal';
|
|
9
9
|
export type { ComponentType, Ref };
|
|
10
10
|
export { Component, createContext, createRef, h, hFragment, hString, render, createPortal };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { D as u, e as
|
|
2
|
-
import { f as Ot } from "./h-edTp7-8E.mjs";
|
|
1
|
+
import { D as u, e as m, a as x, A as v, b as U, h as N, c as B, d as I, f as _ } from "./h-DE267foy.mjs";
|
|
3
2
|
function b(e, t) {
|
|
4
3
|
if (e === null || t === null || e === void 0 || t === void 0)
|
|
5
4
|
return e === t;
|
|
@@ -46,7 +45,7 @@ function M(e, t, r, n = null) {
|
|
|
46
45
|
}
|
|
47
46
|
return r.addEventListener(e, s), s;
|
|
48
47
|
}
|
|
49
|
-
function
|
|
48
|
+
function $(e = {}, t, r = null) {
|
|
50
49
|
const n = {};
|
|
51
50
|
return Object.entries(e).forEach(([s, i]) => {
|
|
52
51
|
n[s] = M(
|
|
@@ -57,7 +56,7 @@ function _(e = {}, t, r = null) {
|
|
|
57
56
|
);
|
|
58
57
|
}), n;
|
|
59
58
|
}
|
|
60
|
-
function
|
|
59
|
+
function q(e = {}, t) {
|
|
61
60
|
Object.entries(e).forEach(([r, n]) => {
|
|
62
61
|
t.removeEventListener(r, n);
|
|
63
62
|
});
|
|
@@ -66,15 +65,15 @@ function p(e) {
|
|
|
66
65
|
const { type: t } = e;
|
|
67
66
|
switch (t) {
|
|
68
67
|
case u.TEXT: {
|
|
69
|
-
|
|
68
|
+
G(e);
|
|
70
69
|
break;
|
|
71
70
|
}
|
|
72
71
|
case u.ELEMENT: {
|
|
73
|
-
|
|
72
|
+
z(e);
|
|
74
73
|
break;
|
|
75
74
|
}
|
|
76
75
|
case u.FRAGMENT: {
|
|
77
|
-
|
|
76
|
+
X(e);
|
|
78
77
|
break;
|
|
79
78
|
}
|
|
80
79
|
case u.COMPONENT: {
|
|
@@ -82,7 +81,7 @@ function p(e) {
|
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
84
83
|
case u.PORTAL: {
|
|
85
|
-
|
|
84
|
+
J(e);
|
|
86
85
|
break;
|
|
87
86
|
}
|
|
88
87
|
default:
|
|
@@ -90,37 +89,37 @@ function p(e) {
|
|
|
90
89
|
}
|
|
91
90
|
delete e.el;
|
|
92
91
|
}
|
|
93
|
-
function
|
|
92
|
+
function G(e) {
|
|
94
93
|
const { el: t } = e;
|
|
95
94
|
t && t.remove();
|
|
96
95
|
}
|
|
97
|
-
function
|
|
96
|
+
function z(e) {
|
|
98
97
|
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 && (
|
|
98
|
+
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), r && r.forEach(p), n && t && (q(n, t), delete e.listeners);
|
|
100
99
|
}
|
|
101
|
-
function
|
|
100
|
+
function X(e) {
|
|
102
101
|
const { children: t } = e;
|
|
103
102
|
t && t.forEach(p);
|
|
104
103
|
}
|
|
105
|
-
function
|
|
104
|
+
function J(e) {
|
|
106
105
|
const { children: t } = e;
|
|
107
106
|
t && t.forEach(p);
|
|
108
107
|
}
|
|
109
108
|
function w(e, t, r) {
|
|
110
109
|
e.style[t] = r.toString();
|
|
111
110
|
}
|
|
112
|
-
function
|
|
111
|
+
function K(e, t) {
|
|
113
112
|
e.style[t] = null;
|
|
114
113
|
}
|
|
115
|
-
function
|
|
114
|
+
function W(e, t) {
|
|
116
115
|
const { class: r, style: n, ...s } = t;
|
|
117
|
-
r &&
|
|
116
|
+
r && Y(e, r), n && Object.entries(n).forEach(([i, o]) => {
|
|
118
117
|
w(e, i, o);
|
|
119
118
|
});
|
|
120
119
|
for (const [i, o] of Object.entries(s))
|
|
121
120
|
D(e, i, o);
|
|
122
121
|
}
|
|
123
|
-
function
|
|
122
|
+
function Y(e, t) {
|
|
124
123
|
if (e instanceof SVGElement) {
|
|
125
124
|
e.removeAttribute("class"), typeof t == "string" ? e.setAttribute("class", t) : Array.isArray(t) && e.classList.add(...t);
|
|
126
125
|
return;
|
|
@@ -136,12 +135,12 @@ function j(e, t) {
|
|
|
136
135
|
let P = !1;
|
|
137
136
|
const O = [];
|
|
138
137
|
function d(e) {
|
|
139
|
-
O.push(e),
|
|
140
|
-
}
|
|
141
|
-
function Y() {
|
|
142
|
-
P || (P = !0, queueMicrotask(H));
|
|
138
|
+
O.push(e), H();
|
|
143
139
|
}
|
|
144
140
|
function H() {
|
|
141
|
+
P || (P = !0, queueMicrotask(Q));
|
|
142
|
+
}
|
|
143
|
+
function Q() {
|
|
145
144
|
for (; O.length > 0; ) {
|
|
146
145
|
const e = O.shift();
|
|
147
146
|
let t;
|
|
@@ -168,11 +167,11 @@ function A(e) {
|
|
|
168
167
|
function h(e, t, r = null, n = null) {
|
|
169
168
|
switch (e.type) {
|
|
170
169
|
case u.TEXT: {
|
|
171
|
-
|
|
170
|
+
Z(e, t, r);
|
|
172
171
|
break;
|
|
173
172
|
}
|
|
174
173
|
case u.ELEMENT: {
|
|
175
|
-
|
|
174
|
+
tt(
|
|
176
175
|
e,
|
|
177
176
|
t,
|
|
178
177
|
r,
|
|
@@ -181,7 +180,7 @@ function h(e, t, r = null, n = null) {
|
|
|
181
180
|
break;
|
|
182
181
|
}
|
|
183
182
|
case u.FRAGMENT: {
|
|
184
|
-
|
|
183
|
+
V(
|
|
185
184
|
e,
|
|
186
185
|
t,
|
|
187
186
|
r,
|
|
@@ -190,7 +189,7 @@ function h(e, t, r = null, n = null) {
|
|
|
190
189
|
break;
|
|
191
190
|
}
|
|
192
191
|
case u.COMPONENT: {
|
|
193
|
-
|
|
192
|
+
rt(
|
|
194
193
|
e,
|
|
195
194
|
t,
|
|
196
195
|
r,
|
|
@@ -201,34 +200,34 @@ function h(e, t, r = null, n = null) {
|
|
|
201
200
|
break;
|
|
202
201
|
}
|
|
203
202
|
case u.PORTAL: {
|
|
204
|
-
|
|
203
|
+
nt(e, n);
|
|
205
204
|
break;
|
|
206
205
|
}
|
|
207
206
|
default:
|
|
208
207
|
throw new Error(`Can't mount DOM of type: ${e.type}`);
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
|
-
function
|
|
210
|
+
function Z(e, t, r) {
|
|
212
211
|
const { value: n } = e, s = document.createTextNode(n);
|
|
213
212
|
e.el = s, L(s, t, r);
|
|
214
213
|
}
|
|
215
|
-
function
|
|
214
|
+
function V(e, t, r, n) {
|
|
216
215
|
const { children: s } = e;
|
|
217
216
|
e.el = t, s?.forEach((i, o) => {
|
|
218
217
|
h(i, t, r != null ? r + o : null, n);
|
|
219
218
|
});
|
|
220
219
|
}
|
|
221
|
-
function
|
|
220
|
+
function tt(e, t, r, n) {
|
|
222
221
|
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
|
-
|
|
222
|
+
et(l, e, n), e.el = l, i?.forEach((f) => {
|
|
224
223
|
h(f, l, null, n);
|
|
225
224
|
}), L(l, t, r);
|
|
226
225
|
}
|
|
227
|
-
function
|
|
226
|
+
function et(e, t, r) {
|
|
228
227
|
const { props: n, events: s } = A(t);
|
|
229
|
-
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners =
|
|
228
|
+
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = $(s, e, r), W(e, n);
|
|
230
229
|
}
|
|
231
|
-
function
|
|
230
|
+
function rt(e, t, r, n) {
|
|
232
231
|
const s = e.tag, { props: i } = A(e), o = new s(i, n);
|
|
233
232
|
o.mount(t, r), e.component = o, e.el = o.firstElement || null;
|
|
234
233
|
}
|
|
@@ -242,7 +241,7 @@ function L(e, t, r) {
|
|
|
242
241
|
const n = t.childNodes;
|
|
243
242
|
r >= n.length ? t.append(e) : t.insertBefore(e, n[r]);
|
|
244
243
|
}
|
|
245
|
-
function
|
|
244
|
+
function nt(e, t) {
|
|
246
245
|
const { children: r, container: n } = e;
|
|
247
246
|
r?.forEach((s) => {
|
|
248
247
|
h(s, n, null, t);
|
|
@@ -281,22 +280,22 @@ function S(e, t) {
|
|
|
281
280
|
updated: i
|
|
282
281
|
};
|
|
283
282
|
}
|
|
284
|
-
function
|
|
283
|
+
function st(e) {
|
|
285
284
|
return e !== "";
|
|
286
285
|
}
|
|
287
286
|
function T(e) {
|
|
288
|
-
return
|
|
287
|
+
return st(e.trim());
|
|
289
288
|
}
|
|
290
289
|
function y(e, t, r, n = null) {
|
|
291
290
|
if (!R(e, t)) {
|
|
292
|
-
const s =
|
|
291
|
+
const s = ot(r, e.el);
|
|
293
292
|
return p(e), h(t, r, s, n), t;
|
|
294
293
|
}
|
|
295
294
|
switch (t.el = e.el, t.type) {
|
|
296
295
|
case u.TEXT:
|
|
297
|
-
return
|
|
296
|
+
return it(e, t), t;
|
|
298
297
|
case u.ELEMENT: {
|
|
299
|
-
|
|
298
|
+
ct(
|
|
300
299
|
e,
|
|
301
300
|
t,
|
|
302
301
|
n
|
|
@@ -304,14 +303,14 @@ function y(e, t, r, n = null) {
|
|
|
304
303
|
break;
|
|
305
304
|
}
|
|
306
305
|
case u.COMPONENT: {
|
|
307
|
-
|
|
306
|
+
ht(
|
|
308
307
|
e,
|
|
309
308
|
t
|
|
310
309
|
);
|
|
311
310
|
break;
|
|
312
311
|
}
|
|
313
312
|
case u.PORTAL: {
|
|
314
|
-
|
|
313
|
+
dt(
|
|
315
314
|
e,
|
|
316
315
|
t,
|
|
317
316
|
n
|
|
@@ -319,18 +318,18 @@ function y(e, t, r, n = null) {
|
|
|
319
318
|
break;
|
|
320
319
|
}
|
|
321
320
|
}
|
|
322
|
-
return
|
|
321
|
+
return F(e, t, n), t;
|
|
323
322
|
}
|
|
324
|
-
function
|
|
323
|
+
function ot(e, t) {
|
|
325
324
|
if (!t) return null;
|
|
326
325
|
const r = Array.from(e.childNodes).indexOf(t);
|
|
327
326
|
return r < 0 ? null : r;
|
|
328
327
|
}
|
|
329
|
-
function
|
|
328
|
+
function it(e, t) {
|
|
330
329
|
const r = e.el, { value: n } = e, { value: s } = t;
|
|
331
330
|
n !== s && r && (r.nodeValue = s);
|
|
332
331
|
}
|
|
333
|
-
function
|
|
332
|
+
function ct(e, t, r) {
|
|
334
333
|
const n = e.el, {
|
|
335
334
|
class: s,
|
|
336
335
|
style: i,
|
|
@@ -341,20 +340,20 @@ function it(e, t, r) {
|
|
|
341
340
|
style: c,
|
|
342
341
|
on: a,
|
|
343
342
|
...E
|
|
344
|
-
} = t.props ?? {}, { listeners:
|
|
345
|
-
|
|
343
|
+
} = t.props ?? {}, { listeners: g } = e;
|
|
344
|
+
ut(n, l, E), lt(n, s, f), ft(
|
|
346
345
|
n,
|
|
347
346
|
i,
|
|
348
347
|
c
|
|
349
|
-
), t.listeners =
|
|
348
|
+
), t.listeners = at(
|
|
350
349
|
n,
|
|
351
|
-
|
|
350
|
+
g,
|
|
352
351
|
o ?? {},
|
|
353
352
|
a ?? {},
|
|
354
353
|
r
|
|
355
354
|
);
|
|
356
355
|
}
|
|
357
|
-
function
|
|
356
|
+
function ut(e, t = {}, r = {}) {
|
|
358
357
|
const n = t.ref, s = r.ref;
|
|
359
358
|
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
360
359
|
const i = { ...t }, o = { ...r };
|
|
@@ -368,21 +367,21 @@ function ct(e, t = {}, r = {}) {
|
|
|
368
367
|
for (const a of l.concat(c))
|
|
369
368
|
D(e, a, o[a]);
|
|
370
369
|
}
|
|
371
|
-
function
|
|
370
|
+
function lt(e, t, r) {
|
|
372
371
|
const n = k(t), s = k(r), { added: i, removed: o } = U(n, s);
|
|
373
372
|
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
374
373
|
}
|
|
375
374
|
function k(e = "") {
|
|
376
375
|
return Array.isArray(e) ? e.filter(T) : String(e).split(/(\s+)/).filter(T);
|
|
377
376
|
}
|
|
378
|
-
function
|
|
377
|
+
function ft(e, t = {}, r = {}) {
|
|
379
378
|
const { added: n, removed: s, updated: i } = S(t, r);
|
|
380
379
|
for (const o of s)
|
|
381
|
-
|
|
380
|
+
K(e, o);
|
|
382
381
|
for (const o of n.concat(i))
|
|
383
382
|
w(e, o, r[o]);
|
|
384
383
|
}
|
|
385
|
-
function
|
|
384
|
+
function at(e, t = {}, r = {}, n = {}, s = null) {
|
|
386
385
|
const { removed: i, added: o, updated: l } = S(r, n), f = { ...t };
|
|
387
386
|
for (const c of i.concat(l)) {
|
|
388
387
|
const a = t?.[c];
|
|
@@ -397,8 +396,8 @@ function ft(e, t = {}, r = {}, n = {}, s = null) {
|
|
|
397
396
|
);
|
|
398
397
|
return f;
|
|
399
398
|
}
|
|
400
|
-
function
|
|
401
|
-
const n =
|
|
399
|
+
function F(e, t, r) {
|
|
400
|
+
const n = m(e), s = m(t), i = e.el, o = x(
|
|
402
401
|
n,
|
|
403
402
|
s,
|
|
404
403
|
R
|
|
@@ -416,8 +415,8 @@ function x(e, t, r) {
|
|
|
416
415
|
for (const f of o)
|
|
417
416
|
switch (f.op) {
|
|
418
417
|
case v.MOVE: {
|
|
419
|
-
const { from: c, index: a } = f, E = n[c].el,
|
|
420
|
-
E && (i.insertBefore(E,
|
|
418
|
+
const { from: c, index: a } = f, E = n[c].el, g = i.childNodes[a + l];
|
|
419
|
+
E && (i.insertBefore(E, g), y(
|
|
421
420
|
n[c],
|
|
422
421
|
s[a],
|
|
423
422
|
i,
|
|
@@ -437,18 +436,18 @@ function x(e, t, r) {
|
|
|
437
436
|
}
|
|
438
437
|
}
|
|
439
438
|
}
|
|
440
|
-
function
|
|
439
|
+
function ht(e, t) {
|
|
441
440
|
const { component: r } = e, { props: n } = A(t);
|
|
442
441
|
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
443
442
|
}
|
|
444
|
-
function
|
|
443
|
+
function dt(e, t, r) {
|
|
445
444
|
if (e.container !== t.container) {
|
|
446
445
|
p(e), h(t, document.body, null, r);
|
|
447
446
|
return;
|
|
448
447
|
}
|
|
449
|
-
|
|
448
|
+
F(e, t, r);
|
|
450
449
|
}
|
|
451
|
-
const
|
|
450
|
+
const pt = (e) => e.isProvider, yt = (e) => e.isConsumer;
|
|
452
451
|
class C {
|
|
453
452
|
isMounted = !1;
|
|
454
453
|
vdom = null;
|
|
@@ -504,7 +503,7 @@ class C {
|
|
|
504
503
|
return b(t, r);
|
|
505
504
|
}
|
|
506
505
|
get elements() {
|
|
507
|
-
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ?
|
|
506
|
+
return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ? m(this.vdom).flatMap((t) => t.type === u.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
|
|
508
507
|
}
|
|
509
508
|
get firstElement() {
|
|
510
509
|
return this.elements[0];
|
|
@@ -514,7 +513,7 @@ class C {
|
|
|
514
513
|
}
|
|
515
514
|
updateProps(t) {
|
|
516
515
|
const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
|
|
517
|
-
this.props = n, !this.shouldComponentUpdate(s, n) && (
|
|
516
|
+
this.props = n, !this.shouldComponentUpdate(s, n) && (pt(this) && this.notify(), this.patch(s, this.state));
|
|
518
517
|
}
|
|
519
518
|
setState(t) {
|
|
520
519
|
const r = this.state;
|
|
@@ -529,7 +528,7 @@ class C {
|
|
|
529
528
|
mount(t, r = null) {
|
|
530
529
|
if (this.isMounted)
|
|
531
530
|
throw new Error("Component is already mounted");
|
|
532
|
-
|
|
531
|
+
yt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
|
|
533
532
|
try {
|
|
534
533
|
const n = this.render(), s = this.normalizeRenderResult(n);
|
|
535
534
|
this.hostEl = t, this.isMounted = !0, s !== null ? (h(s, t, r, this), this.vdom = s) : this.vdom = null;
|
|
@@ -649,10 +648,10 @@ class C {
|
|
|
649
648
|
return this.constructor.getDerivedStateFromError !== void 0;
|
|
650
649
|
}
|
|
651
650
|
normalizeRenderResult(t) {
|
|
652
|
-
return t == null ? null : Array.isArray(t) ? t.length > 0 ? N(t) : null : typeof t == "function" ? B(t, {}) : t;
|
|
651
|
+
return t == null ? null : Array.isArray(t) ? t.length > 0 ? N(t) : null : typeof t == "function" ? B(t, {}) : typeof t == "string" ? I(t) : t;
|
|
653
652
|
}
|
|
654
653
|
}
|
|
655
|
-
function
|
|
654
|
+
function vt(e) {
|
|
656
655
|
class t extends C {
|
|
657
656
|
isProvider = !0;
|
|
658
657
|
render() {
|
|
@@ -686,7 +685,7 @@ function Et(e) {
|
|
|
686
685
|
defaultValue: e
|
|
687
686
|
};
|
|
688
687
|
}
|
|
689
|
-
function
|
|
688
|
+
function gt(e, t) {
|
|
690
689
|
if (!t)
|
|
691
690
|
throw new Error("Container element is not provided for rendering.");
|
|
692
691
|
h(e, t);
|
|
@@ -696,17 +695,17 @@ function mt(e = null) {
|
|
|
696
695
|
current: e
|
|
697
696
|
};
|
|
698
697
|
}
|
|
699
|
-
function
|
|
698
|
+
function bt(e, t) {
|
|
700
699
|
const r = Array.isArray(e) ? e : [e];
|
|
701
|
-
return
|
|
700
|
+
return _(r, t);
|
|
702
701
|
}
|
|
703
702
|
export {
|
|
704
703
|
C as Component,
|
|
705
|
-
|
|
706
|
-
|
|
704
|
+
vt as createContext,
|
|
705
|
+
bt as createPortal,
|
|
707
706
|
mt as createRef,
|
|
708
707
|
B as h,
|
|
709
708
|
N as hFragment,
|
|
710
|
-
|
|
711
|
-
|
|
709
|
+
I as hString,
|
|
710
|
+
gt as render
|
|
712
711
|
};
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as p, c,
|
|
1
|
+
import { h as p, c, d as a } from "./h-DE267foy.mjs";
|
|
2
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;
|