@resulticks/trustsignal-wa-hsm 0.6.0 → 0.7.0
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/README.md +118 -94
- package/dist/resulticks-trustsignal-wa-hsm.cjs.js +27 -22
- package/dist/resulticks-trustsignal-wa-hsm.es.js +1161 -1148
- package/dist/style.css +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -1,94 +1,118 @@
|
|
|
1
|
-
# TrustSignal WebSDK (Library)
|
|
2
|
-
|
|
3
|
-
This package exposes two React components that you can drop into your app:
|
|
4
|
-
|
|
5
|
-
- `Dashboard`: list and entry point
|
|
6
|
-
- `CreateTemplate`: the template builder screen
|
|
7
|
-
- `TrustSignalProvider`: wraps your app and provides the API key/config
|
|
8
|
-
|
|
9
|
-
The library ships its own compiled styles, so you only need to import the CSS once.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm i @resulticks/trustsignal react react-dom
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
> react
|
|
18
|
-
|
|
19
|
-
## Quick Start (Routing
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import {
|
|
25
|
-
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
26
|
-
import "@resulticks/trustsignal/style.css";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
# TrustSignal WebSDK (Library)
|
|
2
|
+
|
|
3
|
+
This package exposes two React components that you can drop into your app:
|
|
4
|
+
|
|
5
|
+
- `Dashboard`: list and entry point
|
|
6
|
+
- `CreateTemplate`: the template builder screen
|
|
7
|
+
- `TrustSignalProvider`: wraps your app and provides the API key/config
|
|
8
|
+
|
|
9
|
+
The library ships its own compiled styles, so you only need to import the CSS once.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @resulticks/trustsignal react react-dom
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> react and react-dom are peer dependencies and must be installed in the host app.
|
|
18
|
+
|
|
19
|
+
## Quick Start (State-Based Toggling - No Routing Required)
|
|
20
|
+
|
|
21
|
+
The components can be toggled using React state without requiring any routing library. Simply manage the view state and pass callbacks to handle navigation between components.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { useState } from "react";
|
|
25
|
+
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
26
|
+
import "@resulticks/trustsignal/style.css";
|
|
27
|
+
|
|
28
|
+
type View = 'dashboard' | 'create' | 'edit';
|
|
29
|
+
|
|
30
|
+
export default function App() {
|
|
31
|
+
const [currentView, setCurrentView] = useState<View>('dashboard');
|
|
32
|
+
const [editId, setEditId] = useState<string | null>(null);
|
|
33
|
+
|
|
34
|
+
const handleCreateTemplate = () => {
|
|
35
|
+
setEditId(null);
|
|
36
|
+
setCurrentView('create');
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleEditTemplate = (id: string) => {
|
|
40
|
+
setEditId(id);
|
|
41
|
+
setCurrentView('edit');
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleBackToDashboard = () => {
|
|
45
|
+
setCurrentView('dashboard');
|
|
46
|
+
setEditId(null);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<TrustSignalProvider
|
|
51
|
+
apiKey="YOUR_API_KEY"
|
|
52
|
+
pConfig={{
|
|
53
|
+
baseUrl: process.env.RESUL_BASE_URL,
|
|
54
|
+
departmentId: Number(process.env.RESUL_DEPARTMENT_ID),
|
|
55
|
+
clientId: Number(process.env.RESUL_CLIENT_ID),
|
|
56
|
+
createdBy: Number(process.env.RESUL_CREATED_BY),
|
|
57
|
+
userId: Number(process.env.RESUL_USER_ID),
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{currentView === 'dashboard' ? (
|
|
61
|
+
<Dashboard
|
|
62
|
+
onCreateTemplate={handleCreateTemplate}
|
|
63
|
+
onEditTemplate={handleEditTemplate}
|
|
64
|
+
/>
|
|
65
|
+
) : (
|
|
66
|
+
<CreateTemplate
|
|
67
|
+
editId={editId || undefined}
|
|
68
|
+
onCancel={handleBackToDashboard}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</TrustSignalProvider>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Component Props
|
|
77
|
+
|
|
78
|
+
#### Dashboard
|
|
79
|
+
- `onCreateTemplate?: () => void` - Callback when user clicks to create a new template
|
|
80
|
+
- `onEditTemplate?: (id: string) => void` - Callback when user clicks to edit a template (receives template ID)
|
|
81
|
+
|
|
82
|
+
#### CreateTemplate
|
|
83
|
+
- `editId?: string` - Optional template ID to edit. If provided, the component will load and edit that template.
|
|
84
|
+
- `onCancel?: () => void` - Callback when user clicks the Back button to return to dashboard
|
|
85
|
+
|
|
86
|
+
### Notes
|
|
87
|
+
- Import the stylesheet once: `import "@resulticks/trustsignal/style.css";`
|
|
88
|
+
- The provider writes the `apiKey` (and optional `pConfig` metadata) to `localStorage('account')` so all API calls work without additional wiring.
|
|
89
|
+
- Pass `pConfig` if you need to override meta identifiers (`departmentId`, `clientId`, `createdBy`, `userId`) and/or `baseUrl` for the Resul API submission; updates propagate automatically.
|
|
90
|
+
- Consider sourcing `pConfig` values from env variables (as in the example) to simplify environment-specific deployments.
|
|
91
|
+
- **No routing required**: The components work with simple state toggling, making integration easier without needing react-router-dom.
|
|
92
|
+
|
|
93
|
+
## Local Development / Building the Library (inside this repo)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Build the library bundles to dist/
|
|
97
|
+
npm run build:lib
|
|
98
|
+
|
|
99
|
+
# (optional) link into another project while developing
|
|
100
|
+
# in this repo
|
|
101
|
+
npm pack # or use a local link strategy
|
|
102
|
+
# then in your host project
|
|
103
|
+
npm i ../path/to/@resulticks/trustsignal-*.tgz
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The library exports:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
CSS is automatically included via the package metadata, but you can also explicitly import it early in your app entry to ensure styles load before first paint:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import "@resulticks/trustsignal/style.css";
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
That's it—drop in `Dashboard` and toggle to `CreateTemplate` when the user clicks create. No routing library needed!
|