@windrun-huaiin/third-ui 31.0.0 → 31.0.1

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,7 +1,6 @@
1
1
  interface FumaGithubInfoProps {
2
2
  owner: string;
3
3
  repo: string;
4
- token?: string;
5
4
  className?: string;
6
5
  }
7
6
  /**
@@ -14,5 +13,5 @@ interface FumaGithubInfoProps {
14
13
  * - 🎨 Three states: loading, success, error
15
14
  * - 💯 Not affected by network issues causing page crashes
16
15
  */
17
- export declare function FumaGithubInfo({ owner, repo, token, className }: FumaGithubInfoProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function FumaGithubInfo({ owner, repo, className }: FumaGithubInfoProps): import("react/jsx-runtime").JSX.Element;
18
17
  export {};
@@ -7,7 +7,7 @@ var React = require('react');
7
7
  var icons = require('@windrun-huaiin/base-ui/icons');
8
8
 
9
9
  // Loading state component
10
- function GitHubInfoSkeleton({ owner, repo, className }) {
10
+ function GitHubInfoSkeleton({ className }) {
11
11
  return (jsxRuntime.jsxs("div", { className: `flex flex-col gap-1.5 p-2 rounded-lg text-sm text-fd-foreground/80 lg:flex-row lg:items-center animate-pulse ${className}`, children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("div", { className: "size-3.5 bg-fd-muted rounded" }), jsxRuntime.jsx("div", { className: "h-4 bg-fd-muted rounded w-20" })] }), jsxRuntime.jsx("div", { className: "h-3 bg-fd-muted rounded w-8" })] }));
12
12
  }
13
13
  // Error state component - graceful fallback
@@ -46,7 +46,7 @@ function humanizeNumber(num) {
46
46
  * - 🎨 Three states: loading, success, error
47
47
  * - 💯 Not affected by network issues causing page crashes
48
48
  */
49
- function FumaGithubInfo({ owner, repo, token, className }) {
49
+ function FumaGithubInfo({ owner, repo, className }) {
50
50
  const [data, setData] = React.useState(null);
51
51
  const [loading, setLoading] = React.useState(true);
52
52
  const [error, setError] = React.useState(null);
@@ -61,9 +61,6 @@ function FumaGithubInfo({ owner, repo, token, className }) {
61
61
  const headers = new Headers({
62
62
  'Accept': 'application/vnd.github.v3+json',
63
63
  });
64
- if (token) {
65
- headers.set('Authorization', `Bearer ${token}`);
66
- }
67
64
  const response = yield fetch(`https://api.github.com/repos/${owner}/${repo}`, {
68
65
  signal: controller.signal,
69
66
  headers,
@@ -97,7 +94,7 @@ function FumaGithubInfo({ owner, repo, token, className }) {
97
94
  }
98
95
  });
99
96
  fetchRepoData();
100
- }, [owner, repo, token]);
97
+ }, [owner, repo]);
101
98
  // Loading state
