ddd-react 1.6.0 → 1.6.2

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.
@@ -11,7 +11,7 @@ export declare abstract class Component<P = {}, S = ComponentState, ContextValue
11
11
  consumer: Component;
12
12
  }[];
13
13
  subscribedProvider: Component<{
14
- value: any;
14
+ value: ContextValueType;
15
15
  }> | null;
16
16
  isProvider: boolean;
17
17
  isConsumer: boolean;
package/dist/index.mjs CHANGED
@@ -135,7 +135,7 @@ function w(e, t) {
135
135
  }
136
136
  let P = !1;
137
137
  const O = [];
138
- function E(e) {
138
+ function b(e) {
139
139
  O.push(e), Y();
140
140
  }
141
141
  function Y() {
@@ -182,7 +182,7 @@ function h(e, t, r = null, n = null) {
182
182
  case c.COMPONENT: {
183
183
  tt(e, t, r, n);
184
184
  const s = e.component;
185
- s && E(() => s.onMount());
185
+ s && b(() => s.onMount());
186
186
  break;
187
187
  }
188
188
  case c.PORTAL: {
@@ -205,8 +205,8 @@ function Q(e, t, r, n) {
205
205
  }
206
206
  function Z(e, t, r, n) {
207
207
  const { tag: s, children: i } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
208
- V(f, e, n), e.el = f, i?.forEach((a) => {
209
- h(a, f, null, n);
208
+ V(f, e, n), e.el = f, i?.forEach((l) => {
209
+ h(l, f, null, n);
210
210
  }), j(f, t, r);
211
211
  }
212
212
  function V(e, t, r) {
@@ -285,11 +285,11 @@ function m(e, t, r, n = null) {
285
285
  break;
286
286
  }
287
287
  case c.COMPONENT: {
288
- at(e, t);
288
+ lt(e, t);
289
289
  break;
290
290
  }
291
291
  case c.PORTAL: {
292
- lt(e, t, n);
292
+ at(e, t, n);
293
293
  break;
294
294
  }
295
295
  }
@@ -311,20 +311,20 @@ function it(e, t, r) {
311
311
  on: o,
312
312
  ...f
313
313
  } = e.props ?? {}, {
314
- class: a,
314
+ class: l,
315
315
  style: u,
316
- on: l,
316
+ on: a,
317
317
  ...d
318
- } = t.props ?? {}, { listeners: b } = e;
319
- ot(n, f, d), ct(n, s, a), ut(
318
+ } = t.props ?? {}, { listeners: E } = e;
319
+ ot(n, f, d), ct(n, s, l), ut(
320
320
  n,
321
321
  i,
322
322
  u
323
323
  ), t.listeners = ft(
324
324
  n,
325
- b,
325
+ E,
326
326
  o ?? {},
327
- l ?? {},
327
+ a ?? {},
328
328
  r
329
329
  );
330
330
  }
@@ -333,11 +333,11 @@ function ot(e, t = {}, r = {}) {
333
333
  n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
334
334
  const i = { ...t }, o = { ...r };
335
335
  delete i.ref, delete o.ref;
336
- const { added: f, removed: a, updated: u } = T(i, o);
337
- for (const l of a)
338
- w(e, l);
339
- for (const l of f.concat(u))
340
- L(e, l, o[l]);
336
+ const { added: f, removed: l, updated: u } = T(i, o);
337
+ for (const a of l)
338
+ w(e, a);
339
+ for (const a of f.concat(u))
340
+ L(e, a, o[a]);
341
341
  }
342
342
  function ct(e, t, r) {
343
343
  const n = M(t), s = M(r), { added: i, removed: o } = F(n, s);
@@ -356,50 +356,50 @@ function ut(e, t = {}, r = {}) {
356
356
  function ft(e, t = {}, r = {}, n = {}, s = null) {
357
357
  const { removed: i, added: o, updated: f } = T(r, n);
358
358
  for (const u of i.concat(f)) {
359
- const l = t?.[u];
360
- l && e.removeEventListener(u, l);
359
+ const a = t?.[u];
360
+ a && e.removeEventListener(u, a);
361
361
  }
362
- const a = {};
362
+ const l = {};
363
363
  for (const u of o.concat(f))
364
- a[u] = S(
364
+ l[u] = S(
365
365
  u,
366
366
  n[u],
367
367
  e,
368
368
  s
369
369
  );
370
- return a;
370
+ return l;
371
371
  }
372
372
  function R(e, t, r) {
373
373
  const n = v(e), s = v(t), i = e.el, o = x(n, s, D), f = r?.offset ?? 0;
374
- for (const a of o)
375
- if (a.op === y.NOOP) {
376
- const { originalIndex: u, index: l } = a;
377
- m(n[u], s[l], i, r);
374
+ for (const l of o)
375
+ if (l.op === y.NOOP) {
376
+ const { originalIndex: u, index: a } = l;
377
+ m(n[u], s[a], i, r);
378
378
  }
379
- for (const a of o)
380
- switch (a.op) {
379
+ for (const l of o)
380
+ switch (l.op) {
381
381
  case y.MOVE: {
382
- const { from: u, index: l } = a, d = n[u].el, b = i.childNodes[l + f];
383
- d && (i.insertBefore(d, b), m(n[u], s[l], i, r));
382
+ const { from: u, index: a } = l, d = n[u].el, E = i.childNodes[a + f];
383
+ d && (i.insertBefore(d, E), m(n[u], s[a], i, r));
384
384
  break;
385
385
  }
386
386
  case y.REMOVE: {
387
- const { item: u } = a;
387
+ const { item: u } = l;
388
388
  p(u);
389
389
  break;
390
390
  }
391
391
  case y.ADD: {
392
- const { index: u, item: l } = a;
393
- h(l, i, u + f, r);
392
+ const { index: u, item: a } = l;
393
+ h(a, i, u + f, r);
394
394
  break;
395
395
  }
396
396
  }
397
397
  }
398
- function at(e, t) {
398
+ function lt(e, t) {
399
399
  const { component: r } = e, { props: n } = A(t);
400
400
  r.updateProps(n), t.component = r, t.el = r.firstElement;
401
401
  }
402
- function lt(e, t, r) {
402
+ function at(e, t, r) {
403
403
  if (e.container !== t.container) {
404
404
  p(e), h(t, document.body, null, r);
405
405
  return;
@@ -463,18 +463,24 @@ class k {
463
463
  pt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), h(this.vdom, t, r, this), this.hostEl = t, this.isMounted = !0;
464
464
  }
465
465
  unmount() {
466
- this.isMounted && (E(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
466
+ this.isMounted && (b(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
467
467
  t.subscribedProvider = null;
468
- }), this.dependencies = [], this.vdom && p(this.vdom), E(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
468
+ }), this.dependencies = [], this.vdom && p(this.vdom), b(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
469
469
  }
470
470
  patch(t, r) {
471
471
  if (!this.isMounted || !this.hostEl || !this.vdom)
472
472
  return;
473
473
  const n = this.render();
474
- this.vdom = m(this.vdom, n, this.hostEl, this), E(() => this.onUpdate(t, r));
474
+ this.vdom = m(this.vdom, n, this.hostEl, this), b(() => this.onUpdate(t, r));
475
475
  }
476
476
  updateContext() {
477
- return this.subscribedProvider ? (this.context = this.subscribedProvider.props.value, !0) : !1;
477
+ const t = Object.getPrototypeOf(this).constructor.contextType;
478
+ if (t != null) {
479
+ if (this.subscribedProvider)
480
+ return console.log("this.subscribedProvider", this.subscribedProvider), this.context = this.subscribedProvider.props.value, !0;
481
+ this.context = t.defaultValue;
482
+ }
483
+ return !1;
478
484
  }
479
485
  subscribeToProvider() {
480
486
  const t = Object.getPrototypeOf(this).constructor.contextType;
@@ -529,12 +535,12 @@ function yt(e) {
529
535
  defaultValue: e
530
536
  };
531
537
  }
532
- function Et(e, t) {
538
+ function bt(e, t) {
533
539
  if (!t)
534
540
  throw new Error("Container element is not provided for rendering.");
535
541
  h(e, t);
536
542
  }
537
- function bt(e = null) {
543
+ function Et(e = null) {
538
544
  return {
539
545
  current: e
540
546
  };
@@ -547,9 +553,9 @@ export {
547
553
  k as Component,
548
554
  yt as createContext,
549
555
  vt as createPortal,
550
- bt as createRef,
556
+ Et as createRef,
551
557
  Ot as h,
552
558
  U as hFragment,
553
559
  mt as hString,
554
- Et as render
560
+ bt as render
555
561
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",