@exegia/corpora-ui 0.9.0 → 0.10.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/dist-lib/components/blocks/auth/linked-accounts-block.d.ts +7 -1
- package/dist-lib/index.js +26 -26
- package/dist-lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/blocks/auth/__tests__/linked-accounts-block.test.tsx +18 -0
- package/src/components/blocks/auth/linked-accounts-block.tsx +10 -2
|
@@ -16,6 +16,12 @@ export interface LinkedAccountsBlockProps {
|
|
|
16
16
|
providers?: SocialProvider[];
|
|
17
17
|
/** Shows the loading row instead of the list. */
|
|
18
18
|
loading?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The account can also sign in through a method that has no row in this
|
|
21
|
+
* list — an email/password credential, say. Lifts the last-method guard,
|
|
22
|
+
* which otherwise refuses to disconnect the final listed identity.
|
|
23
|
+
*/
|
|
24
|
+
hasOtherSignInMethods?: boolean;
|
|
19
25
|
/** Reject (or throw) to show the inline error. */
|
|
20
26
|
onLink?: (provider: SocialProvider) => Promise<void> | void;
|
|
21
27
|
onUnlink?: (id: string) => Promise<void> | void;
|
|
@@ -27,4 +33,4 @@ export interface LinkedAccountsBlockProps {
|
|
|
27
33
|
* remaining method from being disconnected — the guard is a disabled button
|
|
28
34
|
* plus an explanation rather than an error after the fact.
|
|
29
35
|
*/
|
|
30
|
-
export declare function LinkedAccountsBlock({ title, description, identities, providers, loading, onLink, onUnlink, className, }: LinkedAccountsBlockProps): React.JSX.Element;
|
|
36
|
+
export declare function LinkedAccountsBlock({ title, description, identities, providers, loading, hasOtherSignInMethods, onLink, onUnlink, className, }: LinkedAccountsBlockProps): React.JSX.Element;
|
package/dist-lib/index.js
CHANGED
|
@@ -1546,36 +1546,36 @@ function rn({ title: e = "Connected accounts", description: t = "Manage the acco
|
|
|
1546
1546
|
"google",
|
|
1547
1547
|
"apple",
|
|
1548
1548
|
"github"
|
|
1549
|
-
], loading: o = !1,
|
|
1550
|
-
let
|
|
1551
|
-
async function
|
|
1552
|
-
if (!
|
|
1553
|
-
|
|
1549
|
+
], loading: o = !1, hasOtherSignInMethods: s = !1, onLink: c, onUnlink: l, className: u }) {
|
|
1550
|
+
let d = D.useId(), [f, p] = D.useState(null), [m, h] = D.useState(null), [g, _] = D.useState(null), v = new Set(n.map((e) => e.provider)), y = r.filter((e) => !v.has(e)), b = m !== null || g !== null, x = !s && n.length <= 1;
|
|
1551
|
+
async function S(e) {
|
|
1552
|
+
if (!b) {
|
|
1553
|
+
p(null), h(e);
|
|
1554
1554
|
try {
|
|
1555
|
-
await
|
|
1555
|
+
await c?.(e);
|
|
1556
1556
|
} catch (e) {
|
|
1557
|
-
|
|
1557
|
+
p(e instanceof Error ? e.message : "Unable to connect account.");
|
|
1558
1558
|
} finally {
|
|
1559
|
-
|
|
1559
|
+
h(null);
|
|
1560
1560
|
}
|
|
1561
1561
|
}
|
|
1562
1562
|
}
|
|
1563
|
-
async function
|
|
1564
|
-
if (!(
|
|
1565
|
-
|
|
1563
|
+
async function C(e) {
|
|
1564
|
+
if (!(b || x)) {
|
|
1565
|
+
p(null), _(e);
|
|
1566
1566
|
try {
|
|
1567
|
-
await
|
|
1567
|
+
await l?.(e);
|
|
1568
1568
|
} catch (e) {
|
|
1569
|
-
|
|
1569
|
+
p(e instanceof Error ? e.message : "Unable to disconnect account.");
|
|
1570
1570
|
} finally {
|
|
1571
|
-
|
|
1571
|
+
_(null);
|
|
1572
1572
|
}
|
|
1573
1573
|
}
|
|
1574
1574
|
}
|
|
1575
1575
|
return /* @__PURE__ */ i(ge, {
|
|
1576
1576
|
reducedMotion: "user",
|
|
1577
1577
|
children: /* @__PURE__ */ a(Ie, {
|
|
1578
|
-
className: V("w-full",
|
|
1578
|
+
className: V("w-full", u),
|
|
1579
1579
|
"data-slot": "auth-block",
|
|
1580
1580
|
children: [/* @__PURE__ */ a(Ue, { children: [/* @__PURE__ */ i(We, { children: e }), /* @__PURE__ */ i(Ge, { children: t })] }), /* @__PURE__ */ i(qe, { children: o ? /* @__PURE__ */ a("div", {
|
|
1581
1581
|
className: "flex items-center gap-2 text-sm text-muted-foreground",
|
|
@@ -1588,7 +1588,7 @@ function rn({ title: e = "Connected accounts", description: t = "Manage the acco
|
|
|
1588
1588
|
},
|
|
1589
1589
|
className: "flex flex-col gap-3",
|
|
1590
1590
|
children: [
|
|
1591
|
-
/* @__PURE__ */ i(X, { message:
|
|
1591
|
+
/* @__PURE__ */ i(X, { message: f }),
|
|
1592
1592
|
n.length > 0 ? /* @__PURE__ */ i("ul", {
|
|
1593
1593
|
"aria-label": "Connected accounts",
|
|
1594
1594
|
className: "flex flex-col gap-2",
|
|
@@ -1632,14 +1632,14 @@ function rn({ title: e = "Connected accounts", description: t = "Manage the acco
|
|
|
1632
1632
|
})]
|
|
1633
1633
|
})]
|
|
1634
1634
|
}), /* @__PURE__ */ i(H, {
|
|
1635
|
-
"aria-describedby":
|
|
1635
|
+
"aria-describedby": x ? d : void 0,
|
|
1636
1636
|
"aria-label": `Disconnect ${n}`,
|
|
1637
1637
|
size: "sm",
|
|
1638
1638
|
type: "button",
|
|
1639
1639
|
variant: "destructive-outline",
|
|
1640
|
-
disabled:
|
|
1641
|
-
loading:
|
|
1642
|
-
onClick: () => void
|
|
1640
|
+
disabled: b || x,
|
|
1641
|
+
loading: g === e.id,
|
|
1642
|
+
onClick: () => void C(e.id),
|
|
1643
1643
|
children: "Disconnect"
|
|
1644
1644
|
})]
|
|
1645
1645
|
}, e.id);
|
|
@@ -1649,20 +1649,20 @@ function rn({ title: e = "Connected accounts", description: t = "Manage the acco
|
|
|
1649
1649
|
className: "text-sm text-muted-foreground",
|
|
1650
1650
|
children: "No sign-in methods connected yet."
|
|
1651
1651
|
}),
|
|
1652
|
-
|
|
1652
|
+
x && n.length > 0 && /* @__PURE__ */ i("p", {
|
|
1653
1653
|
className: "text-xs text-muted-foreground",
|
|
1654
|
-
id:
|
|
1654
|
+
id: d,
|
|
1655
1655
|
children: nn
|
|
1656
1656
|
}),
|
|
1657
|
-
|
|
1657
|
+
y.map((e) => {
|
|
1658
1658
|
let { label: t, Icon: n } = Gt[e];
|
|
1659
1659
|
return /* @__PURE__ */ a(H, {
|
|
1660
1660
|
className: "w-full",
|
|
1661
1661
|
type: "button",
|
|
1662
1662
|
variant: "outline",
|
|
1663
|
-
disabled:
|
|
1664
|
-
loading:
|
|
1665
|
-
onClick: () => void
|
|
1663
|
+
disabled: b,
|
|
1664
|
+
loading: m === e,
|
|
1665
|
+
onClick: () => void S(e),
|
|
1666
1666
|
children: [/* @__PURE__ */ i(n, { "aria-hidden": "true" }), /* @__PURE__ */ a("span", {
|
|
1667
1667
|
className: "flex-1",
|
|
1668
1668
|
children: ["Connect ", t]
|