nfx-ui 0.7.3 → 0.8.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 +37 -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 +23 -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/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/package.json +19 -22
- package/README +0 -323
- 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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 结果类型:成功为 [T, null],失败为 [null, Error]。
|
|
3
|
+
* Result type: success [T, null], failure [null, Error].
|
|
4
|
+
* @template T - 成功时的值类型。Value type on success.
|
|
5
|
+
* @example const [data, err] = await withRetryResult(() => fetchData()); if (err) return; use(data);
|
|
6
|
+
*/
|
|
7
|
+
export type Result<T> = [T, null] | [null, Error];
|
|
8
|
+
/**
|
|
9
|
+
* 构造成功结果。Create a successful result.
|
|
10
|
+
* @param v - 结果值。Result value.
|
|
11
|
+
* @returns [v, null]
|
|
12
|
+
* @example ok(42) // [42, null]
|
|
13
|
+
*/
|
|
14
|
+
export declare const ok: <T>(v: T) => Result<T>;
|
|
15
|
+
/**
|
|
16
|
+
* 构造失败结果(非 Error 会包装为 Error)。Create a failed result; non-Error wrapped in Error.
|
|
17
|
+
* @param e - 错误或任意值。Error or any value.
|
|
18
|
+
* @returns [null, Error]
|
|
19
|
+
* @example err(new Error("fail")) // [null, Error]
|
|
20
|
+
*/
|
|
21
|
+
export declare const err: (e: unknown) => Result<never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Options as RetryOptions } from 'async-retry';
|
|
2
|
+
import { Result } from './result';
|
|
3
|
+
export type WithRetryOptions = RetryOptions & {
|
|
4
|
+
/** 若返回 true 则不再重试,直接 bail。If true, do not retry and bail. */
|
|
5
|
+
isNonRetryable?: (e: Error) => boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 带重试执行异步函数,成功返回 ok(value),失败返回 err(error)。
|
|
9
|
+
* Retry async function until success or max attempts; returns Result.
|
|
10
|
+
* @param fn - 可接收 bail 与 attempt 的异步函数。Async function receiving bail and attempt.
|
|
11
|
+
* @param opts - async-retry 选项及 isNonRetryable。async-retry options and isNonRetryable.
|
|
12
|
+
* @returns Promise<Result<T>>
|
|
13
|
+
* @example const [data, err] = await withRetryResult(() => fetchData(), { retries: 3 });
|
|
14
|
+
*/
|
|
15
|
+
export declare function withRetryResult<T>(fn: (bail: (e: Error) => void, attempt: number) => Promise<T>, opts?: WithRetryOptions): Promise<Result<T>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Nullable, Maybe, Nilable, Emptyable, Zeroable, Stringable, Array } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* 将 Nilable 规范为 Nullable:undefined 转为 null,null 与 T 原样返回。返回类型 Nullable<T>。
|
|
4
|
+
* Normalize Nilable to Nullable: convert undefined to null; null and T unchanged. Returns Nullable<T>.
|
|
5
|
+
* @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
|
|
6
|
+
* @returns 若为 undefined 则 null,否则原值 (null if undefined, otherwise value)
|
|
7
|
+
* @example safeNullable(apiResponse.data) // undefined → null,便于区分「未设置」与「空」
|
|
8
|
+
*/
|
|
9
|
+
export declare function safeNullable<T>(value: Nilable<T>): Nullable<T>;
|
|
10
|
+
/**
|
|
11
|
+
* 将 Nilable 规范为 Maybe:null 转为 undefined,undefined 与 T 原样返回。返回类型 Maybe<T>。等同 value ?? undefined。
|
|
12
|
+
* Normalize Nilable to Maybe: convert null to undefined; undefined and T unchanged. Returns Maybe<T>. Same as value ?? undefined.
|
|
13
|
+
* @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
|
|
14
|
+
* @returns 若为 null 或 undefined 则 undefined,否则原值 (undefined if null/undefined, otherwise value)
|
|
15
|
+
* @example safeMaybe(product.price) // 代替 product.price ?? undefined
|
|
16
|
+
*/
|
|
17
|
+
export declare function safeMaybe<T>(value: Nilable<T>): Maybe<T>;
|
|
18
|
+
/**
|
|
19
|
+
* 将 Emptyable 字符串规范为 Nilable:空字符串转为 undefined,null/undefined/非空串原样。返回类型 Nilable<T>。常用于表单、接口字段。
|
|
20
|
+
* Normalize Emptyable string to Nilable: "" to undefined; null, undefined, non-empty string unchanged. Returns Nilable<T>. For form/API fields.
|
|
21
|
+
* @param value - 可能为 null、undefined 或空字符串 (value that may be null, undefined or "")
|
|
22
|
+
* @returns 若为 "" 则 undefined,否则原值 (undefined if "", otherwise value)
|
|
23
|
+
* @example safeNilable(product.remark) // "" 也视为「无值」
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeNilable<T extends string>(value: Emptyable<T>): Nilable<T>;
|
|
26
|
+
/**
|
|
27
|
+
* 将 Nilable 数组规范为数组:null/undefined 转为 [] 或 defaultValue。返回类型 Array<T>(即 T[])。
|
|
28
|
+
* Normalize Nilable array to array: null/undefined to [] or defaultValue. Returns Array<T> (i.e. T[]).
|
|
29
|
+
* @param value - 可能为 null 或 undefined 的数组 (array that may be null or undefined)
|
|
30
|
+
* @param defaultValue - 可选,当 value 为 null/undefined 时使用;缺省为 [] (optional default when value is null/undefined; default is [])
|
|
31
|
+
* @returns value ?? defaultValue ?? [] (never null/undefined)
|
|
32
|
+
* @example safeArray(product.tags) // product.tags ?? []
|
|
33
|
+
* @example safeArray(product.tags, ['default'])
|
|
34
|
+
*/
|
|
35
|
+
export declare function safeArray<T>(value: Nilable<Array<T>>, defaultValue?: Array<T>): Array<T>;
|
|
36
|
+
/**
|
|
37
|
+
* 将 Nilable 数值规范为 Zeroable:null/undefined 转为 0。返回类型 Zeroable<number>(即 number,0 为兜底)。
|
|
38
|
+
* Normalize Nilable number to Zeroable: null/undefined to 0. Returns Zeroable<number> (number with 0 as fallback).
|
|
39
|
+
* @param value - 可能为 null 或 undefined 的数值 (number that may be null or undefined)
|
|
40
|
+
* @returns value ?? 0 (never null/undefined)
|
|
41
|
+
* @example safeZeroable(product.stock) // 代替 product.stock ?? 0
|
|
42
|
+
*/
|
|
43
|
+
export declare function safeZeroable(value: Nilable<number>): Zeroable<number>;
|
|
44
|
+
/**
|
|
45
|
+
* 将 Emptyable 字符串规范为 Stringable:null/undefined/"" 转为 ""。返回类型 Stringable<string>(即 string,"" 为兜底)。
|
|
46
|
+
* Normalize Emptyable string to Stringable: null/undefined/"" to "". Returns Stringable<string> (string with "" as fallback).
|
|
47
|
+
* @param value - 可能为 null、undefined 或空字符串 (value that may be null, undefined or "")
|
|
48
|
+
* @returns 若为 null、undefined 或 "" 则 "",否则原值 ("" if null/undefined/"", otherwise value)
|
|
49
|
+
* @example safeStringable(product.name) // 代替 product.name ?? ""
|
|
50
|
+
*/
|
|
51
|
+
export declare function safeStringable<T extends string>(value: Emptyable<T>): Stringable<T>;
|
|
52
|
+
/**
|
|
53
|
+
* 若值为 null/undefined 则返回默认值,否则返回原值。等同 value ?? defaultValue。
|
|
54
|
+
* Return defaultValue when value is null/undefined, otherwise value. Same as value ?? defaultValue.
|
|
55
|
+
* @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
|
|
56
|
+
* @param defaultValue - 默认值 (default value)
|
|
57
|
+
* @returns value ?? defaultValue
|
|
58
|
+
* @example safeOr(product.stock, 0)
|
|
59
|
+
* @example safeOr(product.name, '')
|
|
60
|
+
*/
|
|
61
|
+
export declare function safeOr<T, D>(value: Nilable<T>, defaultValue: D): T | D;
|
|
62
|
+
/**
|
|
63
|
+
* 安全取数字:null/undefined/NaN 转为 undefined,合法数字原样。返回类型 Maybe<number>。
|
|
64
|
+
* Safe number: null/undefined/NaN to undefined; valid number unchanged. Returns Maybe<number>.
|
|
65
|
+
* @param value - 可能为 null、undefined 或非数字 (value that may be null, undefined or NaN)
|
|
66
|
+
* @returns 若为 null、undefined 或 NaN 则 undefined,否则数字 (undefined if null/undefined/NaN, otherwise number)
|
|
67
|
+
* @example safeNum(product.price) // 用于严格「有值才用」的场景
|
|
68
|
+
*/
|
|
69
|
+
export declare function safeNum(value: Nilable<number>): Maybe<number>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 可实例化的构造函数类型。Instantiable constructor type. */
|
|
2
|
+
type Constructor<T extends object = object> = new (...args: unknown[]) => T;
|
|
3
|
+
/**
|
|
4
|
+
* 单例工厂:将传入的构造函数包装为单例模式;Proxy 拦截 construct,多次 new 返回同一实例。
|
|
5
|
+
* Singleton factory: wrap constructor so that multiple new calls return the same instance.
|
|
6
|
+
*
|
|
7
|
+
* @template T - 实例类型(需为 object)。Instance type (must be object).
|
|
8
|
+
* @param className - 被包装的构造函数(class)。Constructor (class) to wrap.
|
|
9
|
+
* @returns 代理后的构造函数,调用时始终返回同一实例。Proxied constructor returning same instance.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* class MyService { ... }
|
|
14
|
+
* const SingletonService = singleton(MyService);
|
|
15
|
+
* const a = new SingletonService();
|
|
16
|
+
* const b = new SingletonService();
|
|
17
|
+
* console.log(a === b); // true
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const singleton: <T extends object>(className: Constructor<T>) => Constructor<T>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Nilable } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* 若值为 null/undefined 则抛出 Promise 使 React Suspense 挂起,否则返回该值。
|
|
4
|
+
* If value is null/undefined, throw a promise to suspend (React Suspense); otherwise return value.
|
|
5
|
+
* @param value - 待检查的值。Value to check.
|
|
6
|
+
* @param delay - 重试前的延迟(毫秒)。Delay in ms before retry.
|
|
7
|
+
* @returns 非空时的 value。Value when non-null.
|
|
8
|
+
* @example const data = suspenseIfNull(resource); // 在 Suspense 边界内,data 非空时才渲染
|
|
9
|
+
*/
|
|
10
|
+
export declare function suspenseIfNull<T>(value: Nilable<T>, delay?: number): T;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化日期为 YYYY/MM/DD(空或无效返回 "")
|
|
3
|
+
* Format date as YYYY/MM/DD; empty or invalid returns "".
|
|
4
|
+
* @param dateString - 日期字符串
|
|
5
|
+
* @returns 格式化后的日期字符串,无效则 ""
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatDisplayDate: (dateString: string | undefined | null) => string;
|
|
8
|
+
/**
|
|
9
|
+
* 格式化为相对时间(如 2 days ago, 3 months ago)
|
|
10
|
+
* Format as relative time (e.g. 2 days ago, 3 months ago).
|
|
11
|
+
* @param dateString - 日期字符串
|
|
12
|
+
* @returns 相对时间字符串,无效为 "Invalid date",空为 "Unknown"
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatRelativeTime: (dateString: string | undefined | null) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 格式化 ISO 日期为图表轴/提示用短格式(如:Jan 4, 02:30 PM)
|
|
17
|
+
* Format ISO date for chart axis/tooltip (e.g. Jan 4, 02:30 PM).
|
|
18
|
+
* @param iso - ISO 日期字符串
|
|
19
|
+
* @returns 格式化字符串,解析失败则返回原串
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatTickDate(iso: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* 格式化时间显示年月日时分 (YYYY/MM/DD HH:mm)
|
|
24
|
+
* Format date-time as year/month/day hour:minute.
|
|
25
|
+
* @param dateString - 时间字符串
|
|
26
|
+
* @returns 格式化后的时间字符串,无效则返回原串
|
|
27
|
+
*/
|
|
28
|
+
export declare const formatDateTime: (dateString: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* 格式化时间显示月日时分 (MM/DD HH:mm)
|
|
31
|
+
* Format date-time as month/day hour:minute.
|
|
32
|
+
* @param dateString - 时间字符串
|
|
33
|
+
* @returns 格式化后的时间字符串,无效则返回原串
|
|
34
|
+
*/
|
|
35
|
+
export declare const formatMonthDayTime: (dateString: string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* 格式化日期仅年月日 (YYYY/MM/DD),用于生日等
|
|
38
|
+
* Format date as year/month/day only.
|
|
39
|
+
* @param dateString - 日期字符串,如 "2000-01-15" 或 ISO
|
|
40
|
+
* @returns 格式化后的日期字符串,无效则返回原串
|
|
41
|
+
*/
|
|
42
|
+
export declare const formatDate: (dateString: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* 格式化时间显示时分 (HH:mm)
|
|
45
|
+
* Format time as hour:minute.
|
|
46
|
+
* @param dateString - 时间字符串
|
|
47
|
+
* @returns 格式化后的时间字符串,无效则返回原串
|
|
48
|
+
*/
|
|
49
|
+
export declare const formatTime: (dateString: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从字符串列表创建键值映射对象;可选 valueMapper 指定值
|
|
3
|
+
* Create record from string list; optional valueMapper for values.
|
|
4
|
+
* @param list - 字符串数组(作为键)
|
|
5
|
+
* @param valueMapper - 可选,(item, index) => value,缺省时值为键本身
|
|
6
|
+
* @returns Record<list[number], V>
|
|
7
|
+
* @example createMap(["a","b","c"]) // { a: "a", b: "b", c: "c" }
|
|
8
|
+
* @example createMap(["a","b","c"], (_, i) => i) // { a: 0, b: 1, c: 2 }
|
|
9
|
+
*/
|
|
10
|
+
export declare function createMap<T extends string, V = T>(list: ReadonlyArray<T>, valueMapper?: (item: T, index: number) => V): Record<T, V>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nfx-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Unified frontend UI library for the NFX product family: shared React components, design tokens, theme variables, and layout primitives for a consistent look and behavior across NFX console and other apps.",
|
|
@@ -14,103 +14,103 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
"./themes": {
|
|
17
|
-
"types": "./dist/themes.d.ts",
|
|
17
|
+
"types": "./dist/src/themes/index.d.ts",
|
|
18
18
|
"import": "./dist/themes.mjs",
|
|
19
19
|
"require": "./dist/themes.cjs",
|
|
20
20
|
"default": "./dist/themes.mjs"
|
|
21
21
|
},
|
|
22
22
|
"./layouts": {
|
|
23
|
-
"types": "./dist/layouts.d.ts",
|
|
23
|
+
"types": "./dist/src/designs/layouts/index.d.ts",
|
|
24
24
|
"import": "./dist/layouts.mjs",
|
|
25
25
|
"require": "./dist/layouts.cjs",
|
|
26
26
|
"default": "./dist/layouts.mjs"
|
|
27
27
|
},
|
|
28
28
|
"./components": {
|
|
29
|
-
"types": "./dist/components.d.ts",
|
|
29
|
+
"types": "./dist/src/designs/components/index.d.ts",
|
|
30
30
|
"import": "./dist/components.mjs",
|
|
31
31
|
"require": "./dist/components.cjs",
|
|
32
32
|
"default": "./dist/components.mjs"
|
|
33
33
|
},
|
|
34
34
|
"./animations": {
|
|
35
|
-
"types": "./dist/animations.d.ts",
|
|
35
|
+
"types": "./dist/src/designs/animations/index.d.ts",
|
|
36
36
|
"import": "./dist/animations.mjs",
|
|
37
37
|
"require": "./dist/animations.cjs",
|
|
38
38
|
"default": "./dist/animations.mjs"
|
|
39
39
|
},
|
|
40
40
|
"./hooks": {
|
|
41
|
-
"types": "./dist/hooks.d.ts",
|
|
41
|
+
"types": "./dist/src/hooks/index.d.ts",
|
|
42
42
|
"import": "./dist/hooks.mjs",
|
|
43
43
|
"require": "./dist/hooks.cjs",
|
|
44
44
|
"default": "./dist/hooks.mjs"
|
|
45
45
|
},
|
|
46
46
|
"./preference": {
|
|
47
|
-
"types": "./dist/preference.d.ts",
|
|
47
|
+
"types": "./dist/src/preference/index.d.ts",
|
|
48
48
|
"import": "./dist/preference.mjs",
|
|
49
49
|
"require": "./dist/preference.cjs",
|
|
50
50
|
"default": "./dist/preference.mjs"
|
|
51
51
|
},
|
|
52
52
|
"./stores": {
|
|
53
|
-
"types": "./dist/stores.d.ts",
|
|
53
|
+
"types": "./dist/src/stores/index.d.ts",
|
|
54
54
|
"import": "./dist/stores.mjs",
|
|
55
55
|
"require": "./dist/stores.cjs",
|
|
56
56
|
"default": "./dist/stores.mjs"
|
|
57
57
|
},
|
|
58
58
|
"./apis": {
|
|
59
|
-
"types": "./dist/apis.d.ts",
|
|
59
|
+
"types": "./dist/src/apis/index.d.ts",
|
|
60
60
|
"import": "./dist/apis.mjs",
|
|
61
61
|
"require": "./dist/apis.cjs",
|
|
62
62
|
"default": "./dist/apis.mjs"
|
|
63
63
|
},
|
|
64
64
|
"./events": {
|
|
65
|
-
"types": "./dist/events.d.ts",
|
|
65
|
+
"types": "./dist/src/events/index.d.ts",
|
|
66
66
|
"import": "./dist/events.mjs",
|
|
67
67
|
"require": "./dist/events.cjs",
|
|
68
68
|
"default": "./dist/events.mjs"
|
|
69
69
|
},
|
|
70
70
|
"./services": {
|
|
71
|
-
"types": "./dist/services.d.ts",
|
|
71
|
+
"types": "./dist/src/services/index.d.ts",
|
|
72
72
|
"import": "./dist/services.mjs",
|
|
73
73
|
"require": "./dist/services.cjs",
|
|
74
74
|
"default": "./dist/services.mjs"
|
|
75
75
|
},
|
|
76
76
|
"./navigations": {
|
|
77
|
-
"types": "./dist/navigations.d.ts",
|
|
77
|
+
"types": "./dist/src/navigations/index.d.ts",
|
|
78
78
|
"import": "./dist/navigations.mjs",
|
|
79
79
|
"require": "./dist/navigations.cjs",
|
|
80
80
|
"default": "./dist/navigations.mjs"
|
|
81
81
|
},
|
|
82
82
|
"./types": {
|
|
83
|
-
"types": "./dist/types.d.ts",
|
|
83
|
+
"types": "./dist/src/types/index.d.ts",
|
|
84
84
|
"import": "./dist/types.mjs",
|
|
85
85
|
"require": "./dist/types.cjs",
|
|
86
86
|
"default": "./dist/types.mjs"
|
|
87
87
|
},
|
|
88
88
|
"./utils": {
|
|
89
|
-
"types": "./dist/utils.d.ts",
|
|
89
|
+
"types": "./dist/src/utils/index.d.ts",
|
|
90
90
|
"import": "./dist/utils.mjs",
|
|
91
91
|
"require": "./dist/utils.cjs",
|
|
92
92
|
"default": "./dist/utils.mjs"
|
|
93
93
|
},
|
|
94
94
|
"./constants": {
|
|
95
|
-
"types": "./dist/constants.d.ts",
|
|
95
|
+
"types": "./dist/src/constants/index.d.ts",
|
|
96
96
|
"import": "./dist/constants.mjs",
|
|
97
97
|
"require": "./dist/constants.cjs",
|
|
98
98
|
"default": "./dist/constants.mjs"
|
|
99
99
|
},
|
|
100
100
|
"./languages": {
|
|
101
|
-
"types": "./dist/languages.d.ts",
|
|
101
|
+
"types": "./dist/src/languages/index.d.ts",
|
|
102
102
|
"import": "./dist/languages.mjs",
|
|
103
103
|
"require": "./dist/languages.cjs",
|
|
104
104
|
"default": "./dist/languages.mjs"
|
|
105
105
|
},
|
|
106
106
|
"./icons": {
|
|
107
|
-
"types": "./dist/icons.d.ts",
|
|
107
|
+
"types": "./dist/src/icons/index.d.ts",
|
|
108
108
|
"import": "./dist/icons.mjs",
|
|
109
109
|
"require": "./dist/icons.cjs",
|
|
110
110
|
"default": "./dist/icons.mjs"
|
|
111
111
|
},
|
|
112
112
|
"./pixel-blast": {
|
|
113
|
-
"types": "./dist/
|
|
113
|
+
"types": "./dist/src/designs/animations/PixelBlast/index.d.ts",
|
|
114
114
|
"import": "./dist/pixel-blast.mjs",
|
|
115
115
|
"require": "./dist/pixel-blast.cjs",
|
|
116
116
|
"default": "./dist/pixel-blast.mjs"
|
|
@@ -216,9 +216,6 @@
|
|
|
216
216
|
"overrides": {
|
|
217
217
|
"vite": "^8.0.3",
|
|
218
218
|
"esbuild": "^0.27.4",
|
|
219
|
-
"minimatch": "^10.2.4"
|
|
220
|
-
"@microsoft/api-extractor": {
|
|
221
|
-
"typescript": "~6.0.2"
|
|
222
|
-
}
|
|
219
|
+
"minimatch": "^10.2.4"
|
|
223
220
|
}
|
|
224
221
|
}
|
package/README
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
# NFX-UI — Unified Frontend UI Library
|
|
2
|
-
|
|
3
|
-
**NFX-UI** is the shared frontend UI library of the NebulaForgeX ecosystem. It provides React components, design tokens, theme system, layout primitives, i18n, and utilities for a consistent look and behavior across NFX Console and other applications. Built with **React 18/19**, **TypeScript**, and **Vite** (library mode), NFX-UI is distributed as ESM/CJS with inlined styles and full type definitions—no separate CSS import required.
|
|
4
|
-
|
|
5
|
-
<div align="center">
|
|
6
|
-
<img src="https://github.com/NebulaForgeX/NFX-UI/raw/main/docs/image1.png" alt="NFX-UI Logo" width="200">
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## How to use in your app
|
|
12
|
-
|
|
13
|
-
### 1. Install
|
|
14
|
-
|
|
15
|
-
- **Option A:** After publishing to npm, run `npm install nfx-ui` in your app.
|
|
16
|
-
- **Option B:** When unpublished, run `npm run build` and `npm link` in NFX-UI, then `npm link nfx-ui` in your app.
|
|
17
|
-
- If your environment requires a script (e.g. `source /volume1/use-menv.sh`) before npm, run it first.
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Option A (in your app)
|
|
21
|
-
npm install nfx-ui
|
|
22
|
-
|
|
23
|
-
# Option B
|
|
24
|
-
# Step 1: in NFX-UI repo
|
|
25
|
-
cd /path/to/NFX-UI
|
|
26
|
-
npm run link
|
|
27
|
-
|
|
28
|
-
# Step 2: in your app
|
|
29
|
-
cd /path/to/your-app
|
|
30
|
-
npm link nfx-ui
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 2. Peer dependencies
|
|
34
|
-
|
|
35
|
-
Your project must have `react` and `react-dom` (^18.0.0 or ^19.0.0). For themes, charts, etc., you may need `lucide-react`, `recharts`, `@tanstack/react-query`, `zustand` (see NFX-UI `package.json` peerDependencies).
|
|
36
|
-
|
|
37
|
-
### 3. Usage
|
|
38
|
-
|
|
39
|
-
Use **subpath imports**; no separate CSS import. Components have typed props; use `import type { ... } from "nfx-ui/..."` for types; styles are inlined.
|
|
40
|
-
|
|
41
|
-
```tsx
|
|
42
|
-
import { ThemeProvider } from "nfx-ui/themes";
|
|
43
|
-
import { LanguageProvider } from "nfx-ui/languages";
|
|
44
|
-
import { LayoutProvider } from "nfx-ui/layouts";
|
|
45
|
-
import { Button, Input } from "nfx-ui/components";
|
|
46
|
-
import type { LanguageEnum } from "nfx-ui/languages";
|
|
47
|
-
import type { ApiErrorBody } from "nfx-ui/types";
|
|
48
|
-
|
|
49
|
-
export function App() {
|
|
50
|
-
return (
|
|
51
|
-
<ThemeProvider defaultTheme="default">
|
|
52
|
-
<LanguageProvider>
|
|
53
|
-
<LayoutProvider>
|
|
54
|
-
<Button>Confirm</Button>
|
|
55
|
-
<Input placeholder="Enter" />
|
|
56
|
-
</LayoutProvider>
|
|
57
|
-
</LanguageProvider>
|
|
58
|
-
</ThemeProvider>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 4. Full steps in another project
|
|
64
|
-
|
|
65
|
-
1. **Environment:** If required, run `source /volume1/use-menv.sh` (or your local equivalent) before any npm commands.
|
|
66
|
-
2. **Install or link:** Published: `npm install nfx-ui`. Unpublished: run `npm run link` in NFX-UI, then `npm link nfx-ui` in this project.
|
|
67
|
-
3. **Peer deps:** Ensure `react` and `react-dom` (v18 or v19) are in your project.
|
|
68
|
-
4. **Optional runtime deps:** When using themes, icons, charts, etc., install `lucide-react`, `@tanstack/react-query`, `recharts`, `zustand` in your app (versions compatible with NFX-UI’s `package.json`).
|
|
69
|
-
5. **Wrap with Providers:** Wrap your root with `ThemeProvider`, `LanguageProvider`, `LayoutProvider`, etc. (see code above).
|
|
70
|
-
6. **Import by subpath:** `import { Button } from "nfx-ui/components"`, `import { useTheme } from "nfx-ui/themes"`, etc.; use `import type { ... } from "nfx-ui/types"` for types.
|
|
71
|
-
7. **Build & run:** Use your usual scripts (`npm run dev` / `npm run build`); the bundler will resolve nfx-ui and tree-shake unused exports.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## What’s included
|
|
76
|
-
|
|
77
|
-
Main modules and contents below; full component and API docs: [docs/](./docs/).
|
|
78
|
-
|
|
79
|
-
| Module | Contents |
|
|
80
|
-
|---------------|----------|
|
|
81
|
-
| **themes** | ThemeProvider, useTheme, theme vars |
|
|
82
|
-
| **languages** | LanguageProvider, i18n, useLanguageLabel, useThemeLabel |
|
|
83
|
-
| **layouts** | LayoutProvider, Sidebar, Header, Footer, Background |
|
|
84
|
-
| **components**| Button, Input, Dropdown, Slider, VirtualList, SlideDownSwitcher, etc. |
|
|
85
|
-
| **animations**| WaveBackground, ECGLoading, TruckLoading, BounceLoading, etc. |
|
|
86
|
-
| **hooks** | makeUnifiedQuery, makeUnifiedInfiniteQuery |
|
|
87
|
-
| **preference**| User preference (e.g. profile.preference) |
|
|
88
|
-
| **types** | Shared TypeScript types |
|
|
89
|
-
| **utils** | getApiErrorMessage, formatDisplayDate, retry, etc. |
|
|
90
|
-
| **constants** | Query key factories, defineEnum |
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Development (this repo)
|
|
95
|
-
|
|
96
|
-
### Setup
|
|
97
|
-
|
|
98
|
-
This repo is library-only: no dev server or demo; test via `npm link` in a real app. Run `npm install` after clone.
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
npm install
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Build
|
|
105
|
-
|
|
106
|
-
Run `npm run build`. Output in `dist/`: ESM (`.mjs`), CJS (`.cjs`), and `.d.ts`; styles inlined.
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
npm run build
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Build messages and warnings
|
|
113
|
-
|
|
114
|
-
You may see these during build; both are safe to ignore:
|
|
115
|
-
1. **TypeScript version:** vite-plugin-dts uses an older TS in API Extractor; the “consider upgrading API Extractor” message does not affect type output.
|
|
116
|
-
2. **PLUGIN_TIMINGS:** Plugin timing breakdown; informational only.
|
|
117
|
-
|
|
118
|
-
### Test locally (npm link)
|
|
119
|
-
|
|
120
|
-
1. In NFX-UI: `npm run link`.
|
|
121
|
-
2. In your app: `npm link nfx-ui`.
|
|
122
|
-
3. After changing NFX-UI, run `npm run build` in NFX-UI again.
|
|
123
|
-
|
|
124
|
-
### Lint & format
|
|
125
|
-
|
|
126
|
-
`npm run lint` for ESLint; `npm run lint:code-format` for Prettier check; `npm run format` for Prettier write.
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
npm run lint
|
|
130
|
-
npm run lint:code-format
|
|
131
|
-
npm run format
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Project structure
|
|
137
|
-
|
|
138
|
-
`src/` contains entry and modules; path alias `@/` (points to `src/`) is used in this repo.
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
src/
|
|
142
|
-
├── designs/ # layouts, components, animations
|
|
143
|
-
├── languages/ # i18n, LanguageProvider, useLanguageLabel, etc.
|
|
144
|
-
├── themes/ # ThemeProvider, useTheme, theme data
|
|
145
|
-
├── hooks/ # makeUnifiedQuery, makeUnifiedInfiniteQuery
|
|
146
|
-
├── preference/ # User preference
|
|
147
|
-
├── types/ # Shared types
|
|
148
|
-
├── utils/ # Helpers
|
|
149
|
-
├── constants/ # Query keys, enums
|
|
150
|
-
├── stores/ # Zustand stores
|
|
151
|
-
├── events/ # EventEmitter
|
|
152
|
-
├── apis/ # API path helpers
|
|
153
|
-
└── ...
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## License
|
|
159
|
-
|
|
160
|
-
[MIT](LICENSE) — see [LICENSE](LICENSE) for details.
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
# NFX-UI — 统一前端 UI 库
|
|
167
|
-
|
|
168
|
-
**NFX-UI** 是 NebulaForgeX 生态的统一前端 UI 库,提供 React 组件、设计令牌、主题系统、布局基元、多语言与工具函数,为 NFX 控制台及其他应用提供一致的外观与交互。基于 **React 18/19**、**TypeScript** 与 **Vite**(库模式)构建,以 ESM/CJS 发布,样式内联、类型完整,使用方无需单独引入 CSS。
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## 外部项目如何使用
|
|
173
|
-
|
|
174
|
-
### 1. 安装
|
|
175
|
-
|
|
176
|
-
- **方式 A**:发布到 npm 后,在业务项目中执行 `npm install nfx-ui`。
|
|
177
|
-
- **方式 B**:未发布时,在 NFX-UI 目录执行 `npm run build` 与 `npm link`,在业务项目目录执行 `npm link nfx-ui`。
|
|
178
|
-
- 若本机约定先加载环境(如 `source /volume1/use-menv.sh`),请在执行任何 npm 命令前先执行。
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
# 方式 A(在业务项目)
|
|
182
|
-
npm install nfx-ui
|
|
183
|
-
|
|
184
|
-
# 方式 B
|
|
185
|
-
# 步骤 1:在 NFX-UI 仓库
|
|
186
|
-
cd /path/to/NFX-UI
|
|
187
|
-
npm run link
|
|
188
|
-
|
|
189
|
-
# 步骤 2:在要使用 NFX-UI 的项目
|
|
190
|
-
cd /path/to/your-app
|
|
191
|
-
npm link nfx-ui
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### 2. 依赖要求
|
|
195
|
-
|
|
196
|
-
你的项目需已安装 `react`、`react-dom`(^18.0.0 或 ^19.0.0)。若使用主题、图表等,可能还需按需安装 `lucide-react`、`recharts`、`@tanstack/react-query`、`zustand` 等(见 NFX-UI 的 `package.json` peerDependencies)。
|
|
197
|
-
|
|
198
|
-
### 3. 在代码里使用
|
|
199
|
-
|
|
200
|
-
使用**子路径导入**,无需单独引入 CSS。组件直接使用即有 props 类型提示;类型通过 `import type { ... } from "nfx-ui/..."` 获取;样式已内联。
|
|
201
|
-
|
|
202
|
-
```tsx
|
|
203
|
-
import { ThemeProvider } from "nfx-ui/themes";
|
|
204
|
-
import { LanguageProvider } from "nfx-ui/languages";
|
|
205
|
-
import { LayoutProvider } from "nfx-ui/layouts";
|
|
206
|
-
import { Button, Input } from "nfx-ui/components";
|
|
207
|
-
import type { LanguageEnum } from "nfx-ui/languages";
|
|
208
|
-
import type { ApiErrorBody } from "nfx-ui/types";
|
|
209
|
-
|
|
210
|
-
export function App() {
|
|
211
|
-
return (
|
|
212
|
-
<ThemeProvider defaultTheme="default">
|
|
213
|
-
<LanguageProvider>
|
|
214
|
-
<LayoutProvider>
|
|
215
|
-
<Button>确定</Button>
|
|
216
|
-
<Input placeholder="请输入" />
|
|
217
|
-
</LayoutProvider>
|
|
218
|
-
</LanguageProvider>
|
|
219
|
-
</ThemeProvider>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### 4. 其他项目中的完整步骤示例
|
|
225
|
-
|
|
226
|
-
在「别的项目」里从零用上 NFX-UI 的推荐顺序:
|
|
227
|
-
|
|
228
|
-
1. **确保环境**:若团队要求,先执行 `source /volume1/use-menv.sh`(或你本机的等价命令)。
|
|
229
|
-
2. **安装或链接**:已发布:`npm install nfx-ui`。未发布:在 NFX-UI 里执行 `npm run link`,再在本项目执行 `npm link nfx-ui`。
|
|
230
|
-
3. **确认 peer**:项目里已有 `react`、`react-dom`(版本 18 或 19)。
|
|
231
|
-
4. **按需装运行时依赖**:用到主题/图标/图表等时,在业务项目安装 `lucide-react`、`@tanstack/react-query`、`recharts`、`zustand` 等(与 NFX-UI 的 `package.json` 一致或兼容)。
|
|
232
|
-
5. **在入口外包一层 Provider**:在根组件外包上 `ThemeProvider`、`LanguageProvider`、`LayoutProvider` 等(见上面代码)。
|
|
233
|
-
6. **按子路径引入**:`import { Button } from "nfx-ui/components"`,`import { useTheme } from "nfx-ui/themes"` 等;类型用 `import type { ... } from "nfx-ui/types"`。
|
|
234
|
-
7. **构建与运行**:按你项目原有方式(如 `npm run dev` / `npm run build`)即可,打包器会从 nfx-ui 解析并做 tree-shaking。
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## 包含模块
|
|
239
|
-
|
|
240
|
-
下表为包内主要模块与内容;完整组件与 API 见 [docs/](./docs/)。
|
|
241
|
-
|
|
242
|
-
| 模块 | 内容 |
|
|
243
|
-
|--------------|------|
|
|
244
|
-
| **themes** | ThemeProvider、useTheme、主题变量 |
|
|
245
|
-
| **languages**| LanguageProvider、i18n、useLanguageLabel、useThemeLabel |
|
|
246
|
-
| **layouts** | LayoutProvider、Sidebar、Header、Footer、Background |
|
|
247
|
-
| **components** | Button、Input、Dropdown、Slider、VirtualList、SlideDownSwitcher 等 |
|
|
248
|
-
| **animations** | WaveBackground、ECGLoading、TruckLoading、BounceLoading 等 |
|
|
249
|
-
| **hooks** | makeUnifiedQuery、makeUnifiedInfiniteQuery |
|
|
250
|
-
| **preference** | 用户偏好(如 profile.preference) |
|
|
251
|
-
| **types** | 共享 TypeScript 类型 |
|
|
252
|
-
| **utils** | getApiErrorMessage、formatDisplayDate、retry 等 |
|
|
253
|
-
| **constants**| Query key 工厂、defineEnum 等 |
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## 本仓库开发
|
|
258
|
-
|
|
259
|
-
### 安装依赖
|
|
260
|
-
|
|
261
|
-
本仓库为纯库,无 dev 服务器或 demo,需在真实应用中通过 `npm link` 测试。克隆后执行 `npm install` 安装依赖。
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
npm install
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### 构建
|
|
268
|
-
|
|
269
|
-
执行 `npm run build`,产物在 `dist/`:ESM(.mjs)、CJS(.cjs)、类型(.d.ts),样式已内联。
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
npm run build
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### 构建时的提示与警告
|
|
276
|
-
|
|
277
|
-
构建过程中可能出现以下提示,均可忽略,不影响产物:
|
|
278
|
-
1. **TypeScript 版本提示**:vite-plugin-dts 内置的 API Extractor 使用较旧 TS 版本,项目使用 5.9.x 时会提示 “consider upgrading API Extractor”,类型仍会正确生成。
|
|
279
|
-
2. **PLUGIN_TIMINGS**:Vite 输出的插件耗时统计,仅作参考,无需处理。
|
|
280
|
-
|
|
281
|
-
### 本地联调(npm link)
|
|
282
|
-
|
|
283
|
-
1. 在 NFX-UI 目录执行 `npm run link`。
|
|
284
|
-
2. 在消费项目中执行 `npm link nfx-ui`。
|
|
285
|
-
3. 修改 NFX-UI 后需在 NFX-UI 目录再次执行 `npm run build` 才能生效。
|
|
286
|
-
|
|
287
|
-
### 代码检查与格式化
|
|
288
|
-
|
|
289
|
-
`npm run lint` 运行 ESLint;`npm run lint:code-format` 检查 Prettier;`npm run format` 执行 Prettier 格式化。
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
npm run lint
|
|
293
|
-
npm run lint:code-format
|
|
294
|
-
npm run format
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
|
|
299
|
-
## 项目结构
|
|
300
|
-
|
|
301
|
-
`src/` 下为入口与各模块;本仓库内使用路径别名 `@/`(指向 `src/`)。
|
|
302
|
-
|
|
303
|
-
```
|
|
304
|
-
src/
|
|
305
|
-
├── designs/ # layouts、components、animations
|
|
306
|
-
├── languages/ # i18n、LanguageProvider、useLanguageLabel 等
|
|
307
|
-
├── themes/ # ThemeProvider、useTheme、主题数据
|
|
308
|
-
├── hooks/ # makeUnifiedQuery、makeUnifiedInfiniteQuery
|
|
309
|
-
├── preference/ # 用户偏好
|
|
310
|
-
├── types/ # 共享类型
|
|
311
|
-
├── utils/ # 工具函数
|
|
312
|
-
├── constants/ # Query keys、枚举等
|
|
313
|
-
├── stores/ # Zustand stores
|
|
314
|
-
├── events/ # EventEmitter
|
|
315
|
-
├── apis/ # API path 等
|
|
316
|
-
└── ...
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
---
|
|
320
|
-
|
|
321
|
-
## 许可证
|
|
322
|
-
|
|
323
|
-
[MIT](LICENSE) — 详见 [LICENSE](LICENSE)。
|
package/dist/animations.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { }
|