@calimero-network/mero-react 1.1.0 → 2.1.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 +107 -16
- package/dist/index.cjs +426 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -7
- package/dist/index.d.ts +108 -7
- package/dist/index.js +420 -247
- package/dist/index.js.map +1 -1
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
React bindings for [@calimero-network/mero-js](../mero-js) — the Calimero Network SDK.
|
|
4
4
|
|
|
5
|
-
No UI
|
|
5
|
+
No external UI framework. No styled-components. No axios. A provider, 44 hooks, storage helpers, and optional headless utility components (ConnectButton, LoginModal).
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm add @calimero-network/mero-react
|
|
10
|
+
pnpm add @calimero-network/mero-react
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Peer dependencies: `react` ^18 || ^19, `react-dom` ^18 || ^19.
|
|
13
|
+
Peer dependencies: `react` ^18 || ^19, `react-dom` ^18 || ^19. `mero-js` is a bundled dependency — no separate install needed.
|
|
14
14
|
|
|
15
15
|
## Quick start
|
|
16
16
|
|
|
@@ -234,50 +234,141 @@ import {
|
|
|
234
234
|
} from '@calimero-network/mero-react';
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
##
|
|
237
|
+
## Theming
|
|
238
|
+
|
|
239
|
+
`ConnectButton` and `LoginModal` default to the green Calimero palette used in admin-dashboard, tauri-app, and app-registry. Pass nothing for the default — provide a partial `MeroTheme` to override any subset.
|
|
238
240
|
|
|
239
241
|
```tsx
|
|
242
|
+
import { ConnectButton } from '@calimero-network/mero-react';
|
|
243
|
+
|
|
244
|
+
// Default green palette — no theme prop needed
|
|
245
|
+
<ConnectButton />
|
|
246
|
+
|
|
247
|
+
// Override only what you want; the rest stay default
|
|
248
|
+
<ConnectButton
|
|
249
|
+
theme={{
|
|
250
|
+
primary: '#ff4081',
|
|
251
|
+
primaryHover: '#e91e63',
|
|
252
|
+
primaryText: '#ffffff',
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The same theme is forwarded to the embedded `LoginModal` and is also exposed as CSS variables on the component root, so a global stylesheet works too:
|
|
258
|
+
|
|
259
|
+
```css
|
|
260
|
+
:root {
|
|
261
|
+
--mero-accent: #ff4081;
|
|
262
|
+
--mero-accent-hover: #e91e63;
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
`MeroTheme` keys (all optional): `primary`, `primaryHover`, `primaryText`, `background`, `backgroundSecondary`, `backgroundTertiary`, `border`, `text`, `textSecondary`, `error`, `overlay`, `radius`. Defaults: `#a5ff11` / `#8ed40d` / `#0d1117` / `#161b22` / `#1c2128` / `#30363d` / `#e6edf3` / `#8b949e` / `#ff6b6b` / `rgba(0,0,0,0.75)` / `8px`.
|
|
267
|
+
|
|
268
|
+
Helpers: `defaultMeroTheme` (the full default palette), `resolveMeroTheme(partial?)` (merges a partial with defaults), and `themeToCssVars(resolved)` (returns a `CSSProperties` map of `--mero-*` variables for applying to your own container) are exported for advanced use.
|
|
269
|
+
|
|
270
|
+
**Browser support**: hover-state and modal tints use CSS [`color-mix()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix), which requires Chrome 111+, Safari 16.2+, or Firefox 113+ (all 2023). On older browsers the bundled `styles.css` falls back to the default green `rgba()` for the button hover; the modal renders without subtle tints but is otherwise fully functional.
|
|
271
|
+
|
|
272
|
+
### `<ConnectButton>` props
|
|
240
273
|
|
|
274
|
+
```tsx
|
|
275
|
+
// Square 40×40 icon button — logo only, no text
|
|
276
|
+
<ConnectButton logoOnly />
|
|
277
|
+
|
|
278
|
+
// Custom label (shorthand: bare string overrides the disconnected label)
|
|
279
|
+
<ConnectButton label="Sign in with Calimero" />
|
|
280
|
+
|
|
281
|
+
// Per-state label overrides
|
|
282
|
+
<ConnectButton
|
|
283
|
+
label={{
|
|
284
|
+
connect: 'Sign in',
|
|
285
|
+
connected: 'Signed in',
|
|
286
|
+
reconnecting: 'Reconnecting…',
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
| Prop | Type | Default | Notes |
|
|
292
|
+
|------|------|---------|-------|
|
|
293
|
+
| `connectionType` | `ConnectionType \| CustomConnectionConfig` | `RemoteAndLocal` | Which options the embedded LoginModal shows. `Custom` skips the modal. |
|
|
294
|
+
| `theme` | `MeroTheme` | — | Partial token override. |
|
|
295
|
+
| `logoOnly` | `boolean` | `false` | Render only the Calimero logo (square button). The label is still announced via `aria-label`. |
|
|
296
|
+
| `label` | `string \| { connect?, connected?, reconnecting? }` | — | Override default labels. Bare string targets the disconnected state. |
|
|
297
|
+
| `className` / `style` | — | — | Forwarded to the inner `<button>`. |
|
|
298
|
+
|
|
299
|
+
## Enums
|
|
300
|
+
|
|
301
|
+
```tsx
|
|
241
302
|
AppMode.SingleContext // 'single-context'
|
|
242
303
|
AppMode.MultiContext // 'multi-context'
|
|
243
304
|
AppMode.Admin // 'admin'
|
|
244
305
|
|
|
245
|
-
ConnectionType.
|
|
246
|
-
ConnectionType.
|
|
247
|
-
ConnectionType.
|
|
248
|
-
|
|
306
|
+
ConnectionType.RemoteAndLocal // 'remote-and-local'
|
|
307
|
+
ConnectionType.Remote // 'remote'
|
|
308
|
+
ConnectionType.Local // 'local'
|
|
309
|
+
ConnectionType.Custom // 'custom'
|
|
249
310
|
```
|
|
250
311
|
|
|
251
312
|
## Types
|
|
252
313
|
|
|
253
314
|
```tsx
|
|
254
315
|
import type {
|
|
255
|
-
MeroContextValue,
|
|
256
|
-
MeroProviderConfig,
|
|
257
|
-
MeroProviderProps,
|
|
258
|
-
CustomConnectionConfig
|
|
259
|
-
AppContext,
|
|
260
|
-
ExecutionResult,
|
|
316
|
+
MeroContextValue, // useMero() return type
|
|
317
|
+
MeroProviderConfig, // MeroProvider props (without children)
|
|
318
|
+
MeroProviderProps, // MeroProvider props (with children)
|
|
319
|
+
CustomConnectionConfig, // { type: ConnectionType.Custom, url: string }
|
|
320
|
+
AppContext, // { contextId, executorId, applicationId }
|
|
321
|
+
ExecutionResult, // { success, result?, error? }
|
|
322
|
+
ApplicationContextRecord,// { contextId, applicationId }
|
|
323
|
+
ContextDiscoveryOptions, // options for useContextDiscovery
|
|
324
|
+
ContextDiscoveryState, // return type of useContextDiscovery
|
|
325
|
+
MeroTheme, // partial theme override for ConnectButton / LoginModal
|
|
326
|
+
ResolvedMeroTheme, // fully populated theme returned by resolveMeroTheme()
|
|
261
327
|
} from '@calimero-network/mero-react';
|
|
262
328
|
```
|
|
263
329
|
|
|
264
330
|
## Full exports list
|
|
265
331
|
|
|
266
332
|
```
|
|
267
|
-
// Provider &
|
|
333
|
+
// Provider & context (mero-react)
|
|
268
334
|
MeroProvider, useMero, MeroContext
|
|
269
|
-
|
|
335
|
+
|
|
336
|
+
// Components (mero-react)
|
|
337
|
+
ConnectButton, LoginModal
|
|
338
|
+
|
|
339
|
+
// Theming (mero-react)
|
|
340
|
+
MeroTheme, ResolvedMeroTheme, defaultMeroTheme, resolveMeroTheme, themeToCssVars
|
|
270
341
|
|
|
271
342
|
// Enums (mero-react)
|
|
343
|
+
AppMode, ConnectionType
|
|
344
|
+
|
|
345
|
+
// Hooks (mero-react)
|
|
346
|
+
useExecute, useSubscription
|
|
347
|
+
useContexts, useApplicationContexts, useContextGroup, useContextDiscovery
|
|
348
|
+
useCreateContext, useDeleteContext, useJoinContext
|
|
349
|
+
useGroupInfo, useGroupMembers, useGroupContexts, useGroupInvitations, useGroupCapabilities
|
|
350
|
+
useJoinGroup, useDeleteGroup, useAddGroupMembers, useRemoveGroupMembers
|
|
351
|
+
useSyncGroup, useNestGroup, useUnnestGroup, useSubgroups
|
|
352
|
+
useUpgradeGroup, useGroupUpgradeStatus, useRetryGroupUpgrade
|
|
353
|
+
useRegisterGroupSigningKey, useUpdateGroupSettings
|
|
354
|
+
useSetGroupAlias, useSetMemberAlias, useUpdateMemberRole
|
|
355
|
+
useSetDefaultCapabilities, useSetSubgroupVisibility, useSetTeeAdmissionPolicy
|
|
356
|
+
useDetachContextFromGroup
|
|
357
|
+
useNamespaces, useNamespace, useNamespaceGroups, useNamespaceIdentity
|
|
358
|
+
useNamespacesForApplication, useCreateNamespace, useDeleteNamespace
|
|
359
|
+
useJoinNamespace, useCreateNamespaceInvitation, useCreateGroupInNamespace
|
|
272
360
|
|
|
273
361
|
// Types (mero-react)
|
|
274
362
|
MeroContextValue, MeroProviderConfig, MeroProviderProps
|
|
275
363
|
CustomConnectionConfig, AppContext, ExecutionResult
|
|
364
|
+
ApplicationContextRecord, ContextDiscoveryOptions, ContextDiscoveryState
|
|
276
365
|
|
|
277
366
|
// Storage (mero-react)
|
|
278
367
|
localStorageTokenStorage
|
|
279
368
|
getNodeUrl, setNodeUrl, clearNodeUrl
|
|
280
369
|
getApplicationId, setApplicationId, clearApplicationId
|
|
370
|
+
getContextId, setContextId, clearContextId
|
|
371
|
+
getContextIdentity, setContextIdentity, clearContextIdentity
|
|
281
372
|
clearAllStorage
|
|
282
373
|
|
|
283
374
|
// Everything from @calimero-network/mero-js (auto re-exported)
|