@alfadocs/ui-kit 0.0.18 → 0.0.20
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/_chunks/sign-in-with-alfadocs-button-BBL11-Rt.js +44 -0
- package/dist/_chunks/sign-in-with-alfadocs-button-BBL11-Rt.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/sign-in-with-alfadocs-button/index.js +1 -1
- package/dist/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.d.ts +20 -0
- package/dist/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/_chunks/sign-in-with-alfadocs-button-BsV5vkHN.js +0 -24
- package/dist/_chunks/sign-in-with-alfadocs-button-BsV5vkHN.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as L, useRef as c, useEffect as y } from "react";
|
|
3
|
+
import { useTranslation as E } from "react-i18next";
|
|
4
|
+
import { B as I } from "./button-CXL8bA8G.js";
|
|
5
|
+
import { L as b } from "./logo-UNWYb9p7.js";
|
|
6
|
+
import { S as A } from "./spinner-77xUGpuX.js";
|
|
7
|
+
const B = /* @__PURE__ */ new Set(["primary", "secondary", "tonal"]), R = L(
|
|
8
|
+
({
|
|
9
|
+
intent: r = "primary",
|
|
10
|
+
size: n,
|
|
11
|
+
loading: t = !1,
|
|
12
|
+
disabled: u,
|
|
13
|
+
label: f,
|
|
14
|
+
onLoadingCancelled: s,
|
|
15
|
+
type: m = "button",
|
|
16
|
+
...p
|
|
17
|
+
}, d) => {
|
|
18
|
+
const { t: h } = E(), l = f ?? h("ui.auth.continueWithAlfadocs", "Continue with AlfaDocs"), w = B.has(r) ? "inherit" : "auto", v = n ?? "md", a = c(t), e = c(s);
|
|
19
|
+
return a.current = t, e.current = s, y(() => {
|
|
20
|
+
const i = (S) => {
|
|
21
|
+
S.persisted && a.current && e.current && e.current();
|
|
22
|
+
};
|
|
23
|
+
return window.addEventListener("pageshow", i), () => window.removeEventListener("pageshow", i);
|
|
24
|
+
}, []), /* @__PURE__ */ o(
|
|
25
|
+
I,
|
|
26
|
+
{
|
|
27
|
+
ref: d,
|
|
28
|
+
type: m,
|
|
29
|
+
intent: r,
|
|
30
|
+
size: n,
|
|
31
|
+
disabled: u || t,
|
|
32
|
+
"aria-busy": t || void 0,
|
|
33
|
+
startIcon: t ? /* @__PURE__ */ o(A, { size: v, variant: "pulse" }) : /* @__PURE__ */ o(b, { variant: "mark", size: "sm", tone: w, decorative: !0 }),
|
|
34
|
+
...p,
|
|
35
|
+
children: l
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
R.displayName = "SignInWithAlfadocsButton";
|
|
41
|
+
export {
|
|
42
|
+
R as S
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=sign-in-with-alfadocs-button-BBL11-Rt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-with-alfadocs-button-BBL11-Rt.js","sources":["../../src/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Button, type ButtonProps } from '../button';\nimport { Logo } from '../logo';\nimport { Spinner } from '../spinner';\n\n// A provider-style button (\"Sign in with AlfaDocs\"). Wraps the Button\n// primitive so it inherits the full intent / size / asChild / endIcon /\n// forced-colors / focus-ring contract for free.\n//\n// The only differences from a plain Button are:\n// 1. A sensible default label resolved from the\n// `ui.auth.continueWithAlfadocs` translation key.\n// 2. The AlfaDocs brand mark rendered as the leading icon.\n// 3. Loading swaps the mark for the kit's `Spinner` (pulse variant)\n// rather than Button's hand-rolled SVG — visually consistent with\n// every other loading affordance in the kit.\n//\n// `destructive` is intentionally omitted — there is no \"delete the\n// user's account\" sign-in flow that this button represents.\n\ntype AllowedIntent = Exclude<NonNullable<ButtonProps['intent']>, 'destructive'>;\n\n// Intents that paint the button surface and use a foreground-tinted\n// text colour. The mark needs to inherit `currentColor` here so it\n// reads against the coloured surface; on transparent intents the\n// mark's own brand violet contrasts naturally with the foreground\n// text.\nconst FILLED_INTENTS = new Set<AllowedIntent>(['primary', 'secondary', 'tonal']);\n\nexport interface SignInWithAlfadocsButtonProps\n extends Omit<ButtonProps, 'startIcon' | 'children' | 'intent'> {\n /**\n * Visual intent. Inherits the Button intent set with `destructive`\n * omitted (no \"destroy account\" sign-in flow exists).\n */\n intent?: AllowedIntent;\n /**\n * Override the visible label. When omitted, the component reads\n * `ui.auth.continueWithAlfadocs` (English fallback: \"Continue with\n * AlfaDocs\"). Pass a node to render e.g. \"Sign in with AlfaDocs\" or a\n * fully-translated string.\n */\n label?: ReactNode;\n /**\n * Fired when the component detects the user has cancelled an\n * in-flight sign-in — typically by pressing the browser back button\n * after the OAuth redirect, which restores the page from bfcache\n * with `loading` still true. Wire this to your loading-state\n * setter so the button returns to idle:\n *\n * ```tsx\n * <SignInWithAlfadocsButton\n * loading={signingIn}\n * onLoadingCancelled={() => setSigningIn(false)}\n * onClick={() => { setSigningIn(true); window.location = oauthUrl }}\n * />\n * ```\n *\n * Without this, your `loading` state would survive the back\n * navigation and the button would appear permanently stuck. Only\n * fires when `loading` is currently true; never fires on first mount.\n */\n onLoadingCancelled?: () => void;\n}\n\nexport const SignInWithAlfadocsButton = forwardRef<\n HTMLButtonElement,\n SignInWithAlfadocsButtonProps\n>(\n (\n {\n intent = 'primary',\n size,\n loading = false,\n disabled,\n label,\n onLoadingCancelled,\n type = 'button',\n ...props\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const resolvedLabel =\n label ?? t('ui.auth.continueWithAlfadocs', 'Continue with AlfaDocs');\n const logoTone = FILLED_INTENTS.has(intent) ? 'inherit' : 'auto';\n const resolvedSize = size ?? 'md';\n\n // Stash the latest values in refs so the `pageshow` listener can\n // read them without re-binding on every render. Only one listener\n // attaches for the lifetime of the component.\n const loadingRef = useRef(loading);\n const onCancelRef = useRef(onLoadingCancelled);\n loadingRef.current = loading;\n onCancelRef.current = onLoadingCancelled;\n\n useEffect(() => {\n const onPageShow = (event: PageTransitionEvent) => {\n // `event.persisted` is true when the page was restored from\n // the back/forward cache — the canonical signal for \"user\n // navigated away and came back without a fresh load.\" If the\n // button thinks it's still loading, that means an OAuth\n // redirect was started but never completed.\n if (\n event.persisted &&\n loadingRef.current &&\n onCancelRef.current\n ) {\n onCancelRef.current();\n }\n };\n window.addEventListener('pageshow', onPageShow);\n return () => window.removeEventListener('pageshow', onPageShow);\n }, []);\n\n // We don't forward `loading` to Button — Button would render its\n // own inline SVG and hide the label. Instead we keep the label\n // visible, swap the leading icon for the kit's Spinner, and\n // reproduce the disabled / aria-busy contract manually.\n return (\n <Button\n ref={ref}\n type={type}\n intent={intent}\n size={size}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n startIcon={\n loading ? (\n <Spinner size={resolvedSize} variant=\"pulse\" />\n ) : (\n <Logo variant=\"mark\" size=\"sm\" tone={logoTone} decorative />\n )\n }\n {...props}\n >\n {resolvedLabel}\n </Button>\n );\n },\n);\n\nSignInWithAlfadocsButton.displayName = 'SignInWithAlfadocsButton';\n"],"names":["FILLED_INTENTS","SignInWithAlfadocsButton","forwardRef","intent","size","loading","disabled","label","onLoadingCancelled","type","props","ref","t","useTranslation","resolvedLabel","logoTone","resolvedSize","loadingRef","useRef","onCancelRef","useEffect","onPageShow","event","jsx","Button","Spinner","Logo"],"mappings":";;;;;;AA4BA,MAAMA,IAAiB,oBAAI,IAAmB,CAAC,WAAW,aAAa,OAAO,CAAC,GAsClEC,IAA2BC;AAAA,EAItC,CACE;AAAA,IACE,QAAAC,IAAS;AAAA,IACT,MAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IACJP,KAASK,EAAE,gCAAgC,wBAAwB,GAC/DG,IAAWf,EAAe,IAAIG,CAAM,IAAI,YAAY,QACpDa,IAAeZ,KAAQ,MAKvBa,IAAaC,EAAOb,CAAO,GAC3Bc,IAAcD,EAAOV,CAAkB;AAC7C,WAAAS,EAAW,UAAUZ,GACrBc,EAAY,UAAUX,GAEtBY,EAAU,MAAM;AACd,YAAMC,IAAa,CAACC,MAA+B;AAMjD,QACEA,EAAM,aACNL,EAAW,WACXE,EAAY,WAEZA,EAAY,QAAA;AAAA,MAEhB;AACA,oBAAO,iBAAiB,YAAYE,CAAU,GACvC,MAAM,OAAO,oBAAoB,YAAYA,CAAU;AAAA,IAChE,GAAG,CAAA,CAAE,GAOH,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAb;AAAA,QACA,MAAAF;AAAA,QACA,QAAAN;AAAA,QACA,MAAAC;AAAA,QACA,UAAUE,KAAYD;AAAA,QACtB,aAAWA,KAAW;AAAA,QACtB,WACEA,IACE,gBAAAkB,EAACE,KAAQ,MAAMT,GAAc,SAAQ,QAAA,CAAQ,IAE7C,gBAAAO,EAACG,GAAA,EAAK,SAAQ,QAAO,MAAK,MAAK,MAAMX,GAAU,YAAU,IAAC;AAAA,QAG7D,GAAGL;AAAA,QAEH,UAAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEAb,EAAyB,cAAc;"}
|
package/dist/agent-catalog.json
CHANGED
|
@@ -14,6 +14,26 @@ export interface SignInWithAlfadocsButtonProps extends Omit<ButtonProps, 'startI
|
|
|
14
14
|
* fully-translated string.
|
|
15
15
|
*/
|
|
16
16
|
label?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Fired when the component detects the user has cancelled an
|
|
19
|
+
* in-flight sign-in — typically by pressing the browser back button
|
|
20
|
+
* after the OAuth redirect, which restores the page from bfcache
|
|
21
|
+
* with `loading` still true. Wire this to your loading-state
|
|
22
|
+
* setter so the button returns to idle:
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <SignInWithAlfadocsButton
|
|
26
|
+
* loading={signingIn}
|
|
27
|
+
* onLoadingCancelled={() => setSigningIn(false)}
|
|
28
|
+
* onClick={() => { setSigningIn(true); window.location = oauthUrl }}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Without this, your `loading` state would survive the back
|
|
33
|
+
* navigation and the button would appear permanently stuck. Only
|
|
34
|
+
* fires when `loading` is currently true; never fires on first mount.
|
|
35
|
+
*/
|
|
36
|
+
onLoadingCancelled?: () => void;
|
|
17
37
|
}
|
|
18
38
|
export declare const SignInWithAlfadocsButton: import("react").ForwardRefExoticComponent<SignInWithAlfadocsButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
19
39
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in-with-alfadocs-button.d.ts","sourceRoot":"","sources":["../../../src/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sign-in-with-alfadocs-button.d.ts","sourceRoot":"","sources":["../../../src/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAmBrD,KAAK,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAShF,MAAM,WAAW,6BACf,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9D;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,wBAAwB,6HA2EpC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { b as S } from "./_chunks/button.agent-BuGZBktn.js";
|
|
|
6
6
|
import { B as g } from "./_chunks/button-group-CI7LFxt3.js";
|
|
7
7
|
import { F as C } from "./_chunks/floating-action-button-BM9ib-Wf.js";
|
|
8
8
|
import { I as A } from "./_chunks/icon-button-group-tERESY-n.js";
|
|
9
|
-
import { S as I } from "./_chunks/sign-in-with-alfadocs-button-
|
|
9
|
+
import { S as I } from "./_chunks/sign-in-with-alfadocs-button-BBL11-Rt.js";
|
|
10
10
|
import { SafeHtml as R, sanitiseHtml as E } from "./safe-html/index.js";
|
|
11
11
|
import { A as N, a as F, b as k } from "./_chunks/autocomplete.agent-kb0nmr6F.js";
|
|
12
12
|
import { C as M, a as D, u as V } from "./_chunks/checkbox-CfiZ0FZc.js";
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as c } from "react";
|
|
3
|
-
import { useTranslation as u } from "react-i18next";
|
|
4
|
-
import { B as f } from "./button-CXL8bA8G.js";
|
|
5
|
-
import { L as l } from "./logo-UNWYb9p7.js";
|
|
6
|
-
const d = /* @__PURE__ */ new Set(["primary", "secondary", "tonal"]), p = c(({ intent: o = "primary", label: r, type: n = "button", ...a }, i) => {
|
|
7
|
-
const { t: s } = u(), e = r ?? s("ui.auth.continueWithAlfadocs", "Continue with AlfaDocs"), m = d.has(o) ? "inherit" : "auto";
|
|
8
|
-
return /* @__PURE__ */ t(
|
|
9
|
-
f,
|
|
10
|
-
{
|
|
11
|
-
ref: i,
|
|
12
|
-
type: n,
|
|
13
|
-
intent: o,
|
|
14
|
-
startIcon: /* @__PURE__ */ t(l, { variant: "mark", size: "sm", tone: m, decorative: !0 }),
|
|
15
|
-
...a,
|
|
16
|
-
children: e
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
p.displayName = "SignInWithAlfadocsButton";
|
|
21
|
-
export {
|
|
22
|
-
p as S
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=sign-in-with-alfadocs-button-BsV5vkHN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in-with-alfadocs-button-BsV5vkHN.js","sources":["../../src/components/sign-in-with-alfadocs-button/sign-in-with-alfadocs-button.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Button, type ButtonProps } from '../button';\nimport { Logo } from '../logo';\n\n// A provider-style button (\"Sign in with AlfaDocs\"). Wraps the Button\n// primitive so it inherits the full intent / size / loading / asChild /\n// startIcon / endIcon / forced-colors / focus-ring contract for free.\n// The only additions are: a sensible default label resolved from the\n// `ui.auth.continueWithAlfadocs` translation key, and the AlfaDocs\n// brand mark rendered as a leading icon.\n//\n// `destructive` is intentionally omitted — there is no \"delete the\n// user's account\" sign-in flow that this button represents.\n\ntype AllowedIntent = Exclude<NonNullable<ButtonProps['intent']>, 'destructive'>;\n\n// Intents that paint the button surface and use a foreground-tinted\n// text colour. The mark needs to inherit `currentColor` here so it\n// reads against the coloured surface; on transparent intents the\n// mark's own brand violet contrasts naturally with the foreground\n// text.\nconst FILLED_INTENTS = new Set<AllowedIntent>(['primary', 'secondary', 'tonal']);\n\nexport interface SignInWithAlfadocsButtonProps\n extends Omit<ButtonProps, 'startIcon' | 'children' | 'intent'> {\n /**\n * Visual intent. Inherits the Button intent set with `destructive`\n * omitted (no \"destroy account\" sign-in flow exists).\n */\n intent?: AllowedIntent;\n /**\n * Override the visible label. When omitted, the component reads\n * `ui.auth.continueWithAlfadocs` (English fallback: \"Continue with\n * AlfaDocs\"). Pass a node to render e.g. \"Sign in with AlfaDocs\" or a\n * fully-translated string.\n */\n label?: ReactNode;\n}\n\nexport const SignInWithAlfadocsButton = forwardRef<\n HTMLButtonElement,\n SignInWithAlfadocsButtonProps\n>(({ intent = 'primary', label, type = 'button', ...props }, ref) => {\n const { t } = useTranslation();\n const resolvedLabel =\n label ?? t('ui.auth.continueWithAlfadocs', 'Continue with AlfaDocs');\n const logoTone = FILLED_INTENTS.has(intent) ? 'inherit' : 'auto';\n\n return (\n <Button\n ref={ref}\n type={type}\n intent={intent}\n startIcon={<Logo variant=\"mark\" size=\"sm\" tone={logoTone} decorative />}\n {...props}\n >\n {resolvedLabel}\n </Button>\n );\n});\n\nSignInWithAlfadocsButton.displayName = 'SignInWithAlfadocsButton';\n"],"names":["FILLED_INTENTS","SignInWithAlfadocsButton","forwardRef","intent","label","type","props","ref","t","useTranslation","resolvedLabel","logoTone","jsx","Button","Logo"],"mappings":";;;;;AAsBA,MAAMA,IAAiB,oBAAI,IAAmB,CAAC,WAAW,aAAa,OAAO,CAAC,GAkBlEC,IAA2BC,EAGtC,CAAC,EAAE,QAAAC,IAAS,WAAW,OAAAC,GAAO,MAAAC,IAAO,UAAU,GAAGC,EAAA,GAASC,MAAQ;AACnE,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IACJN,KAASI,EAAE,gCAAgC,wBAAwB,GAC/DG,IAAWX,EAAe,IAAIG,CAAM,IAAI,YAAY;AAE1D,SACE,gBAAAS;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,MAAAF;AAAA,MACA,QAAAF;AAAA,MACA,WAAW,gBAAAS,EAACE,GAAA,EAAK,SAAQ,QAAO,MAAK,MAAK,MAAMH,GAAU,YAAU,GAAA,CAAC;AAAA,MACpE,GAAGL;AAAA,MAEH,UAAAI;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;AAEDT,EAAyB,cAAc;"}
|