@stokr/components-library 3.0.32 → 3.0.33
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 +72 -287
- package/dist/components/2FA/login-with-otp-flow.js +2 -2
- package/dist/components/Button/GlareButton.js +273 -0
- package/dist/components/Header/Header.js +1 -1
- package/dist/components/Layout/Layout.js +6 -3
- package/dist/components/icons/LinkIcon.js +2 -2
- package/dist/index.js +2 -0
- package/dist/runtime-config.js +1 -1
- package/dist/static/country-list.json +251 -251
- package/dist/static/fonts/Ionicons/ionicons.min.css +2810 -2810
- package/dist/static/fonts/Ionicons/ionicons.min.css.js +1 -1
- package/dist/static/fonts/icomoon/selection.json +910 -910
- package/dist/static/fonts/icomoon/style.css +139 -139
- package/dist/static/images/copy_icon.svg +4 -4
- package/dist/static/images/download_icon.svg +3 -3
- package/dist/static/images/numbers/number_eight.svg +3 -3
- package/dist/static/images/numbers/number_five.svg +4 -4
- package/dist/static/images/numbers/number_four.svg +3 -3
- package/dist/static/images/numbers/number_nine.svg +4 -4
- package/dist/static/images/numbers/number_one.svg +4 -4
- package/dist/static/images/numbers/number_seven.svg +4 -4
- package/dist/static/images/numbers/number_six.svg +4 -4
- package/dist/static/images/numbers/number_three.svg +3 -3
- package/dist/static/images/numbers/number_two.svg +4 -4
- package/dist/static/images/numbers/number_zero.svg +3 -3
- package/dist/static/images/plus-icon.svg +4 -4
- package/dist/static/images/search-icon.svg +3 -3
- package/dist/static/images/transfer-icon.svg +10 -10
- package/dist/static/images/warning-filled.svg +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,96 +1,43 @@
|
|
|
1
1
|
# @stokr/components-library
|
|
2
2
|
|
|
3
|
-
React
|
|
4
|
-
|
|
5
|
-
## Table of contents
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [How to start](#how-to-start)
|
|
9
|
-
- [Configuration](#configuration)
|
|
10
|
-
- [Runtime config (npm consumers)](#runtime-config)
|
|
11
|
-
- [URL variables and behavior](#url-variables-and-behavior)
|
|
12
|
-
- [Reading config with `getConfig()`](#reading-config-with-getconfig)
|
|
13
|
-
- [Ionicons](#ionicons)
|
|
14
|
-
- [React Router](#react-router)
|
|
15
|
-
- [Troubleshooting](#troubleshooting)
|
|
16
|
-
- [Development & publishing](#development--publishing)
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install @stokr/components-library
|
|
24
|
-
```
|
|
3
|
+
React UI library for STOKR apps: modals, forms, navigation, tables, auth context, styles.
|
|
25
4
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install react react-dom styled-components react-router-dom
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
- **React** 18 or 19
|
|
33
|
-
- **styled-components** 6.x
|
|
34
|
-
- **react-router-dom** 6.x (required if you use routing-dependent components)
|
|
35
|
-
|
|
36
|
-
---
|
|
5
|
+
## Contents
|
|
37
6
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
2. **Router** — Wrap the tree with `BrowserRouter` (or another React Router v6 router) if you use `HeaderHo`, `MainMenu`, `LearnMore`, etc. If the host app may already provide a router (e.g. micro-frontend), use **`RouterWrapper`** from the package once at your root so you do not nest two `BrowserRouter` instances (see [step 2](#2-wrap-your-app-with-a-router-if-you-use-routing)).
|
|
44
|
-
3. **Runtime config** — Wrap your authenticated area with `<AuthProvider config={…}>` and pass **your** `import.meta.env.VITE_*` values (see [Runtime config](#runtime-config)). This is required for correct API URLs, Firebase, cookies, and domain-based links in pre-built npm installs.
|
|
45
|
-
4. **Optional** — `configure()` before `AuthProvider` if something (e.g. analytics) must read config earlier; `IoniconsStyles` or `styles.css` if you use icons or shared fonts (see below).
|
|
46
|
-
|
|
47
|
-
Then import components from `@stokr/components-library` as in [step 4 under How to start](#4-import-and-use-components).
|
|
7
|
+
- [Quick start](#quick-start) — install, router, `AuthProvider`, styles
|
|
8
|
+
- [Configuration reference](#runtime-config) — `config` keys & helpers
|
|
9
|
+
- [AuthProvider & AuthContext](#authprovider-optional-props)
|
|
10
|
+
- [Troubleshooting](#troubleshooting)
|
|
11
|
+
- [Development](#development--publishing)
|
|
48
12
|
|
|
49
13
|
---
|
|
50
14
|
|
|
51
|
-
##
|
|
15
|
+
## Quick start
|
|
52
16
|
|
|
53
|
-
|
|
17
|
+
**Install**
|
|
54
18
|
|
|
55
19
|
```bash
|
|
56
|
-
npm install @stokr/components-library
|
|
20
|
+
npm install @stokr/components-library
|
|
21
|
+
npm install react react-dom styled-components react-router-dom
|
|
57
22
|
```
|
|
58
23
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Components that use navigation (e.g. `MainMenu`, `LearnMore`, `HeaderHo`) must live inside a React Router.
|
|
24
|
+
Peers: React 18+/19+, styled-components 6.x, react-router-dom 6.x when you use routing-driven components (`HeaderHo`, `MainMenu`, …).
|
|
62
25
|
|
|
63
|
-
**
|
|
26
|
+
**1. Router** — Navigation helpers need a React Router:
|
|
64
27
|
|
|
65
28
|
```jsx
|
|
66
|
-
// main.jsx or App.jsx
|
|
67
29
|
import { BrowserRouter } from 'react-router-dom'
|
|
68
|
-
import App from './App'
|
|
69
|
-
|
|
70
|
-
root.render(
|
|
71
|
-
<BrowserRouter>
|
|
72
|
-
<App />
|
|
73
|
-
</BrowserRouter>,
|
|
74
|
-
)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Host already has a router** (or you want one `BrowserRouter` only when needed) — wrap the library subtree with **`RouterWrapper`** from `@stokr/components-library`. It renders `BrowserRouter` only when `useInRouterContext()` is false, so you avoid duplicate routers and keep SPA navigation for `withRouter` / `useNavigate`:
|
|
78
|
-
|
|
79
|
-
```jsx
|
|
80
30
|
import { RouterWrapper } from '@stokr/components-library'
|
|
81
|
-
import { BrowserRouter } from 'react-router-dom'
|
|
82
|
-
import App from './App'
|
|
83
31
|
|
|
84
|
-
//
|
|
32
|
+
// Normal app
|
|
85
33
|
root.render(
|
|
86
34
|
<BrowserRouter>
|
|
87
|
-
<
|
|
88
|
-
<App />
|
|
89
|
-
</RouterWrapper>
|
|
35
|
+
<App />
|
|
90
36
|
</BrowserRouter>,
|
|
91
37
|
)
|
|
92
38
|
|
|
93
|
-
//
|
|
39
|
+
// Outside a Router: RouterWrapper wraps children in BrowserRouter once.
|
|
40
|
+
// Inside an existing Router: it renders children only (no nested BrowserRouter).
|
|
94
41
|
root.render(
|
|
95
42
|
<RouterWrapper>
|
|
96
43
|
<App />
|
|
@@ -98,53 +45,12 @@ root.render(
|
|
|
98
45
|
)
|
|
99
46
|
```
|
|
100
47
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
If you use **Modal**, **ConfirmModal**, **BackButton**, **Select**, **InfoIcon**, etc., add the icon styles once at the root:
|
|
104
|
-
|
|
105
|
-
```jsx
|
|
106
|
-
import { IoniconsStyles } from '@stokr/components-library'
|
|
107
|
-
|
|
108
|
-
function App() {
|
|
109
|
-
return (
|
|
110
|
-
<>
|
|
111
|
-
<IoniconsStyles />
|
|
112
|
-
{/* your app */}
|
|
113
|
-
</>
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
You can skip this; the library will inject icon styles when you first use a component that needs them.
|
|
119
|
-
|
|
120
|
-
### 4. Import and use components
|
|
121
|
-
|
|
122
|
-
```jsx
|
|
123
|
-
import { ConfirmModal, Button } from '@stokr/components-library'
|
|
124
|
-
|
|
125
|
-
function MyPage() {
|
|
126
|
-
const [open, setOpen] = useState(false)
|
|
127
|
-
return (
|
|
128
|
-
<>
|
|
129
|
-
<Button onClick={() => setOpen(true)}>Open</Button>
|
|
130
|
-
<ConfirmModal isOpen={open} onClose={() => setOpen(false)} onConfirm={() => {}} title="Confirm?" />
|
|
131
|
-
</>
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Configuration
|
|
139
|
-
|
|
140
|
-
### Runtime config (required when consuming as npm package) {#runtime-config}
|
|
141
|
-
|
|
142
|
-
Since v3.0.16, the library uses a **runtime config** system. When this package is consumed by an external Vite app, `import.meta.env` values are baked at **library build time** and do not reflect the consuming app's `.env` file. Pass a `config` prop to `<AuthProvider>` so API URLs, Firebase credentials, and cookie domain are resolved from **your** environment:
|
|
48
|
+
**2. Auth & runtime config (required when consuming via npm)** — Vite freezes `import.meta.env` inside pre-built deps, so push your `.env` at runtime via `config`:
|
|
143
49
|
|
|
144
50
|
```jsx
|
|
145
51
|
import { AuthProvider } from '@stokr/components-library'
|
|
146
52
|
|
|
147
|
-
function App() {
|
|
53
|
+
export default function App() {
|
|
148
54
|
return (
|
|
149
55
|
<AuthProvider
|
|
150
56
|
config={{
|
|
@@ -167,215 +73,94 @@ function App() {
|
|
|
167
73
|
measurementId: import.meta.env.VITE_FIREBASE_MEASUREMENT_ID,
|
|
168
74
|
},
|
|
169
75
|
}}>
|
|
170
|
-
{/*
|
|
76
|
+
{/* app */}
|
|
171
77
|
</AuthProvider>
|
|
172
78
|
)
|
|
173
79
|
}
|
|
174
80
|
```
|
|
175
81
|
|
|
176
|
-
|
|
177
|
-
| -------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
178
|
-
| `apiUrl` | `VITE_API_URL` | Backend API base URL |
|
|
179
|
-
| `baseUrlPublic` | `VITE_BASE_URL_PUBLIC` | Public (no-auth) API base URL |
|
|
180
|
-
| `cookieDomain` | `VITE_COOKIE_DOMAIN` | Domain attribute for auth cookies |
|
|
181
|
-
| `websiteDomain` | `VITE_WEBSITE_DOMAIN` | Platform domain (redirects, links) |
|
|
182
|
-
| `photoApiUrl` | `VITE_PHOTO_API_URL` | Photo upload / avatar API URL |
|
|
183
|
-
| `onboardingUrl` | `VITE_ONBOARDING_URL` | Full onboarding app URL (signup/signin flow) |
|
|
184
|
-
| `dashboardUrl` | `VITE_DASHBOARD_URL` | Full investor dashboard URL |
|
|
185
|
-
| `adminUrl` | `VITE_ADMIN_URL` | Full admin/venture dashboard URL |
|
|
186
|
-
| `registerUrl` | `VITE_REGISTER_URL` | Public registration entry URL |
|
|
187
|
-
| `firebase` | `VITE_FIREBASE_*` | Full Firebase config object |
|
|
188
|
-
|
|
189
|
-
> **Why is this needed?** With the old CRA / `react-scripts` build, Webpack re-processed library code through the consuming app's build pipeline, so the app's `.env` values were injected automatically. Vite treats npm packages as pre-built — `import.meta.env` values in the compiled library are frozen at library build time. The `config` prop passes them at runtime instead.
|
|
190
|
-
|
|
191
|
-
If you also need config values **before** `<AuthProvider>` mounts (e.g. for analytics init), you can call `configure()` directly:
|
|
192
|
-
|
|
193
|
-
```js
|
|
194
|
-
import { configure } from '@stokr/components-library'
|
|
195
|
-
|
|
196
|
-
configure({
|
|
197
|
-
apiUrl: import.meta.env.VITE_API_URL,
|
|
198
|
-
cookieDomain: import.meta.env.VITE_COOKIE_DOMAIN,
|
|
199
|
-
// ...
|
|
200
|
-
})
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
After `configure()` / `<AuthProvider config>`, the library may log a **one-time `console.warn`** listing any **`VITE_*`** variables that are still missing (no override and no env fallback). Fix your `.env` or extend the `config` object until the list is empty.
|
|
82
|
+
**3. Earlier config** (e.g. analytics before mount): `import { configure } from '@stokr/components-library'` with the same shape as `config`.
|
|
204
83
|
|
|
205
|
-
|
|
84
|
+
**4. Icons / fonts** — Optional: `<IoniconsStyles />` at root, or rely on lazy injection when a component uses icons; for Layout / Open Sans: `import '@stokr/components-library/styles.css'`.
|
|
206
85
|
|
|
207
|
-
|
|
86
|
+
**5. Imports** — `import { ConfirmModal, Button, … } from '@stokr/components-library'`.
|
|
208
87
|
|
|
209
|
-
|
|
88
|
+
Full URL env example:
|
|
210
89
|
|
|
211
90
|
```bash
|
|
212
|
-
VITE_WEBSITE_DOMAIN=
|
|
213
|
-
VITE_ONBOARDING_URL=https://signup.
|
|
214
|
-
VITE_DASHBOARD_URL=https://dashboard.
|
|
215
|
-
VITE_ADMIN_URL=https://admin.
|
|
216
|
-
VITE_REGISTER_URL=https://
|
|
91
|
+
VITE_WEBSITE_DOMAIN=example.com
|
|
92
|
+
VITE_ONBOARDING_URL=https://signup.example.com
|
|
93
|
+
VITE_DASHBOARD_URL=https://dashboard.example.com
|
|
94
|
+
VITE_ADMIN_URL=https://admin.example.com
|
|
95
|
+
VITE_REGISTER_URL=https://example.com/signup
|
|
217
96
|
```
|
|
218
97
|
|
|
219
|
-
How each value is used:
|
|
220
|
-
|
|
221
|
-
- `VITE_ONBOARDING_URL`: signup/signin flow redirects (for example `/welcome`, `/resend-activation-email`).
|
|
222
|
-
- `VITE_DASHBOARD_URL`: investor dashboard entry point.
|
|
223
|
-
- `VITE_ADMIN_URL`: admin/venture dashboard entry point.
|
|
224
|
-
- `VITE_REGISTER_URL`: register CTA/entry URL.
|
|
225
|
-
- `VITE_WEBSITE_DOMAIN`: base host used by `getPlatformURL()` and fixed subdomains (analytics/backoffice).
|
|
226
|
-
|
|
227
|
-
Derived helpers:
|
|
228
|
-
|
|
229
|
-
- `getPlatformURL()` => `https://{VITE_WEBSITE_DOMAIN}` (for example `https://stokr.info`).
|
|
230
|
-
- `getAnalyticsIngestUrl()` => `https://analytics.{VITE_WEBSITE_DOMAIN}`.
|
|
231
|
-
- `getBackofficeAppUrl('/path')` => `https://backoffice.{VITE_WEBSITE_DOMAIN}/path`.
|
|
232
|
-
|
|
233
|
-
**Authentication-only HTTP** — backend routes under `auth/*` (e.g. forgot password) are exposed as **`authenticationApi.post(segment, body)`** from `src/api/authenticationApi.js` (also re-exported from the package entry). The default axios instance is the **general API client** for all authenticated backend calls, not auth-only.
|
|
234
|
-
|
|
235
|
-
### Reading config with `getConfig()` {#reading-config-with-getconfig}
|
|
236
|
-
|
|
237
|
-
In your app (or in code next to the library), read the same resolved values the package uses:
|
|
238
|
-
|
|
239
|
-
```js
|
|
240
|
-
import { getConfig } from '@stokr/components-library'
|
|
241
|
-
|
|
242
|
-
const api = getConfig('apiUrl')
|
|
243
|
-
const domain = getConfig('websiteDomain')
|
|
244
|
-
const firebaseOptions = getConfig('firebase') // override object or env-built fallback
|
|
245
|
-
const onboarding = getConfig('onboardingUrl')
|
|
246
|
-
const dashboard = getConfig('dashboardUrl')
|
|
247
|
-
const admin = getConfig('adminUrl')
|
|
248
|
-
const register = getConfig('registerUrl')
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Supported keys: `apiUrl`, `baseUrlPublic`, `cookieDomain`, `websiteDomain`, `photoApiUrl`, `onboardingUrl`, `dashboardUrl`, `adminUrl`, `registerUrl`, `firebase`. Resolution order is always **explicit `configure()` / `AuthProvider` `config`** first, then **`import.meta.env`** in the consuming Vite app (where a `VITE_*` mapping exists).
|
|
252
|
-
|
|
253
|
-
**Marketing site origin** — the old `platformDomain` / `platformURL` exports were removed. Use **`getPlatformURL()`** for `https://{websiteDomain}`, or **`getConfig('websiteDomain')`** for the bare host (e.g. `"example.com"`). Both read the same runtime config after **`configure()`** / **`AuthProvider`**.
|
|
254
|
-
|
|
255
|
-
```js
|
|
256
|
-
import { getConfig, getPlatformURL } from '@stokr/components-library'
|
|
257
|
-
|
|
258
|
-
const host = getConfig('websiteDomain') // e.g. "example.com"
|
|
259
|
-
const origin = getPlatformURL() // e.g. "https://example.com"
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
**Footer link groups** — if you previously imported the static `footerGroups` from `FooterLayout`, import **`getFooterGroups`** instead (same package entry as other footer exports). It returns fresh URLs using the current `getPlatformURL()`.
|
|
263
|
-
|
|
264
|
-
### Ionicons
|
|
265
|
-
|
|
266
|
-
Components such as **Modal**, **ConfirmModal**, **BackButton**, **InfoIcon**, **Select**, **MainMenu**, and **RegisterLiquidSteps** use [Ionicons](http://ionicons.com/). You can enable them in three ways:
|
|
267
|
-
|
|
268
|
-
| Approach | When to use |
|
|
269
|
-
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
270
|
-
| **Global injection** | Render `<IoniconsStyles />` once at app root. Full icon set, singleton. |
|
|
271
|
-
| **No setup** | Don’t render anything; styles inject on first use of an icon component. |
|
|
272
|
-
| **CSS import** | Prefer loading via CSS: `import '@stokr/components-library/styles.css'` or `import '@stokr/components-library/ionicons.css'`. |
|
|
273
|
-
|
|
274
|
-
**Global injection example:**
|
|
275
|
-
|
|
276
|
-
```jsx
|
|
277
|
-
import { IoniconsStyles } from '@stokr/components-library'
|
|
278
|
-
|
|
279
|
-
function App() {
|
|
280
|
-
return (
|
|
281
|
-
<>
|
|
282
|
-
<IoniconsStyles />
|
|
283
|
-
{/* your routes, layout, etc. */}
|
|
284
|
-
</>
|
|
285
|
-
)
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
If you use **Layout**, **GlobalStyle**, or need **Open Sans**, import the full styles once:
|
|
290
|
-
|
|
291
|
-
```js
|
|
292
|
-
import '@stokr/components-library/styles.css'
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### React Router
|
|
296
|
-
|
|
297
|
-
Any component that uses `useNavigate()` or routing must be rendered inside a `Router` from `react-router-dom` (e.g. `BrowserRouter`), or under **`RouterWrapper`** so a router exists when the host does not provide one. Components wrapped with **`withRouter`** receive `navigate` from `useNavigate()` when inside a Router; outside a Router, `navigate` throws with a message to add `BrowserRouter` or `RouterWrapper`. See [How to start – step 2](#2-wrap-your-app-with-a-router-if-you-use-routing).
|
|
298
|
-
|
|
299
98
|
---
|
|
300
99
|
|
|
301
|
-
##
|
|
100
|
+
## Configuration reference {#runtime-config}
|
|
302
101
|
|
|
303
|
-
|
|
102
|
+
| `config` key | Typical `VITE_*` | Role |
|
|
103
|
+
| ----------------- | -------------------------- | ----------------------------------------- |
|
|
104
|
+
| `apiUrl` | `VITE_API_URL` | Authenticated REST base |
|
|
105
|
+
| `baseUrlPublic` | `VITE_BASE_URL_PUBLIC` | Public API base |
|
|
106
|
+
| `cookieDomain` | `VITE_COOKIE_DOMAIN` | Auth cookie `domain` attribute |
|
|
107
|
+
| `websiteDomain` | `VITE_WEBSITE_DOMAIN` | Bare host → links / `getPlatformURL()` |
|
|
108
|
+
| `photoApiUrl` | `VITE_PHOTO_API_URL` | Avatars / media |
|
|
109
|
+
| `onboardingUrl` | `VITE_ONBOARDING_URL` | Full signup/sign-in app URL |
|
|
110
|
+
| `dashboardUrl` | `VITE_DASHBOARD_URL` | Investor dashboard URL |
|
|
111
|
+
| `adminUrl` | `VITE_ADMIN_URL` | Venture / admin dashboard URL |
|
|
112
|
+
| `registerUrl` | `VITE_REGISTER_URL` | Public registration entry |
|
|
113
|
+
| `firebase` | `VITE_FIREBASE_*` | Firebase client config |
|
|
304
114
|
|
|
305
|
-
|
|
115
|
+
**Helpers:** `getConfig('…')` for any key above; `getPlatformURL()` → `https://{websiteDomain}`; `getAnalyticsIngestUrl()`, `getBackofficeAppUrl(path)`; **`getFooterGroups()`** replaces static footer URL lists.
|
|
306
116
|
|
|
307
|
-
|
|
308
|
-
import { BrowserRouter } from 'react-router-dom'
|
|
117
|
+
**Auth-only HTTP:** `authenticationApi.post(segment, body)` for `auth/*`; default axios stays the main API client after login.
|
|
309
118
|
|
|
310
|
-
|
|
311
|
-
<BrowserRouter>
|
|
312
|
-
<App />
|
|
313
|
-
</BrowserRouter>,
|
|
314
|
-
)
|
|
315
|
-
```
|
|
119
|
+
Missing overrides may trigger a **one-time** warning listing unresolved `VITE_*` expectations.
|
|
316
120
|
|
|
317
|
-
|
|
318
|
-
import { RouterWrapper } from '@stokr/components-library'
|
|
121
|
+
---
|
|
319
122
|
|
|
320
|
-
|
|
321
|
-
<RouterWrapper>
|
|
322
|
-
<App />
|
|
323
|
-
</RouterWrapper>,
|
|
324
|
-
)
|
|
325
|
-
```
|
|
123
|
+
## AuthProvider & AuthContext {#authprovider-optional-props}
|
|
326
124
|
|
|
327
|
-
|
|
125
|
+
`AuthProvider` is wrapped with **`withRouter`** — mount it inside a **`Router`** so redirects work.
|
|
328
126
|
|
|
329
|
-
###
|
|
127
|
+
### Optional provider props
|
|
330
128
|
|
|
331
|
-
|
|
129
|
+
- **`inactivityTimeMs`** — Idle timeout before auto-logout + session modal (default 5 min).
|
|
130
|
+
- **`accessTokenExpiryMs`** — Cookie TTL when **`Auth.setAccessToken`** runs (default **`DEFAULT_TOKEN_EXPIRY_MS`** = 1 h); not extended by **`getUser`** alone.
|
|
131
|
+
- **`hideInactivityModal`** — Suppress built-in session modal.
|
|
132
|
+
- **`customValidateGetUser(user)`** — Hook after **`user/get`** succeeds (see `src/context/AuthContext.js`).
|
|
332
133
|
|
|
333
|
-
|
|
334
|
-
`npm install react react-dom styled-components`
|
|
134
|
+
### AuthContext consumer {#authcontext-usecontext}
|
|
335
135
|
|
|
336
|
-
|
|
136
|
+
`import { AuthContext } from '…'` then `useContext(AuthContext)`.
|
|
337
137
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
dedupe: ['react', 'react-dom', 'styled-components'],
|
|
342
|
-
},
|
|
343
|
-
// ...rest of config
|
|
344
|
-
})
|
|
345
|
-
```
|
|
138
|
+
- **Invalid Firebase guard:** value is **`{ user: null, isFetchingUser: false }`** only (no methods).
|
|
139
|
+
- **State (grouped):** `user` / `firebaseUser`, `isFetchingUser`, `avatar`; MFA (`waitingFor2fa`, `userMfaEnrollment`, `firebaseError`); verify-email (`verifyEmailError`, `isVerifyingEmail`); session UX (`loggedOutDueToInactivity`, `loggedOutDueToCookieExpiry`, `sessionExpiryPendingReason`).
|
|
140
|
+
- **Actions (grouped):** `userRef`, `loginUser`, `logoutUser`, `getUser`, `setUser`, `updateUser`, `refreshIdToken`; `checkUserIsValid`, `checkTokenIsValid`; `uploadPhoto`, `deletePhoto`, `checkUserPhoto`; MFA enroll / verify / unenroll + `reset2faFlow`; subscription/onboarding helpers; password & email (`handleResetPassword`, `handleVerifyEmail`, `requestUpdateEmail`, …); wallets / PoA (`uploaProofOfAddress` keeps the source spelling); **`dismissSessionExpiryModal`**.
|
|
346
141
|
|
|
347
|
-
|
|
142
|
+
Use **`AuthConsumer`** for the render-prop pattern.
|
|
348
143
|
|
|
349
144
|
---
|
|
350
145
|
|
|
351
|
-
##
|
|
352
|
-
|
|
353
|
-
### Run Storybook
|
|
146
|
+
## Troubleshooting {#troubleshooting}
|
|
354
147
|
|
|
355
|
-
|
|
356
|
-
npm run storybook
|
|
357
|
-
```
|
|
148
|
+
**`useNavigate` / Router**
|
|
358
149
|
|
|
359
|
-
|
|
150
|
+
Add `BrowserRouter` (or **`RouterWrapper`** from this package where the shell has no router). Install `react-router-dom`.
|
|
360
151
|
|
|
361
|
-
|
|
152
|
+
**Invalid hook call / duplicated React**
|
|
362
153
|
|
|
363
|
-
|
|
364
|
-
npm run build:dist
|
|
365
|
-
```
|
|
154
|
+
Dedupe peers in Vite: `resolve: { dedupe: ['react', 'react-dom', 'styled-components'] }`.
|
|
366
155
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
### Publish a new version
|
|
370
|
-
|
|
371
|
-
1. Commit your changes.
|
|
372
|
-
2. Update [CHANGELOG.md](CHANGELOG.md) – add a new `# vX.Y.Z` section at the top with the list of changes.
|
|
373
|
-
3. Bump the version: `npm version <version>` (e.g. `npm version 3.0.7`).
|
|
374
|
-
4. (ensure you are authenticated) Run `npm login` to log first on NPM package (only needed one time a day)
|
|
375
|
-
5. Run `npm run pub` (will first run `npm run build:dist`).
|
|
156
|
+
---
|
|
376
157
|
|
|
377
|
-
|
|
158
|
+
## Development {#development--publishing}
|
|
378
159
|
|
|
379
|
-
|
|
160
|
+
| Command | Meaning |
|
|
161
|
+
| -------------------- | -------------------------------- |
|
|
162
|
+
| `npm run storybook` | Local docs / stories |
|
|
163
|
+
| `npm run build:dist` | Library build + static copy |
|
|
164
|
+
| `npm run pub` | Build then publish (`npm login`) |
|
|
380
165
|
|
|
381
|
-
|
|
166
|
+
Release: changelog entry → `npm version` → `npm run pub`. Details: [CHANGELOG.md](CHANGELOG.md).
|
|
@@ -11,7 +11,7 @@ import { authenticationApi } from "../../api/authenticationApi.js";
|
|
|
11
11
|
import { getConfig, getPlatformURL } from "../../runtime-config.js";
|
|
12
12
|
import { navigateToHref } from "../../routing/navigate-app.js";
|
|
13
13
|
import { useNavigate } from "react-router-dom";
|
|
14
|
-
const LoginWithOTP = ({ withBackground }) => {
|
|
14
|
+
const LoginWithOTP = ({ withBackground, useRelativePathForMenu = false }) => {
|
|
15
15
|
const navigate = useNavigate();
|
|
16
16
|
const { loginUser, waitingFor2fa, firebaseError, loginUserWithTotp, reset2faFlow } = useContext(AuthContext);
|
|
17
17
|
const [isModalOpen, setIsModalOpen] = useState({
|
|
@@ -60,7 +60,7 @@ const LoginWithOTP = ({ withBackground }) => {
|
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
const backgroundProp = `url(${background}) left top no-repeat`;
|
|
63
|
-
return /* @__PURE__ */ jsxs(Layout, { noHeader: true, noFooter: true, children: [
|
|
63
|
+
return /* @__PURE__ */ jsxs(Layout, { noHeader: true, noFooter: true, useRelativePathForMenu, children: [
|
|
64
64
|
/* @__PURE__ */ jsx(
|
|
65
65
|
stdin_default$1,
|
|
66
66
|
{
|