@next-core/brick-kit 2.204.2 → 2.205.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/index.esm.js CHANGED
@@ -13283,6 +13283,7 @@ function SingleBrickAsComponentFactory(React) {
13283
13283
  }
13284
13284
  })();
13285
13285
  }, [runtimeBrick, updateBrick]);
13286
+ var previousObserverRef = React.useRef();
13286
13287
  innerRefCallbackRef.current = /*#__PURE__*/function () {
13287
13288
  var _ref6 = _asyncToGenerator$3(function* (element) {
13288
13289
  immediatelyRefCallback === null || immediatelyRefCallback === void 0 ? void 0 : immediatelyRefCallback(element);
@@ -13296,15 +13297,46 @@ function SingleBrickAsComponentFactory(React) {
13296
13297
  // sub-brick rendering is ignored.
13297
13298
  if (brick) {
13298
13299
  if (element) {
13299
- var _useBrick$lifeCycle;
13300
+ var _useBrick$lifeCycle, _useBrick$lifeCycle2;
13300
13301
  updateBrick(brick, element);
13301
- if ((_useBrick$lifeCycle = useBrick.lifeCycle) !== null && _useBrick$lifeCycle !== void 0 && _useBrick$lifeCycle.onMount) {
13302
- dispatchLifeCycleEvent(new CustomEvent("mount"), useBrick.lifeCycle.onMount, brick);
13302
+ var onMount = (_useBrick$lifeCycle = useBrick.lifeCycle) === null || _useBrick$lifeCycle === void 0 ? void 0 : _useBrick$lifeCycle.onMount;
13303
+ if (onMount) {
13304
+ dispatchLifeCycleEvent(new CustomEvent("mount"), transformEvents(data, {
13305
+ onMount
13306
+ }).onMount, brick);
13307
+ }
13308
+ var onScrollIntoView = (_useBrick$lifeCycle2 = useBrick.lifeCycle) === null || _useBrick$lifeCycle2 === void 0 ? void 0 : _useBrick$lifeCycle2.onScrollIntoView;
13309
+ if (onScrollIntoView) {
13310
+ var _onScrollIntoView$thr;
13311
+ var threshold = (_onScrollIntoView$thr = onScrollIntoView.threshold) !== null && _onScrollIntoView$thr !== void 0 ? _onScrollIntoView$thr : 0.1;
13312
+ var observer = new IntersectionObserver((entries, observer) => {
13313
+ entries.forEach(entry => {
13314
+ if (entry.isIntersecting) {
13315
+ if (entry.intersectionRatio >= threshold) {
13316
+ dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), transformEvents(data, {
13317
+ onScrollIntoView: onScrollIntoView.handlers
13318
+ }).onScrollIntoView, brick);
13319
+ observer.disconnect();
13320
+ }
13321
+ }
13322
+ });
13323
+ }, {
13324
+ threshold
13325
+ });
13326
+ observer.observe(element);
13327
+ previousObserverRef.current = observer;
13303
13328
  }
13304
13329
  } else {
13305
- var _useBrick$lifeCycle2;
13306
- if ((_useBrick$lifeCycle2 = useBrick.lifeCycle) !== null && _useBrick$lifeCycle2 !== void 0 && _useBrick$lifeCycle2.onUnmount) {
13307
- dispatchLifeCycleEvent(new CustomEvent("unmount"), useBrick.lifeCycle.onUnmount, brick);
13330
+ var _useBrick$lifeCycle3;
13331
+ var onUnmount = (_useBrick$lifeCycle3 = useBrick.lifeCycle) === null || _useBrick$lifeCycle3 === void 0 ? void 0 : _useBrick$lifeCycle3.onUnmount;
13332
+ if (onUnmount) {
13333
+ dispatchLifeCycleEvent(new CustomEvent("unmount"), transformEvents(data, {
13334
+ onUnmount
13335
+ }).onUnmount, brick);
13336
+ }
13337
+ if (previousObserverRef.current) {
13338
+ previousObserverRef.current.disconnect();
13339
+ previousObserverRef.current = undefined;
13308
13340
  }
13309
13341
  }
13310
13342
  }
@@ -13561,6 +13593,7 @@ function ForwardRefSingleBrickAsComponentFactory(React) {
13561
13593
  }
13562
13594
  })();
13563
13595
  }, [runtimeBrick, updateBrick]);
