ddd-react 1.3.8 → 1.3.9
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/index.mjs +84 -84
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as c, e as v, a as
|
|
1
|
+
import { D as c, e as v, a as U, A as g, b as q, h as I, c as $ } from "./h-BbaMkkC7.mjs";
|
|
2
2
|
import { d as me, f as Oe } from "./h-BbaMkkC7.mjs";
|
|
3
3
|
function E(t, e) {
|
|
4
4
|
if (t === null || e === null || t === void 0 || e === void 0)
|
|
@@ -39,17 +39,17 @@ function E(t, e) {
|
|
|
39
39
|
}
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function w(t, e, n, r = null) {
|
|
43
43
|
function s(o) {
|
|
44
44
|
const i = o;
|
|
45
45
|
r ? e.call(r, i) : e(i);
|
|
46
46
|
}
|
|
47
47
|
return n.addEventListener(t, s), s;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function G(t = {}, e, n = null) {
|
|
50
50
|
const r = {};
|
|
51
51
|
return Object.entries(t).forEach(([s, o]) => {
|
|
52
|
-
r[s] =
|
|
52
|
+
r[s] = w(
|
|
53
53
|
s,
|
|
54
54
|
o,
|
|
55
55
|
e,
|
|
@@ -57,7 +57,7 @@ function $(t = {}, e, n = null) {
|
|
|
57
57
|
);
|
|
58
58
|
}), r;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function W(t = {}, e) {
|
|
61
61
|
Object.entries(t).forEach(([n, r]) => {
|
|
62
62
|
e.removeEventListener(n, r);
|
|
63
63
|
});
|
|
@@ -66,15 +66,15 @@ function p(t) {
|
|
|
66
66
|
const { type: e } = t;
|
|
67
67
|
switch (e) {
|
|
68
68
|
case c.TEXT: {
|
|
69
|
-
|
|
69
|
+
B(t);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
case c.ELEMENT: {
|
|
73
|
-
|
|
73
|
+
X(t);
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
case c.FRAGMENT: {
|
|
77
|
-
|
|
77
|
+
_(t);
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
case c.COMPONENT: {
|
|
@@ -82,7 +82,7 @@ function p(t) {
|
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
case c.PORTAL: {
|
|
85
|
-
|
|
85
|
+
J(t);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
default:
|
|
@@ -90,58 +90,58 @@ function p(t) {
|
|
|
90
90
|
}
|
|
91
91
|
delete t.el;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function B(t) {
|
|
94
94
|
const { el: e } = t;
|
|
95
95
|
e && e.remove();
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function X(t) {
|
|
98
98
|
const { el: e, children: n, listeners: r, props: s } = t;
|
|
99
|
-
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), e && e.remove(), n && n.forEach(p), r && e && (
|
|
99
|
+
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), e && e.remove(), n && n.forEach(p), r && e && (W(r, e), delete t.listeners);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function _(t) {
|
|
102
102
|
const { children: e } = t;
|
|
103
103
|
e && e.forEach(p);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function J(t) {
|
|
106
106
|
const { children: e } = t;
|
|
107
107
|
e && e.forEach(p);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function L(t, e, n) {
|
|
110
110
|
t.style[e] = n.toString();
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function K(t, e) {
|
|
113
113
|
t.style[e] = null;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Y(t, e) {
|
|
116
116
|
const { class: n, style: r, ...s } = e;
|
|
117
|
-
n &&
|
|
118
|
-
|
|
117
|
+
n && H(t, n), r && Object.entries(r).forEach(([o, i]) => {
|
|
118
|
+
L(t, o, i);
|
|
119
119
|
});
|
|
120
120
|
for (const [o, i] of Object.entries(s))
|
|
121
|
-
|
|
121
|
+
j(t, o, i);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function H(t, e) {
|
|
124
124
|
if (t instanceof SVGElement) {
|
|
125
125
|
t.removeAttribute("class"), typeof e == "string" ? t.setAttribute("class", e) : Array.isArray(e) && t.classList.add(...e);
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
t.className = "", typeof e == "string" ? t.className = e : Array.isArray(e) && t.classList.add(...e);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
n == null ?
|
|
130
|
+
function j(t, e, n) {
|
|
131
|
+
n == null ? x(t, e) : t.setAttribute(e, String(n));
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function x(t, e) {
|
|
134
134
|
t[e] = null, t.removeAttribute(e);
|
|
135
135
|
}
|
|
136
136
|
let P = !1;
|
|
137
137
|
const m = [];
|
|
138
138
|
function y(t) {
|
|
139
|
-
m.push(t),
|
|
140
|
-
}
|
|
141
|
-
function H() {
|
|
142
|
-
P || (P = !0, queueMicrotask(z));
|
|
139
|
+
m.push(t), z();
|
|
143
140
|
}
|
|
144
141
|
function z() {
|
|
142
|
+
P || (P = !0, queueMicrotask(Q));
|
|
143
|
+
}
|
|
144
|
+
function Q() {
|
|
145
145
|
for (; m.length > 0; ) {
|
|
146
146
|
const t = m.shift();
|
|
147
147
|
let e;
|
|
@@ -168,56 +168,56 @@ function A(t) {
|
|
|
168
168
|
function h(t, e, n = null, r = null) {
|
|
169
169
|
switch (t.type) {
|
|
170
170
|
case c.TEXT: {
|
|
171
|
-
|
|
171
|
+
Z(t, e, n);
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
case c.ELEMENT: {
|
|
175
|
-
|
|
175
|
+
ee(t, e, n, r);
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
case c.FRAGMENT: {
|
|
179
|
-
|
|
179
|
+
V(t, e, n, r);
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
case c.COMPONENT: {
|
|
183
|
-
|
|
183
|
+
ne(t, e, n, r);
|
|
184
184
|
const s = t.component;
|
|
185
185
|
s && y(() => s.onMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
188
|
case c.PORTAL: {
|
|
189
|
-
|
|
189
|
+
re(t, r);
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
default:
|
|
193
193
|
throw new Error(`Can't mount DOM of type: ${t.type}`);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Z(t, e, n) {
|
|
197
197
|
const { value: r } = t, s = document.createTextNode(r);
|
|
198
|
-
t.el = s,
|
|
198
|
+
t.el = s, D(s, e, n);
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function V(t, e, n, r) {
|
|
201
201
|
const { children: s } = t;
|
|
202
202
|
t.el = e, s?.forEach((o, i) => {
|
|
203
203
|
h(o, e, n != null ? n + i : null, r);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function ee(t, e, n, r) {
|
|
207
207
|
const { tag: s, children: o } = t, u = s === "svg" || e instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
-
|
|
208
|
+
te(u, t, r), t.el = u, o?.forEach((f) => {
|
|
209
209
|
h(f, u, null, r);
|
|
210
|
-
}),
|
|
210
|
+
}), D(u, e, n);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function te(t, e, n) {
|
|
213
213
|
const { props: r, events: s } = A(e);
|
|
214
|
-
r.ref && typeof r.ref == "object" && "current" in r.ref && (r.ref.current = t, delete r.ref), e.listeners =
|
|
214
|
+
r.ref && typeof r.ref == "object" && "current" in r.ref && (r.ref.current = t, delete r.ref), e.listeners = G(s, t, n), Y(t, r);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function ne(t, e, n, r) {
|
|
217
217
|
const s = t.tag, { props: o } = A(t), i = new s(o, r);
|
|
218
218
|
i.mount(e, n), t.component = i, t.el = i.firstElement || null;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function D(t, e, n) {
|
|
221
221
|
if (n == null) {
|
|
222
222
|
e.append(t);
|
|
223
223
|
return;
|
|
@@ -227,13 +227,13 @@ function x(t, e, n) {
|
|
|
227
227
|
const r = e.childNodes;
|
|
228
228
|
n >= r.length ? e.append(t) : e.insertBefore(t, r[n]);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function re(t, e) {
|
|
231
231
|
const { children: n, container: r } = t;
|
|
232
232
|
n?.forEach((s) => {
|
|
233
233
|
h(s, r, null, e);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function R(t, e) {
|
|
237
237
|
if (t.type !== e.type)
|
|
238
238
|
return !1;
|
|
239
239
|
if (t.type === c.ELEMENT) {
|
|
@@ -266,45 +266,45 @@ function T(t, e) {
|
|
|
266
266
|
updated: o
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function se(t) {
|
|
270
270
|
return t !== "";
|
|
271
271
|
}
|
|
272
272
|
function N(t) {
|
|
273
|
-
return
|
|
273
|
+
return se(t.trim());
|
|
274
274
|
}
|
|
275
275
|
function O(t, e, n, r = null) {
|
|
276
|
-
if (!
|
|
277
|
-
const s =
|
|
276
|
+
if (!R(t, e)) {
|
|
277
|
+
const s = oe(n, t.el);
|
|
278
278
|
return p(t), h(e, n, s, r), e;
|
|
279
279
|
}
|
|
280
280
|
switch (e.el = t.el, e.type) {
|
|
281
281
|
case c.TEXT:
|
|
282
|
-
return
|
|
282
|
+
return ie(t, e), e;
|
|
283
283
|
case c.ELEMENT: {
|
|
284
|
-
|
|
284
|
+
ce(t, e, r);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case c.COMPONENT: {
|
|
288
|
-
|
|
288
|
+
he(t, e);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case c.PORTAL: {
|
|
292
|
-
|
|
292
|
+
pe(t, e, r);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
return
|
|
296
|
+
return F(t, e, r), e;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function oe(t, e) {
|
|
299
299
|
if (!e) return null;
|
|
300
300
|
const n = Array.from(t.childNodes).indexOf(e);
|
|
301
301
|
return n < 0 ? null : n;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function ie(t, e) {
|
|
304
304
|
const n = t.el, { value: r } = t, { value: s } = e;
|
|
305
305
|
r !== s && n && (n.nodeValue = s);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function ce(t, e, n) {
|
|
308
308
|
const r = t.el, {
|
|
309
309
|
class: s,
|
|
310
310
|
style: o,
|
|
@@ -316,11 +316,11 @@ function ie(t, e, n) {
|
|
|
316
316
|
on: a,
|
|
317
317
|
...d
|
|
318
318
|
} = e.props ?? {}, { listeners: b } = t;
|
|
319
|
-
|
|
319
|
+
le(r, u, d), ue(r, s, f), fe(
|
|
320
320
|
r,
|
|
321
321
|
o,
|
|
322
322
|
l
|
|
323
|
-
), e.listeners =
|
|
323
|
+
), e.listeners = ae(
|
|
324
324
|
r,
|
|
325
325
|
b,
|
|
326
326
|
i ?? {},
|
|
@@ -328,32 +328,32 @@ function ie(t, e, n) {
|
|
|
328
328
|
n
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function le(t, e = {}, n = {}) {
|
|
332
332
|
const r = e.ref, s = n.ref;
|
|
333
333
|
r !== s && (r && typeof r == "object" && "current" in r && (r.current = null), s && typeof s == "object" && "current" in s && (s.current = t));
|
|
334
334
|
const o = { ...e }, i = { ...n };
|
|
335
335
|
delete o.ref, delete i.ref;
|
|
336
336
|
const { added: u, removed: f, updated: l } = T(o, i);
|
|
337
337
|
for (const a of f)
|
|
338
|
-
|
|
338
|
+
x(t, a);
|
|
339
339
|
for (const a of u.concat(l))
|
|
340
|
-
|
|
340
|
+
j(t, a, i[a]);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
const r = M(e), s = M(n), { added: o, removed: i } =
|
|
342
|
+
function ue(t, e, n) {
|
|
343
|
+
const r = M(e), s = M(n), { added: o, removed: i } = q(r, s);
|
|
344
344
|
i.length > 0 && t.classList.remove(...i), o.length > 0 && t.classList.add(...o);
|
|
345
345
|
}
|
|
346
346
|
function M(t = "") {
|
|
347
347
|
return Array.isArray(t) ? t.filter(N) : String(t).split(/(\s+)/).filter(N);
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function fe(t, e = {}, n = {}) {
|
|
350
350
|
const { added: r, removed: s, updated: o } = T(e, n);
|
|
351
351
|
for (const i of s)
|
|
352
|
-
|
|
352
|
+
K(t, i);
|
|
353
353
|
for (const i of r.concat(o))
|
|
354
|
-
|
|
354
|
+
L(t, i, n[i]);
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function ae(t, e = {}, n = {}, r = {}, s = null) {
|
|
357
357
|
const { removed: o, added: i, updated: u } = T(n, r);
|
|
358
358
|
for (const l of o.concat(u)) {
|
|
359
359
|
const a = e?.[l];
|
|
@@ -361,7 +361,7 @@ function fe(t, e = {}, n = {}, r = {}, s = null) {
|
|
|
361
361
|
}
|
|
362
362
|
const f = {};
|
|
363
363
|
for (const l of i.concat(u))
|
|
364
|
-
f[l] =
|
|
364
|
+
f[l] = w(
|
|
365
365
|
l,
|
|
366
366
|
r[l],
|
|
367
367
|
t,
|
|
@@ -369,8 +369,8 @@ function fe(t, e = {}, n = {}, r = {}, s = null) {
|
|
|
369
369
|
);
|
|
370
370
|
return f;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
const r = v(t), s = v(e), o = t.el, i =
|
|
372
|
+
function F(t, e, n) {
|
|
373
|
+
const r = v(t), s = v(e), o = t.el, i = U(r, s, R), u = n?.offset ?? 0;
|
|
374
374
|
for (const f of i)
|
|
375
375
|
if (f.op === g.NOOP) {
|
|
376
376
|
const { originalIndex: l, index: a } = f;
|
|
@@ -395,19 +395,19 @@ function R(t, e, n) {
|
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function he(t, e) {
|
|
399
399
|
const { component: n } = t, { props: r } = A(e);
|
|
400
400
|
n.updateProps(r), e.component = n, e.el = n.firstElement;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function pe(t, e, n) {
|
|
403
403
|
if (t.container !== e.container) {
|
|
404
404
|
p(t), h(e, document.body, null, n);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
|
|
407
|
+
F(t, e, n);
|
|
408
408
|
}
|
|
409
|
-
const k = (t) => (console.log("isProvider"), console.log("component.constructor.name", t.constructor.name), t.constructor.name.includes("Provider")),
|
|
410
|
-
class
|
|
409
|
+
const k = (t) => (console.log("isProvider"), console.log("component.constructor.name", t.constructor.name), t.constructor.name.includes("Provider")), C = (t) => (console.log("isConsumer"), console.log("component.constructor.name", t.constructor.name), t.constructor.name.includes("Consumer"));
|
|
410
|
+
class S {
|
|
411
411
|
constructor(e = {}, n) {
|
|
412
412
|
this.isMounted = !1, this.vdom = null, this.hostEl = null, this.parent = null, this.state = {}, this.context = null, this.dependencies = [], this.subscribedProvider = null, this.props = e, this.parent = n;
|
|
413
413
|
}
|
|
@@ -456,7 +456,7 @@ class C {
|
|
|
456
456
|
console.log("return");
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
459
|
-
console.log("isProvider(this as Component)", k(this)), k(this) && this.notify(), this.patch();
|
|
459
|
+
console.log("this.parent", this.parent), console.log("isProvider(this.parent as Component)", k(this.parent)), k(this.parent) && this.notify(), this.patch();
|
|
460
460
|
}
|
|
461
461
|
setState(e) {
|
|
462
462
|
typeof e == "function" ? this.state = {
|
|
@@ -467,7 +467,7 @@ class C {
|
|
|
467
467
|
mount(e, n = null) {
|
|
468
468
|
if (this.isMounted)
|
|
469
469
|
throw new Error("Component is already mounted");
|
|
470
|
-
|
|
470
|
+
console.log("this.parent", this.parent), console.log("isConsumer(this as Component)", C(this)), C(this) && !this.subscribedProvider && (console.log(" this.subscribeToProvider()"), this.subscribeToProvider()), this.updateContext(), this.vdom = this.render(), h(this.vdom, e, n, this), this.hostEl = e, this.isMounted = !0;
|
|
471
471
|
}
|
|
472
472
|
unmount() {
|
|
473
473
|
this.isMounted && (y(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: e }) => {
|
|
@@ -510,13 +510,13 @@ class C {
|
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
512
|
function ge(t) {
|
|
513
|
-
class e extends
|
|
513
|
+
class e extends S {
|
|
514
514
|
render() {
|
|
515
515
|
let o = [];
|
|
516
|
-
return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [],
|
|
516
|
+
return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], I(o);
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
const r = class r extends
|
|
519
|
+
const r = class r extends S {
|
|
520
520
|
render() {
|
|
521
521
|
let o = this.props.children;
|
|
522
522
|
if (Array.isArray(o))
|
|
@@ -554,15 +554,15 @@ function Ee(t = null) {
|
|
|
554
554
|
}
|
|
555
555
|
function be(t, e) {
|
|
556
556
|
const n = Array.isArray(t) ? t : [t];
|
|
557
|
-
return
|
|
557
|
+
return $(n, e);
|
|
558
558
|
}
|
|
559
559
|
export {
|
|
560
|
-
|
|
560
|
+
S as Component,
|
|
561
561
|
ge as createContext,
|
|
562
562
|
be as createPortal,
|
|
563
563
|
Ee as createRef,
|
|
564
564
|
me as h,
|
|
565
|
-
|
|
565
|
+
I as hFragment,
|
|
566
566
|
Oe as hString,
|
|
567
567
|
ye as render
|
|
568
568
|
};
|