@ninetailed/experience.js-react 7.20.1 → 7.20.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.
- package/index.cjs.js +15 -7
- package/index.esm.js +15 -7
- package/package.json +4 -4
- package/src/lib/Experience/DefaultExperienceLoadingComponent.d.ts +7 -0
- package/src/lib/Experience/Experience.d.ts +4 -26
- package/src/lib/Experience/index.d.ts +1 -1
- package/src/lib/Experience/types/Experience.d.ts +21 -0
- package/src/lib/Experience/types/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -497,21 +497,28 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
497
497
|
const {
|
|
498
498
|
logger
|
|
499
499
|
} = useNinetailed();
|
|
500
|
-
const [
|
|
500
|
+
const [isHidden, setIsHidden] = React.useState(true);
|
|
501
501
|
React.useEffect(() => {
|
|
502
|
+
if (!isHidden) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
502
505
|
const timer = setTimeout(() => {
|
|
503
|
-
|
|
506
|
+
setIsHidden(false);
|
|
504
507
|
logger.error(new Error(`The experience was still in loading state after ${unhideAfterMs}ms. That happens when no events are sent to the Ninetailed API. The baseline is now shown instead.`));
|
|
505
508
|
}, unhideAfterMs);
|
|
506
509
|
return () => {
|
|
507
510
|
clearTimeout(timer);
|
|
508
511
|
};
|
|
509
|
-
}, []);
|
|
510
|
-
if (
|
|
512
|
+
}, [isHidden, logger, unhideAfterMs]);
|
|
513
|
+
if (isHidden) {
|
|
511
514
|
return jsxRuntime.jsx("div", Object.assign({
|
|
512
515
|
style: {
|
|
513
|
-
|
|
514
|
-
|
|
516
|
+
visibility: 'hidden',
|
|
517
|
+
pointerEvents: 'none'
|
|
518
|
+
},
|
|
519
|
+
"aria-hidden": "true",
|
|
520
|
+
// Prevent focus and interaction within the hidden loading subtree.
|
|
521
|
+
inert: true
|
|
515
522
|
}, {
|
|
516
523
|
children: jsxRuntime.jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
517
524
|
ninetailed: {
|
|
@@ -521,7 +528,7 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
521
528
|
}
|
|
522
529
|
}
|
|
523
530
|
}))
|
|
524
|
-
}), "
|
|
531
|
+
}), "experience-loader-hidden-baseline");
|
|
525
532
|
}
|
|
526
533
|
return jsxRuntime.jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
527
534
|
ninetailed: {
|
|
@@ -532,6 +539,7 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
532
539
|
}
|
|
533
540
|
}));
|
|
534
541
|
};
|
|
542
|
+
|
|
535
543
|
const Experience = _a => {
|
|
536
544
|
var {
|
|
537
545
|
experiences,
|
package/index.esm.js
CHANGED
|
@@ -495,21 +495,28 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
495
495
|
const {
|
|
496
496
|
logger
|
|
497
497
|
} = useNinetailed();
|
|
498
|
-
const [
|
|
498
|
+
const [isHidden, setIsHidden] = useState(true);
|
|
499
499
|
useEffect(() => {
|
|
500
|
+
if (!isHidden) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
500
503
|
const timer = setTimeout(() => {
|
|
501
|
-
|
|
504
|
+
setIsHidden(false);
|
|
502
505
|
logger.error(new Error(`The experience was still in loading state after ${unhideAfterMs}ms. That happens when no events are sent to the Ninetailed API. The baseline is now shown instead.`));
|
|
503
506
|
}, unhideAfterMs);
|
|
504
507
|
return () => {
|
|
505
508
|
clearTimeout(timer);
|
|
506
509
|
};
|
|
507
|
-
}, []);
|
|
508
|
-
if (
|
|
510
|
+
}, [isHidden, logger, unhideAfterMs]);
|
|
511
|
+
if (isHidden) {
|
|
509
512
|
return jsx("div", Object.assign({
|
|
510
513
|
style: {
|
|
511
|
-
|
|
512
|
-
|
|
514
|
+
visibility: 'hidden',
|
|
515
|
+
pointerEvents: 'none'
|
|
516
|
+
},
|
|
517
|
+
"aria-hidden": "true",
|
|
518
|
+
// Prevent focus and interaction within the hidden loading subtree.
|
|
519
|
+
inert: true
|
|
513
520
|
}, {
|
|
514
521
|
children: jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
515
522
|
ninetailed: {
|
|
@@ -519,7 +526,7 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
519
526
|
}
|
|
520
527
|
}
|
|
521
528
|
}))
|
|
522
|
-
}), "
|
|
529
|
+
}), "experience-loader-hidden-baseline");
|
|
523
530
|
}
|
|
524
531
|
return jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
525
532
|
ninetailed: {
|
|
@@ -530,6 +537,7 @@ const DefaultExperienceLoadingComponent = _a => {
|
|
|
530
537
|
}
|
|
531
538
|
}));
|
|
532
539
|
};
|
|
540
|
+
|
|
533
541
|
const Experience = _a => {
|
|
534
542
|
var {
|
|
535
543
|
experiences,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.2",
|
|
4
4
|
"description": "Ninetailed SDK for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ninetailed/experience.js": "7.20.
|
|
32
|
-
"@ninetailed/experience.js-shared": "7.20.
|
|
33
|
-
"@ninetailed/experience.js-plugin-analytics": "7.20.
|
|
31
|
+
"@ninetailed/experience.js": "7.20.2",
|
|
32
|
+
"@ninetailed/experience.js-shared": "7.20.2",
|
|
33
|
+
"@ninetailed/experience.js-plugin-analytics": "7.20.2",
|
|
34
34
|
"radash": "10.9.0",
|
|
35
35
|
"react-is": "19.2.4"
|
|
36
36
|
},
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Reference } from '@ninetailed/experience.js';
|
|
2
|
+
import type { ExperienceBaseProps } from './types/Experience';
|
|
3
|
+
type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<Record<string, unknown>, Record<string, unknown>, Record<string, unknown> & Reference> & {
|
|
4
|
+
unhideAfterMs?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const DefaultExperienceLoadingComponent: ({ component: Component, unhideAfterMs, passthroughProps, ...baseline }: DefaultExperienceLoadingComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
export type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> & {
|
|
4
|
-
ninetailed?: {
|
|
5
|
-
isPersonalized: boolean;
|
|
6
|
-
audience: {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
}>;
|
|
11
|
-
export type ExperienceBaseProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
|
|
12
|
-
experiences: ExperienceConfiguration<Variant>[];
|
|
13
|
-
component: React.ComponentType<P>;
|
|
14
|
-
passthroughProps?: PassThroughProps;
|
|
15
|
-
};
|
|
16
|
-
export type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps, Variant>>;
|
|
17
|
-
export type ExperienceProps<P, PassThroughProps extends Partial<P> = Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference = Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = ExperienceBaseProps<P, PassThroughProps, Variant> & {
|
|
18
|
-
experiences: ExperienceConfiguration<Variant>[];
|
|
19
|
-
component: React.ComponentType<P>;
|
|
20
|
-
loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps, Variant>;
|
|
21
|
-
};
|
|
22
|
-
type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<Record<string, unknown>, Record<string, unknown>, Record<string, unknown> & Reference> & {
|
|
23
|
-
unhideAfterMs?: number;
|
|
24
|
-
};
|
|
25
|
-
export declare const DefaultExperienceLoadingComponent: React.FC<DefaultExperienceLoadingComponentProps>;
|
|
1
|
+
import type { Reference } from '@ninetailed/experience.js';
|
|
2
|
+
import type { ExperienceProps } from './types/Experience';
|
|
26
3
|
export declare const Experience: <P, PassThroughProps extends Partial<P> = Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference = Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference>({ experiences, component: Component, loadingComponent: LoadingComponent, passthroughProps, ...baseline }: ExperienceProps<P, PassThroughProps, Variant>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export {};
|
|
4
|
+
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './types/Experience';
|
|
5
|
+
export { DefaultExperienceLoadingComponent } from './DefaultExperienceLoadingComponent';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Experience, DefaultExperienceLoadingComponent } from './Experience';
|
|
2
|
-
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
|
|
2
|
+
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './types/Experience';
|
|
3
3
|
export { ESRProvider, ESRLoadingComponent } from './ESRLoadingComponent';
|
|
4
4
|
export { useExperience } from './useExperience';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { Baseline, ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
|
|
3
|
+
export type ExperienceComponent<P> = ComponentType<Omit<P, 'id'> & {
|
|
4
|
+
ninetailed?: {
|
|
5
|
+
isPersonalized: boolean;
|
|
6
|
+
audience: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export type ExperienceBaseProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
|
|
12
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
13
|
+
component: ComponentType<P>;
|
|
14
|
+
passthroughProps?: PassThroughProps;
|
|
15
|
+
};
|
|
16
|
+
export type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = ComponentType<ExperienceBaseProps<P, PassThroughProps, Variant>>;
|
|
17
|
+
export type ExperienceProps<P, PassThroughProps extends Partial<P> = Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference = Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = ExperienceBaseProps<P, PassThroughProps, Variant> & {
|
|
18
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
19
|
+
component: ComponentType<P>;
|
|
20
|
+
loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps, Variant>;
|
|
21
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { Baseline } from './Baseline';
|
|
2
2
|
export type { Variant } from './Variant';
|
|
3
3
|
export type { BaselineWithVariants } from './BaselineWithVariants';
|
|
4
|
+
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
|