@incodetech/web 2.0.0-alpha.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/dev/README.md +163 -0
- package/dev/getToken.ts +36 -0
- package/dev/headless.html +875 -0
- package/dev/index.html +366 -0
- package/dev/main-headless.tsx +1332 -0
- package/dev/main-orchestrated-flow.tsx +1158 -0
- package/dev/main-preact.tsx +323 -0
- package/dev/main-simplified.tsx +123 -0
- package/dev/main-web-component.tsx +256 -0
- package/dev/main.tsx +332 -0
- package/dev/manual.html +27 -0
- package/dev/orchestrated-flow.html +64 -0
- package/dev/simplified.html +64 -0
- package/dev/tiktok-logo.svg +7 -0
- package/package.json +85 -0
- package/src/defineCustomElement.tsx +30 -0
- package/src/email/email.test.tsx +368 -0
- package/src/email/email.tsx +255 -0
- package/src/email/emailInput.test.tsx +264 -0
- package/src/email/emailInput.tsx +85 -0
- package/src/email/styles.css +59 -0
- package/src/flow/flow.test.tsx +796 -0
- package/src/flow/flow.tsx +292 -0
- package/src/flow/flowCompleted.css +30 -0
- package/src/flow/flowCompleted.test.tsx +331 -0
- package/src/flow/flowCompleted.tsx +121 -0
- package/src/flow/flowInit.test.ts +264 -0
- package/src/flow/flowInit.ts +94 -0
- package/src/flow/flowStart.css +58 -0
- package/src/flow/flowStart.test.tsx +49 -0
- package/src/flow/flowStart.tsx +41 -0
- package/src/flow/incode-logo.svg +8 -0
- package/src/flow/index.ts +7 -0
- package/src/flow/preloadFlow.test.ts +421 -0
- package/src/flow/preloadFlow.ts +171 -0
- package/src/flow/styles.css +9 -0
- package/src/flow/unsupportedModule.css +21 -0
- package/src/flow/unsupportedModule.tsx +39 -0
- package/src/flow/useFlowInitialization.test.tsx +292 -0
- package/src/flow/useFlowInitialization.ts +128 -0
- package/src/flow/useModuleLoader.test.tsx +212 -0
- package/src/flow/useModuleLoader.ts +92 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useManager.test.ts +91 -0
- package/src/hooks/useManager.ts +40 -0
- package/src/i18n/index.ts +3 -0
- package/src/i18n/instance.ts +16 -0
- package/src/i18n/setup.ts +184 -0
- package/src/i18n/useTranslation.ts +42 -0
- package/src/index.ts +27 -0
- package/src/permissions/assets/android-dots-icon.svg +7 -0
- package/src/permissions/assets/android-settings-icon.svg +16 -0
- package/src/permissions/assets/android-toggle-icon.svg +20 -0
- package/src/permissions/assets/bank-card-icon.svg +14 -0
- package/src/permissions/assets/camera-icon.svg +12 -0
- package/src/permissions/assets/camera-ios.svg +53 -0
- package/src/permissions/assets/check-icon.svg +8 -0
- package/src/permissions/assets/chrome-icon.svg +43 -0
- package/src/permissions/assets/password-icon.svg +11 -0
- package/src/permissions/assets/permissions-img.svg +51 -0
- package/src/permissions/assets/safari-icon.svg +37 -0
- package/src/permissions/assets/settings-icon.svg +33 -0
- package/src/permissions/assets/toggle-icon.svg +19 -0
- package/src/permissions/assets/warning-icon.svg +6 -0
- package/src/permissions/boldWithArrow.css +9 -0
- package/src/permissions/boldWithArrow.tsx +41 -0
- package/src/permissions/denied.css +37 -0
- package/src/permissions/denied.tsx +29 -0
- package/src/permissions/deniedAndroid.tsx +56 -0
- package/src/permissions/deniedDesktop.css +9 -0
- package/src/permissions/deniedDesktop.tsx +64 -0
- package/src/permissions/deniedIOS.tsx +73 -0
- package/src/permissions/deniedInstructions.tsx +19 -0
- package/src/permissions/iconWrapper.css +9 -0
- package/src/permissions/iconWrapper.tsx +15 -0
- package/src/permissions/learnMore.css +37 -0
- package/src/permissions/learnMore.tsx +85 -0
- package/src/permissions/numberedStep.css +13 -0
- package/src/permissions/numberedStep.tsx +14 -0
- package/src/permissions/permissions.css +13 -0
- package/src/permissions/permissions.tsx +68 -0
- package/src/phone/phone.tsx +246 -0
- package/src/phone/phoneInput.test.tsx +275 -0
- package/src/phone/phoneInput.tsx +249 -0
- package/src/phone/styles.css +158 -0
- package/src/selfie/cameraButton.css +13 -0
- package/src/selfie/cameraButton.tsx +35 -0
- package/src/selfie/capture.css +57 -0
- package/src/selfie/capture.tsx +232 -0
- package/src/selfie/errorModal.tsx +218 -0
- package/src/selfie/errorModalContent.css +33 -0
- package/src/selfie/errorModalContent.tsx +44 -0
- package/src/selfie/faceOutline.css +5 -0
- package/src/selfie/faceOutline.tsx +22 -0
- package/src/selfie/loadingBorder.css +12 -0
- package/src/selfie/loadingBorder.tsx +77 -0
- package/src/selfie/manualCaptureButton.css +13 -0
- package/src/selfie/manualCaptureButton.tsx +35 -0
- package/src/selfie/noMoreAttemptsModal.tsx +44 -0
- package/src/selfie/notification.css +9 -0
- package/src/selfie/notification.tsx +36 -0
- package/src/selfie/retryErrorModal.tsx +56 -0
- package/src/selfie/selfie.test.tsx +458 -0
- package/src/selfie/selfie.tsx +83 -0
- package/src/selfie/selfieTutorial.json +2626 -0
- package/src/selfie/styles.css +1 -0
- package/src/selfie/tutorial.test.tsx +200 -0
- package/src/selfie/tutorial.tsx +43 -0
- package/src/setup.ts +33 -0
- package/src/shared/baseTutorial/baseTutorial.css +21 -0
- package/src/shared/baseTutorial/baseTutorial.test.tsx +184 -0
- package/src/shared/baseTutorial/baseTutorial.tsx +55 -0
- package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +267 -0
- package/src/shared/baseTutorial/replaceBaseTutorial.ts +68 -0
- package/src/shared/button/button.css +55 -0
- package/src/shared/button/button.test.tsx +101 -0
- package/src/shared/button/button.tsx +47 -0
- package/src/shared/componentRoot/incodeComponent.tsx +12 -0
- package/src/shared/countries/countries.test.ts +75 -0
- package/src/shared/countries/countries.ts +139 -0
- package/src/shared/countries/index.ts +6 -0
- package/src/shared/icons/chevronDown.tsx +22 -0
- package/src/shared/icons/index.ts +2 -0
- package/src/shared/icons/successIcon.css +5 -0
- package/src/shared/icons/successIcon.test.tsx +40 -0
- package/src/shared/icons/successIcon.tsx +26 -0
- package/src/shared/loader/loadingIcon.css +28 -0
- package/src/shared/loader/loadingIcon.tsx +67 -0
- package/src/shared/lottie/lottie.tsx +108 -0
- package/src/shared/otpInput/otpInput.css +85 -0
- package/src/shared/otpInput/otpInput.test.tsx +356 -0
- package/src/shared/otpInput/otpInput.tsx +241 -0
- package/src/shared/page/incode-logo.svg +3 -0
- package/src/shared/page/page.css +47 -0
- package/src/shared/page/page.test.tsx +97 -0
- package/src/shared/page/page.tsx +91 -0
- package/src/shared/page/pageUiConfig.test.ts +112 -0
- package/src/shared/page/pageUiConfig.ts +64 -0
- package/src/shared/page/verifiedByIncode.css +5 -0
- package/src/shared/page/verifiedByIncode.tsx +75 -0
- package/src/shared/spacer/spacer.css +149 -0
- package/src/shared/spacer/spacer.test.tsx +143 -0
- package/src/shared/spacer/spacer.tsx +88 -0
- package/src/shared/spinner/index.ts +2 -0
- package/src/shared/spinner/spinner.css +28 -0
- package/src/shared/spinner/spinner.test.tsx +82 -0
- package/src/shared/spinner/spinner.tsx +65 -0
- package/src/shared/title/title.css +7 -0
- package/src/shared/title/title.tsx +12 -0
- package/src/shared/uiConfig/uiConfig.ts +36 -0
- package/src/shared/webComponent/incodeModule.ts +29 -0
- package/src/shared/webComponent/registerIncodeElement.ts +15 -0
- package/src/styles/__mocks__/fetchTheme.ts +19 -0
- package/src/styles/applyTheme.ts +37 -0
- package/src/styles/cn.test.tsx +57 -0
- package/src/styles/cn.tsx +21 -0
- package/src/styles/core.css +12 -0
- package/src/styles/fetchTheme.test.ts +390 -0
- package/src/styles/fetchTheme.ts +88 -0
- package/src/styles/generatePalette.ts +111 -0
- package/src/styles/reset.css +65 -0
- package/src/styles/resolveCssVariableToHex.ts +28 -0
- package/src/styles/tailwind.css +291 -0
- package/src/styles/themeTypes.ts +18 -0
- package/src/styles/tokens/colors.css +190 -0
- package/src/styles/tokens/components.css +174 -0
- package/src/styles/tokens/index.css +4 -0
- package/src/styles/tokens/primitives.css +129 -0
- package/src/styles/tokens/semantic.css +51 -0
- package/src/svg.d.ts +4 -0
- package/src/types/assets.d.ts +1 -0
- package/src/types/custom-elements.d.ts +104 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +260 -0
- package/vitest.config.ts +40 -0
- package/vitest.setup.ts +16 -0
package/dev/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# UI Dev Demos
|
|
2
|
+
|
|
3
|
+
This folder contains various demo files to test and demonstrate different integration patterns for the Incode Web SDK.
|
|
4
|
+
|
|
5
|
+
## Running the Demos
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd packages/ui
|
|
9
|
+
pnpm dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Then open the landing page at `/dev/index.html` to see all available demos.
|
|
13
|
+
|
|
14
|
+
### Landing Page
|
|
15
|
+
|
|
16
|
+
The landing page (`/dev/index.html`) provides:
|
|
17
|
+
- Overview of all integration patterns
|
|
18
|
+
- Config ID input field (persisted to localStorage)
|
|
19
|
+
- Quick links to each demo with configId passed as query parameter
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Demo Scenarios
|
|
24
|
+
|
|
25
|
+
### 1. Simplified Flow (`/dev/simplified.html`)
|
|
26
|
+
|
|
27
|
+
**Files:** `simplified.html`, `main-simplified.tsx`
|
|
28
|
+
|
|
29
|
+
**Pattern:** Drop-in `<incode-flow>` web component
|
|
30
|
+
|
|
31
|
+
**Best for:** Customers who want the simplest integration with minimal code.
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<incode-flow id="flow"></incode-flow>
|
|
35
|
+
|
|
36
|
+
<script type="module">
|
|
37
|
+
import '@incodetech/ui/flow';
|
|
38
|
+
|
|
39
|
+
const flow = document.getElementById('flow');
|
|
40
|
+
flow.token = 'your-session-token';
|
|
41
|
+
flow.onComplete = (result) => {
|
|
42
|
+
console.log('Done!', result);
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**What it demonstrates:**
|
|
48
|
+
- Single web component handles everything
|
|
49
|
+
- No manual flow management needed
|
|
50
|
+
- Automatic module orchestration
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### 2. Orchestrated Flow with Custom UI (`/dev/orchestrated-flow.html`)
|
|
55
|
+
|
|
56
|
+
**Files:** `orchestrated-flow.html`, `main-orchestrated-flow.tsx`
|
|
57
|
+
|
|
58
|
+
**Pattern:** `createOrchestratedFlowManager` with custom UI components
|
|
59
|
+
|
|
60
|
+
**Best for:** Customers who want orchestration benefits but need custom UI.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
const [state, flowManager] = useManager(() =>
|
|
64
|
+
createOrchestratedFlowManager({
|
|
65
|
+
modules: { PHONE: phoneMachine },
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Render your own UI, signal completion when done
|
|
70
|
+
<Phone
|
|
71
|
+
config={config}
|
|
72
|
+
onFinish={() => flowManager.completeModule()}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**What it demonstrates:**
|
|
77
|
+
- Using the orchestrator directly
|
|
78
|
+
- Custom UI rendering based on flow state
|
|
79
|
+
- Signaling module completion with `completeModule()`
|
|
80
|
+
- Access to `finishStatus` when flow completes
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### 3. Manual Flow Control (`/dev/manual.html`)
|
|
85
|
+
|
|
86
|
+
**Files:** `manual.html`, `main-web-component.tsx`
|
|
87
|
+
|
|
88
|
+
**Pattern:** `createFlowManager` with manual `nextStep()` calls
|
|
89
|
+
|
|
90
|
+
**Best for:** Legacy pattern or customers needing full manual control.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
const [state, flowManager] = useManager(() => createFlowManager());
|
|
94
|
+
|
|
95
|
+
// Manually advance the flow
|
|
96
|
+
<Phone
|
|
97
|
+
config={config}
|
|
98
|
+
onFinish={() => flowManager.nextStep()}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**What it demonstrates:**
|
|
103
|
+
- Original flow manager (non-orchestrated)
|
|
104
|
+
- Manual step advancement
|
|
105
|
+
- Full control over flow progression
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### 4. Headless Demo (`/dev/headless.html`)
|
|
110
|
+
|
|
111
|
+
**Files:** `headless.html`, `main-headless.tsx`
|
|
112
|
+
|
|
113
|
+
**Pattern:** Core SDK only, custom vanilla UI
|
|
114
|
+
|
|
115
|
+
**Best for:** Customers building completely custom UIs (React, Vue, vanilla JS, etc.)
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { createPhoneManager } from '@incodetech/core/phone';
|
|
119
|
+
|
|
120
|
+
const manager = createPhoneManager({ config });
|
|
121
|
+
|
|
122
|
+
// Subscribe to state changes
|
|
123
|
+
manager.subscribe((state) => {
|
|
124
|
+
// Render your own UI based on state
|
|
125
|
+
renderCustomUI(state);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Call manager methods
|
|
129
|
+
manager.setPhoneNumber('+1234567890', true);
|
|
130
|
+
manager.submit();
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**What it demonstrates:**
|
|
134
|
+
- Using Core SDK without any Incode UI components
|
|
135
|
+
- Building custom UI with vanilla JavaScript (or any framework)
|
|
136
|
+
- Full state machine visibility and control
|
|
137
|
+
- Manager pattern API
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Comparison Chart
|
|
142
|
+
|
|
143
|
+
| Demo | Flow Manager | UI Components | Complexity | Use Case |
|
|
144
|
+
|------|--------------|---------------|------------|----------|
|
|
145
|
+
| Simplified | Orchestrated (internal) | `<incode-flow>` | ⭐ Lowest | Drop-in integration |
|
|
146
|
+
| Orchestrated | `createOrchestratedFlowManager` | Incode UI | ⭐⭐ Medium | Custom flow, Incode UI |
|
|
147
|
+
| Manual | `createFlowManager` | Incode UI | ⭐⭐⭐ Higher | Full manual control |
|
|
148
|
+
| Headless | None | Custom | ⭐⭐⭐⭐ Highest | Fully custom UI |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Architecture Layers
|
|
153
|
+
|
|
154
|
+
All demos follow the three-layer architecture:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Layer 2 (UI) → Preact components, CSS, web components
|
|
158
|
+
Layer 1 (Core) → State machines, managers, business logic
|
|
159
|
+
Layer 0 (Infra) → Browser APIs, WASM, utilities
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
See `/docs/ARCHITECTURE_GOALS.md` for full details.
|
|
163
|
+
|
package/dev/getToken.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// this never will be export or use in production, this is for development purposes only
|
|
2
|
+
|
|
3
|
+
const DEFAULT_CONFIG_ID = '67ddc65d36b9814a930c4dff';
|
|
4
|
+
|
|
5
|
+
export function getConfigIdFromUrl(): string {
|
|
6
|
+
const params = new URLSearchParams(window.location.search);
|
|
7
|
+
return params.get('configId') ?? DEFAULT_CONFIG_ID;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type GetTokenOptions = {
|
|
11
|
+
configId?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const getToken = async (options: GetTokenOptions = {}) => {
|
|
15
|
+
const configId = options.configId ?? getConfigIdFromUrl();
|
|
16
|
+
|
|
17
|
+
const response = await fetch(
|
|
18
|
+
'https://user-service-k8s.stage.incodetest.com/omni/start',
|
|
19
|
+
{
|
|
20
|
+
headers: {
|
|
21
|
+
'x-api-key': '5fbc0ab5a652b7808fbec42fffd8b4c9ec248413',
|
|
22
|
+
'api-version': '1.0',
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
Accept: 'application/json',
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
configurationId: configId,
|
|
28
|
+
uuid: null,
|
|
29
|
+
interviewId: null,
|
|
30
|
+
language: 'en-US',
|
|
31
|
+
}),
|
|
32
|
+
method: 'POST',
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
return response.json();
|
|
36
|
+
};
|