nfx-ui 0.7.4 → 0.9.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/src/apis/index.d.ts +2 -0
- package/dist/src/apis/ip.d.ts +4 -0
- package/dist/src/constants/caches.d.ts +5 -0
- package/dist/src/constants/enums.d.ts +18 -0
- package/dist/src/constants/index.d.ts +9 -0
- package/dist/src/constants/query.itemkeys.d.ts +31 -0
- package/dist/src/constants/query.listkeys.d.ts +30 -0
- package/dist/src/constants/querykeys.d.ts +42 -0
- package/dist/src/designs/animations/BounceLoading/index.d.ts +7 -0
- package/dist/src/designs/animations/ECGLoading/index.d.ts +6 -0
- package/dist/src/designs/animations/LetterGlitch/index.d.ts +12 -0
- package/dist/src/designs/animations/PixelBlast/index.d.ts +28 -0
- package/dist/src/designs/animations/Squares/index.d.ts +13 -0
- package/dist/src/designs/animations/TruckLoading/index.d.ts +6 -0
- package/dist/src/designs/animations/Waves/index.d.ts +18 -0
- package/dist/src/designs/animations/index.d.ts +6 -0
- package/dist/src/designs/components/Button/index.d.ts +20 -0
- package/dist/src/designs/components/Dropdown/index.d.ts +24 -0
- package/dist/src/designs/components/Icon/index.d.ts +9 -0
- package/dist/src/designs/components/Input/index.d.ts +23 -0
- package/dist/src/designs/components/KeyValueEditor/index.d.ts +30 -0
- package/dist/src/designs/components/LayoutSwitcher/index.d.ts +3 -0
- package/dist/src/designs/components/SearchInput/index.d.ts +12 -0
- package/dist/src/designs/components/ShowFilter/index.d.ts +28 -0
- package/dist/src/designs/components/SlideDownSwitcher/index.d.ts +16 -0
- package/dist/src/designs/components/Slider/index.d.ts +26 -0
- package/dist/src/designs/components/Suspense/SuspenseErrorBoundary.d.ts +21 -0
- package/dist/src/designs/components/Suspense/index.d.ts +47 -0
- package/dist/src/designs/components/Textarea/index.d.ts +21 -0
- package/dist/src/designs/components/ThemeSwitcher/index.d.ts +3 -0
- package/dist/src/designs/components/VirtualList/index.d.ts +41 -0
- package/dist/src/designs/components/VirtualWindowList/index.d.ts +41 -0
- package/dist/src/designs/components/index.d.ts +33 -0
- package/dist/src/designs/layouts/components/Background/index.d.ts +11 -0
- package/dist/src/designs/layouts/components/Footer/index.d.ts +5 -0
- package/dist/src/designs/layouts/components/Header/index.d.ts +4 -0
- package/dist/src/designs/layouts/components/LayoutFrame/index.d.ts +3 -0
- package/dist/src/designs/layouts/components/MainWrapper/index.d.ts +3 -0
- package/dist/src/designs/layouts/components/SideHideLayout/index.d.ts +3 -0
- package/dist/src/designs/layouts/components/SideShowLayout/index.d.ts +3 -0
- package/dist/src/designs/layouts/components/Sidebar/index.d.ts +3 -0
- package/dist/src/designs/layouts/components/index.d.ts +8 -0
- package/dist/src/designs/layouts/hooks/index.d.ts +3 -0
- package/dist/src/designs/layouts/hooks/useAction.d.ts +7 -0
- package/dist/src/designs/layouts/hooks/useLayout.d.ts +5 -0
- package/dist/src/designs/layouts/hooks/useSet.d.ts +10 -0
- package/dist/src/designs/layouts/index.d.ts +8 -0
- package/dist/src/designs/layouts/providers/index.d.ts +3 -0
- package/dist/src/designs/layouts/types/components.d.ts +117 -0
- package/dist/src/designs/layouts/types/context.d.ts +12 -0
- package/dist/src/designs/layouts/types/index.d.ts +6 -0
- package/dist/src/designs/layouts/types/layout.d.ts +11 -0
- package/dist/src/designs/layouts/utils/index.d.ts +4 -0
- package/dist/src/designs/layouts/utils/layoutStorage.d.ts +4 -0
- package/dist/src/events/EventEmitter.d.ts +48 -0
- package/dist/src/events/index.d.ts +5 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/makeCursorFetchFunction.d.ts +84 -0
- package/dist/src/hooks/makeUnifiedInfiniteQuery.d.ts +124 -0
- package/dist/src/hooks/makeUnifiedQuery.d.ts +19 -0
- package/dist/src/hooks/type.d.ts +36 -0
- package/dist/src/icons/index.d.ts +1 -0
- package/dist/src/icons/lucide.d.ts +2 -0
- package/dist/src/languages/hooks/index.d.ts +8 -0
- package/dist/src/languages/hooks/useLanguageLabel.d.ts +6 -0
- package/dist/src/languages/hooks/useLayoutLabel.d.ts +6 -0
- package/dist/src/languages/hooks/usePreferenceLabel.d.ts +6 -0
- package/dist/src/languages/hooks/useThemeLabel.d.ts +6 -0
- package/dist/src/languages/index.d.ts +11 -0
- package/dist/src/languages/languages/i18n.d.ts +8 -0
- package/dist/src/languages/languages/i18nResources.d.ts +13 -0
- package/dist/src/languages/languages/index.d.ts +2 -0
- package/dist/src/languages/providers/index.d.ts +3 -0
- package/dist/src/languages/resources/index.d.ts +8 -0
- package/dist/src/languages/types/components.d.ts +23 -0
- package/dist/src/languages/types/i18n.d.ts +28 -0
- package/dist/src/languages/types/index.d.ts +6 -0
- package/dist/src/languages/types/language.d.ts +13 -0
- package/dist/src/languages/utils/getLocalLanguage.d.ts +2 -0
- package/dist/src/languages/utils/index.d.ts +5 -0
- package/dist/src/languages/utils/languageStorage.d.ts +5 -0
- package/dist/src/navigations/index.d.ts +1 -0
- package/dist/src/navigations/navigation.d.ts +50 -0
- package/dist/src/preference/constants.d.ts +12 -0
- package/dist/src/preference/index.d.ts +35 -0
- package/dist/src/services/imageService.d.ts +6 -0
- package/dist/src/services/index.d.ts +1 -0
- package/dist/src/stores/index.d.ts +1 -0
- package/dist/src/stores/makeStore.d.ts +92 -0
- package/dist/src/themes/hooks/index.d.ts +2 -0
- package/dist/src/themes/hooks/useTheme.d.ts +5 -0
- package/dist/src/themes/hooks/useThemeVariables.d.ts +10 -0
- package/dist/src/themes/index.d.ts +8 -0
- package/dist/src/themes/providers/index.d.ts +3 -0
- package/dist/src/themes/themes/bases/android.d.ts +4 -0
- package/dist/src/themes/themes/bases/default.d.ts +5 -0
- package/dist/src/themes/themes/bases/index.d.ts +7 -0
- package/dist/src/themes/themes/bases/ios.d.ts +4 -0
- package/dist/src/themes/themes/bases/linux.d.ts +4 -0
- package/dist/src/themes/themes/bases/windows.d.ts +4 -0
- package/dist/src/themes/themes/colors/coffee.d.ts +7 -0
- package/dist/src/themes/themes/colors/corporate.d.ts +7 -0
- package/dist/src/themes/themes/colors/cosmic.d.ts +7 -0
- package/dist/src/themes/themes/colors/dark.d.ts +7 -0
- package/dist/src/themes/themes/colors/default.d.ts +7 -0
- package/dist/src/themes/themes/colors/forest.d.ts +7 -0
- package/dist/src/themes/themes/colors/index.d.ts +12 -0
- package/dist/src/themes/themes/colors/light.d.ts +7 -0
- package/dist/src/themes/themes/colors/wheat.d.ts +8 -0
- package/dist/src/themes/themes/colors/wine.d.ts +7 -0
- package/dist/src/themes/themes/index.d.ts +2 -0
- package/dist/src/themes/types/components.d.ts +20 -0
- package/dist/src/themes/types/context.d.ts +16 -0
- package/dist/src/themes/types/index.d.ts +6 -0
- package/dist/src/themes/types/theme.d.ts +209 -0
- package/dist/src/themes/utils/index.d.ts +4 -0
- package/dist/src/themes/utils/themeStorage.d.ts +7 -0
- package/dist/src/types/api.d.ts +75 -0
- package/dist/src/types/index.d.ts +2 -0
- package/dist/src/types/utils.d.ts +83 -0
- package/dist/src/utils/address.d.ts +7 -0
- package/dist/src/utils/apiError.d.ts +16 -0
- package/dist/src/utils/array.d.ts +21 -0
- package/dist/src/utils/colors.d.ts +41 -0
- package/dist/src/utils/email.d.ts +7 -0
- package/dist/src/utils/form.d.ts +14 -0
- package/dist/src/utils/index.d.ts +24 -0
- package/dist/src/utils/lstorage.d.ts +4 -0
- package/dist/src/utils/object.d.ts +10 -0
- package/dist/src/utils/polling.d.ts +12 -0
- package/dist/src/utils/price.d.ts +28 -0
- package/dist/src/utils/promise.d.ts +17 -0
- package/dist/src/utils/random.d.ts +39 -0
- package/dist/src/utils/result.d.ts +21 -0
- package/dist/src/utils/retry.d.ts +15 -0
- package/dist/src/utils/safe.d.ts +69 -0
- package/dist/src/utils/singleton.d.ts +21 -0
- package/dist/src/utils/suspense.d.ts +10 -0
- package/dist/src/utils/time.d.ts +49 -0
- package/dist/src/utils/types.d.ts +10 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +171 -147
- package/dist/utils.mjs.map +1 -1
- package/package.json +19 -22
- package/dist/animations.d.ts +0 -1
- package/dist/apis.d.ts +0 -1
- package/dist/components.d.ts +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/events.d.ts +0 -1
- package/dist/hooks.d.ts +0 -1
- package/dist/icons.d.ts +0 -1
- package/dist/languages.d.ts +0 -1
- package/dist/layouts.d.ts +0 -1
- package/dist/navigations.d.ts +0 -1
- package/dist/pixel-blast.d.ts +0 -1
- package/dist/preference.d.ts +0 -1
- package/dist/services.d.ts +0 -1
- package/dist/stores.d.ts +0 -1
- package/dist/themes.d.ts +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/utils.d.ts +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UseInfiniteQueryOptions, UseQueryOptions, UseSuspenseInfiniteQueryOptions, UseSuspenseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { AxiosError } from 'axios';
|
|
3
|
+
import { ListDTOWithNextCursor, ListDTOWithTotalNumber, OffsetLimitNumber, OffsetLimitString } from '../../types/api';
|
|
4
|
+
/** 普通模式(useQuery),可配合 enabled 等。Normal mode (useQuery); supports enabled etc. */
|
|
5
|
+
declare const NORMAL: "normal";
|
|
6
|
+
/** Suspense 模式(useSuspenseQuery),由 React 挂起。Suspense mode (useSuspenseQuery); suspended by React. */
|
|
7
|
+
declare const SUSPENSE: "suspense";
|
|
8
|
+
/** 仅允许 "normal" | "suspense",请使用 NORMAL / SUSPENSE 避免拼写错误。Only "normal" | "suspense"; use NORMAL / SUSPENSE to avoid typos. */
|
|
9
|
+
type QueryMode = typeof NORMAL | typeof SUSPENSE;
|
|
10
|
+
/** F & OffsetLimitNumber,数字分页列表请求参数。Params for number-offset list fetch. */
|
|
11
|
+
type FetchNumberListParams<F extends object = Record<string, unknown>> = F & OffsetLimitNumber;
|
|
12
|
+
/** F & OffsetLimitString,字符串游标列表请求参数。Params for string-cursor list fetch. */
|
|
13
|
+
type FetchStringListParams<F extends object = Record<string, unknown>> = F & OffsetLimitString;
|
|
14
|
+
/** 变更上下文(如 prev)。Mutation context (e.g. prev). */
|
|
15
|
+
type MutationCtx = {
|
|
16
|
+
prev?: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** 无限查询 options(不含 queryKey/queryFn/getNextPageParam/initialPageParam)。Infinite query options (excludes queryKey, queryFn, getNextPageParam, initialPageParam). */
|
|
19
|
+
type InfiniteQueryOptions<T> = Omit<UseInfiniteQueryOptions<ListDTOWithTotalNumber<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
20
|
+
/** 字符串游标无限查询 options。String-cursor infinite query options. */
|
|
21
|
+
type StringInfiniteQueryOptions<T> = Omit<UseInfiniteQueryOptions<ListDTOWithNextCursor<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
22
|
+
/** Suspense 无限查询 options。Suspense infinite query options. */
|
|
23
|
+
type SuspenseInfiniteQueryOptions<T> = Omit<UseSuspenseInfiniteQueryOptions<ListDTOWithTotalNumber<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
24
|
+
/** InfiniteQueryOptions | SuspenseInfiniteQueryOptions。Union of normal and suspense infinite query options. */
|
|
25
|
+
type InfiniteQueryOptionsUnion<T> = InfiniteQueryOptions<T> | SuspenseInfiniteQueryOptions<T>;
|
|
26
|
+
/** 单条查询 Suspense options。Single-item suspense query options. */
|
|
27
|
+
type SuspenseUnifiedQueryOptions<T> = Omit<UseSuspenseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">;
|
|
28
|
+
/** 普通单条查询 options(含 enabled)。Normal single-item query options (includes enabled). */
|
|
29
|
+
type NormalUnifiedQueryOptions<T> = Omit<UseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">;
|
|
30
|
+
/** 单条查询参数(options、postProcess + 业务参数)。Single-item query params (options, postProcess, and business params). */
|
|
31
|
+
type UnifiedQueryParams<T> = {
|
|
32
|
+
options?: SuspenseUnifiedQueryOptions<T>;
|
|
33
|
+
postProcess?: (data: T) => void;
|
|
34
|
+
} & Record<string, unknown>;
|
|
35
|
+
export { NORMAL, SUSPENSE };
|
|
36
|
+
export type { FetchNumberListParams, FetchStringListParams, InfiniteQueryOptions, InfiniteQueryOptionsUnion, MutationCtx, NormalUnifiedQueryOptions, QueryMode, StringInfiniteQueryOptions, SuspenseInfiniteQueryOptions, SuspenseUnifiedQueryOptions, UnifiedQueryParams, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lucide';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { LucideIcon } from 'lucide-react';
|
|
2
|
+
export { AlertCircle, ArrowLeft, ArrowRight, Ban, Bell, Box, Briefcase, Calendar, Camera, Check, CheckCircle, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Clock, Coffee, CreditCard, DollarSign, Edit, ExternalLink, Eye, EyeOff, FileText, Filter, FolderOpen, FolderPlus, FolderTree, Folders, Globe, GraduationCap, GripVertical, Hash, History, Home, Image, Info, Languages, LayoutGrid, LayoutList, Leaf, Layers, List, Loader, Loader2, Lock, LockKeyhole, LogOut, Mail, Menu, MessageCircle, Package, Pencil, Phone, Plus, Search, Settings, Shield, Tag, Trash2, TrendingUp, Upload, User, UserCheck, UserPlus, UserRound, UserRoundSearch, UserX, Wand2, X, XCircle, } from 'lucide-react';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 语言模块 Hooks:返回 { getXxxDisplayName },便于扩展;getXxxDisplayName 可传给 SlideDownSwitcher getDisplayName。
|
|
3
|
+
* Language hooks: return { getXxxDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.
|
|
4
|
+
*/
|
|
5
|
+
export { getLanguageDisplayName, useLanguageLabel } from './useLanguageLabel';
|
|
6
|
+
export { getLayoutDisplayName, useLayoutLabel } from './useLayoutLabel';
|
|
7
|
+
export { getPreferenceDisplayName, usePreferenceLabel } from './usePreferenceLabel';
|
|
8
|
+
export { getThemeDisplayName, useThemeLabel } from './useThemeLabel';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LanguageEnum } from '../types';
|
|
2
|
+
declare function getLanguageDisplayNameImpl(lang: LanguageEnum): string;
|
|
3
|
+
export declare function useLanguageLabel(): {
|
|
4
|
+
getLanguageDisplayName: (lang: LanguageEnum) => string;
|
|
5
|
+
};
|
|
6
|
+
export { getLanguageDisplayNameImpl as getLanguageDisplayName };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LayoutModeEnum } from '../../../designs/layouts/types';
|
|
2
|
+
declare function getLayoutDisplayNameImpl(mode: LayoutModeEnum): string;
|
|
3
|
+
export declare function useLayoutLabel(): {
|
|
4
|
+
getLayoutDisplayName: (mode: LayoutModeEnum) => string;
|
|
5
|
+
};
|
|
6
|
+
export { getLayoutDisplayNameImpl as getLayoutDisplayName };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseEnum } from '../../../themes/types';
|
|
2
|
+
declare function getPreferenceDisplayNameImpl(base: BaseEnum): string;
|
|
3
|
+
export declare function usePreferenceLabel(): {
|
|
4
|
+
getPreferenceDisplayName: (base: BaseEnum) => string;
|
|
5
|
+
};
|
|
6
|
+
export { getPreferenceDisplayNameImpl as getPreferenceDisplayName };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ThemeEnum } from '../../../themes/types';
|
|
2
|
+
declare function getThemeDisplayNameImpl(theme: ThemeEnum): string;
|
|
3
|
+
export declare function useThemeLabel(): {
|
|
4
|
+
getThemeDisplayName: (theme: ThemeEnum) => string;
|
|
5
|
+
};
|
|
6
|
+
export { getThemeDisplayNameImpl as getThemeDisplayName };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 语言模块统一导出。Languages module barrel exports.
|
|
3
|
+
*/
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export * from './languages';
|
|
6
|
+
export { default as i18n } from './languages/i18n';
|
|
7
|
+
export { default as LanguageProvider } from './providers';
|
|
8
|
+
export * from './providers';
|
|
9
|
+
export * from './resources';
|
|
10
|
+
export * from './types';
|
|
11
|
+
export * from './utils';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InitI18nOptions } from '../types';
|
|
2
|
+
import { default as i18n } from 'i18next';
|
|
3
|
+
/**
|
|
4
|
+
* 初始化 i18n。会先合并 NFX-UI 自带的四类 JSON(theme/language/layout/preference),再与用户传入的 bundles 合并(用户可覆盖)。
|
|
5
|
+
* Init i18n. Merges built-in NFX bundles (theme, language, layout, preference) with user bundles (user overrides).
|
|
6
|
+
*/
|
|
7
|
+
export declare function initI18n(options: InitI18nOptions): void;
|
|
8
|
+
export default i18n;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CreateI18nResourcesResult, LanguageEnum, NameSpacesMap, Resources } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 由调用方传入 resources 和 nameSpacesMap,生成 i18n 所需的 RESOURCES、NAME_SPACES_MAP、NAME_SPACES。
|
|
4
|
+
* Caller provides resources and nameSpacesMap; returns RESOURCES, NAME_SPACES_MAP, NAME_SPACES for i18n.
|
|
5
|
+
*
|
|
6
|
+
* @param resources - 各语言下的命名空间文案。Bundles per language.
|
|
7
|
+
* @param nameSpacesMap - 命名空间 key → 命名空间字符串。Namespace key to string.
|
|
8
|
+
*/
|
|
9
|
+
declare function createI18nResources(resources: Resources, nameSpacesMap: NameSpacesMap): CreateI18nResourcesResult;
|
|
10
|
+
/** 切换当前语言。Switch current language. */
|
|
11
|
+
declare function changeLanguage(lng: LanguageEnum): void;
|
|
12
|
+
export { createI18nResources, changeLanguage };
|
|
13
|
+
export type { CreateI18nResourcesResult, Resources, NameSpacesMap, NamespaceBundle } from '../types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { LanguageProviderProps } from '../types';
|
|
2
|
+
declare const LanguageProvider: import('react').MemoExoticComponent<({ children, bundles, fallbackLng, onLoadExtraBundles }: LanguageProviderProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
export default LanguageProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CreateI18nResourcesResult, NameSpacesMap } from '../types';
|
|
2
|
+
export declare const NFX_NAMESPACES: readonly ["theme", "language", "layout", "preference"];
|
|
3
|
+
export declare const NFX_NAMESPACES_MAP: NameSpacesMap;
|
|
4
|
+
/**
|
|
5
|
+
* 返回 NFX-UI 默认文案包,可与使用方自建 resources 合并后传入 createI18nResources。
|
|
6
|
+
* Returns default NFX bundles; merge with your resources and pass to createI18nResources.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDefaultNfxBundles(): CreateI18nResourcesResult;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CreateI18nResourcesResult, onLoadExtraBundles } from './i18n';
|
|
3
|
+
import { LanguageEnum } from './language';
|
|
4
|
+
/** 语言 Provider 的 props。LanguageProvider props. */
|
|
5
|
+
export interface LanguageProviderProps {
|
|
6
|
+
/** 子节点。Children. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** 用户自建 JSON 后调用 createI18nResources 得到的结果。Result of createI18nResources(resources, nameSpacesMap). */
|
|
9
|
+
bundles: CreateI18nResourcesResult;
|
|
10
|
+
/** 回退语言。Fallback language. */
|
|
11
|
+
fallbackLng?: LanguageEnum;
|
|
12
|
+
/** 语言切换后拉取额外文案(如错误码);返回 { namespace, bundle },由 Provider 内部 addResourceBundle。Caller only fetches; Provider injects. */
|
|
13
|
+
onLoadExtraBundles?: onLoadExtraBundles;
|
|
14
|
+
}
|
|
15
|
+
/** 语言切换器 props。LanguageSwitcher props. */
|
|
16
|
+
export interface LanguageSwitcherProps {
|
|
17
|
+
/** 样式状态。Visual status. */
|
|
18
|
+
status?: "primary" | "default";
|
|
19
|
+
/** 根据 lang 返回显示名称;未传则使用 lang 原值。Display name for language; default is lang value. */
|
|
20
|
+
getLanguageDisplayName?: (lang: LanguageEnum) => string;
|
|
21
|
+
/** 处理语言改变。Handle language change. */
|
|
22
|
+
handleChangeLanguage?: (language: LanguageEnum) => void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LanguageEnum } from './language';
|
|
2
|
+
/** 单语言下的命名空间 → 文案对象。One language: namespace -> key-value bundle. */
|
|
3
|
+
export type NamespaceBundle = Record<string, unknown>;
|
|
4
|
+
/** 所有语言的资源:语言码 → 命名空间 → 文案。Resources: lng -> ns -> bundle. */
|
|
5
|
+
export type Resources = Record<string, Record<string, NamespaceBundle>>;
|
|
6
|
+
/** 命名空间映射:命名空间 key → 命名空间字符串(用于 ns 列表)。Name space key -> string. */
|
|
7
|
+
export type NameSpacesMap = Record<string, string>;
|
|
8
|
+
/** createI18nResources 返回值,含 RESOURCES / NAME_SPACES_MAP / NAME_SPACES。Return type of createI18nResources. */
|
|
9
|
+
export interface CreateI18nResourcesResult {
|
|
10
|
+
RESOURCES: Resources;
|
|
11
|
+
NAME_SPACES_MAP: NameSpacesMap;
|
|
12
|
+
NAME_SPACES: string[];
|
|
13
|
+
}
|
|
14
|
+
/** 单条额外 bundle:命名空间 + 文案对象,由 initI18n 注入到 i18n。 */
|
|
15
|
+
export interface ExtraBundleItem {
|
|
16
|
+
namespace: string;
|
|
17
|
+
bundle: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export type onLoadExtraBundles = (lng: LanguageEnum) => Promise<ExtraBundleItem | ExtraBundleItem[] | null | undefined>;
|
|
20
|
+
/** initI18n 的选项。Options for initI18n. */
|
|
21
|
+
export interface InitI18nOptions {
|
|
22
|
+
/** 由 createI18nResources(resources, nameSpacesMap) 得到;用户自建 JSON 后组装传入。From createI18nResources; user builds from their JSON. */
|
|
23
|
+
bundles: CreateI18nResourcesResult;
|
|
24
|
+
/** 回退语言。Fallback language. */
|
|
25
|
+
fallbackLng?: LanguageEnum;
|
|
26
|
+
/** 语言切换后由调用方拉取额外文案(如错误码);返回 { namespace, bundle } 或数组,由 initI18n 负责 addResourceBundle。 */
|
|
27
|
+
onLoadExtraBundles?: onLoadExtraBundles;
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 语言枚举与常量,不引用任何 JSON,供需要轻量引用的模块使用。
|
|
3
|
+
* Language enum and constants; no JSON deps for lightweight usage.
|
|
4
|
+
*/
|
|
5
|
+
declare enum LanguageEnum {
|
|
6
|
+
EN = "en",
|
|
7
|
+
ZH = "zh",
|
|
8
|
+
FR = "fr"
|
|
9
|
+
}
|
|
10
|
+
declare const DEFAULT_LANGUAGE = LanguageEnum.ZH;
|
|
11
|
+
declare const LANGUAGE_VALUES: LanguageEnum[];
|
|
12
|
+
declare const LANGUAGE_STORAGE_KEY = "language-storage";
|
|
13
|
+
export { LanguageEnum, DEFAULT_LANGUAGE, LANGUAGE_VALUES, LANGUAGE_STORAGE_KEY };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Nilable } from '../../../types/utils';
|
|
2
|
+
import { LanguageEnum } from '../types';
|
|
3
|
+
export declare function getLanguageStorage(): Nilable<LanguageEnum>;
|
|
4
|
+
export declare function setLanguageStorage(value: LanguageEnum): void;
|
|
5
|
+
export declare function removeLanguageStorage(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigation';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Defined, KeyOf } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* 通用路由类型与 defineRouter / createRouter(与 EventEmitter 的 defineEvents 约定一致)
|
|
4
|
+
* Generic route types and defineRouter / createRouter; only values from defineRouter are accepted by createRouter.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineRouter, createRouter } from "@/types/navigation";
|
|
9
|
+
* const routeMap = defineRouter({ HOME: "/", LOGIN: "/login", USER: "/user/:id" });
|
|
10
|
+
* const router = createRouter(routeMap);
|
|
11
|
+
* router.ROUTES.HOME; // "/"
|
|
12
|
+
* router.matchRoute(pathname, router.ROUTES.USER);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
/** 由 defineRouter 返回的「已规范路由表」类型;createRouter 只接受此类型。 */
|
|
16
|
+
export type DefinedRouter<R extends Record<string, string>> = Defined<R, "router">;
|
|
17
|
+
/** 由路由表 R 推导的 key 类型 */
|
|
18
|
+
export type RouteKey<R extends Record<string, string>> = KeyOf<R>;
|
|
19
|
+
/** 由路由表 R 推导的 path 联合类型 */
|
|
20
|
+
export type RoutePath<R extends Record<string, string>> = R[RouteKey<R>];
|
|
21
|
+
/**
|
|
22
|
+
* 规范创建路由表:仅允许 defineRouter 返回的值传入 createRouter(类型约束)。
|
|
23
|
+
* Define route map: only the return value of defineRouter may be passed to createRouter.
|
|
24
|
+
*
|
|
25
|
+
* @param routes - 路由 key-value 对象(值可为含 :param 的 path)
|
|
26
|
+
* @returns DefinedRouter<R>,仅此类型可传入 createRouter
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineRouter<R extends Record<string, string>>(routes: R): DefinedRouter<R>;
|
|
29
|
+
/**
|
|
30
|
+
* 精确匹配:当前路径是否等于目标 path
|
|
31
|
+
* Exact match: current path equals target path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isActiveRoute(currentPath: string, targetPath: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 模式匹配:pathname 是否匹配带 :param 的 route 模式
|
|
36
|
+
* Pattern match: pathname matches route pattern (supports :param segments).
|
|
37
|
+
*/
|
|
38
|
+
export declare function matchRoute(pathname: string, route: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 创建路由对象:仅接受 defineRouter(...) 的返回值,得到只读 ROUTES + matchRoute / isActiveRoute / getRouteByKey
|
|
41
|
+
* Create router: accepts only the return value of defineRouter(...); returns ROUTES and typed helpers.
|
|
42
|
+
*
|
|
43
|
+
* @param routes - 须为 defineRouter(...) 的返回值(DefinedRouter)
|
|
44
|
+
*/
|
|
45
|
+
export declare function createRouter<R extends Record<string, string>>(routes: DefinedRouter<R>): {
|
|
46
|
+
ROUTES: Readonly<R>;
|
|
47
|
+
matchRoute: (pathname: string, route: R[keyof R]) => boolean;
|
|
48
|
+
isActiveRoute: (currentPath: string, targetPath: R[keyof R]) => boolean;
|
|
49
|
+
getRouteByKey: (key: keyof R) => R[keyof R];
|
|
50
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Array } from '../../types';
|
|
2
|
+
/** 仪表盘背景枚举。Dashboard background enum. */
|
|
3
|
+
export declare enum DashboardBackgroundEnum {
|
|
4
|
+
NONE = "none",
|
|
5
|
+
WAVES = "waves",
|
|
6
|
+
SQUARES = "squares",
|
|
7
|
+
LETTER_GLITCH = "letterGlitch",
|
|
8
|
+
PIXEL_BLAST = "pixelBlast"
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_DASHBOARD_BACKGROUND = DashboardBackgroundEnum.NONE;
|
|
11
|
+
/** 仪表盘背景可选值列表。Dashboard background values list. */
|
|
12
|
+
export declare const DASHBOARD_BACKGROUND_VALUES: Array<DashboardBackgroundEnum>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LayoutModeEnum } from '../../designs/layouts/types';
|
|
2
|
+
import { LanguageEnum } from '../../languages/types';
|
|
3
|
+
import { BaseEnum, ThemeEnum } from '../../themes/types';
|
|
4
|
+
import { DashboardBackgroundEnum } from './constants';
|
|
5
|
+
export { DashboardBackgroundEnum, DEFAULT_DASHBOARD_BACKGROUND, DASHBOARD_BACKGROUND_VALUES } from './constants';
|
|
6
|
+
/** 前端统一的偏好结构;后端存为 JSON:theme, base, language, layoutMode, other.dashboardBackground */
|
|
7
|
+
export type Preference = {
|
|
8
|
+
theme: ThemeEnum;
|
|
9
|
+
base: BaseEnum;
|
|
10
|
+
language: LanguageEnum;
|
|
11
|
+
layoutMode: LayoutModeEnum;
|
|
12
|
+
other?: {
|
|
13
|
+
dashboardBackground: DashboardBackgroundEnum;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 从后端 preference JSON 解析为前端 Preference,解析失败或空返回 null
|
|
18
|
+
* Parse backend preference JSON to Preference; returns null on empty or parse error.
|
|
19
|
+
* @param json - 后端存的 JSON 字符串
|
|
20
|
+
* @returns Preference 或 null
|
|
21
|
+
*/
|
|
22
|
+
export declare function parsePreferenceJson(json: string | null | undefined): Preference | null;
|
|
23
|
+
/**
|
|
24
|
+
* 将前端 Preference 序列化为后端存的完整 JSON 字符串(每次更新都传完整 JSON)
|
|
25
|
+
* Serialize Preference to backend JSON string (full payload on each update).
|
|
26
|
+
* @param preference - 前端偏好对象
|
|
27
|
+
* @returns JSON 字符串
|
|
28
|
+
*/
|
|
29
|
+
export declare function preferenceToJson(preference: Preference): string;
|
|
30
|
+
/**
|
|
31
|
+
* 默认偏好(解析不到或同步时兜底):默认中文、default 主题、default base
|
|
32
|
+
* Default preference (fallback when parse fails or for initial sync).
|
|
33
|
+
* @returns 默认 Preference
|
|
34
|
+
*/
|
|
35
|
+
export declare function getDefaultPreference(): Preference;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './imageService';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './makeStore';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用 Store 工厂(学习 hooks 的 make 函数模式)。
|
|
3
|
+
* Generic store factory (make pattern like hooks makeUnifiedQuery).
|
|
4
|
+
*/
|
|
5
|
+
/** SetState:与 zustand 的 set 一致。Same as zustand set. */
|
|
6
|
+
export type SetState<S> = (partial: Partial<S> | ((state: S) => Partial<S>)) => void;
|
|
7
|
+
/** GetState:与 zustand 的 get 一致。Same as zustand get. */
|
|
8
|
+
export type GetState<S> = () => S;
|
|
9
|
+
/**
|
|
10
|
+
* 创建带 subscribeWithSelector 的 Store(不持久化)。
|
|
11
|
+
* Create store with subscribeWithSelector (no persist).
|
|
12
|
+
*
|
|
13
|
+
* @param initialState - 初始状态。Initial state.
|
|
14
|
+
* @param actions - (set, get) => actions 对象。(set, get) => actions object.
|
|
15
|
+
* @returns { store, useStore } 供外部使用。Returns { store, useStore }.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { store, useStore } = makeStore(
|
|
20
|
+
* { count: 0 },
|
|
21
|
+
* (set) => ({ increment: () => set((s) => ({ count: s.count + 1 })) })
|
|
22
|
+
* );
|
|
23
|
+
* const count = useStore((s) => s.count);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function makeStore<S extends object, A extends object>(initialState: S, actions: (set: SetState<S & A>, get: GetState<S & A>) => A): {
|
|
27
|
+
store: Omit<import('zustand').StoreApi<S & A>, "subscribe"> & {
|
|
28
|
+
subscribe: {
|
|
29
|
+
(listener: (selectedState: S & A, previousSelectedState: S & A) => void): () => void;
|
|
30
|
+
<U>(selector: (state: S & A) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
31
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
32
|
+
fireImmediately?: boolean;
|
|
33
|
+
} | undefined): () => void;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
useStore: <T>(selector: (state: S & A) => T) => T;
|
|
37
|
+
};
|
|
38
|
+
/** makePersistStore 的配置。Config for makePersistStore. */
|
|
39
|
+
export interface MakePersistStoreOptions<S extends object, A extends object> {
|
|
40
|
+
/** 持久化 key(localStorage)。Persist key (localStorage). */
|
|
41
|
+
name: string;
|
|
42
|
+
/** 初始状态。Initial state. */
|
|
43
|
+
initialState: S;
|
|
44
|
+
/** (set, get) => actions。(set, get) => actions. */
|
|
45
|
+
actions: (set: SetState<S & A>, get: GetState<S & A>) => A;
|
|
46
|
+
/** 只持久化部分 state;缺省则全量。Partialize state to persist; default full. */
|
|
47
|
+
partialize?: (state: S & A) => Partial<S & A>;
|
|
48
|
+
/** 版本号(用于 migrate)。Version for migrate. */
|
|
49
|
+
version?: number;
|
|
50
|
+
/** 迁移旧持久化数据。Migrate persisted state. */
|
|
51
|
+
migrate?: (persistedState: unknown, version: number) => Partial<S & A>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 创建带 persist + subscribeWithSelector 的 Store。
|
|
55
|
+
* Create store with persist and subscribeWithSelector.
|
|
56
|
+
*
|
|
57
|
+
* @param options - name, initialState, actions, partialize?, version?, migrate?
|
|
58
|
+
* @returns { store, useStore }
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const { store, useStore } = makePersistStore({
|
|
63
|
+
* name: "auth-storage",
|
|
64
|
+
* initialState: { token: null },
|
|
65
|
+
* actions: (set) => ({ setToken: (t) => set({ token: t }) }),
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function makePersistStore<S extends object, A extends object>(options: MakePersistStoreOptions<S, A>): {
|
|
70
|
+
store: Omit<Omit<import('zustand').StoreApi<S & A>, "subscribe"> & {
|
|
71
|
+
subscribe: {
|
|
72
|
+
(listener: (selectedState: S & A, previousSelectedState: S & A) => void): () => void;
|
|
73
|
+
<U>(selector: (state: S & A) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
74
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
75
|
+
fireImmediately?: boolean;
|
|
76
|
+
} | undefined): () => void;
|
|
77
|
+
};
|
|
78
|
+
}, "setState" | "persist"> & {
|
|
79
|
+
setState(partial: (S & A) | Partial<S & A> | ((state: S & A) => (S & A) | Partial<S & A>), replace?: false | undefined): unknown;
|
|
80
|
+
setState(state: (S & A) | ((state: S & A) => S & A), replace: true): unknown;
|
|
81
|
+
persist: {
|
|
82
|
+
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<S & A, Partial<S & A>, unknown>>) => void;
|
|
83
|
+
clearStorage: () => void;
|
|
84
|
+
rehydrate: () => Promise<void> | void;
|
|
85
|
+
hasHydrated: () => boolean;
|
|
86
|
+
onHydrate: (fn: (state: S & A) => void) => () => void;
|
|
87
|
+
onFinishHydration: (fn: (state: S & A) => void) => () => void;
|
|
88
|
+
getOptions: () => Partial<import('zustand/middleware').PersistOptions<S & A, Partial<S & A>, unknown>>;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
useStore: <T>(selector: (state: S & A) => T) => T;
|
|
92
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Theme, ThemeEnum } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 将当前主题变量注入到 document 的 CSS Variables,并持久化主题名到 localStorage。
|
|
4
|
+
* Injects current theme variables into document CSS custom properties and persists theme name to localStorage.
|
|
5
|
+
*
|
|
6
|
+
* @param currentTheme - 完整主题对象(颜色 + 基础)。Full theme (colors + base).
|
|
7
|
+
* @param themeName - 当前主题枚举名,用于持久化。Current theme enum key for persistence.
|
|
8
|
+
*/
|
|
9
|
+
declare const useThemeVariables: (currentTheme: Theme, themeName: ThemeEnum) => void;
|
|
10
|
+
export default useThemeVariables;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseTheme, BaseEnum } from '../../types';
|
|
2
|
+
export declare const bases: Record<BaseEnum, BaseTheme>;
|
|
3
|
+
export { defaultBaseTheme, defaultBaseVariables } from './default';
|
|
4
|
+
export { iosBaseTheme, iosBaseVariables } from './ios';
|
|
5
|
+
export { androidBaseTheme, androidBaseVariables } from './android';
|
|
6
|
+
export { windowsBaseTheme, windowsBaseVariables } from './windows';
|
|
7
|
+
export { linuxBaseTheme, linuxBaseVariables } from './linux';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Theme, ThemeEnum } from '../../types';
|
|
2
|
+
declare const defaultTheme: Theme;
|
|
3
|
+
declare const lightTheme: Theme;
|
|
4
|
+
declare const darkTheme: Theme;
|
|
5
|
+
declare const cosmicTheme: Theme;
|
|
6
|
+
declare const corporateTheme: Theme;
|
|
7
|
+
declare const forestTheme: Theme;
|
|
8
|
+
declare const coffeeTheme: Theme;
|
|
9
|
+
declare const wineTheme: Theme;
|
|
10
|
+
declare const wheatTheme: Theme;
|
|
11
|
+
export declare const themes: Record<ThemeEnum, Theme>;
|
|
12
|
+
export { defaultTheme, lightTheme, darkTheme, cosmicTheme, corporateTheme, forestTheme, coffeeTheme, wineTheme, wheatTheme };
|