102
99
  if (loading) {
103
100
  return jsxRuntime.jsx(GitHubInfoSkeleton, { owner: owner, repo: repo, className: className });
@@ -5,7 +5,7 @@ import { useState, useEffect } from 'react';
5
5
  import { ExternalLinkIcon, StarIcon } from '@windrun-huaiin/base-ui/icons';
6
6
 
7
7
  // Loading state component
8
- function GitHubInfoSkeleton({ owner, repo, className }) {
8
+ function GitHubInfoSkeleton({ className }) {
9
9
  return (jsxs("div", { className: `flex flex-col gap-1.5 p-2 rounded-lg text-sm text-fd-foreground/80 lg:flex-row lg:items-center animate-pulse ${className}`, children: [jsxs("div", { className: "flex items-center gap-2", children: [jsx("div", { className: "size-3.5 bg-fd-muted rounded" }), jsx("div", { className: "h-4 bg-fd-muted rounded w-20" })] }), jsx("div", { className: "h-3 bg-fd-muted rounded w-8" })] }));
10
10
  }
11
11
  // Error state component - graceful fallback
@@ -44,7 +44,7 @@ function humanizeNumber(num) {
44
44
  * - 🎨 Three states: loading, success, error
45
45
  * - 💯 Not affected by network issues causing page crashes
46
46
  */
47
- function FumaGithubInfo({ owner, repo, token, className }) {
47
+ function FumaGithubInfo({ owner, repo, className }) {
48
48
  const [data, setData] = useState(null);
49
49
  const [loading, setLoading] = useState(true);
50
50
  const [error, setError] = useState(null);
@@ -59,9 +59,6 @@ function FumaGithubInfo({ owner, repo, token, className }) {
59
59
  const headers = new Headers({
60
60
  'Accept': 'application/vnd.github.v3+json',
61
61
  });
62
- if (token) {
63
- headers.set('Authorization', `Bearer ${token}`);
64
- }
65
62
  const response = yield fetch(`https://api.github.com/repos/${owner}/${repo}`, {
66
63
  signal: controller.signal,
67
64
  headers,
@@ -95,7 +92,7 @@ function FumaGithubInfo({ owner, repo, token, className }) {
95
92
  }
96
93
  });
97
94
  fetchRepoData();
98
- }, [owner, repo, token]);
95
+ }, [owner, repo]);
99
96
  // Loading state
100
97
  if (loading) {
101
98
  return jsx(GitHubInfoSkeleton, { owner: owner, repo: repo, className: className });
@@ -0,0 +1,12 @@
1
+ import { type CreditOverviewTranslations } from './credit-overview-client';
2
+ import type { CreditOverviewData } from './types';
3
+ export interface CreditOverviewPayload {
4
+ data: CreditOverviewData;
5
+ totalLabel: string;
6
+ translations: CreditOverviewTranslations;
7
+ }
8
+ export interface CreditOverviewNavClientProps {
9
+ locale: string;
10
+ endpoint: string;
11
+ }
12
+ export declare function CreditOverviewNavClient({ locale, endpoint, }: CreditOverviewNavClientProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var tslib = require('tslib');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var nextjs = require('@clerk/nextjs');
7
+ var React = require('react');
8
+ var creditNavButton = require('./credit-nav-button.js');
9
+ var creditOverviewClient = require('./credit-overview-client.js');
10
+
11
+ function buildCreditOverviewUrl(endpoint, locale) {
12
+ const url = new URL(endpoint, window.location.origin);
13
+ url.searchParams.set('locale', locale);
14
+ return url.toString();
15
+ }
16
+ function CreditOverviewNavClient({ locale, endpoint, }) {
17
+ const { isLoaded, isSignedIn, userId } = nextjs.useAuth();
18
+ const [payload, setPayload] = React.useState(null);
19
+ React.useEffect(() => {
20
+ if (!isLoaded) {
21
+ return;
22
+ }
23
+ if (!isSignedIn) {
24
+ setPayload(null);
25
+ return;
26
+ }
27
+ const controller = new AbortController();
28
+ function loadCreditOverview() {
29
+ return tslib.__awaiter(this, void 0, void 0, function* () {
30
+ try {
31
+ const response = yield fetch(buildCreditOverviewUrl(endpoint, locale), {
32
+ credentials: 'same-origin',
33
+ signal: controller.signal,
34
+ });
35
+ if (!response.ok) {
36
+ if (!controller.signal.aborted) {
37
+ setPayload(null);
38
+ }
39
+ return;
40
+ }
41
+ const nextPayload = (yield response.json());
42
+ if (!controller.signal.aborted) {
43
+ setPayload(nextPayload);
44
+ }
45
+ }
46
+ catch (error) {
47
+ if (!controller.signal.aborted) {
48
+ setPayload(null);
49
+ console.warn('[CreditOverviewNavClient] Failed to load credit overview', error);
50
+ }
51
+ }
52
+ });
53
+ }
54
+ loadCreditOverview();
55
+ return () => {
56
+ controller.abort();
57
+ };
58
+ }, [endpoint, isLoaded, isSignedIn, locale, userId]);
59
+ if (!payload) {
60
+ return null;
61
+ }
62
+ return (jsxRuntime.jsx(creditNavButton.CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, children: jsxRuntime.jsx(creditOverviewClient.CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
63
+ }
64
+
65
+ exports.CreditOverviewNavClient = CreditOverviewNavClient;
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { __awaiter } from 'tslib';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useAuth } from '@clerk/nextjs';
5
+ import { useState, useEffect } from 'react';
6
+ import { CreditNavButton } from './credit-nav-button.mjs';
7
+ import { CreditOverviewClient } from './credit-overview-client.mjs';
8
+
9
+ function buildCreditOverviewUrl(endpoint, locale) {
10
+ const url = new URL(endpoint, window.location.origin);
11
+ url.searchParams.set('locale', locale);
12
+ return url.toString();
13
+ }
14
+ function CreditOverviewNavClient({ locale, endpoint, }) {
15
+ const { isLoaded, isSignedIn, userId } = useAuth();
16
+ const [payload, setPayload] = useState(null);
17
+ useEffect(() => {
18
+ if (!isLoaded) {
19
+ return;
20
+ }
21
+ if (!isSignedIn) {
22
+ setPayload(null);
23
+ return;
24
+ }
25
+ const controller = new AbortController();
26
+ function loadCreditOverview() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ try {
29
+ const response = yield fetch(buildCreditOverviewUrl(endpoint, locale), {
30
+ credentials: 'same-origin',
31
+ signal: controller.signal,
32
+ });
33
+ if (!response.ok) {
34
+ if (!controller.signal.aborted) {
35
+ setPayload(null);
36
+ }
37
+ return;
38
+ }
39
+ const nextPayload = (yield response.json());
40
+ if (!controller.signal.aborted) {
41
+ setPayload(nextPayload);
42
+ }
43
+ }
44
+ catch (error) {
45
+ if (!controller.signal.aborted) {
46
+ setPayload(null);
47
+ console.warn('[CreditOverviewNavClient] Failed to load credit overview', error);
48
+ }
49
+ }
50
+ });
51
+ }
52
+ loadCreditOverview();
53
+ return () => {
54
+ controller.abort();
55
+ };
56
+ }, [endpoint, isLoaded, isSignedIn, locale, userId]);
57
+ if (!payload) {
58
+ return null;
59
+ }
60
+ return (jsx(CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, children: jsx(CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
61
+ }
62
+
63
+ export { CreditOverviewNavClient };
@@ -1,4 +1,6 @@
1
1
  export { CreditOverviewClient } from './credit-overview-client';
2
+ export { CreditOverviewNavClient } from './credit-overview-nav-client';
2
3
  export { CreditNavButton } from './credit-nav-button';
3
4
  export type { CreditOverviewTranslations } from './credit-overview-client';
5
+ export type { CreditOverviewNavClientProps, CreditOverviewPayload, } from './credit-overview-nav-client';
4
6
  export type { CreditOverviewData, CreditBucket, CreditBucketStatus, SubscriptionInfo, } from './types';
@@ -2,9 +2,11 @@
2
2
  'use strict';
3
3
 
4
4
  var creditOverviewClient = require('./credit-overview-client.js');
5
+ var creditOverviewNavClient = require('./credit-overview-nav-client.js');
5
6
  var creditNavButton = require('./credit-nav-button.js');
6
7
 
7
8
 
8
9
 
9
10
  exports.CreditOverviewClient = creditOverviewClient.CreditOverviewClient;
11
+ exports.CreditOverviewNavClient = creditOverviewNavClient.CreditOverviewNavClient;
10
12
  exports.CreditNavButton = creditNavButton.CreditNavButton;
@@ -1,3 +1,4 @@
1
1
  "use client";
2
2
  export { CreditOverviewClient } from './credit-overview-client.mjs';
3
+ export { CreditOverviewNavClient } from './credit-overview-nav-client.mjs';
3
4
  export { CreditNavButton } from './credit-nav-button.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "31.0.0",
3
+ "version": "31.0.1",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "exports": {
6
6
  "./clerk": {
@@ -244,8 +244,8 @@
244
244
  "unified": "^11.0.5",
245
245
  "zod": "^4.3.6",
246
246
  "@windrun-huaiin/base-ui": "^31.0.0",
247
- "@windrun-huaiin/lib": "^31.0.0",
248
- "@windrun-huaiin/contracts": "^31.0.0"
247
+ "@windrun-huaiin/contracts": "^31.0.0",
248
+ "@windrun-huaiin/lib": "^31.0.0"
249
249
  },
250
250
  "peerDependencies": {
251
251
  "clsx": "^2.1.1",
@@ -6,7 +6,6 @@ import { ExternalLinkIcon, StarIcon } from '@windrun-huaiin/base-ui/icons';
6
6
  interface FumaGithubInfoProps {
7
7
  owner: string;
8
8
  repo: string;
9
- token?: string;
10
9
  className?: string;
11
10
  }
12
11
 
@@ -16,7 +15,7 @@ interface GitHubRepoData {
16
15
  }
17
16
 
18
17
  // Loading state component
19
- function GitHubInfoSkeleton({ owner, repo, className }: Pick<FumaGithubInfoProps, 'owner' | 'repo' | 'className'>) {
18
+ function GitHubInfoSkeleton({ className }: Pick<FumaGithubInfoProps, 'owner' | 'repo' | 'className'>) {
20
19
  return (
21
20
  <div className={`flex flex-col gap-1.5 p-2 rounded-lg text-sm text-fd-foreground/80 lg:flex-row lg:items-center animate-pulse ${className}`}>
22
21
  <div className="flex items-center gap-2">
@@ -114,7 +113,7 @@ function humanizeNumber(num: number): string {
114
113
  * - 🎨 Three states: loading, success, error
115
114
  * - 💯 Not affected by network issues causing page crashes
116
115
  */
117
- export function FumaGithubInfo({ owner, repo, token, className }: FumaGithubInfoProps) {
116
+ export function FumaGithubInfo({ owner, repo, className }: FumaGithubInfoProps) {
118
117
  const [data, setData] = useState<GitHubRepoData | null>(null);
119
118
  const [loading, setLoading] = useState(true);
120
119
  const [error, setError] = useState<string | null>(null);
@@ -133,10 +132,6 @@ export function FumaGithubInfo({ owner, repo, token, className }: FumaGithubInfo
133
132
  'Accept': 'application/vnd.github.v3+json',
134
133
  });
135
134
 
136
- if (token) {
137
- headers.set('Authorization', `Bearer ${token}`);
138
- }
139
-
140
135
  const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
141
136
  signal: controller.signal,
142
137
  headers,
@@ -170,7 +165,7 @@ export function FumaGithubInfo({ owner, repo, token, className }: FumaGithubInfo
170
165
  };
171
166
 
172
167
  fetchRepoData();
173
- }, [owner, repo, token]);
168
+ }, [owner, repo]);
174
169
 
175
170
  // Loading state
176
171
  if (loading) {
@@ -0,0 +1,95 @@
1
+ 'use client';
2
+
3
+ import { useAuth } from '@clerk/nextjs';
4
+ import { useEffect, useState } from 'react';
5
+ import { CreditNavButton } from './credit-nav-button';
6
+ import { CreditOverviewClient, type CreditOverviewTranslations } from './credit-overview-client';
7
+ import type { CreditOverviewData } from './types';
8
+
9
+ export interface CreditOverviewPayload {
10
+ data: CreditOverviewData;
11
+ totalLabel: string;
12
+ translations: CreditOverviewTranslations;
13
+ }
14
+
15
+ export interface CreditOverviewNavClientProps {
16
+ locale: string;
17
+ endpoint: string;
18
+ }
19
+
20
+ function buildCreditOverviewUrl(endpoint: string, locale: string) {
21
+ const url = new URL(endpoint, window.location.origin);
22
+ url.searchParams.set('locale', locale);
23
+ return url.toString();
24
+ }
25
+
26
+ export function CreditOverviewNavClient({
27
+ locale,
28
+ endpoint,
29
+ }: CreditOverviewNavClientProps) {
30
+ const { isLoaded, isSignedIn, userId } = useAuth();
31
+ const [payload, setPayload] = useState<CreditOverviewPayload | null>(null);
32
+
33
+ useEffect(() => {
34
+ if (!isLoaded) {
35
+ return;
36
+ }
37
+
38
+ if (!isSignedIn) {
39
+ setPayload(null);
40
+ return;
41
+ }
42
+
43
+ const controller = new AbortController();
44
+
45
+ async function loadCreditOverview() {
46
+ try {
47
+ const response = await fetch(buildCreditOverviewUrl(endpoint, locale), {
48
+ credentials: 'same-origin',
49
+ signal: controller.signal,
50
+ });
51
+
52
+ if (!response.ok) {
53
+ if (!controller.signal.aborted) {
54
+ setPayload(null);
55
+ }
56
+ return;
57
+ }
58
+
59
+ const nextPayload = (await response.json()) as CreditOverviewPayload | null;
60
+ if (!controller.signal.aborted) {
61
+ setPayload(nextPayload);
62
+ }
63
+ } catch (error) {
64
+ if (!controller.signal.aborted) {
65
+ setPayload(null);
66
+ console.warn('[CreditOverviewNavClient] Failed to load credit overview', error);
67
+ }
68
+ }
69
+ }
70
+
71
+ loadCreditOverview();
72
+
73
+ return () => {
74
+ controller.abort();
75
+ };
76
+ }, [endpoint, isLoaded, isSignedIn, locale, userId]);
77
+
78
+ if (!payload) {
79
+ return null;
80
+ }
81
+
82
+ return (
83
+ <CreditNavButton
84
+ locale={locale}
85
+ totalBalance={payload.data.totalBalance}
86
+ totalLabel={payload.totalLabel}
87
+ >
88
+ <CreditOverviewClient
89
+ locale={locale}
90
+ data={payload.data}
91
+ translations={payload.translations}
92
+ />
93
+ </CreditNavButton>
94
+ );
95
+ }
@@ -1,8 +1,13 @@
1
1
  'use client';
2
2
 
3
3
  export { CreditOverviewClient } from './credit-overview-client';
4
+ export { CreditOverviewNavClient } from './credit-overview-nav-client';
4
5
  export { CreditNavButton } from './credit-nav-button';
5
6
  export type { CreditOverviewTranslations } from './credit-overview-client';
7
+ export type {
8
+ CreditOverviewNavClientProps,
9
+ CreditOverviewPayload,
10
+ } from './credit-overview-nav-client';
6
11
  export type {
7
12
  CreditOverviewData,
8
13
  CreditBucket,