@incodetech/web 2.0.0-alpha.1 → 2.0.0-alpha.3
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/asset-manifest.json +18 -0
- package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
- package/dist/button-DeMZ_34N.js +266 -0
- package/dist/button.css +335 -0
- package/dist/email/email.es.js +145 -0
- package/dist/email/styles.css +123 -0
- package/dist/flow/flow.es.js +9 -0
- package/dist/flow/styles.css +204 -0
- package/dist/flow-ZK6OBsa3.js +568 -0
- package/dist/incodeModule-BF5MX9GT.js +243 -0
- package/dist/incodeModule.css +119 -0
- package/dist/index.es.js +101 -0
- package/dist/otpInput-BUrV4IAF.js +151 -0
- package/dist/otpInput.css +167 -0
- package/dist/phone/phone.es.js +3442 -0
- package/dist/phone/styles.css +305 -0
- package/dist/selfie/selfie.es.js +893 -0
- package/dist/selfie/styles.css +1163 -0
- package/dist/selfieTutorial-C-u5GufD.js +29 -0
- package/dist/styles/core.css +1013 -0
- package/dist/styles/tokens.css +543 -0
- package/dist/successIcon.css +4 -0
- package/dist/title-ng7q7YDh.js +2161 -0
- package/dist/title.css +38 -0
- package/dist/types/core.d.ts +1 -0
- package/dist/types/email/email.d.ts +2 -0
- package/dist/types/email.d.ts +50 -0
- package/dist/types/flow/flow.d.ts +2 -0
- package/dist/types/flow.d.ts +46 -0
- package/dist/types/index.d.ts +223 -0
- package/dist/types/phone/phone.d.ts +2 -0
- package/dist/types/phone.d.ts +51 -0
- package/dist/types/selfie/selfie.d.ts +2 -0
- package/dist/types/selfie.d.ts +24 -0
- package/dist/types/styles/core.d.ts +1 -0
- package/dist/vendor-preact-CK0WeTOR.js +584 -0
- package/package.json +20 -17
- package/dev/README.md +0 -163
- package/dev/getToken.ts +0 -36
- package/dev/headless.html +0 -875
- package/dev/index.html +0 -366
- package/dev/main-headless.tsx +0 -1332
- package/dev/main-orchestrated-flow.tsx +0 -1158
- package/dev/main-preact.tsx +0 -323
- package/dev/main-simplified.tsx +0 -123
- package/dev/main-web-component.tsx +0 -256
- package/dev/main.tsx +0 -332
- package/dev/manual.html +0 -27
- package/dev/orchestrated-flow.html +0 -64
- package/dev/simplified.html +0 -64
- package/dev/tiktok-logo.svg +0 -7
- package/src/defineCustomElement.tsx +0 -30
- package/src/email/email.test.tsx +0 -368
- package/src/email/email.tsx +0 -255
- package/src/email/emailInput.test.tsx +0 -264
- package/src/email/emailInput.tsx +0 -85
- package/src/email/styles.css +0 -59
- package/src/flow/flow.test.tsx +0 -796
- package/src/flow/flow.tsx +0 -292
- package/src/flow/flowCompleted.css +0 -30
- package/src/flow/flowCompleted.test.tsx +0 -331
- package/src/flow/flowCompleted.tsx +0 -121
- package/src/flow/flowInit.test.ts +0 -264
- package/src/flow/flowInit.ts +0 -94
- package/src/flow/flowStart.css +0 -58
- package/src/flow/flowStart.test.tsx +0 -49
- package/src/flow/flowStart.tsx +0 -41
- package/src/flow/incode-logo.svg +0 -8
- package/src/flow/index.ts +0 -7
- package/src/flow/preloadFlow.test.ts +0 -421
- package/src/flow/preloadFlow.ts +0 -171
- package/src/flow/styles.css +0 -9
- package/src/flow/unsupportedModule.css +0 -21
- package/src/flow/unsupportedModule.tsx +0 -39
- package/src/flow/useFlowInitialization.test.tsx +0 -292
- package/src/flow/useFlowInitialization.ts +0 -128
- package/src/flow/useModuleLoader.test.tsx +0 -212
- package/src/flow/useModuleLoader.ts +0 -92
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useManager.test.ts +0 -91
- package/src/hooks/useManager.ts +0 -40
- package/src/i18n/index.ts +0 -3
- package/src/i18n/instance.ts +0 -16
- package/src/i18n/setup.ts +0 -184
- package/src/i18n/useTranslation.ts +0 -42
- package/src/index.ts +0 -27
- package/src/permissions/assets/android-dots-icon.svg +0 -7
- package/src/permissions/assets/android-settings-icon.svg +0 -16
- package/src/permissions/assets/android-toggle-icon.svg +0 -20
- package/src/permissions/assets/bank-card-icon.svg +0 -14
- package/src/permissions/assets/camera-icon.svg +0 -12
- package/src/permissions/assets/camera-ios.svg +0 -53
- package/src/permissions/assets/check-icon.svg +0 -8
- package/src/permissions/assets/chrome-icon.svg +0 -43
- package/src/permissions/assets/password-icon.svg +0 -11
- package/src/permissions/assets/permissions-img.svg +0 -51
- package/src/permissions/assets/safari-icon.svg +0 -37
- package/src/permissions/assets/settings-icon.svg +0 -33
- package/src/permissions/assets/toggle-icon.svg +0 -19
- package/src/permissions/assets/warning-icon.svg +0 -6
- package/src/permissions/boldWithArrow.css +0 -9
- package/src/permissions/boldWithArrow.tsx +0 -41
- package/src/permissions/denied.css +0 -37
- package/src/permissions/denied.tsx +0 -29
- package/src/permissions/deniedAndroid.tsx +0 -56
- package/src/permissions/deniedDesktop.css +0 -9
- package/src/permissions/deniedDesktop.tsx +0 -64
- package/src/permissions/deniedIOS.tsx +0 -73
- package/src/permissions/deniedInstructions.tsx +0 -19
- package/src/permissions/iconWrapper.css +0 -9
- package/src/permissions/iconWrapper.tsx +0 -15
- package/src/permissions/learnMore.css +0 -37
- package/src/permissions/learnMore.tsx +0 -85
- package/src/permissions/numberedStep.css +0 -13
- package/src/permissions/numberedStep.tsx +0 -14
- package/src/permissions/permissions.css +0 -13
- package/src/permissions/permissions.tsx +0 -68
- package/src/phone/phone.tsx +0 -246
- package/src/phone/phoneInput.test.tsx +0 -275
- package/src/phone/phoneInput.tsx +0 -249
- package/src/phone/styles.css +0 -158
- package/src/selfie/cameraButton.css +0 -13
- package/src/selfie/cameraButton.tsx +0 -35
- package/src/selfie/capture.css +0 -57
- package/src/selfie/capture.tsx +0 -232
- package/src/selfie/errorModal.tsx +0 -218
- package/src/selfie/errorModalContent.css +0 -33
- package/src/selfie/errorModalContent.tsx +0 -44
- package/src/selfie/faceOutline.css +0 -5
- package/src/selfie/faceOutline.tsx +0 -22
- package/src/selfie/loadingBorder.css +0 -12
- package/src/selfie/loadingBorder.tsx +0 -77
- package/src/selfie/manualCaptureButton.css +0 -13
- package/src/selfie/manualCaptureButton.tsx +0 -35
- package/src/selfie/noMoreAttemptsModal.tsx +0 -44
- package/src/selfie/notification.css +0 -9
- package/src/selfie/notification.tsx +0 -36
- package/src/selfie/retryErrorModal.tsx +0 -56
- package/src/selfie/selfie.test.tsx +0 -458
- package/src/selfie/selfie.tsx +0 -83
- package/src/selfie/selfieTutorial.json +0 -2626
- package/src/selfie/styles.css +0 -1
- package/src/selfie/tutorial.test.tsx +0 -200
- package/src/selfie/tutorial.tsx +0 -43
- package/src/setup.ts +0 -33
- package/src/shared/baseTutorial/baseTutorial.css +0 -21
- package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
- package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
- package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
- package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
- package/src/shared/button/button.css +0 -55
- package/src/shared/button/button.test.tsx +0 -101
- package/src/shared/button/button.tsx +0 -47
- package/src/shared/componentRoot/incodeComponent.tsx +0 -12
- package/src/shared/countries/countries.test.ts +0 -75
- package/src/shared/countries/countries.ts +0 -139
- package/src/shared/countries/index.ts +0 -6
- package/src/shared/icons/chevronDown.tsx +0 -22
- package/src/shared/icons/index.ts +0 -2
- package/src/shared/icons/successIcon.css +0 -5
- package/src/shared/icons/successIcon.test.tsx +0 -40
- package/src/shared/icons/successIcon.tsx +0 -26
- package/src/shared/loader/loadingIcon.css +0 -28
- package/src/shared/loader/loadingIcon.tsx +0 -67
- package/src/shared/lottie/lottie.tsx +0 -108
- package/src/shared/otpInput/otpInput.css +0 -85
- package/src/shared/otpInput/otpInput.test.tsx +0 -356
- package/src/shared/otpInput/otpInput.tsx +0 -241
- package/src/shared/page/incode-logo.svg +0 -3
- package/src/shared/page/page.css +0 -47
- package/src/shared/page/page.test.tsx +0 -97
- package/src/shared/page/page.tsx +0 -91
- package/src/shared/page/pageUiConfig.test.ts +0 -112
- package/src/shared/page/pageUiConfig.ts +0 -64
- package/src/shared/page/verifiedByIncode.css +0 -5
- package/src/shared/page/verifiedByIncode.tsx +0 -75
- package/src/shared/spacer/spacer.css +0 -149
- package/src/shared/spacer/spacer.test.tsx +0 -143
- package/src/shared/spacer/spacer.tsx +0 -88
- package/src/shared/spinner/index.ts +0 -2
- package/src/shared/spinner/spinner.css +0 -28
- package/src/shared/spinner/spinner.test.tsx +0 -82
- package/src/shared/spinner/spinner.tsx +0 -65
- package/src/shared/title/title.css +0 -7
- package/src/shared/title/title.tsx +0 -12
- package/src/shared/uiConfig/uiConfig.ts +0 -36
- package/src/shared/webComponent/incodeModule.ts +0 -29
- package/src/shared/webComponent/registerIncodeElement.ts +0 -15
- package/src/styles/__mocks__/fetchTheme.ts +0 -19
- package/src/styles/applyTheme.ts +0 -37
- package/src/styles/cn.test.tsx +0 -57
- package/src/styles/cn.tsx +0 -21
- package/src/styles/core.css +0 -12
- package/src/styles/fetchTheme.test.ts +0 -390
- package/src/styles/fetchTheme.ts +0 -88
- package/src/styles/generatePalette.ts +0 -111
- package/src/styles/reset.css +0 -65
- package/src/styles/resolveCssVariableToHex.ts +0 -28
- package/src/styles/tailwind.css +0 -291
- package/src/styles/themeTypes.ts +0 -18
- package/src/styles/tokens/colors.css +0 -190
- package/src/styles/tokens/components.css +0 -174
- package/src/styles/tokens/index.css +0 -4
- package/src/styles/tokens/primitives.css +0 -129
- package/src/styles/tokens/semantic.css +0 -51
- package/src/svg.d.ts +0 -4
- package/src/types/assets.d.ts +0 -1
- package/src/types/custom-elements.d.ts +0 -104
- package/tsconfig.json +0 -22
- package/vite.config.ts +0 -260
- package/vitest.config.ts +0 -40
- package/vitest.setup.ts +0 -16
package/src/selfie/styles.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "../styles/tailwind.css";
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import type { SelfieManager } from '@incodetech/core/selfie';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/preact';
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import { Tutorial } from './tutorial';
|
|
5
|
-
|
|
6
|
-
const mockAnimationData = {
|
|
7
|
-
v: '5.5.7',
|
|
8
|
-
fr: 60,
|
|
9
|
-
ip: 0,
|
|
10
|
-
op: 240,
|
|
11
|
-
w: 296,
|
|
12
|
-
h: 296,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
vi.mock('@/i18n', () => ({
|
|
16
|
-
useTranslation: () => ({
|
|
17
|
-
t: (key: string) => key,
|
|
18
|
-
ready: true,
|
|
19
|
-
}),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock('./selfieTutorial.json', () => ({
|
|
23
|
-
default: mockAnimationData,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('@/shared/baseTutorial/baseTutorial', () => ({
|
|
27
|
-
default: ({
|
|
28
|
-
title,
|
|
29
|
-
subtitle,
|
|
30
|
-
buttonText,
|
|
31
|
-
disclaimerText,
|
|
32
|
-
onContinue,
|
|
33
|
-
isLoading,
|
|
34
|
-
animationData,
|
|
35
|
-
}: {
|
|
36
|
-
title: string;
|
|
37
|
-
subtitle: string;
|
|
38
|
-
buttonText: string;
|
|
39
|
-
disclaimerText: string;
|
|
40
|
-
onContinue: () => void;
|
|
41
|
-
isLoading?: boolean;
|
|
42
|
-
animationData: unknown;
|
|
43
|
-
}) => (
|
|
44
|
-
<div
|
|
45
|
-
data-testid="base-tutorial"
|
|
46
|
-
data-is-loading={isLoading}
|
|
47
|
-
data-has-animation={!!animationData}
|
|
48
|
-
>
|
|
49
|
-
<div data-testid="title">{title}</div>
|
|
50
|
-
<div data-testid="subtitle">{subtitle}</div>
|
|
51
|
-
<div data-testid="button-text">{buttonText}</div>
|
|
52
|
-
<div data-testid="disclaimer">{disclaimerText}</div>
|
|
53
|
-
<button type="button" onClick={onContinue} data-testid="continue-button">
|
|
54
|
-
{buttonText}
|
|
55
|
-
</button>
|
|
56
|
-
</div>
|
|
57
|
-
),
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
describe('Tutorial', () => {
|
|
61
|
-
const mockNextStep = vi.fn();
|
|
62
|
-
const mockManager = {
|
|
63
|
-
nextStep: mockNextStep,
|
|
64
|
-
} as unknown as SelfieManager;
|
|
65
|
-
|
|
66
|
-
beforeEach(() => {
|
|
67
|
-
vi.clearAllMocks();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('rendering', () => {
|
|
71
|
-
it('returns null when animationData is not loaded', async () => {
|
|
72
|
-
vi.resetModules();
|
|
73
|
-
vi.doUnmock('./selfieTutorial.json');
|
|
74
|
-
let resolveAnimation:
|
|
75
|
-
| ((value: typeof mockAnimationData) => void)
|
|
76
|
-
| undefined;
|
|
77
|
-
const animationPromise = new Promise<typeof mockAnimationData>(
|
|
78
|
-
(resolve) => {
|
|
79
|
-
resolveAnimation = resolve;
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
vi.doMock('./selfieTutorial.json', () => ({
|
|
83
|
-
default: animationPromise,
|
|
84
|
-
}));
|
|
85
|
-
const { Tutorial: TutorialComponent } = await import('./tutorial');
|
|
86
|
-
const { container } = render(<TutorialComponent manager={mockManager} />);
|
|
87
|
-
expect(container.firstChild).toBeNull();
|
|
88
|
-
if (resolveAnimation) {
|
|
89
|
-
resolveAnimation(mockAnimationData);
|
|
90
|
-
}
|
|
91
|
-
await waitFor(
|
|
92
|
-
() => {
|
|
93
|
-
expect(screen.getByTestId('base-tutorial')).toBeTruthy();
|
|
94
|
-
},
|
|
95
|
-
{ timeout: 1000 },
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('renders BaseTutorial component', async () => {
|
|
100
|
-
render(<Tutorial manager={mockManager} />);
|
|
101
|
-
await waitFor(() => {
|
|
102
|
-
expect(screen.getByTestId('base-tutorial')).toBeTruthy();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('passes animation data to BaseTutorial', async () => {
|
|
107
|
-
render(<Tutorial manager={mockManager} />);
|
|
108
|
-
await waitFor(() => {
|
|
109
|
-
expect(screen.getByTestId('base-tutorial').dataset.hasAnimation).toBe(
|
|
110
|
-
'true',
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('translations', () => {
|
|
117
|
-
it('passes correct title translation key', async () => {
|
|
118
|
-
render(<Tutorial manager={mockManager} />);
|
|
119
|
-
await waitFor(() => {
|
|
120
|
-
expect(screen.getByTestId('title').textContent).toBe(
|
|
121
|
-
'face.tutorial.title',
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('passes correct subtitle translation key', async () => {
|
|
127
|
-
render(<Tutorial manager={mockManager} />);
|
|
128
|
-
await waitFor(() => {
|
|
129
|
-
expect(screen.getByTestId('subtitle').textContent).toBe(
|
|
130
|
-
'face.tutorial.subtitle',
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('passes correct button text translation key', async () => {
|
|
136
|
-
render(<Tutorial manager={mockManager} />);
|
|
137
|
-
await waitFor(() => {
|
|
138
|
-
expect(screen.getByTestId('button-text').textContent).toBe(
|
|
139
|
-
'face.tutorial.startCapture',
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('passes correct disclaimer translation key', async () => {
|
|
145
|
-
render(<Tutorial manager={mockManager} />);
|
|
146
|
-
await waitFor(() => {
|
|
147
|
-
expect(screen.getByTestId('disclaimer').textContent).toBe(
|
|
148
|
-
'face.tutorial.autoCapture',
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('onContinue callback', () => {
|
|
155
|
-
it('calls manager.nextStep when button is clicked', async () => {
|
|
156
|
-
render(<Tutorial manager={mockManager} />);
|
|
157
|
-
await waitFor(() => {
|
|
158
|
-
expect(screen.getByTestId('continue-button')).toBeTruthy();
|
|
159
|
-
});
|
|
160
|
-
screen.getByTestId('continue-button').click();
|
|
161
|
-
expect(mockNextStep).toHaveBeenCalledTimes(1);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('calls manager.nextStep multiple times on multiple clicks', async () => {
|
|
165
|
-
render(<Tutorial manager={mockManager} />);
|
|
166
|
-
await waitFor(() => {
|
|
167
|
-
expect(screen.getByTestId('continue-button')).toBeTruthy();
|
|
168
|
-
});
|
|
169
|
-
const button = screen.getByTestId('continue-button');
|
|
170
|
-
button.click();
|
|
171
|
-
button.click();
|
|
172
|
-
expect(mockNextStep).toHaveBeenCalledTimes(2);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe('isLoading prop', () => {
|
|
177
|
-
it('passes isLoading=false by default', async () => {
|
|
178
|
-
render(<Tutorial manager={mockManager} />);
|
|
179
|
-
await waitFor(() => {
|
|
180
|
-
expect(screen.getByTestId('base-tutorial').dataset.isLoading).toBe(
|
|
181
|
-
'false',
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('passes isLoading=true after button click', async () => {
|
|
187
|
-
render(<Tutorial manager={mockManager} />);
|
|
188
|
-
await waitFor(() => {
|
|
189
|
-
expect(screen.getByTestId('continue-button')).toBeTruthy();
|
|
190
|
-
});
|
|
191
|
-
const button = screen.getByTestId('continue-button');
|
|
192
|
-
button.click();
|
|
193
|
-
await waitFor(() => {
|
|
194
|
-
expect(screen.getByTestId('base-tutorial').dataset.isLoading).toBe(
|
|
195
|
-
'true',
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
package/src/selfie/tutorial.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { SelfieManager } from '@incodetech/core/selfie';
|
|
2
|
-
import { useEffect, useState } from 'preact/hooks';
|
|
3
|
-
import { useTranslation } from '@/i18n';
|
|
4
|
-
import BaseTutorial from '@/shared/baseTutorial/baseTutorial';
|
|
5
|
-
import type { LottieAnimationData } from '@/shared/lottie/lottie';
|
|
6
|
-
|
|
7
|
-
type TutorialProps = {
|
|
8
|
-
manager: SelfieManager;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Tutorial = ({ manager }: TutorialProps) => {
|
|
12
|
-
const { t } = useTranslation();
|
|
13
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
14
|
-
const [animationData, setAnimationData] =
|
|
15
|
-
useState<LottieAnimationData | null>(null);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
import('./selfieTutorial.json').then((module) => {
|
|
19
|
-
setAnimationData(module.default);
|
|
20
|
-
});
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
const handleContinue = () => {
|
|
24
|
-
setIsLoading(true);
|
|
25
|
-
manager.nextStep();
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if (!animationData) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<BaseTutorial
|
|
34
|
-
animationData={animationData}
|
|
35
|
-
title={t('face.tutorial.title')}
|
|
36
|
-
subtitle={t('face.tutorial.subtitle')}
|
|
37
|
-
onContinue={handleContinue}
|
|
38
|
-
buttonText={t('face.tutorial.startCapture')}
|
|
39
|
-
disclaimerText={t('face.tutorial.autoCapture')}
|
|
40
|
-
isLoading={isLoading}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
package/src/setup.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { WasmConfig } from '@incodetech/core';
|
|
2
|
-
import { setup as coreSetup } from '@incodetech/core';
|
|
3
|
-
import { createI18n, type I18nOptions, setI18nInstance } from './i18n';
|
|
4
|
-
import type { UiConfig } from './shared/uiConfig/uiConfig';
|
|
5
|
-
import { setUiConfig } from './shared/uiConfig/uiConfig';
|
|
6
|
-
|
|
7
|
-
type SetupOptions = {
|
|
8
|
-
apiURL: string;
|
|
9
|
-
token: string;
|
|
10
|
-
customHeaders?: Record<string, string>;
|
|
11
|
-
timeout?: number;
|
|
12
|
-
wasm?: WasmConfig;
|
|
13
|
-
i18n?: I18nOptions;
|
|
14
|
-
uiConfig?: UiConfig;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export async function setup({
|
|
18
|
-
apiURL,
|
|
19
|
-
token,
|
|
20
|
-
customHeaders,
|
|
21
|
-
timeout,
|
|
22
|
-
wasm,
|
|
23
|
-
i18n,
|
|
24
|
-
uiConfig,
|
|
25
|
-
}: SetupOptions): Promise<void> {
|
|
26
|
-
if (uiConfig) {
|
|
27
|
-
setUiConfig(uiConfig);
|
|
28
|
-
}
|
|
29
|
-
await coreSetup({ apiURL, token, customHeaders, timeout, wasm });
|
|
30
|
-
|
|
31
|
-
const i18nInstance = createI18n(i18n);
|
|
32
|
-
setI18nInstance(i18nInstance);
|
|
33
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
@reference "../../styles/tailwind.css";
|
|
2
|
-
|
|
3
|
-
.IncodeBaseTutorialContainer {
|
|
4
|
-
@apply flex flex-col justify-between flex-1 m-auto;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.IncodeBaseTutorialAnimationContainer {
|
|
8
|
-
@apply h-full px-24 m-auto max-w-[400px];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.IncodeBaseTutorialDisclaimer {
|
|
12
|
-
@apply text-base text-center text-text-body-secondary leading-[114%] font-medium tracking-[-0.5px] text-18 py-12;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.IncodeBaseTutorialButtonContainer {
|
|
16
|
-
@apply px-8 py-16 m-auto;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.IncodeBaseTutorialAnimation {
|
|
20
|
-
@apply h-full;
|
|
21
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/preact';
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import BaseTutorial from './baseTutorial';
|
|
4
|
-
import { getCssVariableAsHex, replaceLottieColor } from './replaceBaseTutorial';
|
|
5
|
-
|
|
6
|
-
vi.mock('./replaceBaseTutorial', () => ({
|
|
7
|
-
getCssVariableAsHex: vi.fn(() => '#006aff'),
|
|
8
|
-
replaceLottieColor: vi.fn((json) => json),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
vi.mock('../lottie/lottie', () => ({
|
|
12
|
-
Lottie: ({ animationData }: { animationData: unknown }) => (
|
|
13
|
-
<div data-testid="lottie-animation">{JSON.stringify(animationData)}</div>
|
|
14
|
-
),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const mockAnimationData = {
|
|
18
|
-
fr: 30,
|
|
19
|
-
v: '5.5.7',
|
|
20
|
-
ip: 0,
|
|
21
|
-
op: 60,
|
|
22
|
-
w: 100,
|
|
23
|
-
h: 100,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
describe('BaseTutorial', () => {
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
vi.clearAllMocks();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders title and subtitle', () => {
|
|
32
|
-
render(
|
|
33
|
-
<BaseTutorial
|
|
34
|
-
animationData={mockAnimationData}
|
|
35
|
-
title="Test Title"
|
|
36
|
-
subtitle="Test Subtitle"
|
|
37
|
-
onContinue={() => {}}
|
|
38
|
-
buttonText="Continue"
|
|
39
|
-
disclaimerText="Test disclaimer"
|
|
40
|
-
/>,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
expect(screen.getByText('Test Title')).toBeTruthy();
|
|
44
|
-
expect(screen.getByText('Test Subtitle')).toBeTruthy();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('renders disclaimer text', () => {
|
|
48
|
-
render(
|
|
49
|
-
<BaseTutorial
|
|
50
|
-
animationData={mockAnimationData}
|
|
51
|
-
title="Title"
|
|
52
|
-
subtitle="Subtitle"
|
|
53
|
-
onContinue={() => {}}
|
|
54
|
-
buttonText="Continue"
|
|
55
|
-
disclaimerText="Test disclaimer text"
|
|
56
|
-
/>,
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
expect(screen.getByText('Test disclaimer text')).toBeTruthy();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('renders button with correct text', () => {
|
|
63
|
-
render(
|
|
64
|
-
<BaseTutorial
|
|
65
|
-
animationData={mockAnimationData}
|
|
66
|
-
title="Title"
|
|
67
|
-
subtitle="Subtitle"
|
|
68
|
-
onContinue={() => {}}
|
|
69
|
-
buttonText="Start Now"
|
|
70
|
-
disclaimerText="Disclaimer"
|
|
71
|
-
/>,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
expect(screen.getByText('Start Now')).toBeTruthy();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('calls onContinue when button is clicked', () => {
|
|
78
|
-
const handleContinue = vi.fn();
|
|
79
|
-
render(
|
|
80
|
-
<BaseTutorial
|
|
81
|
-
animationData={mockAnimationData}
|
|
82
|
-
title="Title"
|
|
83
|
-
subtitle="Subtitle"
|
|
84
|
-
onContinue={handleContinue}
|
|
85
|
-
buttonText="Continue"
|
|
86
|
-
disclaimerText="Disclaimer"
|
|
87
|
-
/>,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const button = screen.getByRole('button');
|
|
91
|
-
button.click();
|
|
92
|
-
expect(handleContinue).toHaveBeenCalledTimes(1);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('renders Lottie animation', () => {
|
|
96
|
-
render(
|
|
97
|
-
<BaseTutorial
|
|
98
|
-
animationData={mockAnimationData}
|
|
99
|
-
title="Title"
|
|
100
|
-
subtitle="Subtitle"
|
|
101
|
-
onContinue={() => {}}
|
|
102
|
-
buttonText="Continue"
|
|
103
|
-
disclaimerText="Disclaimer"
|
|
104
|
-
/>,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
expect(screen.getByTestId('lottie-animation')).toBeTruthy();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('shows loading state on button when isLoading is true', () => {
|
|
111
|
-
render(
|
|
112
|
-
<BaseTutorial
|
|
113
|
-
animationData={mockAnimationData}
|
|
114
|
-
title="Title"
|
|
115
|
-
subtitle="Subtitle"
|
|
116
|
-
onContinue={() => {}}
|
|
117
|
-
buttonText="Continue"
|
|
118
|
-
disclaimerText="Disclaimer"
|
|
119
|
-
isLoading
|
|
120
|
-
/>,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const button = screen.getByRole('button');
|
|
124
|
-
expect(button.hasAttribute('disabled')).toBe(true);
|
|
125
|
-
expect(button.classList.contains('IncodeButtonLoading')).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('does not show loading state when isLoading is false', () => {
|
|
129
|
-
render(
|
|
130
|
-
<BaseTutorial
|
|
131
|
-
animationData={mockAnimationData}
|
|
132
|
-
title="Title"
|
|
133
|
-
subtitle="Subtitle"
|
|
134
|
-
onContinue={() => {}}
|
|
135
|
-
buttonText="Continue"
|
|
136
|
-
disclaimerText="Disclaimer"
|
|
137
|
-
isLoading={false}
|
|
138
|
-
/>,
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const button = screen.getByRole('button');
|
|
142
|
-
expect(button.classList.contains('IncodeButtonLoading')).toBe(false);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('uses default brand color when CSS variable is not available', () => {
|
|
146
|
-
vi.mocked(getCssVariableAsHex).mockReturnValue(null);
|
|
147
|
-
|
|
148
|
-
render(
|
|
149
|
-
<BaseTutorial
|
|
150
|
-
animationData={mockAnimationData}
|
|
151
|
-
title="Title"
|
|
152
|
-
subtitle="Subtitle"
|
|
153
|
-
onContinue={() => {}}
|
|
154
|
-
buttonText="Continue"
|
|
155
|
-
disclaimerText="Disclaimer"
|
|
156
|
-
/>,
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
expect(replaceLottieColor).toHaveBeenCalledWith(
|
|
160
|
-
mockAnimationData,
|
|
161
|
-
'#006aff',
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('uses CSS variable color when available', () => {
|
|
166
|
-
vi.mocked(getCssVariableAsHex).mockReturnValue('#ff0000');
|
|
167
|
-
|
|
168
|
-
render(
|
|
169
|
-
<BaseTutorial
|
|
170
|
-
animationData={mockAnimationData}
|
|
171
|
-
title="Title"
|
|
172
|
-
subtitle="Subtitle"
|
|
173
|
-
onContinue={() => {}}
|
|
174
|
-
buttonText="Continue"
|
|
175
|
-
disclaimerText="Disclaimer"
|
|
176
|
-
/>,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
expect(replaceLottieColor).toHaveBeenCalledWith(
|
|
180
|
-
mockAnimationData,
|
|
181
|
-
'#ff0000',
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Button } from '../button/button';
|
|
2
|
-
import { Lottie, type LottieAnimationData } from '../lottie/lottie';
|
|
3
|
-
import { Page } from '../page/page';
|
|
4
|
-
import './baseTutorial.css';
|
|
5
|
-
import { getCssVariableAsHex, replaceLottieColor } from './replaceBaseTutorial';
|
|
6
|
-
|
|
7
|
-
type BaseTutorialProps = {
|
|
8
|
-
animationData: LottieAnimationData;
|
|
9
|
-
title: string;
|
|
10
|
-
subtitle: string;
|
|
11
|
-
onContinue: () => void;
|
|
12
|
-
buttonText: string;
|
|
13
|
-
disclaimerText: string;
|
|
14
|
-
isLoading?: boolean;
|
|
15
|
-
};
|
|
16
|
-
const BaseTutorial = ({
|
|
17
|
-
animationData,
|
|
18
|
-
title,
|
|
19
|
-
subtitle,
|
|
20
|
-
onContinue,
|
|
21
|
-
buttonText,
|
|
22
|
-
disclaimerText,
|
|
23
|
-
isLoading,
|
|
24
|
-
}: BaseTutorialProps) => {
|
|
25
|
-
const brandColor = getCssVariableAsHex('--surface-brand-500');
|
|
26
|
-
return (
|
|
27
|
-
<Page className="IncodeTutorialPage" title={title} subtitle={subtitle}>
|
|
28
|
-
<div class="IncodeBaseTutorialContainer">
|
|
29
|
-
<div class="IncodeBaseTutorialAnimationContainer">
|
|
30
|
-
<Lottie
|
|
31
|
-
animationData={replaceLottieColor(
|
|
32
|
-
animationData,
|
|
33
|
-
brandColor ?? '#006aff',
|
|
34
|
-
)}
|
|
35
|
-
className="IncodeBaseTutorialAnimation"
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
<div>
|
|
40
|
-
<p class="IncodeBaseTutorialDisclaimer">{disclaimerText}</p>
|
|
41
|
-
<div class="IncodeBaseTutorialButtonContainer">
|
|
42
|
-
<Button
|
|
43
|
-
onClick={onContinue}
|
|
44
|
-
class="max-w-[420px] m-auto"
|
|
45
|
-
isLoading={isLoading}
|
|
46
|
-
>
|
|
47
|
-
{buttonText}
|
|
48
|
-
</Button>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</Page>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default BaseTutorial;
|