@ninetailed/experience.js-react 7.5.2-beta.5 → 7.5.3-beta.1
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 +22 -4
- package/index.js +22 -4
- package/package.json +3 -3
- package/src/lib/Experience/ComponentMarker.d.ts +5 -1
package/index.cjs
CHANGED
|
@@ -380,7 +380,9 @@ const useExperience = ({
|
|
|
380
380
|
}));
|
|
381
381
|
};
|
|
382
382
|
|
|
383
|
-
const ComponentMarker = /*#__PURE__*/React.forwardRef((
|
|
383
|
+
const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
384
|
+
hidden: _hidden = false
|
|
385
|
+
}, ref) => {
|
|
384
386
|
const {
|
|
385
387
|
logger
|
|
386
388
|
} = useNinetailed();
|
|
@@ -398,7 +400,7 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
|
398
400
|
}, [logger]);
|
|
399
401
|
React.useEffect(() => {
|
|
400
402
|
if (markerRef.current) {
|
|
401
|
-
const nextSibling = markerRef.current
|
|
403
|
+
const nextSibling = getNextSibling(markerRef.current, _hidden);
|
|
402
404
|
if (ref) {
|
|
403
405
|
if (typeof ref === 'function') {
|
|
404
406
|
ref(nextSibling);
|
|
@@ -407,7 +409,7 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
|
-
}, []);
|
|
412
|
+
}, [_hidden]);
|
|
411
413
|
return jsxRuntime.jsx("div", {
|
|
412
414
|
className: "nt-cmp-marker",
|
|
413
415
|
style: {
|
|
@@ -416,6 +418,21 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
|
416
418
|
ref: markerRef
|
|
417
419
|
});
|
|
418
420
|
});
|
|
421
|
+
const getNextSibling = (element, recursive = false) => {
|
|
422
|
+
if (!recursive) {
|
|
423
|
+
return element.nextSibling;
|
|
424
|
+
}
|
|
425
|
+
const {
|
|
426
|
+
parentElement
|
|
427
|
+
} = element;
|
|
428
|
+
if (!parentElement) {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
if (parentElement.nextSibling) {
|
|
432
|
+
return parentElement.nextSibling;
|
|
433
|
+
}
|
|
434
|
+
return getNextSibling(parentElement, true);
|
|
435
|
+
};
|
|
419
436
|
|
|
420
437
|
const DefaultExperienceLoadingComponent = _a => {
|
|
421
438
|
var {
|
|
@@ -542,7 +559,8 @@ const Experience = _a => {
|
|
|
542
559
|
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
543
560
|
if (isVariantHidden) {
|
|
544
561
|
return jsxRuntime.jsx(ComponentMarker, {
|
|
545
|
-
ref: componentRef
|
|
562
|
+
ref: componentRef,
|
|
563
|
+
hidden: true
|
|
546
564
|
}, `marker-hidden-${(experience === null || experience === void 0 ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
547
565
|
}
|
|
548
566
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
package/index.js
CHANGED
|
@@ -372,7 +372,9 @@ const useExperience = ({
|
|
|
372
372
|
}));
|
|
373
373
|
};
|
|
374
374
|
|
|
375
|
-
const ComponentMarker = /*#__PURE__*/forwardRef((
|
|
375
|
+
const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
376
|
+
hidden: _hidden = false
|
|
377
|
+
}, ref) => {
|
|
376
378
|
const {
|
|
377
379
|
logger
|
|
378
380
|
} = useNinetailed();
|
|
@@ -390,7 +392,7 @@ const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
|
390
392
|
}, [logger]);
|
|
391
393
|
useEffect(() => {
|
|
392
394
|
if (markerRef.current) {
|
|
393
|
-
const nextSibling = markerRef.current
|
|
395
|
+
const nextSibling = getNextSibling(markerRef.current, _hidden);
|
|
394
396
|
if (ref) {
|
|
395
397
|
if (typeof ref === 'function') {
|
|
396
398
|
ref(nextSibling);
|
|
@@ -399,7 +401,7 @@ const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
}
|
|
402
|
-
}, []);
|
|
404
|
+
}, [_hidden]);
|
|
403
405
|
return jsx("div", {
|
|
404
406
|
className: "nt-cmp-marker",
|
|
405
407
|
style: {
|
|
@@ -408,6 +410,21 @@ const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
|
408
410
|
ref: markerRef
|
|
409
411
|
});
|
|
410
412
|
});
|
|
413
|
+
const getNextSibling = (element, recursive = false) => {
|
|
414
|
+
if (!recursive) {
|
|
415
|
+
return element.nextSibling;
|
|
416
|
+
}
|
|
417
|
+
const {
|
|
418
|
+
parentElement
|
|
419
|
+
} = element;
|
|
420
|
+
if (!parentElement) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
if (parentElement.nextSibling) {
|
|
424
|
+
return parentElement.nextSibling;
|
|
425
|
+
}
|
|
426
|
+
return getNextSibling(parentElement, true);
|
|
427
|
+
};
|
|
411
428
|
|
|
412
429
|
const DefaultExperienceLoadingComponent = _a => {
|
|
413
430
|
var {
|
|
@@ -534,7 +551,8 @@ const Experience = _a => {
|
|
|
534
551
|
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
535
552
|
if (isVariantHidden) {
|
|
536
553
|
return jsx(ComponentMarker, {
|
|
537
|
-
ref: componentRef
|
|
554
|
+
ref: componentRef,
|
|
555
|
+
hidden: true
|
|
538
556
|
}, `marker-hidden-${(experience === null || experience === void 0 ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
539
557
|
}
|
|
540
558
|
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
|
+
"version": "7.5.3-beta.1",
|
|
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.
|
|
20
|
-
"@ninetailed/experience.js-shared": "7.5.
|
|
19
|
+
"@ninetailed/experience.js": "7.5.3-beta.1",
|
|
20
|
+
"@ninetailed/experience.js-shared": "7.5.3-beta.1",
|
|
21
21
|
"radash": "10.9.0",
|
|
22
22
|
"react-intersection-observer": "8.34.0",
|
|
23
23
|
"react-is": "18.2.0"
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
type ComponentMarkerProps = {
|
|
3
|
+
hidden?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const ComponentMarker: React.ForwardRefExoticComponent<ComponentMarkerProps & React.RefAttributes<unknown>>;
|
|
6
|
+
export {};
|