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