@visma-swno/customer-onboarding-wizard 1.0.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 ADDED
@@ -0,0 +1,233 @@
1
+ # Customer Onboarding Wizard
2
+
3
+ A modern Web Component built with Lit for managing customer onboarding workflows.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Built with Lit and TypeScript
8
+ - 📦 Bundled with Vite
9
+ - ✅ Fully tested with Vitest
10
+ - 🎨 Customizable with CSS variables
11
+ - 🔧 Type-safe with TypeScript strict mode
12
+ - 📱 Responsive and accessible
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @visma-swno/customer-onboarding-wizard
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Basic Usage
23
+
24
+ ```html
25
+ <vsn-customer-onboarding-wizard
26
+ baseUrl="https://api.example.com"
27
+ taskId="task-12345"
28
+ customerId="customer-67890"
29
+ locale="en-GB">
30
+ </vsn-customer-onboarding-wizard>
31
+ ```
32
+
33
+ ### With Module Import
34
+
35
+ ```javascript
36
+ import '@visma-swno/customer-onboarding-wizard';
37
+
38
+ // Or import specific components
39
+ import { CustomerOnboardingWizard } from '@visma-swno/customer-onboarding-wizard';
40
+ ```
41
+
42
+ ## Properties
43
+
44
+ | Property | Type | Default | Required | Description |
45
+ |----------|------|---------|----------|-------------|
46
+ | `baseUrl` | String | `''` | **Yes** | Base URL for API calls (e.g., 'https://api.example.com') |
47
+ | `taskId` | String | `''` | No | Onboarding task ID. Required for saving progress (`save and close`) and completing the wizard; omitting it skips those API calls |
48
+ | `customerId` | String | `''` | **Yes** | Customer ID used to load company information in Step 1 (Company) |
49
+ | `locale` | String | `'en-GB'` | No | Locale for translations (en-GB, en-US, da-DK, fi-FI, nb-NO, nl-NL, sv-SE) |
50
+ | `step` | String | `'welcome'` | No | Initial step to navigate to: `welcome`, `company`, `administrators`, `partner-access`, `complete` |
51
+ | `adminUrl` | String | `''` | No | Absolute `http`/`https` URL to redirect to after task cleanup when the user clicks "Go to Admin" on the completion step. Relative paths and other schemes are ignored and the wizard closes without redirecting. |
52
+
53
+ ## CSS Custom Properties
54
+
55
+ Customize the appearance using CSS variables:
56
+
57
+ ```css
58
+ vsn-customer-onboarding-wizard {
59
+ /* Parent application should load font files and set this variable */
60
+ --font-family: Inter, ui-sans-serif, system-ui, sans-serif;
61
+ }
62
+ ```
63
+
64
+ ### Available CSS Variables
65
+
66
+ | Variable | Default | Description |
67
+ |----------|---------|-------------|
68
+ | `--font-family` | System fonts fallback | **Required**: Parent application should provide font files and set this variable to avoid duplicate font loading |
69
+
70
+ ### Font Configuration
71
+
72
+ **Important**: This component does NOT bundle font files. The parent application must:
73
+
74
+ 1. Load font files (e.g., Inter font via `@font-face` or CDN)
75
+ 2. Set the `--font-family` CSS variable
76
+
77
+ ```html
78
+ <style>
79
+ /* Load fonts in parent application */
80
+ @font-face {
81
+ font-family: 'Inter';
82
+ src: url('/fonts/Inter-Regular.woff2') format('woff2');
83
+ font-weight: 400;
84
+ }
85
+
86
+ @font-face {
87
+ font-family: 'Inter';
88
+ src: url('/fonts/Inter-Medium.woff2') format('woff2');
89
+ font-weight: 500;
90
+ }
91
+
92
+ @font-face {
93
+ font-family: 'Inter';
94
+ src: url('/fonts/Inter-SemiBold.woff2') format('woff2');
95
+ font-weight: 600;
96
+ }
97
+
98
+ /* Set font variable for component */
99
+ vsn-customer-onboarding-wizard {
100
+ --font-family: Inter, ui-sans-serif, system-ui, sans-serif;
101
+ }
102
+ </style>
103
+
104
+ <vsn-customer-onboarding-wizard baseUrl="https://api.example.com"></vsn-customer-onboarding-wizard>
105
+ ```
106
+
107
+ **Font Requirements**:
108
+ - Font weights needed: 400 (Regular), 500 (Medium), 600 (SemiBold)
109
+ - Recommended font: Inter (see `fonts/README.md` for download links)
110
+
111
+ ## Events
112
+
113
+ The component emits custom events for host application integration:
114
+
115
+ ### `request-token`
116
+
117
+ **Emitted**: Once during component initialization
118
+
119
+ **Purpose**: Request OAuth2 access token from host application
120
+
121
+ **Detail**:
122
+ ```typescript
123
+ {
124
+ callback: (token: string | null) => void
125
+ }
126
+ ```
127
+
128
+ **Usage**:
129
+ ```javascript
130
+ document.addEventListener('request-token', async (event) => {
131
+ const token = sessionStorage.getItem('accessToken');
132
+ event.detail.callback(token);
133
+ });
134
+ ```
135
+
136
+ ### `http-error`
137
+
138
+ **Emitted**: Only for authentication/authorization errors (401, 403)
139
+
140
+ **Purpose**: Allow host application to handle auth errors (e.g., refresh token on 401, redirect on 403)
141
+
142
+ **Note**: All other errors (400, 422, 500, network errors) are **automatically displayed by the component** via an internal error banner. No handling required by host application.
143
+
144
+ **Detail**:
145
+ ```typescript
146
+ {
147
+ status: number; // 401 or 403 only
148
+ statusText: string; // HTTP status text
149
+ message: string; // Error message
150
+ endpoint: string; // Failed endpoint
151
+ method: string; // HTTP method
152
+ retry: () => Promise<any>; // Retry callback
153
+ }
154
+ ```
155
+
156
+ **Usage**:
157
+ ```javascript
158
+ document.addEventListener('http-error', async (event) => {
159
+ const { status, retry } = event.detail;
160
+
161
+ if (status === 401) {
162
+ // Refresh token
163
+ const newToken = await fetchNewToken();
164
+
165
+ // Update component token
166
+ document.querySelector('vsn-customer-onboarding-wizard').updateToken(newToken);
167
+
168
+ // Retry failed request
169
+ await retry();
170
+ }
171
+
172
+ if (status === 403) {
173
+ // Handle permission denied
174
+ window.location.href = '/access-denied';
175
+ }
176
+ });
177
+ ```
178
+
179
+ ### `error-message` (Internal)
180
+
181
+ **Emitted**: For validation errors, server errors, and network errors
182
+
183
+ **Purpose**: Component listens to this event internally and displays a translated error banner
184
+
185
+ **Detail**:
186
+ ```typescript
187
+ {
188
+ status: number; // HTTP status code or 0 for network errors
189
+ errorKey: string; // Translation key (e.g., 'serverError', 'validationError')
190
+ endpoint: string; // Failed endpoint
191
+ method: string; // HTTP method
192
+ }
193
+ ```
194
+
195
+ **Handled Automatically**: Host application does not need to listen to this event. The component:
196
+ - Displays a red error banner at the top of the wizard
197
+ - Automatically translates error title and message to the user's selected language
198
+ - Supports all 7 languages: da-DK, en-GB, en-US, fi-FI, nb-NO, nl-NL, sv-SE
199
+ - Banner remains visible until the user manually dismisses it by clicking the X button
200
+ - Allows users to report errors to support
201
+
202
+ ## Public Methods
203
+
204
+ ### `updateToken(token: string | null)`
205
+
206
+ Update the authentication token. Call this method after refreshing the token.
207
+
208
+ ```javascript
209
+ const wizard = document.querySelector('vsn-customer-onboarding-wizard');
210
+ wizard.updateToken('new-access-token');
211
+ ```
212
+
213
+ ## Development
214
+
215
+ See [DEVELOPER-GUIDE.md](./DEVELOPER-GUIDE.md) for development instructions.
216
+
217
+ ## Testing
218
+
219
+ See [TESTING-SETUP.md](./TESTING-SETUP.md) for testing documentation.
220
+
221
+ ## Browser Support
222
+
223
+ - Chrome/Edge (latest)
224
+ - Firefox (latest)
225
+ - Safari (latest)
226
+
227
+ ## License
228
+
229
+ ISC
230
+
231
+ ## Contributing
232
+
233
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Binary file
Binary file
Binary file