@choiceform/shared-auth 0.1.7 → 0.1.8

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.
@@ -1,49 +1,20 @@
1
1
  import React from "react";
2
2
  import type { AuthInstance } from "../core";
3
3
  interface SignInPageProps {
4
+ afterElement?: React.ReactNode;
4
5
  auth: AuthInstance;
5
- /**
6
- * 自定义样式类名
7
- */
6
+ beforeElement?: React.ReactNode;
8
7
  className?: string;
9
- /**
10
- * 描述
11
- */
12
8
  description?: string;
13
- /**
14
- * 自定义 Logo 组件
15
- */
16
- logo?: React.ReactNode;
17
- /**
18
- * OAuth 提供商
19
- * @default 'github'
20
- */
9
+ footerText?: React.ReactNode;
10
+ githubButton?: (isSigningIn: boolean) => React.ReactNode;
21
11
  provider?: string;
22
- /**
23
- * 登录成功后的重定向路径
24
- * @default '/explore'
25
- */
26
12
  redirectAfterLogin?: string;
27
- /**
28
- * 登录按钮图标
29
- */
30
- signInButtonIcon?: React.ReactNode;
31
- /**
32
- * 登录按钮文本
33
- */
34
- signInButtonText?: string;
35
- /**
36
- * 登录中按钮文本
37
- */
38
- signingInButtonText?: string;
39
- /**
40
- * 标题
41
- */
42
13
  title?: string;
43
14
  }
44
15
  /**
45
16
  * 登录页面组件
46
17
  */
47
- export declare function SignInPage({ auth, redirectAfterLogin, provider, logo, title, description, signInButtonText, signingInButtonText, signInButtonIcon, className, }: SignInPageProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function SignInPage({ afterElement, auth, beforeElement, redirectAfterLogin, provider, title, description, githubButton, className, footerText, }: SignInPageProps): import("react/jsx-runtime").JSX.Element;
48
19
  export {};
49
20
  //# sourceMappingURL=sign-in-page.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sign-in-page.d.ts","sourceRoot":"","sources":["../../src/components/sign-in-page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,OAAO,KAAK,EAAE,YAAY,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AAO,KAAK,KAAK,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,kBAA+B,EAC/B,QAAmB,EACnB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,GACX,EAAE,eAAe,2CAgDjB"}
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Slot } from "@choiceform/design-system";
3
+ import { use$ } from "@legendapp/state/react";
2
4
  import { useEffect, useState } from "react";
3
5
  import { useNavigate } from "react-router";
4
- import { use$ } from "@legendapp/state/react";
5
- import { Button } from "@choiceform/design-system";
6
6
  /**
7
7
  * 登录页面组件
8
8
  */
9
- export function SignInPage({ auth, redirectAfterLogin = "/explore", provider = "github", logo, title, description, signInButtonText = "Sign in with GitHub", signingInButtonText = "Redirecting to GitHub...", signInButtonIcon, className, }) {
9
+ export function SignInPage({ afterElement, auth, beforeElement, redirectAfterLogin = "/explore", provider = "github", title, description, githubButton, className, footerText, }) {
10
10
  const navigate = useNavigate();
11
11
  const { authStore, authActions } = auth;
12
12
  const { isAuthenticated, error } = use$(authStore);
@@ -29,5 +29,5 @@ export function SignInPage({ auth, redirectAfterLogin = "/explore", provider = "
29
29
  setIsSigningIn(false);
30
30
  }
31
31
  };
32
- return (_jsx("div", { className: className || "flex min-h-screen items-center justify-center bg-gray-50 dark:bg-gray-900", children: _jsxs("div", { className: "w-full max-w-md space-y-8", children: [logo && (_jsxs("div", { className: "mb-8", children: [_jsx("div", { className: "flex items-center gap-2", children: logo }), title && (_jsxs("div", { className: "p-4", children: [title && _jsx("p", { className: "text-heading-large mt-2", children: title }), description && (_jsx("p", { className: "text-secondary-foreground text-body-large mt-2", children: description }))] }))] })), _jsxs("div", { className: "flex flex-col items-start justify-start gap-2 p-4", children: [_jsxs(Button, { onClick: handleSignIn, disabled: isSigningIn, loading: isSigningIn, size: "large", children: [signInButtonIcon && _jsx("span", { className: "flex items-center", children: signInButtonIcon }), _jsx("span", { children: isSigningIn ? signingInButtonText : signInButtonText })] }), error && _jsx("p", { className: "text-danger-foreground", children: error })] })] }) }));
32
+ return (_jsxs("div", { className: className, children: [beforeElement, title && (_jsxs("div", { className: "flex flex-col gap-2", children: [title && _jsx("p", { className: "text-heading-large", children: title }), description && (_jsx("p", { className: "text-secondary-foreground text-body-large", children: description }))] })), provider === "github" && (_jsx(Slot, { onClick: handleSignIn, children: githubButton?.(isSigningIn) })), error && _jsx("p", { className: "text-danger-foreground mt-2", children: error }), footerText, afterElement] }));
33
33
  }
package/dist/index.js CHANGED
@@ -22,4 +22,3 @@ export { useAuthInit } from "./hooks/use-auth-init";
22
22
  export { createAuthClientFromConfig } from "./lib/auth-client";
23
23
  // 快速初始化
24
24
  export { initAuth } from "./init";
25
- console.log("OK");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choiceform/shared-auth",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Shared authentication package for Choiceform projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,8 @@
20
20
  "build": "tsc",
21
21
  "dev": "tsc --watch",
22
22
  "clean": "rimraf dist",
23
- "prepublishOnly": "pnpm run build"
23
+ "prepublishOnly": "pnpm run build",
24
+ "publish": "npm publish"
24
25
  },
25
26
  "repository": {
26
27
  "type": "git",