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.
Files changed (162) hide show
  1. package/dist/src/apis/index.d.ts +2 -0
  2. package/dist/src/apis/ip.d.ts +4 -0
  3. package/dist/src/constants/caches.d.ts +5 -0
  4. package/dist/src/constants/enums.d.ts +18 -0
  5. package/dist/src/constants/index.d.ts +9 -0
  6. package/dist/src/constants/query.itemkeys.d.ts +31 -0
  7. package/dist/src/constants/query.listkeys.d.ts +30 -0
  8. package/dist/src/constants/querykeys.d.ts +42 -0
  9. package/dist/src/designs/animations/BounceLoading/index.d.ts +7 -0
  10. package/dist/src/designs/animations/ECGLoading/index.d.ts +6 -0
  11. package/dist/src/designs/animations/LetterGlitch/index.d.ts +12 -0
  12. package/dist/src/designs/animations/PixelBlast/index.d.ts +28 -0
  13. package/dist/src/designs/animations/Squares/index.d.ts +13 -0
  14. package/dist/src/designs/animations/TruckLoading/index.d.ts +6 -0
  15. package/dist/src/designs/animations/Waves/index.d.ts +18 -0
  16. package/dist/src/designs/animations/index.d.ts +6 -0
  17. package/dist/src/designs/components/Button/index.d.ts +20 -0
  18. package/dist/src/designs/components/Dropdown/index.d.ts +24 -0
  19. package/dist/src/designs/components/Icon/index.d.ts +9 -0
  20. package/dist/src/designs/components/Input/index.d.ts +23 -0
  21. package/dist/src/designs/components/KeyValueEditor/index.d.ts +30 -0
  22. package/dist/src/designs/components/LayoutSwitcher/index.d.ts +3 -0
  23. package/dist/src/designs/components/SearchInput/index.d.ts +12 -0
  24. package/dist/src/designs/components/ShowFilter/index.d.ts +28 -0
  25. package/dist/src/designs/components/SlideDownSwitcher/index.d.ts +16 -0
  26. package/dist/src/designs/components/Slider/index.d.ts +26 -0
  27. package/dist/src/designs/components/Suspense/SuspenseErrorBoundary.d.ts +21 -0
  28. package/dist/src/designs/components/Suspense/index.d.ts +47 -0
  29. package/dist/src/designs/components/Textarea/index.d.ts +21 -0
  30. package/dist/src/designs/components/ThemeSwitcher/index.d.ts +3 -0
  31. package/dist/src/designs/components/VirtualList/index.d.ts +41 -0
  32. package/dist/src/designs/components/VirtualWindowList/index.d.ts +41 -0
  33. package/dist/src/designs/components/index.d.ts +33 -0
  34. package/dist/src/designs/layouts/components/Background/index.d.ts +11 -0
  35. package/dist/src/designs/layouts/components/Footer/index.d.ts +5 -0
  36. package/dist/src/designs/layouts/components/Header/index.d.ts +4 -0
  37. package/dist/src/designs/layouts/components/LayoutFrame/index.d.ts +3 -0
  38. package/dist/src/designs/layouts/components/MainWrapper/index.d.ts +3 -0
  39. package/dist/src/designs/layouts/components/SideHideLayout/index.d.ts +3 -0
  40. package/dist/src/designs/layouts/components/SideShowLayout/index.d.ts +3 -0
  41. package/dist/src/designs/layouts/components/Sidebar/index.d.ts +3 -0
  42. package/dist/src/designs/layouts/components/index.d.ts +8 -0
  43. package/dist/src/designs/layouts/hooks/index.d.ts +3 -0
  44. package/dist/src/designs/layouts/hooks/useAction.d.ts +7 -0
  45. package/dist/src/designs/layouts/hooks/useLayout.d.ts +5 -0
  46. package/dist/src/designs/layouts/hooks/useSet.d.ts +10 -0
  47. package/dist/src/designs/layouts/index.d.ts +8 -0
  48. package/dist/src/designs/layouts/providers/index.d.ts +3 -0
  49. package/dist/src/designs/layouts/types/components.d.ts +117 -0
  50. package/dist/src/designs/layouts/types/context.d.ts +12 -0
  51. package/dist/src/designs/layouts/types/index.d.ts +6 -0
  52. package/dist/src/designs/layouts/types/layout.d.ts +11 -0
  53. package/dist/src/designs/layouts/utils/index.d.ts +4 -0
  54. package/dist/src/designs/layouts/utils/layoutStorage.d.ts +4 -0
  55. package/dist/src/events/EventEmitter.d.ts +48 -0
  56. package/dist/src/events/index.d.ts +5 -0
  57. package/dist/src/hooks/index.d.ts +4 -0
  58. package/dist/src/hooks/makeCursorFetchFunction.d.ts +84 -0
  59. package/dist/src/hooks/makeUnifiedInfiniteQuery.d.ts +124 -0
  60. package/dist/src/hooks/makeUnifiedQuery.d.ts +19 -0
  61. package/dist/src/hooks/type.d.ts +36 -0
  62. package/dist/src/icons/index.d.ts +1 -0
  63. package/dist/src/icons/lucide.d.ts +2 -0
  64. package/dist/src/languages/hooks/index.d.ts +8 -0
  65. package/dist/src/languages/hooks/useLanguageLabel.d.ts +6 -0
  66. package/dist/src/languages/hooks/useLayoutLabel.d.ts +6 -0
  67. package/dist/src/languages/hooks/usePreferenceLabel.d.ts +6 -0
  68. package/dist/src/languages/hooks/useThemeLabel.d.ts +6 -0
  69. package/dist/src/languages/index.d.ts +11 -0
  70. package/dist/src/languages/languages/i18n.d.ts +8 -0
  71. package/dist/src/languages/languages/i18nResources.d.ts +13 -0
  72. package/dist/src/languages/languages/index.d.ts +2 -0
  73. package/dist/src/languages/providers/index.d.ts +3 -0
  74. package/dist/src/languages/resources/index.d.ts +8 -0
  75. package/dist/src/languages/types/components.d.ts +23 -0
  76. package/dist/src/languages/types/i18n.d.ts +28 -0
  77. package/dist/src/languages/types/index.d.ts +6 -0
  78. package/dist/src/languages/types/language.d.ts +13 -0
  79. package/dist/src/languages/utils/getLocalLanguage.d.ts +2 -0
  80. package/dist/src/languages/utils/index.d.ts +5 -0
  81. package/dist/src/languages/utils/languageStorage.d.ts +5 -0
  82. package/dist/src/navigations/index.d.ts +1 -0
  83. package/dist/src/navigations/navigation.d.ts +50 -0
  84. package/dist/src/preference/constants.d.ts +12 -0
  85. package/dist/src/preference/index.d.ts +35 -0
  86. package/dist/src/services/imageService.d.ts +6 -0
  87. package/dist/src/services/index.d.ts +1 -0
  88. package/dist/src/stores/index.d.ts +1 -0
  89. package/dist/src/stores/makeStore.d.ts +92 -0
  90. package/dist/src/themes/hooks/index.d.ts +2 -0
  91. package/dist/src/themes/hooks/useTheme.d.ts +5 -0
  92. package/dist/src/themes/hooks/useThemeVariables.d.ts +10 -0
  93. package/dist/src/themes/index.d.ts +8 -0
  94. package/dist/src/themes/providers/index.d.ts +3 -0
  95. package/dist/src/themes/themes/bases/android.d.ts +4 -0
  96. package/dist/src/themes/themes/bases/default.d.ts +5 -0
  97. package/dist/src/themes/themes/bases/index.d.ts +7 -0
  98. package/dist/src/themes/themes/bases/ios.d.ts +4 -0
  99. package/dist/src/themes/themes/bases/linux.d.ts +4 -0
  100. package/dist/src/themes/themes/bases/windows.d.ts +4 -0
  101. package/dist/src/themes/themes/colors/coffee.d.ts +7 -0
  102. package/dist/src/themes/themes/colors/corporate.d.ts +7 -0
  103. package/dist/src/themes/themes/colors/cosmic.d.ts +7 -0
  104. package/dist/src/themes/themes/colors/dark.d.ts +7 -0
  105. package/dist/src/themes/themes/colors/default.d.ts +7 -0
  106. package/dist/src/themes/themes/colors/forest.d.ts +7 -0
  107. package/dist/src/themes/themes/colors/index.d.ts +12 -0
  108. package/dist/src/themes/themes/colors/light.d.ts +7 -0
  109. package/dist/src/themes/themes/colors/wheat.d.ts +8 -0
  110. package/dist/src/themes/themes/colors/wine.d.ts +7 -0
  111. package/dist/src/themes/themes/index.d.ts +2 -0
  112. package/dist/src/themes/types/components.d.ts +20 -0
  113. package/dist/src/themes/types/context.d.ts +16 -0
  114. package/dist/src/themes/types/index.d.ts +6 -0
  115. package/dist/src/themes/types/theme.d.ts +209 -0
  116. package/dist/src/themes/utils/index.d.ts +4 -0
  117. package/dist/src/themes/utils/themeStorage.d.ts +7 -0
  118. package/dist/src/types/api.d.ts +75 -0
  119. package/dist/src/types/index.d.ts +2 -0
  120. package/dist/src/types/utils.d.ts +83 -0
  121. package/dist/src/utils/address.d.ts +7 -0
  122. package/dist/src/utils/apiError.d.ts +16 -0
  123. package/dist/src/utils/array.d.ts +21 -0
  124. package/dist/src/utils/colors.d.ts +41 -0
  125. package/dist/src/utils/email.d.ts +7 -0
  126. package/dist/src/utils/form.d.ts +14 -0
  127. package/dist/src/utils/index.d.ts +24 -0
  128. package/dist/src/utils/lstorage.d.ts +4 -0
  129. package/dist/src/utils/object.d.ts +10 -0
  130. package/dist/src/utils/polling.d.ts +12 -0
  131. package/dist/src/utils/price.d.ts +28 -0
  132. package/dist/src/utils/promise.d.ts +17 -0
  133. package/dist/src/utils/random.d.ts +39 -0
  134. package/dist/src/utils/result.d.ts +21 -0
  135. package/dist/src/utils/retry.d.ts +15 -0
  136. package/dist/src/utils/safe.d.ts +69 -0
  137. package/dist/src/utils/singleton.d.ts +21 -0
  138. package/dist/src/utils/suspense.d.ts +10 -0
  139. package/dist/src/utils/time.d.ts +49 -0
  140. package/dist/src/utils/types.d.ts +10 -0
  141. package/dist/utils.cjs +1 -1
  142. package/dist/utils.cjs.map +1 -1
  143. package/dist/utils.mjs +171 -147
  144. package/dist/utils.mjs.map +1 -1
  145. package/package.json +19 -22
  146. package/dist/animations.d.ts +0 -1
  147. package/dist/apis.d.ts +0 -1
  148. package/dist/components.d.ts +0 -1
  149. package/dist/constants.d.ts +0 -1
  150. package/dist/events.d.ts +0 -1
  151. package/dist/hooks.d.ts +0 -1
  152. package/dist/icons.d.ts +0 -1
  153. package/dist/languages.d.ts +0 -1
  154. package/dist/layouts.d.ts +0 -1
  155. package/dist/navigations.d.ts +0 -1
  156. package/dist/pixel-blast.d.ts +0 -1
  157. package/dist/preference.d.ts +0 -1
  158. package/dist/services.d.ts +0 -1
  159. package/dist/stores.d.ts +0 -1
  160. package/dist/themes.d.ts +0 -1
  161. package/dist/types.d.ts +0 -1
  162. 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,2 @@
