nfx-ui 0.24.2 → 0.26.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/animations/AnimatedIcon.d.ts +13 -0
- package/dist/animations/AnimatedIcon.d.ts.map +1 -0
- package/dist/animations/AnimatedIcon.js +25 -0
- package/dist/animations/AnimatedIcon.js.map +1 -0
- package/dist/animations/accessibility-icon.js +9 -9
- package/dist/animations/airplane-icon.js +7 -7
- package/dist/animations/alarm-clock-plus-icon.js +11 -11
- package/dist/animations/align-center-icon.js +7 -7
- package/dist/animations/align-vertical-space-around-icon.js +7 -7
- package/dist/animations/ambulance-icon.js +12 -12
- package/dist/animations/ampersand-icon.js +5 -5
- package/dist/animations/angry-icon.js +10 -10
- package/dist/animations/annoyed-icon.js +8 -8
- package/dist/animations/apple-brand-logo.js +7 -7
- package/dist/animations/arrow-back-icon.js +8 -8
- package/dist/animations/arrow-back-up-icon.js +9 -9
- package/dist/animations/arrow-big-down-dash-icon.js +6 -6
- package/dist/animations/arrow-big-down-icon.js +5 -5
- package/dist/animations/arrow-big-left-dash-icon.js +6 -6
- package/dist/animations/arrow-big-left-icon.js +5 -5
- package/dist/animations/arrow-big-right-dash-icon.js +6 -6
- package/dist/animations/arrow-big-right-icon.js +5 -5
- package/dist/animations/arrow-big-up-dash-icon.js +6 -6
- package/dist/animations/arrow-big-up-icon.js +5 -5
- package/dist/animations/arrow-down-0-1-icon.js +9 -9
- package/dist/animations/arrow-down-1-0-icon.js +9 -9
- package/dist/animations/arrow-down-a-z-icon.js +9 -9
- package/dist/animations/arrow-narrow-down-dashed-icon.js +11 -11
- package/dist/animations/arrow-narrow-down-icon.js +10 -10
- package/dist/animations/arrow-narrow-left-dashed-icon.js +10 -10
- package/dist/animations/arrow-narrow-left-icon.js +10 -10
- package/dist/animations/arrow-narrow-right-dashed-icon.js +10 -10
- package/dist/animations/arrow-narrow-right-icon.js +10 -10
- package/dist/animations/arrow-narrow-up-dashed-icon.js +10 -10
- package/dist/animations/arrow-narrow-up-icon.js +10 -10
- package/dist/animations/at-sign-icon.js +7 -7
- package/dist/animations/banana-icon.js +6 -6
- package/dist/animations/battery-charging-icon.js +11 -11
- package/dist/animations/battery-icon.js +8 -8
- package/dist/animations/battery-pause-icon.js +11 -11
- package/dist/animations/bell-off-icon.js +8 -8
- package/dist/animations/bluetooth-connected-icon.js +8 -8
- package/dist/animations/book-icon.js +10 -10
- package/dist/animations/bookmark-icon.js +6 -6
- package/dist/animations/brain-circuit-icon.js +18 -18
- package/dist/animations/brand-aistudio-icon.js +9 -9
- package/dist/animations/brand-anthropic-icon.js +9 -9
- package/dist/animations/brand-aws-icon.js +13 -13
- package/dist/animations/brand-bags-fm-icon.js +6 -6
- package/dist/animations/brand-chrome-icon.js +12 -12
- package/dist/animations/brand-cursor-icon.js +5 -5
- package/dist/animations/brand-gemini-icon.js +5 -5
- package/dist/animations/brand-google-icon.js +6 -6
- package/dist/animations/brand-grok-icon.js +7 -7
- package/dist/animations/brand-lmstudio-icon.js +11 -11
- package/dist/animations/brand-midjourney-icon.js +8 -8
- package/dist/animations/brand-nextjs-icon.js +7 -7
- package/dist/animations/brand-notion-icon.js +7 -7
- package/dist/animations/brand-ollama-icon.js +10 -10
- package/dist/animations/brand-openai-icon.js +6 -6
- package/dist/animations/brand-paypal-icon.js +7 -7
- package/dist/animations/brand-qwen-icon.js +5 -5
- package/dist/animations/brand-railway-icon.js +7 -7
- package/dist/animations/brand-react-icon.js +12 -12
- package/dist/animations/brand-react-native-icon.js +13 -13
- package/dist/animations/brand-stripe-icon.js +9 -9
- package/dist/animations/brand-telegram-icon.js +6 -6
- package/dist/animations/brand-threads-icon.js +6 -6
- package/dist/animations/brand-twitch-icon.js +7 -7
- package/dist/animations/brand-vercel-icon.js +6 -6
- package/dist/animations/brand-windows-icon.js +9 -9
- package/dist/animations/brand-wordpress-icon.js +11 -11
- package/dist/animations/brand-xai-icon.js +9 -9
- package/dist/animations/brand-zoom-icon.js +7 -7
- package/dist/animations/brightness-down-icon.js +16 -16
- package/dist/animations/bug-icon.js +14 -14
- package/dist/animations/bulb-svg.js +13 -13
- package/dist/animations/camera-icon.js +6 -6
- package/dist/animations/camera-off-icon.js +9 -9
- package/dist/animations/candy-cane-icon.js +10 -10
- package/dist/animations/cart-icon.js +10 -10
- package/dist/animations/chart-bar-icon.js +9 -9
- package/dist/animations/chart-covariate-icon.js +11 -11
- package/dist/animations/chart-histogram-icon.js +11 -11
- package/dist/animations/chart-line-icon.js +7 -7
- package/dist/animations/chart-pie-icon.js +7 -7
- package/dist/animations/checked-icon.js +8 -8
- package/dist/animations/clock-icon.js +7 -7
- package/dist/animations/cloud-1-icon.js +5 -5
- package/dist/animations/cloud-2-icon.js +8 -8
- package/dist/animations/cloud-3-icon.js +8 -8
- package/dist/animations/code-icon.js +6 -6
- package/dist/animations/code-xml-icon.js +7 -7
- package/dist/animations/coffee-icon.js +8 -8
- package/dist/animations/coin-bitcoin-icon.js +6 -6
- package/dist/animations/copy-icon.js +8 -8
- package/dist/animations/copy-off-icon.js +9 -9
- package/dist/animations/copyright-icon.js +6 -6
- package/dist/animations/cpu-icon.js +19 -19
- package/dist/animations/credit-card.js +9 -9
- package/dist/animations/currency-bitcoin-icon.js +16 -16
- package/dist/animations/currency-dollar-icon.js +9 -9
- package/dist/animations/currency-ethereum-icon.js +9 -9
- package/dist/animations/currency-euro-icon.js +10 -10
- package/dist/animations/currency-rupee-icon.js +8 -8
- package/dist/animations/device-airpods-icon.js +7 -7
- package/dist/animations/dialpad-icon.js +12 -12
- package/dist/animations/dino-icon.js +14 -14
- package/dist/animations/discord-icon.js +9 -9
- package/dist/animations/docker-icon.js +14 -14
- package/dist/animations/dots-horizontal-icon.js +8 -8
- package/dist/animations/dots-vertical-icon.js +8 -8
- package/dist/animations/double-check-icon.js +7 -7
- package/dist/animations/down-chevron.js +7 -7
- package/dist/animations/download-icon.js +7 -7
- package/dist/animations/drum-icon.js +11 -11
- package/dist/animations/expand-icon.js +12 -12
- package/dist/animations/external-link-icon.js +8 -8
- package/dist/animations/eye-icon.js +7 -7
- package/dist/animations/eye-off-icon.js +8 -8
- package/dist/animations/facebook-icon.js +7 -7
- package/dist/animations/figma-icon.js +8 -8
- package/dist/animations/file-description-icon.js +9 -9
- package/dist/animations/filled-bell-icon.js +7 -7
- package/dist/animations/filled-checked-icon.js +8 -8
- package/dist/animations/filter-icon.js +15 -15
- package/dist/animations/flame-icon.js +6 -6
- package/dist/animations/focus-icon.js +9 -9
- package/dist/animations/gamepad-icon.js +10 -10
- package/dist/animations/gauge-icon.js +5 -5
- package/dist/animations/gear-icon.js +7 -7
- package/dist/animations/ghost-icon.js +7 -7
- package/dist/animations/github-copilot-icon.js +13 -13
- package/dist/animations/github-icon.js +7 -7
- package/dist/animations/gitlab-icon.js +8 -8
- package/dist/animations/globe-icon.js +13 -13
- package/dist/animations/gmail-icon.js +9 -9
- package/dist/animations/golang-icon.js +11 -11
- package/dist/animations/hand-heart-icon.js +9 -9
- package/dist/animations/hashtag-icon.js +9 -9
- package/dist/animations/heart-icon.js +6 -6
- package/dist/animations/history-circle-icon.js +7 -7
- package/dist/animations/home-icon.js +8 -8
- package/dist/animations/hotel-icon.js +7 -7
- package/dist/animations/index.d.ts +2 -0
- package/dist/animations/index.d.ts.map +1 -1
- package/dist/animations/index.js +267 -266
- package/dist/animations/info-circle-icon.js +8 -8
- package/dist/animations/instagram-icon.js +8 -8
- package/dist/animations/javascript-icon.js +8 -8
- package/dist/animations/keyframes-icon.js +9 -9
- package/dist/animations/layers-icon.js +6 -6
- package/dist/animations/layout-bottombar-collapse-icon.js +8 -8
- package/dist/animations/layout-dashboard-icon.js +8 -8
- package/dist/animations/layout-sidebar-right-collapse-icon.js +8 -8
- package/dist/animations/layout-sidebar-right-icon.js +7 -7
- package/dist/animations/letter-a-icon.js +7 -7
- package/dist/animations/letter-b-icon.js +6 -6
- package/dist/animations/letter-c-icon.js +5 -5
- package/dist/animations/letter-d-icon.js +5 -5
- package/dist/animations/letter-e-icon.js +8 -8
- package/dist/animations/letter-f-icon.js +7 -7
- package/dist/animations/letter-g-icon.js +5 -5
- package/dist/animations/letter-h-icon.js +8 -8
- package/dist/animations/letter-i-icon.js +5 -5
- package/dist/animations/letter-j-icon.js +8 -8
- package/dist/animations/letter-k-icon.js +7 -7
- package/dist/animations/letter-l-icon.js +6 -6
- package/dist/animations/letter-m-icon.js +5 -5
- package/dist/animations/letter-n-icon.js +5 -5
- package/dist/animations/letter-o-icon.js +5 -5
- package/dist/animations/letter-p-icon.js +5 -5
- package/dist/animations/letter-q-icon.js +6 -6
- package/dist/animations/letter-r-icon.js +6 -6
- package/dist/animations/letter-s-icon.js +5 -5
- package/dist/animations/letter-t-icon.js +6 -6
- package/dist/animations/letter-u-icon.js +5 -5
- package/dist/animations/letter-v-icon.js +6 -6
- package/dist/animations/letter-w-icon.js +8 -8
- package/dist/animations/letter-x-icon.js +6 -6
- package/dist/animations/letter-y-icon.js +6 -6
- package/dist/animations/letter-z-icon.js +5 -5
- package/dist/animations/library-icon.js +8 -8
- package/dist/animations/like-icon.js +7 -7
- package/dist/animations/link-icon.js +8 -8
- package/dist/animations/linkedin-icon.js +10 -10
- package/dist/animations/locate-icon.js +11 -11
- package/dist/animations/lock-icon.js +8 -8
- package/dist/animations/logout-icon.js +8 -8
- package/dist/animations/magnifier-icon.js +6 -6
- package/dist/animations/mail-filled-icon.js +7 -7
- package/dist/animations/map-pin-icon.js +5 -5
- package/dist/animations/meh-icon.js +8 -8
- package/dist/animations/message-circle-icon.js +5 -5
- package/dist/animations/moon-icon.js +6 -6
- package/dist/animations/mouse-pointer-2-icon.js +5 -5
- package/dist/animations/mysql-icon.js +7 -7
- package/dist/animations/nodejs-icon.js +7 -7
- package/dist/animations/paint-icon.js +10 -10
- package/dist/animations/party-popper-icon.js +13 -13
- package/dist/animations/passport-icon.js +9 -9
- package/dist/animations/paw-print-icon.js +9 -9
- package/dist/animations/pen-icon.js +7 -7
- package/dist/animations/phone-volume.js +8 -8
- package/dist/animations/pinterest-icon.js +8 -8
- package/dist/animations/player-icon.js +7 -7
- package/dist/animations/plug-connected-icon.js +11 -11
- package/dist/animations/plug-connected-x-icon.js +13 -13
- package/dist/animations/python-icon.js +10 -10
- package/dist/animations/qrcode-icon.js +18 -18
- package/dist/animations/question-mark.js +8 -8
- package/dist/animations/radio-icon.js +11 -11
- package/dist/animations/rainbow-icon.js +7 -7
- package/dist/animations/refresh-icon.js +7 -7
- package/dist/animations/right-chevron.js +6 -6
- package/dist/animations/rocket-icon.js +10 -10
- package/dist/animations/rosette-discount-check-icon.js +8 -8
- package/dist/animations/rosette-discount-icon.js +10 -10
- package/dist/animations/router-icon.js +10 -10
- package/dist/animations/satellite-dish-icon.js +8 -8
- package/dist/animations/save-icon.js +7 -7
- package/dist/animations/scan-barcode-icon.js +14 -14
- package/dist/animations/scan-heart-icon.js +9 -9
- package/dist/animations/send-horizontal-icon.js +6 -6
- package/dist/animations/send-icon.js +8 -8
- package/dist/animations/shield-check.js +6 -6
- package/dist/animations/shopping-cart-icon.js +12 -12
- package/dist/animations/simple-checked-icon.js +7 -7
- package/dist/animations/skull-emoji.js +10 -10
- package/dist/animations/slack-icon.js +13 -13
- package/dist/animations/sliders-horizontal-icon.js +13 -13
- package/dist/animations/snapchat-icon.js +8 -8
- package/dist/animations/soup-icon.js +12 -12
- package/dist/animations/sparkles-icon.js +7 -7
- package/dist/animations/spotify-icon.js +9 -9
- package/dist/animations/stack-3-icon.js +8 -8
- package/dist/animations/stack-icon.js +6 -6
- package/dist/animations/star-icon.js +7 -7
- package/dist/animations/subscript-icon.js +7 -7
- package/dist/animations/target-icon.js +7 -7
- package/dist/animations/telephone-icon.js +10 -10
- package/dist/animations/terminal-icon.js +7 -7
- package/dist/animations/toggle-icon.js +6 -6
- package/dist/animations/trash-icon.js +10 -10
- package/dist/animations/travel-bag.js +11 -11
- package/dist/animations/triangle-alert-icon.js +7 -7
- package/dist/animations/trophy-icon.js +15 -15
- package/dist/animations/truck-electric-icon.js +12 -12
- package/dist/animations/twitter-icon.js +5 -5
- package/dist/animations/twitter-x-icon.js +8 -8
- package/dist/animations/typescript-icon.js +9 -9
- package/dist/animations/unlink-icon.js +11 -11
- package/dist/animations/unordered-list-icon.js +12 -12
- package/dist/animations/upload-icon.js +6 -6
- package/dist/animations/user-check-icon.js +8 -8
- package/dist/animations/user-icon.js +7 -7
- package/dist/animations/user-plus-icon.js +9 -9
- package/dist/animations/users-group-icon.js +11 -11
- package/dist/animations/users-icon.js +9 -9
- package/dist/animations/vinyl-icon.js +9 -9
- package/dist/animations/volume-2-icon.js +7 -7
- package/dist/animations/volume-x-icon.js +8 -8
- package/dist/animations/wallet-icon.js +7 -7
- package/dist/animations/washing-machine-icon.js +11 -11
- package/dist/animations/whatsapp-icon.js +7 -7
- package/dist/animations/wifi-icon.js +9 -9
- package/dist/animations/wifi-off-icon.js +11 -11
- package/dist/animations/world-icon.js +11 -11
- package/dist/animations/x-icon.js +7 -7
- package/dist/animations/youtube-icon.js +7 -7
- package/dist/apis/repositories/AssetRepository.d.ts +2 -0
- package/dist/apis/repositories/AssetRepository.d.ts.map +1 -1
- package/dist/apis/repositories/AssetRepository.js +4 -0
- package/dist/apis/repositories/AssetRepository.js.map +1 -1
- package/dist/apis/repositories/AuthRepository.d.ts +2 -0
- package/dist/apis/repositories/AuthRepository.d.ts.map +1 -1
- package/dist/apis/repositories/AuthRepository.js +4 -0
- package/dist/apis/repositories/AuthRepository.js.map +1 -1
- package/dist/providers/LanguageProvider/index.d.ts +3 -1
- package/dist/providers/LanguageProvider/index.d.ts.map +1 -1
- package/dist/providers/LanguageProvider/index.js +50 -23
- package/dist/providers/LanguageProvider/index.js.map +1 -1
- package/dist/utils/apiError.d.ts +4 -0
- package/dist/utils/apiError.d.ts.map +1 -1
- package/dist/utils/apiError.js +9 -8
- package/dist/utils/apiError.js.map +1 -1
- package/dist/utils/index.js +29 -29
- package/package.json +1 -1
- package/src/animations/AnimatedIcon.tsx +25 -0
- package/src/animations/index.ts +2 -0
- package/src/apis/repositories/AssetRepository.ts +6 -0
- package/src/apis/repositories/AuthRepository.ts +6 -0
- package/src/providers/LanguageProvider/index.tsx +39 -7
- package/src/utils/apiError.ts +8 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
+
|
|
3
|
+
import type { AnimatedIconHandle, AnimatedIconProps } from "./types";
|
|
4
|
+
import { useAnimatedIconTrigger } from "./useAnimatedIconTrigger";
|
|
5
|
+
|
|
6
|
+
export type AnimatedIconComponent = ForwardRefExoticComponent<AnimatedIconProps & RefAttributes<AnimatedIconHandle>>;
|
|
7
|
+
|
|
8
|
+
export type AnimatedIconViewProps = {
|
|
9
|
+
icon: AnimatedIconComponent;
|
|
10
|
+
size?: number | string;
|
|
11
|
+
strokeWidth?: number;
|
|
12
|
+
className?: string;
|
|
13
|
+
color?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function AnimatedIcon({ icon: Icon, size = 18, strokeWidth = 1.75, className, color = "currentColor" }: AnimatedIconViewProps) {
|
|
17
|
+
const { iconRef, start, stop } = useAnimatedIconTrigger();
|
|
18
|
+
return (
|
|
19
|
+
<span className={className} style={{ display: "inline-flex", lineHeight: 0 }} onPointerEnter={start} onPointerLeave={stop}>
|
|
20
|
+
<Icon ref={iconRef} size={size} strokeWidth={strokeWidth} color={color} />
|
|
21
|
+
</span>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default AnimatedIcon;
|
package/src/animations/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type {
|
|
|
5
5
|
} from './types'
|
|
6
6
|
export { DEFAULT_STROKE_WIDTH, scaledStrokeWidth } from './types'
|
|
7
7
|
export { useAnimatedIconTrigger } from './useAnimatedIconTrigger'
|
|
8
|
+
export { AnimatedIcon } from './AnimatedIcon'
|
|
9
|
+
export type { AnimatedIconComponent, AnimatedIconViewProps } from './AnimatedIcon'
|
|
8
10
|
|
|
9
11
|
export { default as AccessibilityIcon } from './accessibility-icon'
|
|
10
12
|
export { default as AirplaneIcon } from './airplane-icon'
|
|
@@ -7,6 +7,7 @@ type Kind = Asset.Kind;
|
|
|
7
7
|
|
|
8
8
|
export interface AssetRepository {
|
|
9
9
|
GetErrorTranslations(lang: string): Promise<Record<string, string>>;
|
|
10
|
+
GetMessageTranslations(lang: string): Promise<Record<string, unknown>>;
|
|
10
11
|
List(kind: Kind): Promise<Asset.Response.Detail[]>;
|
|
11
12
|
PrepareUpload(kind: Kind, params: Asset.Request.PrepareUpload): Promise<Asset.Response.PrepareUpload>;
|
|
12
13
|
PrepareUploads(kind: Kind, params: Asset.Request.PrepareUploads): Promise<Asset.Response.PrepareUploads>;
|
|
@@ -35,6 +36,11 @@ export class ApiAssetRepository implements AssetRepository {
|
|
|
35
36
|
return data;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
async GetMessageTranslations(lang: string): Promise<Record<string, unknown>> {
|
|
40
|
+
const { data } = await publicClientWithoutTransform.get<Record<string, unknown>>(URL_PATHS.ASSET.Messages.byLang(lang));
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
async List(kind: Kind): Promise<Asset.Response.Detail[]> {
|
|
39
45
|
const { data } = await protectedClient.get<DataResponse<Asset.Response.Detail[]>>(String(kindPaths(kind)));
|
|
40
46
|
return dataFromResponse(data, `List ${kind}`);
|
|
@@ -7,6 +7,7 @@ import { dataFromResponse, URL_PATHS } from "../ip";
|
|
|
7
7
|
|
|
8
8
|
export interface AuthRepository {
|
|
9
9
|
GetErrorTranslations(lang: string): Promise<Record<string, string>>;
|
|
10
|
+
GetMessageTranslations(lang: string): Promise<Record<string, unknown>>;
|
|
10
11
|
SendVerificationCode(params: Signup.Request.SendVerificationCode): Promise<void>;
|
|
11
12
|
SignupWithEmail(params: Signup.Request.SignupWithEmail): Promise<Signup.Response.SignupWithEmail>;
|
|
12
13
|
LoginWithEmail(params: Login.Request.LoginWithEmail): Promise<Login.Response.LoginWithEmail>;
|
|
@@ -55,6 +56,11 @@ export class ApiAuthRepository implements AuthRepository {
|
|
|
55
56
|
return data;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
async GetMessageTranslations(lang: string): Promise<Record<string, unknown>> {
|
|
60
|
+
const { data } = await publicClientWithoutTransform.get<Record<string, unknown>>(URL_PATHS.AUTH.Messages.byLang(lang));
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
async SendVerificationCode(params: Signup.Request.SendVerificationCode): Promise<void> {
|
|
59
65
|
await publicClient.post(URL_PATHS.AUTH.SignupSendCode, params);
|
|
60
66
|
}
|
|
@@ -1,39 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared LanguageProvider — host passes product builtin bundles.
|
|
3
|
+
* Identity error/message namespaces load here (PulsoLink LanguageProvider pattern).
|
|
3
4
|
*/
|
|
4
5
|
import type { CreateI18nResourcesResult, ExtraBundleItem, onLoadExtraBundles } from "@/languages/types";
|
|
5
6
|
import type { ReactNode } from "react";
|
|
6
7
|
|
|
7
8
|
import { useEffect, useRef } from "react";
|
|
8
9
|
|
|
10
|
+
import { getIdentityRepositories } from "@/apis";
|
|
9
11
|
import { DEFAULT_LANGUAGE, LANGUAGE_VALUES, LanguageEnum } from "@/enums/language";
|
|
10
12
|
import i18n, { initI18n, toSupportedLanguage } from "@/languages/languages/i18n";
|
|
11
13
|
import { PreferenceStore } from "@/stores/preference";
|
|
14
|
+
import { ERRORS_NS_IDENTITY, MESSAGES_NS_IDENTITY } from "@/utils/apiError";
|
|
12
15
|
|
|
13
16
|
export interface LanguageProviderProps {
|
|
14
17
|
children: ReactNode;
|
|
15
18
|
getBuiltinBundles: () => CreateI18nResourcesResult;
|
|
16
19
|
fallbackLng?: LanguageEnum;
|
|
20
|
+
identityMockErrors?: Record<string, unknown>;
|
|
21
|
+
identityMockMessages?: Record<string, unknown>;
|
|
17
22
|
onLoadExtraBundles?: onLoadExtraBundles;
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
async function loadIdentityExtraBundles(lng: LanguageEnum, identityMockErrors?: Record<string, unknown>, identityMockMessages?: Record<string, unknown>): Promise<ExtraBundleItem[]> {
|
|
26
|
+
if (!LANGUAGE_VALUES.includes(lng)) return [];
|
|
27
|
+
|
|
28
|
+
if (identityMockErrors != null || identityMockMessages != null) {
|
|
29
|
+
const items: ExtraBundleItem[] = [];
|
|
30
|
+
if (identityMockErrors) items.push({ namespace: ERRORS_NS_IDENTITY, bundle: identityMockErrors });
|
|
31
|
+
if (identityMockMessages) items.push({ namespace: MESSAGES_NS_IDENTITY, bundle: identityMockMessages });
|
|
32
|
+
return items;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const lang = lng.toString();
|
|
37
|
+
const repos = getIdentityRepositories();
|
|
38
|
+
const [identityErrors, identityMessages] = await Promise.all([
|
|
39
|
+
repos.asset.GetErrorTranslations(lang),
|
|
40
|
+
repos.asset.GetMessageTranslations(lang),
|
|
41
|
+
]);
|
|
42
|
+
const items: ExtraBundleItem[] = [];
|
|
43
|
+
if (identityErrors) items.push({ namespace: ERRORS_NS_IDENTITY, bundle: identityErrors as Record<string, unknown> });
|
|
44
|
+
if (identityMessages) items.push({ namespace: MESSAGES_NS_IDENTITY, bundle: identityMessages });
|
|
45
|
+
return items;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("Failed to load Identity translation bundles", error);
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
20
52
|
function normalizeExtra(result: Awaited<ReturnType<onLoadExtraBundles>>): ExtraBundleItem[] {
|
|
21
53
|
if (result == null) return [];
|
|
22
54
|
return Array.isArray(result) ? result : [result];
|
|
23
55
|
}
|
|
24
56
|
|
|
25
|
-
const LanguageProvider = ({ children, getBuiltinBundles, fallbackLng, onLoadExtraBundles }: LanguageProviderProps) => {
|
|
57
|
+
const LanguageProvider = ({ children, getBuiltinBundles, fallbackLng, identityMockErrors, identityMockMessages, onLoadExtraBundles }: LanguageProviderProps) => {
|
|
26
58
|
const hasInitialized = useRef(false);
|
|
27
59
|
if (!hasInitialized.current) {
|
|
28
60
|
initI18n({
|
|
29
61
|
fallbackLng,
|
|
30
62
|
getBuiltinBundles,
|
|
31
|
-
onLoadExtraBundles:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
onLoadExtraBundles: async (lng) => {
|
|
64
|
+
const identity = await loadIdentityExtraBundles(lng, identityMockErrors, identityMockMessages);
|
|
65
|
+
const extra = onLoadExtraBundles ? normalizeExtra(await onLoadExtraBundles(lng)) : [];
|
|
66
|
+
const merged = [...identity, ...extra];
|
|
67
|
+
return merged.length > 0 ? merged : null;
|
|
68
|
+
},
|
|
37
69
|
});
|
|
38
70
|
hasInitialized.current = true;
|
|
39
71
|
}
|
package/src/utils/apiError.ts
CHANGED
|
@@ -9,6 +9,12 @@ import type { ApiErrorBody } from "@/types/api";
|
|
|
9
9
|
|
|
10
10
|
import i18n from "@/languages/languages/i18n";
|
|
11
11
|
|
|
12
|
+
/** Identity error copy namespace (GET /asset/locales/:lang). */
|
|
13
|
+
export const ERRORS_NS_IDENTITY = "errors";
|
|
14
|
+
|
|
15
|
+
/** Identity message copy namespace (GET /asset/messages/:lang). */
|
|
16
|
+
export const MESSAGES_NS_IDENTITY = "messages";
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* 仅当为后端错误(有 response.data)时解析为 ApiErrorBody,否则返回 null
|
|
14
20
|
* Parse to ApiErrorBody only when response.data exists; otherwise null.
|
|
@@ -37,8 +43,8 @@ export function getApiError(error: unknown): ApiErrorBody | null {
|
|
|
37
43
|
export function getApiErrorMessage(error: unknown, fallback: string): string {
|
|
38
44
|
const api = getApiError(error);
|
|
39
45
|
if (api?.errCode) {
|
|
40
|
-
const out = i18n.t(
|
|
41
|
-
if (out && out !==
|
|
46
|
+
const out = i18n.t(`${ERRORS_NS_IDENTITY}:${api.errCode}`);
|
|
47
|
+
if (out && out !== `${ERRORS_NS_IDENTITY}:${api.errCode}`) return out;
|
|
42
48
|
}
|
|
43
49
|
if (api?.message) return api.message;
|
|
44
50
|
return fallback;
|