@ninetailed/experience.js-react 7.5.3-beta.3 → 7.5.3-beta.5
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/index.cjs
CHANGED
|
@@ -380,9 +380,7 @@ const useExperience = ({
|
|
|
380
380
|
}));
|
|
381
381
|
};
|
|
382
382
|
|
|
383
|
-
const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
384
|
-
hidden: _hidden = false
|
|
385
|
-
}, ref) => {
|
|
383
|
+
const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
386
384
|
const {
|
|
387
385
|
logger
|
|
388
386
|
} = useNinetailed();
|
|
@@ -400,16 +398,16 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
|
400
398
|
}, [logger]);
|
|
401
399
|
React.useEffect(() => {
|
|
402
400
|
if (markerRef.current) {
|
|
403
|
-
const
|
|
401
|
+
const observableElement = getObservableElement(markerRef.current);
|
|
404
402
|
if (ref) {
|
|
405
403
|
if (typeof ref === 'function') {
|
|
406
|
-
ref(
|
|
404
|
+
ref(observableElement);
|
|
407
405
|
} else {
|
|
408
|
-
ref.current =
|
|
406
|
+
ref.current = observableElement;
|
|
409
407
|
}
|
|
410
408
|
}
|
|
411
409
|
}
|
|
412
|
-
}, [
|
|
410
|
+
}, []);
|
|
413
411
|
return jsxRuntime.jsx("div", {
|
|
414
412
|
className: "nt-cmp-marker",
|
|
415
413
|
style: {
|
|
@@ -418,9 +416,22 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
|
418
416
|
ref: markerRef
|
|
419
417
|
});
|
|
420
418
|
});
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
419
|
+
const getObservableSibling = element => {
|
|
420
|
+
const nextSibling = element.nextElementSibling;
|
|
421
|
+
if (!nextSibling) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const nextSiblingStyle = getComputedStyle(nextSibling);
|
|
425
|
+
// Elements with display: none are not observable by the IntersectionObserver
|
|
426
|
+
if (nextSiblingStyle.display !== 'none') {
|
|
427
|
+
return nextSibling;
|
|
428
|
+
}
|
|
429
|
+
return getObservableSibling(nextSibling);
|
|
430
|
+
};
|
|
431
|
+
const getObservableElement = element => {
|
|
432
|
+
const observableSibling = getObservableSibling(element);
|
|
433
|
+
if (observableSibling) {
|
|
434
|
+
return observableSibling;
|
|
424
435
|
}
|
|
425
436
|
const {
|
|
426
437
|
parentElement
|
|
@@ -428,10 +439,7 @@ const getNextSibling = (element, recursive = false) => {
|
|
|
428
439
|
if (!parentElement) {
|
|
429
440
|
return null;
|
|
430
441
|
}
|
|
431
|
-
|
|
432
|
-
return parentElement.nextSibling;
|
|
433
|
-
}
|
|
434
|
-
return getNextSibling(parentElement, true);
|
|
442
|
+
return getObservableElement(parentElement);
|
|
435
443
|
};
|
|
436
444
|
|
|
437
445
|
const DefaultExperienceLoadingComponent = _a => {
|
|
@@ -539,7 +547,7 @@ const Experience = _a => {
|
|
|
539
547
|
return () => {
|
|
540
548
|
// noop
|
|
541
549
|
};
|
|
542
|
-
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience]);
|
|
550
|
+
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience, isVariantHidden]);
|
|
543
551
|
if (!hasVariants) {
|
|
544
552
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
545
553
|
children: [!isComponentForwardRef && jsxRuntime.jsx(ComponentMarker, {
|
|
@@ -561,8 +569,7 @@ const Experience = _a => {
|
|
|
561
569
|
}
|
|
562
570
|
if (isVariantHidden) {
|
|
563
571
|
return jsxRuntime.jsx(ComponentMarker, {
|
|
564
|
-
ref: componentRef
|
|
565
|
-
hidden: true
|
|
572
|
+
ref: componentRef
|
|
566
573
|
}, `marker-hidden-${(experience === null || experience === void 0 ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
567
574
|
}
|
|
568
575
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
package/index.js
CHANGED
|
@@ -372,9 +372,7 @@ const useExperience = ({
|
|
|
372
372
|
}));
|
|
373
373
|
};
|
|
374
374
|
|
|
375
|
-
const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
376
|
-
hidden: _hidden = false
|
|
377
|
-
}, ref) => {
|
|
375
|
+
const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
378
376
|
const {
|
|
379
377
|
logger
|
|
380
378
|
} = useNinetailed();
|
|
@@ -392,16 +390,16 @@ const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
|
392
390
|
}, [logger]);
|
|
393
391
|
useEffect(() => {
|
|
394
392
|
if (markerRef.current) {
|
|
395
|
-
const
|
|
393
|
+
const observableElement = getObservableElement(markerRef.current);
|
|
396
394
|
if (ref) {
|
|
397
395
|
if (typeof ref === 'function') {
|
|
398
|
-
ref(
|
|
396
|
+
ref(observableElement);
|
|
399
397
|
} else {
|
|
400
|
-
ref.current =
|
|
398
|
+
ref.current = observableElement;
|
|
401
399
|
}
|
|
402
400
|
}
|
|
403
401
|
}
|
|
404
|
-
}, [
|
|
402
|
+
}, []);
|
|
405
403
|
return jsx("div", {
|
|
406
404
|
className: "nt-cmp-marker",
|
|
407
405
|
style: {
|
|
@@ -410,9 +408,22 @@ const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
|
410
408
|
ref: markerRef
|
|
411
409
|
});
|
|
412
410
|
});
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
411
|
+
const getObservableSibling = element => {
|
|
412
|
+
const nextSibling = element.nextElementSibling;
|
|
413
|
+
if (!nextSibling) {
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
const nextSiblingStyle = getComputedStyle(nextSibling);
|
|
417
|
+
// Elements with display: none are not observable by the IntersectionObserver
|
|
418
|
+
if (nextSiblingStyle.display !== 'none') {
|
|
419
|
+
return nextSibling;
|
|
420
|
+
}
|
|
421
|
+
return getObservableSibling(nextSibling);
|
|
422
|
+
};
|
|
423
|
+
const getObservableElement = element => {
|
|
424
|
+
const observableSibling = getObservableSibling(element);
|
|
425
|
+
if (observableSibling) {
|
|
426
|
+
return observableSibling;
|
|
416
427
|
}
|
|
417
428
|
const {
|
|
418
429
|
parentElement
|
|
@@ -420,10 +431,7 @@ const getNextSibling = (element, recursive = false) => {
|
|
|
420
431
|
if (!parentElement) {
|
|
421
432
|
return null;
|
|
422
433
|
}
|
|
423
|
-
|
|
424
|
-
return parentElement.nextSibling;
|
|
425
|
-
}
|
|
426
|
-
return getNextSibling(parentElement, true);
|
|
434
|
+
return getObservableElement(parentElement);
|
|
427
435
|
};
|
|
428
436
|
|
|
429
437
|
const DefaultExperienceLoadingComponent = _a => {
|
|
@@ -531,7 +539,7 @@ const Experience = _a => {
|
|
|
531
539
|
return () => {
|
|
532
540
|
// noop
|
|
533
541
|
};
|
|
534
|
-
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience]);
|
|
542
|
+
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience, isVariantHidden]);
|
|
535
543
|
if (!hasVariants) {
|
|
536
544
|
return jsxs(Fragment, {
|
|
537
545
|
children: [!isComponentForwardRef && jsx(ComponentMarker, {
|
|
@@ -553,8 +561,7 @@ const Experience = _a => {
|
|
|
553
561
|
}
|
|
554
562
|
if (isVariantHidden) {
|
|
555
563
|
return jsx(ComponentMarker, {
|
|
556
|
-
ref: componentRef
|
|
557
|
-
hidden: true
|
|
564
|
+
ref: componentRef
|
|
558
565
|
}, `marker-hidden-${(experience === null || experience === void 0 ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
559
566
|
}
|
|
560
567
|
return jsxs(Fragment, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "7.5.3-beta.
|
|
3
|
+
"version": "7.5.3-beta.5",
|
|
4
4
|
"description": "Ninetailed SDK for React",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"react": ">=16.8.0"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"types": "./src/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ninetailed/experience.js": "7.5.3-beta.
|
|
20
|
-
"@ninetailed/experience.js-shared": "7.5.3-beta.
|
|
19
|
+
"@ninetailed/experience.js": "7.5.3-beta.5",
|
|
20
|
+
"@ninetailed/experience.js-shared": "7.5.3-beta.5",
|
|
21
21
|
"radash": "10.9.0",
|
|
22
22
|
"react-intersection-observer": "8.34.0",
|
|
23
23
|
"react-is": "18.2.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ComponentMarker';
|