1
+ export * from './i18n';
2
+ export * from './i18nResources';
@@ -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,6 @@
1
+ /**
2
+ * 语言模块类型统一导出。All language module types re-exported.
3
+ */
4
+ export * from './language';
5
+ export * from './i18n';
6
+ export * from './components';
@@ -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,2 @@
1
+ import { LanguageEnum } from '../types';
2
+ export declare function getLocalLanguage(): LanguageEnum;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 语言模块工具函数。Language module utils.
3
+ */
4
+ export { getLocalLanguage } from './getLocalLanguage';
5
+ export { getLanguageStorage, removeLanguageStorage, setLanguageStorage, } from './languageStorage';
@@ -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,6 @@
1
+ /**
2
+ * 压缩头像图片(用于上传)
3
+ * @param file - 用户选择的图片文件
4
+ * @returns File - 压缩后的文件
5
+ */
6
+ export declare const compressImage: (file: File) => Promise<File>;
@@ -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,2 @@
1
+ export * from './useTheme';
2
+ export * from './useThemeVariables';
@@ -0,0 +1,5 @@
1
+ import { ThemeContextType } from '../types';
2
+ declare const ThemeContext: import('react').Context<ThemeContextType | undefined>;
3
+ declare function useTheme(): ThemeContextType;
4
+ export { ThemeContext, useTheme };
5
+ export type { ThemeContextType } from '../types';
@@ -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,8 @@
1
+ /**
2
+ * 主题模块统一导出。Themes module barrel exports.
3
+ */
4
+ export * from './types';
5
+ export * from './utils';
6
+ export { default as ThemeProvider } from './providers';
7
+ export * from './hooks';
8
+ export * from './themes';
@@ -0,0 +1,3 @@
1
+ import { ThemeProviderProps } from '../types';
2
+ declare const ThemeProvider: import('react').MemoExoticComponent<({ children, defaultTheme, defaultBase }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element>;
3
+ export default ThemeProvider;
@@ -0,0 +1,4 @@
1
+ import { BaseTheme, BaseVariables } from '../../types';
2
+ /** Android 风格圆角(如 6) */
3
+ export declare const androidBaseVariables: BaseVariables;
4
+ export declare const androidBaseTheme: BaseTheme;
@@ -0,0 +1,5 @@
1
+ import { BaseTheme, BaseVariables } from '../../types';
2
+ /** 默认基础变量(跨平台通用) */
3
+ export declare const defaultBaseVariables: BaseVariables;
4
+ /** 默认基础主题 */
5
+ export declare const defaultBaseTheme: BaseTheme;
@@ -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,4 @@
1
+ import { BaseTheme, BaseVariables } from '../../types';
2
+ /** iOS 风格圆角(较大,如 24) */
3
+ export declare const iosBaseVariables: BaseVariables;
4
+ export declare const iosBaseTheme: BaseTheme;
@@ -0,0 +1,4 @@
1
+ import { BaseTheme, BaseVariables } from '../../types';
2
+ /** Linux 风格圆角(较小,如 4) */
3
+ export declare const linuxBaseVariables: BaseVariables;
4
+ export declare const linuxBaseTheme: BaseTheme;
@@ -0,0 +1,4 @@
1
+ import { BaseTheme, BaseVariables } from '../../types';
2
+ /** Windows 风格圆角(如 6) */
3
+ export declare const windowsBaseVariables: BaseVariables;
4
+ export declare const windowsBaseTheme: BaseTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Coffee — Warm Earth
4
+ * 深色暖棕,焦糖拿铁主色 #C49A6C。
5
+ * 深咖啡背景 + 奶油色文字,温暖舒适。
6
+ */
7
+ export declare const coffeeColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Corporate — Blue Professional
4
+ * 企业蓝 #2563EB,搭配轻量蓝灰 Slate 中性色。
5
+ * 冷静、值得信赖、专业感。
6
+ */
7
+ export declare const corporateColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Cosmic — Electric Purple
4
+ * 深空紫调,梦幻科幻。
5
+ * 主色电紫 #8B5CF6,深靛蓝背景,薰衣草文字层次。
6
+ */
7
+ export declare const cosmicColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Dark — Amber Gold on Zinc
4
+ * 深色模式,琥珀金主色 + 锌灰背景。
5
+ * 暖色调暗色,层级分明,阅读舒适。
6
+ */
7
+ export declare const darkColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Default — Crimson Red
4
+ * 品牌主色:鲜红 #DC2626,搭配 Tailwind gray 中性色。
5
+ * 适合 IoT 仪表盘的告警/操作视觉调性。
6
+ */
7
+ export declare const defaultColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Forest — Deep Green
4
+ * 自然绿 #15803D,翡翠色层级。
5
+ * 有机、宁静、自然,带金黄 warning 做暖色点缀。
6
+ */
7
+ export declare const forestColorTheme: ColorTheme;
@@ -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 };
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Light — Slate Professional
4
+ * 中性蓝灰色系,无强色彩偏向。
5
+ * 深色 Slate 做主色,适合专业办公/阅读场景。
6
+ */
7
+ export declare const lightColorTheme: ColorTheme;
@@ -0,0 +1,8 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Wheat — Golden Harvest
4
+ * 浅色暖金,主色琥珀 #B45309。
5
+ * 暖奶油色背景 + 深棕文字,丰收质感。
6
+ * danger 使用独立红色,不与 primary 金色混淆。
7
+ */
8
+ export declare const wheatColorTheme: ColorTheme;
@@ -0,0 +1,7 @@
1
+ import { ColorTheme } from '../../types';
2
+ /**
3
+ * Wine — Burgundy Rose
4
+ * 深色酒红,主色 #9F1239 (Rose-800)。
5
+ * 深酒红背景 + 淡玫瑰文字,高贵典雅。
6
+ */
7
+ export declare const wineColorTheme: ColorTheme;