@calimero-network/mero-react 9.14.1 → 9.15.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 CHANGED
@@ -353,6 +353,28 @@ The same theme is forwarded to the embedded `LoginModal` and is also exposed as
353
353
  }
354
354
  ```
355
355
 
356
+ The connect dialog also carries stable class names, for what the tokens do not cover. Its inline styles still win over a class, so a class rule can add what the dialog leaves unset (its font is inherited from the page, for one) but not replace an inline value; the dialog's shadow, the one look that is neither a token nor inherited, reads `--mero-login-shadow` and keeps its default when that is unset.
357
+
358
+ | Class | Element |
359
+ | --- | --- |
360
+ | `mero-login-overlay` | the full-screen backdrop, a direct child of `body` |
361
+ | `mero-login-dialog` | the dialog surface |
362
+ | `mero-login-close`, `mero-login-header`, `mero-login-logo`, `mero-login-title` | close button, header, emblem, "Connect to Calimero" |
363
+ | `mero-login-tabs`, `mero-login-tab` (+ `mero-login-tab-active`), `mero-login-panel` | Node / Cloud tabs and their panels |
364
+ | `mero-login-info`, `mero-login-error`, `mero-login-note`, `mero-login-hint` | body copy, the connection error, the Cloud tab's note and wallet hint |
365
+ | `mero-login-options`, `mero-login-option` (+ `mero-login-option-active`), `mero-login-option-indicator`, `mero-login-option-dot`, `mero-login-option-meta` | discovered-node radio list |
366
+ | `mero-login-input`, `mero-login-toolbar`, `mero-login-rescan` | manual URL field, rescan link |
367
+ | `mero-login-actions`, `mero-login-button mero-login-primary` | Connect / Enrol buttons |
368
+ | `mero-login-discovering`, `mero-login-loading`, `mero-login-spinner`, `mero-login-account` | progress states, the Cloud tab's body |
369
+
370
+ ```css
371
+ /* `body >` outranks mero-react's own single-class rules, injected after yours. */
372
+ body > .mero-login-overlay {
373
+ --mero-login-shadow: 0 30px 60px -30px rgba(20, 26, 60, 0.45);
374
+ font-family: 'Figtree', sans-serif;
375
+ }
376
+ ```
377
+
356
378
  `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`.
357
379
 
358
380
  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.
package/dist/index.cjs CHANGED
@@ -813,28 +813,46 @@ function AccountSignInPanel({
813
813
  }
814
814
  };
815
815
  }, [theme]);
816
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.root, "data-testid": "account-sign-in-panel", children: [
817
- note && /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.note, role: "status", "data-testid": "account-note", children: note }),
818
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.info, children: "You will approve a device key on the wallet's own page, then come back here. The relay never sees your account root \u2014 only the certificate it signed." }),
819
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.info, children: "That one certificate is all of it: finding the relay that serves your account, writing through it, reading your own contexts and namespaces, and live events. Nothing to paste in." }),
820
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.buttonGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
821
- "button",
822
- {
823
- type: "button",
824
- style: styles.button,
825
- onClick: onEnrol,
826
- "data-testid": "enrol-button",
827
- children: "Enrol with your account"
828
- }
829
- ) }),
830
- customWallet && walletUrl && /* Shown only when an app overrode it, so a local rig can see at a
831
- glance that it is not enrolling against the hosted wallet. */
832
- /* @__PURE__ */ jsxRuntime.jsxs("p", { style: styles.hint, children: [
833
- "Enrolling at ",
834
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: walletUrl }),
835
- ", not the hosted wallet."
836
- ] })
837
- ] });
816
+ return /* @__PURE__ */ jsxRuntime.jsxs(
817
+ "div",
818
+ {
819
+ className: "mero-login-account",
820
+ style: styles.root,
821
+ "data-testid": "account-sign-in-panel",
822
+ children: [
823
+ note && /* @__PURE__ */ jsxRuntime.jsx(
824
+ "p",
825
+ {
826
+ className: "mero-login-note",
827
+ style: styles.note,
828
+ role: "status",
829
+ "data-testid": "account-note",
830
+ children: note
831
+ }
832
+ ),
833
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-login-info", style: styles.info, children: "You will approve a device key on the wallet's own page, then come back here. The relay never sees your account root \u2014 only the certificate it signed." }),
834
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-login-info", style: styles.info, children: "That one certificate is all of it: finding the relay that serves your account, writing through it, reading your own contexts and namespaces, and live events. Nothing to paste in." }),
835
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-login-actions", style: styles.buttonGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
836
+ "button",
837
+ {
838
+ type: "button",
839
+ className: "mero-login-button mero-login-primary",
840
+ style: styles.button,
841
+ onClick: onEnrol,
842
+ "data-testid": "enrol-button",
843
+ children: "Enrol with your account"
844
+ }
845
+ ) }),
846
+ customWallet && walletUrl && /* Shown only when an app overrode it, so a local rig can see at a
847
+ glance that it is not enrolling against the hosted wallet. */
848
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-login-hint", style: styles.hint, children: [
849
+ "Enrolling at ",
850
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: walletUrl }),
851
+ ", not the hosted wallet."
852
+ ] })
853
+ ]
854
+ }
855
+ );
838
856
  }
839
857
  var DEVICE_KEY = "calimero.device";
840
858
  var STATE_KEY = "calimero.enrol.state";
@@ -1109,7 +1127,10 @@ function buildStyles(t) {
1109
1127
  width: "100%",
1110
1128
  position: "relative",
1111
1129
  border: `1px solid ${border}`,
1112
- boxShadow: `0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px ${accentGlow}`,
1130
+ // Not a theme token, so an app could not reach it past the inline style:
1131
+ // `--mero-login-shadow` replaces it whole. Unset, it is the shadow and
1132
+ // accent ring the dialog always had.
1133
+ boxShadow: `var(--mero-login-shadow, 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px ${accentGlow})`,
1113
1134
  animation: "meroSlideIn 0.25s ease-out",
1114
1135
  color: text
1115
1136
  },
@@ -1432,6 +1453,7 @@ function LoginModal({
1432
1453
  /* @__PURE__ */ jsxRuntime.jsxs(
1433
1454
  "label",
1434
1455
  {
1456
+ className: active ? "mero-login-option mero-login-option-active" : "mero-login-option",
1435
1457
  "data-testid": `node-option-${value === CUSTOM_SELECTION ? "custom" : displayNodeUrl(value)}`,
1436
1458
  style: {
1437
1459
  ...styles.radioItem,
@@ -1452,15 +1474,16 @@ function LoginModal({
1452
1474
  /* @__PURE__ */ jsxRuntime.jsx(
1453
1475
  "span",
1454
1476
  {
1477
+ className: "mero-login-option-indicator",
1455
1478
  style: {
1456
1479
  ...styles.radioIndicator,
1457
1480
  ...active ? styles.radioIndicatorActive : {}
1458
1481
  },
1459
- children: active && /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.radioDot })
1482
+ children: active && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-login-option-dot", style: styles.radioDot })
1460
1483
  }
1461
1484
  ),
1462
1485
  label,
1463
- meta && /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.nodeMeta, children: meta })
1486
+ meta && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-login-option-meta", style: styles.nodeMeta, children: meta })
1464
1487
  ]
1465
1488
  },
1466
1489
  value
@@ -1469,16 +1492,25 @@ function LoginModal({
1469
1492
  };
1470
1493
  const renderNodeSection = () => {
1471
1494
  if (discovering) {
1472
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.discovering, "data-testid": "node-discovering", children: [
1473
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.spinnerSmall }),
1474
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Searching for local nodes..." })
1475
- ] });
1495
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1496
+ "div",
1497
+ {
1498
+ className: "mero-login-discovering",
1499
+ style: styles.discovering,
1500
+ "data-testid": "node-discovering",
1501
+ children: [
1502
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-login-spinner", style: styles.spinnerSmall }),
1503
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Searching for local nodes..." })
1504
+ ]
1505
+ }
1506
+ );
1476
1507
  }
1477
1508
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1478
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.info, children: hasDiscovered ? "Select your Calimero node to continue." : "No local node found. Enter a node URL to continue." }),
1509
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-login-info", style: styles.info, children: hasDiscovered ? "Select your Calimero node to continue." : "No local node found. Enter a node URL to continue." }),
1479
1510
  hasDiscovered && /* @__PURE__ */ jsxRuntime.jsxs(
1480
1511
  "div",
1481
1512
  {
1513
+ className: "mero-login-options",
1482
1514
  style: styles.radioList,
1483
1515
  role: "radiogroup",
1484
1516
  "aria-label": "Available nodes",
@@ -1497,6 +1529,7 @@ function LoginModal({
1497
1529
  value: customUrl,
1498
1530
  onChange: (e) => setCustomUrl(e.target.value),
1499
1531
  placeholder: "https://your-node-url.calimero.network",
1532
+ className: "mero-login-input",
1500
1533
  style: styles.input,
1501
1534
  "data-testid": "node-url-input",
1502
1535
  autoFocus: !hasDiscovered,
@@ -1507,10 +1540,11 @@ function LoginModal({
1507
1540
  }
1508
1541
  }
1509
1542
  ),
1510
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.toolbar, children: /* @__PURE__ */ jsxRuntime.jsx(
1543
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-login-toolbar", style: styles.toolbar, children: /* @__PURE__ */ jsxRuntime.jsx(
1511
1544
  "button",
1512
1545
  {
1513
1546
  type: "button",
1547
+ className: "mero-login-rescan",
1514
1548
  style: styles.rescan,
1515
1549
  onClick: () => setScanNonce((n) => n + 1),
1516
1550
  "data-testid": "rescan-button",
@@ -1520,15 +1554,16 @@ function LoginModal({
1520
1554
  ] });
1521
1555
  };
1522
1556
  const renderNodeBody = () => {
1523
- const body = loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.loading, children: [
1557
+ const body = loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-login-loading", style: styles.loading, children: [
1524
1558
  /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Connecting to node..." }),
1525
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.spinner })
1559
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-login-spinner", style: styles.spinner })
1526
1560
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1527
- error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles.error, children: error }),
1561
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-login-error", style: styles.error, children: error }),
1528
1562
  renderNodeSection(),
1529
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.buttonGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
1563
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-login-actions", style: styles.buttonGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
1530
1564
  "button",
1531
1565
  {
1566
+ className: "mero-login-button mero-login-primary",
1532
1567
  onClick: handleConnect,
1533
1568
  disabled: !canConnect,
1534
1569
  style: {
@@ -1544,6 +1579,7 @@ function LoginModal({
1544
1579
  return /* @__PURE__ */ jsxRuntime.jsx(
1545
1580
  "div",
1546
1581
  {
1582
+ className: "mero-login-panel",
1547
1583
  role: "tabpanel",
1548
1584
  id: "mero-login-panel-node",
1549
1585
  "aria-labelledby": "mero-login-tab-node",
@@ -1566,62 +1602,105 @@ function LoginModal({
1566
1602
  e.preventDefault();
1567
1603
  selectTab(TABS[next].id);
1568
1604
  };
1569
- const renderTabs = () => /* @__PURE__ */ jsxRuntime.jsx("div", { role: "tablist", "aria-label": "How to connect", style: styles.tabList, children: TABS.map((t) => {
1570
- const selected2 = activeTab === t.id;
1571
- return /* @__PURE__ */ jsxRuntime.jsx(
1572
- "button",
1573
- {
1574
- ref: (el) => {
1575
- tabRefs.current[t.id] = el;
1576
- },
1577
- type: "button",
1578
- role: "tab",
1579
- id: `mero-login-tab-${t.id}`,
1580
- "aria-selected": selected2,
1581
- "aria-controls": `mero-login-panel-${t.id}`,
1582
- tabIndex: selected2 ? 0 : -1,
1583
- onClick: () => setTab(t.id),
1584
- onKeyDown: onTabKeyDown,
1585
- style: { ...styles.tab, ...selected2 ? styles.tabActive : {} },
1586
- "data-testid": `login-tab-${t.id}`,
1587
- children: t.label
1588
- },
1589
- t.id
1590
- );
1591
- }) });
1605
+ const renderTabs = () => /* @__PURE__ */ jsxRuntime.jsx(
1606
+ "div",
1607
+ {
1608
+ className: "mero-login-tabs",
1609
+ role: "tablist",
1610
+ "aria-label": "How to connect",
1611
+ style: styles.tabList,
1612
+ children: TABS.map((t) => {
1613
+ const selected2 = activeTab === t.id;
1614
+ return /* @__PURE__ */ jsxRuntime.jsx(
1615
+ "button",
1616
+ {
1617
+ ref: (el) => {
1618
+ tabRefs.current[t.id] = el;
1619
+ },
1620
+ type: "button",
1621
+ className: selected2 ? "mero-login-tab mero-login-tab-active" : "mero-login-tab",
1622
+ role: "tab",
1623
+ id: `mero-login-tab-${t.id}`,
1624
+ "aria-selected": selected2,
1625
+ "aria-controls": `mero-login-panel-${t.id}`,
1626
+ tabIndex: selected2 ? 0 : -1,
1627
+ onClick: () => setTab(t.id),
1628
+ onKeyDown: onTabKeyDown,
1629
+ style: { ...styles.tab, ...selected2 ? styles.tabActive : {} },
1630
+ "data-testid": `login-tab-${t.id}`,
1631
+ children: t.label
1632
+ },
1633
+ t.id
1634
+ );
1635
+ })
1636
+ }
1637
+ );
1592
1638
  const modalContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1593
1639
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
1594
1640
  @keyframes meroSpin { to { transform: rotate(360deg); } }
1595
1641
  @keyframes meroFadeIn { from { opacity: 0; } to { opacity: 1; } }
1596
1642
  @keyframes meroSlideIn { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
1597
1643
  ` }),
