@ninetailed/experience.js-react 7.6.0-beta.4 → 7.6.0-beta.6
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.js
CHANGED
|
@@ -284,9 +284,7 @@ const useExperience = ({
|
|
|
284
284
|
return experience;
|
|
285
285
|
};
|
|
286
286
|
|
|
287
|
-
const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
288
|
-
hidden: _hidden = false
|
|
289
|
-
}, ref) => {
|
|
287
|
+
const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
290
288
|
const {
|
|
291
289
|
logger
|
|
292
290
|
} = useNinetailed();
|
|
@@ -304,16 +302,16 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
|
304
302
|
}, [logger]);
|
|
305
303
|
React.useEffect(() => {
|
|
306
304
|
if (markerRef.current) {
|
|
307
|
-
const
|
|
305
|
+
const observableElement = getObservableElement(markerRef.current);
|
|
308
306
|
if (ref) {
|
|
309
307
|
if (typeof ref === 'function') {
|
|
310
|
-
ref(
|
|
308
|
+
ref(observableElement);
|
|
311
309
|
} else {
|
|
312
|
-
ref.current =
|
|
310
|
+
ref.current = observableElement;
|
|
313
311
|
}
|
|
314
312
|
}
|
|
315
313
|
}
|
|
316
|
-
}, [
|
|
314
|
+
}, []);
|
|
317
315
|
return jsxRuntime.jsx("div", {
|
|
318
316
|
className: "nt-cmp-marker",
|
|
319
317
|
style: {
|
|
@@ -322,9 +320,22 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef(({
|
|
|
322
320
|
ref: markerRef
|
|
323
321
|
});
|
|
324
322
|
});
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
323
|
+
const getObservableSibling = element => {
|
|
324
|
+
const nextSibling = element.nextElementSibling;
|
|
325
|
+
if (!nextSibling) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
const nextSiblingStyle = getComputedStyle(nextSibling);
|
|
329
|
+
// Elements with display: none are not observable by the IntersectionObserver
|
|
330
|
+
if (nextSiblingStyle.display !== 'none') {
|
|
331
|
+
return nextSibling;
|
|
332
|
+
}
|
|
333
|
+
return getObservableSibling(nextSibling);
|
|
334
|
+
};
|
|
335
|
+
const getObservableElement = element => {
|
|
336
|
+
const observableSibling = getObservableSibling(element);
|
|
337
|
+
if (observableSibling) {
|
|
338
|
+
return observableSibling;
|
|
328
339
|
}
|
|
329
340
|
const {
|
|
330
341
|
parentElement
|
|
@@ -332,10 +343,7 @@ const getNextSibling = (element, recursive = false) => {
|
|
|
332
343
|
if (!parentElement) {
|
|
333
344
|
return null;
|
|
334
345
|
}
|
|
335
|
-
|
|
336
|
-
return parentElement.nextSibling;
|
|
337
|
-
}
|
|
338
|
-
return getNextSibling(parentElement, true);
|
|
346
|
+
return getObservableElement(parentElement);
|
|
339
347
|
};
|
|
340
348
|
|
|
341
349
|
const DefaultExperienceLoadingComponent = _a => {
|
|
@@ -465,8 +473,7 @@ const Experience = _a => {
|
|
|
465
473
|
}
|
|
466
474
|
if (isVariantHidden) {
|
|
467
475
|
return jsxRuntime.jsx(ComponentMarker, {
|
|
468
|
-
ref: componentRef
|
|
469
|
-
hidden: true
|
|
476
|
+
ref: componentRef
|
|
470
477
|
}, `marker-hidden-${(experience === null || experience === void 0 ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
471
478
|
}
|
|
472
479
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
package/index.esm.js
CHANGED
|
@@ -262,9 +262,7 @@ const useExperience = ({
|
|
|
262
262
|
return experience;
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
-
const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
266
|
-
hidden: _hidden = false
|
|
267
|
-
}, ref) => {
|
|
265
|
+
const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
268
266
|
const {
|
|
269
267
|
logger
|
|
270
268
|
} = useNinetailed();
|
|
@@ -282,16 +280,16 @@ const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
|
282
280
|
}, [logger]);
|
|
283
281
|
useEffect(() => {
|
|
284
282
|
if (markerRef.current) {
|
|
285
|
-
const
|
|
283
|
+
const observableElement = getObservableElement(markerRef.current);
|
|
286
284
|
if (ref) {
|
|
287
285
|
if (typeof ref === 'function') {
|
|
288
|
-
ref(
|
|
286
|
+
ref(observableElement);
|
|
289
287
|
} else {
|
|
290
|
-
ref.current =
|
|
288
|
+
ref.current = observableElement;
|
|
291
289
|
}
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
|
-
}, [
|
|
292
|
+
}, []);
|
|
295
293
|
return /*#__PURE__*/jsx("div", {
|
|
296
294
|
className: "nt-cmp-marker",
|
|
297
295
|
style: {
|
|
@@ -300,9 +298,23 @@ const ComponentMarker = /*#__PURE__*/forwardRef(({
|
|
|
300
298
|
ref: markerRef
|
|
301
299
|
});
|
|
302
300
|
});
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
301
|
+
const getObservableSibling = element => {
|
|
302
|
+
const nextSibling = element.nextElementSibling;
|
|
303
|
+
if (!nextSibling) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
const nextSiblingStyle = getComputedStyle(nextSibling);
|
|
307
|
+
|
|
308
|
+
// Elements with display: none are not observable by the IntersectionObserver
|
|
309
|
+
if (nextSiblingStyle.display !== 'none') {
|
|
310
|
+
return nextSibling;
|
|
311
|
+
}
|
|
312
|
+
return getObservableSibling(nextSibling);
|
|
313
|
+
};
|
|
314
|
+
const getObservableElement = element => {
|
|
315
|
+
const observableSibling = getObservableSibling(element);
|
|
316
|
+
if (observableSibling) {
|
|
317
|
+
return observableSibling;
|
|
306
318
|
}
|
|
307
319
|
const {
|
|
308
320
|
parentElement
|
|
@@ -310,10 +322,7 @@ const getNextSibling = (element, recursive = false) => {
|
|
|
310
322
|
if (!parentElement) {
|
|
311
323
|
return null;
|
|
312
324
|
}
|
|
313
|
-
|
|
314
|
-
return parentElement.nextSibling;
|
|
315
|
-
}
|
|
316
|
-
return getNextSibling(parentElement, true);
|
|
325
|
+
return getObservableElement(parentElement);
|
|
317
326
|
};
|
|
318
327
|
|
|
319
328
|
const _excluded$1 = ["component", "unhideAfterMs", "passthroughProps"],
|
|
@@ -445,8 +454,7 @@ const Experience = _ref2 => {
|
|
|
445
454
|
}
|
|
446
455
|
if (isVariantHidden) {
|
|
447
456
|
return /*#__PURE__*/jsx(ComponentMarker, {
|
|
448
|
-
ref: componentRef
|
|
449
|
-
hidden: true
|
|
457
|
+
ref: componentRef
|
|
450
458
|
}, `marker-hidden-${(experience == null ? void 0 : experience.id) || 'baseline'}-${variant.id}`);
|
|
451
459
|
}
|
|
452
460
|
return /*#__PURE__*/jsxs(Fragment, {
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "7.6.0-beta.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "7.6.0-beta.6",
|
|
5
4
|
"description": "Ninetailed SDK for React",
|
|
6
5
|
"dependencies": {
|
|
7
|
-
"@ninetailed/experience.js": "7.6.0-beta.
|
|
8
|
-
"@ninetailed/experience.js-shared": "7.6.0-beta.
|
|
9
|
-
"@ninetailed/experience.js-plugin-analytics": "7.6.0-beta.
|
|
6
|
+
"@ninetailed/experience.js": "7.6.0-beta.6",
|
|
7
|
+
"@ninetailed/experience.js-shared": "7.6.0-beta.6",
|
|
8
|
+
"@ninetailed/experience.js-plugin-analytics": "7.6.0-beta.6",
|
|
10
9
|
"radash": "10.9.0",
|
|
11
10
|
"react-intersection-observer": "8.34.0",
|
|
12
11
|
"react-is": "18.2.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ComponentMarker';
|