13596
+ var previousObserverRef = React.useRef();
13564
13597
  innerRefCallbackRef.current = /*#__PURE__*/function () {
13565
13598
  var _ref14 = _asyncToGenerator$3(function* (element) {
13566
13599
  elementRef.current = element;
@@ -13573,15 +13606,46 @@ function ForwardRefSingleBrickAsComponentFactory(React) {
13573
13606
  // sub-brick rendering is ignored.
13574
13607
  if (brick) {
13575
13608
  if (element) {
13576
- var _useBrick$lifeCycle3;
13609
+ var _useBrick$lifeCycle4, _useBrick$lifeCycle5;
13577
13610
  updateBrick(brick, element);
13578
- if ((_useBrick$lifeCycle3 = useBrick.lifeCycle) !== null && _useBrick$lifeCycle3 !== void 0 && _useBrick$lifeCycle3.onMount) {
13579
- dispatchLifeCycleEvent(new CustomEvent("mount"), useBrick.lifeCycle.onMount, brick);
13611
+ var onMount = (_useBrick$lifeCycle4 = useBrick.lifeCycle) === null || _useBrick$lifeCycle4 === void 0 ? void 0 : _useBrick$lifeCycle4.onMount;
13612
+ if (onMount) {
13613
+ dispatchLifeCycleEvent(new CustomEvent("mount"), transformEvents(data, {
13614
+ onMount
13615
+ }).onMount, brick);
13616
+ }
13617
+ var onScrollIntoView = (_useBrick$lifeCycle5 = useBrick.lifeCycle) === null || _useBrick$lifeCycle5 === void 0 ? void 0 : _useBrick$lifeCycle5.onScrollIntoView;
13618
+ if (onScrollIntoView) {
13619
+ var _onScrollIntoView$thr2;
13620
+ var threshold = (_onScrollIntoView$thr2 = onScrollIntoView.threshold) !== null && _onScrollIntoView$thr2 !== void 0 ? _onScrollIntoView$thr2 : 0.1;
13621
+ var observer = new IntersectionObserver((entries, observer) => {
13622
+ entries.forEach(entry => {
13623
+ if (entry.isIntersecting) {
13624
+ if (entry.intersectionRatio >= threshold) {
13625
+ dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), transformEvents(data, {
13626
+ onScrollIntoView: onScrollIntoView.handlers
13627
+ }).onScrollIntoView, brick);
13628
+ observer.disconnect();
13629
+ }
13630
+ }
13631
+ });
13632
+ }, {
13633
+ threshold
13634
+ });
13635
+ observer.observe(element);
13636
+ previousObserverRef.current = observer;
13580
13637
  }
13581
13638
  } else {
13582
- var _useBrick$lifeCycle4;
13583
- if ((_useBrick$lifeCycle4 = useBrick.lifeCycle) !== null && _useBrick$lifeCycle4 !== void 0 && _useBrick$lifeCycle4.onUnmount) {
13584
- dispatchLifeCycleEvent(new CustomEvent("unmount"), useBrick.lifeCycle.onUnmount, brick);
13639
+ var _useBrick$lifeCycle6;
13640
+ var onUnmount = (_useBrick$lifeCycle6 = useBrick.lifeCycle) === null || _useBrick$lifeCycle6 === void 0 ? void 0 : _useBrick$lifeCycle6.onUnmount;
13641
+ if (onUnmount) {
13642
+ dispatchLifeCycleEvent(new CustomEvent("unmount"), transformEvents(data, {
13643
+ onUnmount
13644
+ }).onUnmount, brick);
13645
+ }
13646
+ if (previousObserverRef.current) {
13647
+ previousObserverRef.current.disconnect();
13648
+ previousObserverRef.current = undefined;
13585
13649
  }
13586
13650
  }
13587
13651
  }