1598
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...themeVars, ...styles.overlay }, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.content, onClick: (e) => e.stopPropagation(), children: [
1599
- /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles.closeButton, onClick: onClose, "aria-label": "Close", children: "\xD7" }),
1600
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.header, children: [
1601
- /* @__PURE__ */ jsxRuntime.jsx(CalimeroLogo, { size: 44, color: cssVar(resolved, "primary") }),
1602
- /* @__PURE__ */ jsxRuntime.jsx("h1", { style: styles.title, children: "Connect to Calimero" })
1603
- ] }),
1604
- cloudTab && renderTabs(),
1605
- activeTab === "cloud" && cloudTab ? /* @__PURE__ */ jsxRuntime.jsx(
1606
- "div",
1607
- {
1608
- role: "tabpanel",
1609
- id: "mero-login-panel-cloud",
1610
- "aria-labelledby": "mero-login-tab-cloud",
1611
- tabIndex: 0,
1612
- children: /* @__PURE__ */ jsxRuntime.jsx(
1613
- AccountSignInPanel,
1614
- {
1615
- onEnrol: cloudTab.onEnrol,
1616
- note: cloudTab.note,
1617
- walletUrl: cloudTab.walletUrl,
1618
- customWallet: cloudTab.customWallet,
1619
- theme
1620
- }
1621
- )
1622
- }
1623
- ) : renderNodeBody()
1624
- ] }) })
1644
+ /* @__PURE__ */ jsxRuntime.jsx(
1645
+ "div",
1646
+ {
1647
+ className: "mero-login-overlay",
1648
+ style: { ...themeVars, ...styles.overlay },
1649
+ onClick: onClose,
1650
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1651
+ "div",
1652
+ {
1653
+ className: "mero-login-dialog",
1654
+ style: styles.content,
1655
+ onClick: (e) => e.stopPropagation(),
1656
+ children: [
1657
+ /* @__PURE__ */ jsxRuntime.jsx(
1658
+ "button",
1659
+ {
1660
+ className: "mero-login-close",
1661
+ style: styles.closeButton,
1662
+ onClick: onClose,
1663
+ "aria-label": "Close",
1664
+ children: "\xD7"
1665
+ }
1666
+ ),
1667
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-login-header", style: styles.header, children: [
1668
+ /* @__PURE__ */ jsxRuntime.jsx(
1669
+ CalimeroLogo,
1670
+ {
1671
+ size: 44,
1672
+ color: cssVar(resolved, "primary"),
1673
+ className: "mero-login-logo"
1674
+ }
1675
+ ),
1676
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "mero-login-title", style: styles.title, children: "Connect to Calimero" })
1677
+ ] }),
1678
+ cloudTab && renderTabs(),
1679
+ activeTab === "cloud" && cloudTab ? /* @__PURE__ */ jsxRuntime.jsx(
1680
+ "div",
1681
+ {
1682
+ className: "mero-login-panel",
1683
+ role: "tabpanel",
1684
+ id: "mero-login-panel-cloud",
1685
+ "aria-labelledby": "mero-login-tab-cloud",
1686
+ tabIndex: 0,
1687
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1688
+ AccountSignInPanel,
1689
+ {
1690
+ onEnrol: cloudTab.onEnrol,
1691
+ note: cloudTab.note,
1692
+ walletUrl: cloudTab.walletUrl,
1693
+ customWallet: cloudTab.customWallet,
1694
+ theme
1695
+ }
1696
+ )
1697
+ }
1698
+ ) : renderNodeBody()
1699
+ ]
1700
+ }
1701
+ )
1702
+ }
1703
+ )
1625
1704
  ] });
1626
1705
  return reactDom.createPortal(modalContent, document.body);
1627
1706
  }