nfx-ui 0.6.3 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animations.d.ts +0 -72
- package/dist/apis.d.ts +0 -6
- package/dist/chunk-BounceLoading-CwvDT5HF.cjs.map +1 -1
- package/dist/chunk-animations-CO7zKbti.cjs.map +1 -1
- package/dist/chunk-theme-9dcwRKw8.mjs.map +1 -1
- package/dist/chunk-theme-BFvDRCYS.cjs.map +1 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.ts +0 -412
- package/dist/constants.d.ts +0 -129
- package/dist/events.d.ts +0 -60
- package/dist/hooks.d.ts +0 -315
- package/dist/icons.d.ts +0 -217
- package/dist/languages.cjs.map +1 -1
- package/dist/languages.d.ts +0 -178
- package/dist/layouts.cjs.map +1 -1
- package/dist/layouts.d.ts +0 -208
- package/dist/layouts.mjs.map +1 -1
- package/dist/navigations.d.ts +0 -71
- package/dist/pixel-blast.cjs.map +1 -1
- package/dist/pixel-blast.d.ts +0 -32
- package/dist/preference.d.ts +0 -95
- package/dist/services.d.ts +0 -7
- package/dist/stores.cjs +1 -1
- package/dist/stores.cjs.map +1 -1
- package/dist/stores.d.ts +1 -101
- package/dist/stores.mjs +52 -52
- package/dist/stores.mjs.map +1 -1
- package/dist/themes.cjs +1 -1
- package/dist/themes.cjs.map +1 -1
- package/dist/themes.d.ts +0 -232
- package/dist/themes.mjs +883 -712
- package/dist/themes.mjs.map +1 -1
- package/dist/types.d.ts +0 -180
- package/dist/utils.d.ts +0 -469
- package/package.json +36 -32
package/dist/hooks.d.ts
CHANGED
|
@@ -1,316 +1 @@
|
|
|
1
|
-
import { AxiosError } from 'axios';
|
|
2
|
-
import { QueryKey } from '@tanstack/react-query';
|
|
3
|
-
import { UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
4
|
-
import { UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
5
|
-
import { UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
7
|
-
import { UseSuspenseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
8
|
-
import { UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
|
|
9
|
-
import { UseSuspenseQueryOptions } from '@tanstack/react-query';
|
|
10
|
-
import { UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 数组类型。Array type.
|
|
14
|
-
* @example Array<string> => string[]
|
|
15
|
-
*/
|
|
16
|
-
declare type Array_2<T> = T[];
|
|
17
|
-
|
|
18
|
-
/** F & OffsetLimitNumber,数字分页列表请求参数。Params for number-offset list fetch. */
|
|
19
|
-
export declare type FetchNumberListParams<F extends object = Record<string, unknown>> = F & OffsetLimitNumber;
|
|
20
|
-
|
|
21
|
-
/** F & OffsetLimitString,字符串游标列表请求参数。Params for string-cursor list fetch. */
|
|
22
|
-
export declare type FetchStringListParams<F extends object = Record<string, unknown>> = F & OffsetLimitString;
|
|
23
|
-
|
|
24
|
-
/** 无限查询 options(不含 queryKey/queryFn/getNextPageParam/initialPageParam)。Infinite query options (excludes queryKey, queryFn, getNextPageParam, initialPageParam). */
|
|
25
|
-
export declare type InfiniteQueryOptions<T> = Omit<UseInfiniteQueryOptions<ListDTOWithTotalNumber<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
26
|
-
|
|
27
|
-
/** InfiniteQueryOptions | SuspenseInfiniteQueryOptions。Union of normal and suspense infinite query options. */
|
|
28
|
-
export declare type InfiniteQueryOptionsUnion<T> = InfiniteQueryOptions<T> | SuspenseInfiniteQueryOptions<T>;
|
|
29
|
-
|
|
30
|
-
/** 字符串游标列表:items + nextCursor(用于 nextCursor 为 string 的 API)。List with string nextCursor. */
|
|
31
|
-
declare interface ListDTOWithNextCursor<T> {
|
|
32
|
-
/** 列表项。Items. */
|
|
33
|
-
items: Array_2<T>;
|
|
34
|
-
/** 下一页游标。Next cursor. */
|
|
35
|
-
nextCursor: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** 列表 + 总数:items + total(用于 offset/limit 分页的返回)。List with total count; used as offset/limit response. */
|
|
39
|
-
declare interface ListDTOWithTotalNumber<T> {
|
|
40
|
-
/** 列表项。Items. */
|
|
41
|
-
items: Array_2<T>;
|
|
42
|
-
/** 总数。Total count. */
|
|
43
|
-
total: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 创建基于游标(Cursor)的分页获取函数
|
|
48
|
-
*
|
|
49
|
-
* 将标准的分页 API(基于 offset/limit)转换为游标分页函数,用于无限查询。
|
|
50
|
-
* 自动计算下一页游标,并支持数据后处理。
|
|
51
|
-
*
|
|
52
|
-
* @template T - 数据项类型
|
|
53
|
-
* @template F - 过滤器对象类型,必须是对象类型,默认为 Record<string, unknown>
|
|
54
|
-
*
|
|
55
|
-
* @param {Function} fetchFunc - 远程数据获取函数,接收 FetchListParams 参数,返回包含 items 和 total 的结果
|
|
56
|
-
* @param {number} [pageSize=20] - 每页数据条数,默认 20
|
|
57
|
-
* @param {Function} [postProcess] - 可选的数据后处理函数,在每次数据获取后调用
|
|
58
|
-
*
|
|
59
|
-
* @returns {Function} 返回一个游标分页函数,接收 pageParam(页码)和 filter(过滤器)参数
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```tsx
|
|
63
|
-
* * 定义标准的分页 API
|
|
64
|
-
* const fetchProductsAPI = async (params: { offset: number; limit: number; category?: string }) => {
|
|
65
|
-
* const response = await fetch('/api/products?' + new URLSearchParams(params));
|
|
66
|
-
* const { items, total } = await response.json();
|
|
67
|
-
* return { items, total };
|
|
68
|
-
* };
|
|
69
|
-
*
|
|
70
|
-
* * 创建游标分页函数
|
|
71
|
-
* const fetchProducts = makeCursorFetchFunction(
|
|
72
|
-
* fetchProductsAPI,
|
|
73
|
-
* 20,
|
|
74
|
-
* (data) => {
|
|
75
|
-
* * 数据后处理:为每个商品添加缓存
|
|
76
|
-
* data.forEach(product => cache.set(product.id, product));
|
|
77
|
-
* }
|
|
78
|
-
* );
|
|
79
|
-
*
|
|
80
|
-
* * 使用游标函数
|
|
81
|
-
* const firstPage = await fetchProducts(0, { category: "electronics" });
|
|
82
|
-
* * 返回: ListDTOWithTotalNumber<Product> = { items, total }
|
|
83
|
-
* * getNextPageParam 由 makeUnifiedInfiniteQuery 根据 total 与 pageSize 计算
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* **为什么需要游标转换?**
|
|
88
|
-
* - React Query 的无限查询使用 pageParam(游标)来跟踪分页位置
|
|
89
|
-
* - 后端 API 通常使用 offset/limit 分页,两者需要转换才能配合使用
|
|
90
|
-
* - 游标模式更适合无限滚动,避免在组件中手动计算 offset
|
|
91
|
-
*
|
|
92
|
-
* **游标计算逻辑:**
|
|
93
|
-
* - **offset 计算**:`offset = pageParam × pageSize`
|
|
94
|
-
* - 示例:pageParam=0 → offset=0(第一页)
|
|
95
|
-
* - 示例:pageParam=2, pageSize=20 → offset=40(第三页,跳过前 40 条)
|
|
96
|
-
* - **nextCursor 判断**:`(pageParam + 1) × pageSize < total ? pageParam + 1 : undefined`
|
|
97
|
-
* - 如果下一页的起始位置小于总数,返回下一页页码
|
|
98
|
-
* - 否则返回 undefined,告知 React Query 没有更多数据
|
|
99
|
-
*
|
|
100
|
-
* **为什么 pageParam 从 0 开始?**
|
|
101
|
-
* - 符合数组索引习惯,第 0 页、第 1 页...
|
|
102
|
-
* - 计算 offset 时公式更简洁:`offset = pageParam × pageSize`
|
|
103
|
-
* - 避免使用 1-based 索引时需要额外的 -1 运算
|
|
104
|
-
*
|
|
105
|
-
* **postProcess 的作用:**
|
|
106
|
-
* - 在数据返回后、缓存前执行,适合进行副作用操作
|
|
107
|
-
* - 常见用途:更新单项缓存、触发分析事件、数据预处理
|
|
108
|
-
* - 不影响返回值,保持数据流的纯净性
|
|
109
|
-
*/
|
|
110
|
-
export declare function makeCursorFetchFunction<T, F extends object = Record<string, unknown>>(fetchFunc: (params: FetchNumberListParams<F>) => Promise<ListDTOWithTotalNumber<T>>, pageSize?: number, postProcess?: (data: T[]) => void): (pageParam?: number, filter?: F) => Promise<ListDTOWithTotalNumber<T>>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 创建基于字符串游标的分页获取函数(用于 nextCursor 为 string 的 API)。
|
|
114
|
-
* Creates cursor-based fetch function for string cursor (API returns nextCursor: string).
|
|
115
|
-
*
|
|
116
|
-
* @param fetchFunc - 远程获取函数,参数含 offset: string, limit,返回 { items, nextCursor }。Fetch (params: FetchStringListParams<F>) => Promise<ListDTOWithNextCursor<T>>.
|
|
117
|
-
* @param pageSize - 每页条数,默认 20。Page size.
|
|
118
|
-
* @param postProcess - 可选,数据返回后调用。Optional post-process (data: T[]) => void.
|
|
119
|
-
* @returns 返回 (pageParam: string, filter?: F) => Promise<ListDTOWithNextCursor<T>>。Returns async cursor fetcher.
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* const fetch = makeStringCursorFetchFunction(fetchByToken, 20);
|
|
123
|
-
* const page = await fetch("", { q: "x" });
|
|
124
|
-
* if (page.nextCursor) await fetch(page.nextCursor, { q: "x" });
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export declare function makeStringCursorFetchFunction<T, F extends object = Record<string, unknown>>(fetchFunc: (params: FetchStringListParams<F>) => Promise<ListDTOWithNextCursor<T>>, pageSize?: number, postProcess?: (data: T[]) => void): (pageParam?: string, filter?: F) => Promise<ListDTOWithNextCursor<T>>;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 创建统一的无限查询 Hook(Suspense 模式)
|
|
131
|
-
*
|
|
132
|
-
* 这是一个高阶函数工厂,用于创建支持无限滚动的数据查询 Hook。
|
|
133
|
-
* 它自动处理分页、缓存、错误重试等常见场景,并支持 Suspense 模式。
|
|
134
|
-
*
|
|
135
|
-
* @template T - 数据项类型
|
|
136
|
-
* @template F - 过滤器对象类型,必须是对象类型,默认为 Record<string, unknown>
|
|
137
|
-
*
|
|
138
|
-
* @param {Function} fetchRemote - 远程数据获取函数,接收分页参数和过滤器,返回 Promise
|
|
139
|
-
* @param {string} mode - 查询模式,设置为 "suspense" 启用 React Suspense 支持
|
|
140
|
-
* @param {number} [pageSize=20] - 每页数据条数,默认 20
|
|
141
|
-
* @param {Function} [postProcess] - 可选的数据后处理函数,在数据返回后调用
|
|
142
|
-
*
|
|
143
|
-
* @returns {Function} 返回一个 Hook 函数,接收 queryKey、filter 和 options 参数
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```tsx
|
|
147
|
-
* * 定义 API 获取函数
|
|
148
|
-
* const fetchProducts = async (params: FetchListParams<ProductFilter>) => {
|
|
149
|
-
* const { items, total } = await api.getProducts(params);
|
|
150
|
-
* return { items, total };
|
|
151
|
-
* };
|
|
152
|
-
*
|
|
153
|
-
* * 创建 Hook(Suspense 模式)
|
|
154
|
-
* const useProductList = makeUnifiedInfiniteQuery(
|
|
155
|
-
* fetchProducts,
|
|
156
|
-
* "suspense",
|
|
157
|
-
* 20,
|
|
158
|
-
* (data) => console.warn('数据已加载:', data.length)
|
|
159
|
-
* );
|
|
160
|
-
*
|
|
161
|
-
* * 在组件中使用
|
|
162
|
-
* function ProductList() {
|
|
163
|
-
* const { data, fetchNextPage, hasNextPage } = useProductList(
|
|
164
|
-
* ["products"],
|
|
165
|
-
* { category: "electronics" },
|
|
166
|
-
* { staleTime: 60000 }
|
|
167
|
-
* );
|
|
168
|
-
*
|
|
169
|
-
* return (
|
|
170
|
-
* <div>
|
|
171
|
-
* {data.map(product => <ProductCard key={product.id} {...product} />)}
|
|
172
|
-
* {hasNextPage && <button onClick={() => fetchNextPage()}>加载更多</button>}
|
|
173
|
-
* </div>
|
|
174
|
-
* );
|
|
175
|
-
* }
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* @remarks
|
|
179
|
-
* **为什么需要这个函数?**
|
|
180
|
-
* - React Query 的无限查询 API 较为底层,需要手动配置 queryFn、initialPageParam、getNextPageParam 等
|
|
181
|
-
* - 大多数列表查询都有相似的分页逻辑(offset/limit),重复编写这些配置容易出错
|
|
182
|
-
* - 通过工厂函数统一封装,确保分页逻辑的一致性,减少样板代码
|
|
183
|
-
*
|
|
184
|
-
* **为什么区分 Suspense 和普通模式?**
|
|
185
|
-
* - Suspense 模式:数据未就绪时会挂起组件渲染,适合配合 React Suspense 边界使用
|
|
186
|
-
* - 普通模式:提供 isLoading 状态,需要手动处理加载状态,更灵活
|
|
187
|
-
* - 两种模式的 Hook 返回类型不同,TypeScript 需要通过函数重载区分
|
|
188
|
-
*
|
|
189
|
-
* **内部实现原理:**
|
|
190
|
-
* 1. **游标转换**:使用 makeCursorFetchFunction 将 offset/limit 转换为页码游标
|
|
191
|
-
* 2. **查询键构造**:自动将 filter 合并到 queryKey 中,确保不同过滤条件有独立缓存
|
|
192
|
-
* 3. **数据扁平化**:通过 select 将分页数据 pages 扁平化为单一数组,简化组件使用
|
|
193
|
-
* 4. **智能重试**:仅对 5xx 服务器错误和网络错误重试,避免对 4xx 客户端错误无意义重试
|
|
194
|
-
* 5. **选项合并**:使用 spread 运算符允许外部覆盖默认配置(如 staleTime、retry)
|
|
195
|
-
*/
|
|
196
|
-
export declare function makeUnifiedInfiniteQuery<T, F extends object = Record<string, unknown>>(fetchRemote: (params: FetchNumberListParams<F>) => Promise<ListDTOWithTotalNumber<T>>, mode: "suspense", pageSize?: number, postProcess?: (data: T[]) => void): (queryKey: QueryKey, filter?: F, options?: SuspenseInfiniteQueryOptions<T>) => UseSuspenseInfiniteQueryResult<T[], AxiosError>;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* 创建统一的无限查询 Hook(普通模式)
|
|
200
|
-
*
|
|
201
|
-
* 这是一个高阶函数工厂,用于创建支持无限滚动的数据查询 Hook。
|
|
202
|
-
* 它自动处理分页、缓存、错误重试等常见场景,普通模式不使用 Suspense。
|
|
203
|
-
*
|
|
204
|
-
* @template T - 数据项类型
|
|
205
|
-
* @template F - 过滤器对象类型,必须是对象类型,默认为 Record<string, unknown>
|
|
206
|
-
*
|
|
207
|
-
* @param {Function} fetchRemote - 远程数据获取函数,接收分页参数和过滤器,返回 Promise
|
|
208
|
-
* @param {string} [mode="normal"] - 查询模式,设置为 "normal" 或省略使用普通模式
|
|
209
|
-
* @param {number} [pageSize=20] - 每页数据条数,默认 20
|
|
210
|
-
* @param {Function} [postProcess] - 可选的数据后处理函数,在数据返回后调用
|
|
211
|
-
*
|
|
212
|
-
* @returns {Function} 返回一个 Hook 函数,接收 queryKey、filter 和 options 参数
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
* ```tsx
|
|
216
|
-
* * 定义 API 获取函数
|
|
217
|
-
* const fetchProducts = async (params: FetchListParams<ProductFilter>) => {
|
|
218
|
-
* const { items, total } = await api.getProducts(params);
|
|
219
|
-
* return { items, total };
|
|
220
|
-
* };
|
|
221
|
-
*
|
|
222
|
-
* * 创建 Hook(普通模式)
|
|
223
|
-
* const useProductList = makeUnifiedInfiniteQuery(
|
|
224
|
-
* fetchProducts,
|
|
225
|
-
* "normal", * 或省略此参数
|
|
226
|
-
* 20
|
|
227
|
-
* );
|
|
228
|
-
*
|
|
229
|
-
* * 在组件中使用
|
|
230
|
-
* function ProductList() {
|
|
231
|
-
* const { data, fetchNextPage, hasNextPage, isLoading } = useProductList(
|
|
232
|
-
* ["products"],
|
|
233
|
-
* { category: "electronics" },
|
|
234
|
-
* { staleTime: 60000 }
|
|
235
|
-
* );
|
|
236
|
-
*
|
|
237
|
-
* if (isLoading) return <Loading />;
|
|
238
|
-
*
|
|
239
|
-
* return (
|
|
240
|
-
* <div>
|
|
241
|
-
* {data?.map(product => <ProductCard key={product.id} {...product} />)}
|
|
242
|
-
* {hasNextPage && <button onClick={() => fetchNextPage()}>加载更多</button>}
|
|
243
|
-
* </div>
|
|
244
|
-
* );
|
|
245
|
-
* }
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
export declare function makeUnifiedInfiniteQuery<T, F extends object = Record<string, unknown>>(fetchRemote: (params: FetchNumberListParams<F>) => Promise<ListDTOWithTotalNumber<T>>, mode?: "normal", pageSize?: number, postProcess?: (data: T[]) => void): (queryKey: QueryKey, filter?: F, options?: InfiniteQueryOptions<T>) => UseInfiniteQueryResult<T[], AxiosError>;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* 创建统一的单条查询 Hook 工厂(支持 normal / suspense 模式)。
|
|
252
|
-
* Creates a unified single-item query Hook factory (normal or suspense mode).
|
|
253
|
-
*
|
|
254
|
-
* @param fetchRemote - 拉取函数,接收 filter 返回 Promise<T>。Fetch function (params: F) => Promise<T>.
|
|
255
|
-
* @param mode - "suspense" 或 "normal"(默认)。Query mode.
|
|
256
|
-
* @param postProcess - 可选,数据返回后调用。Optional post-process (data: T) => void.
|
|
257
|
-
* @returns 返回一个 Hook:(queryKey, filter?, options?) => UseQueryResult 或 UseSuspenseQueryResult。Returns a Hook.
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* const useProfile = makeUnifiedQuery(fetchProfile, "normal");
|
|
261
|
-
* const { data } = useProfile(profileKey, { id }, { enabled: !!id });
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
export declare function makeUnifiedQuery<T, F extends object = Record<string, unknown>>(fetchRemote: (params: F) => Promise<T>, mode: "suspense", postProcess?: (data: T) => void): (queryKey: QueryKey, filter?: F, options?: Omit<UseSuspenseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">) => UseSuspenseQueryResult<T, AxiosError>;
|
|
265
|
-
|
|
266
|
-
export declare function makeUnifiedQuery<T, F extends object = Record<string, unknown>>(fetchRemote: (params: F) => Promise<T>, mode?: "normal", postProcess?: (data: T) => void): (queryKey: QueryKey, filter?: F, options?: Omit<UseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">) => UseQueryResult<T, AxiosError>;
|
|
267
|
-
|
|
268
|
-
/** 变更上下文(如 prev)。Mutation context (e.g. prev). */
|
|
269
|
-
export declare type MutationCtx = {
|
|
270
|
-
prev?: unknown;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/** 普通模式(useQuery),可配合 enabled 等。Normal mode (useQuery); supports enabled etc. */
|
|
274
|
-
export declare const NORMAL: "normal";
|
|
275
|
-
|
|
276
|
-
/** 普通单条查询 options(含 enabled)。Normal single-item query options (includes enabled). */
|
|
277
|
-
export declare type NormalUnifiedQueryOptions<T> = Omit<UseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">;
|
|
278
|
-
|
|
279
|
-
/** 数字 offset 分页参数(用于 makeCursorFetchFunction 等)。Number offset pagination params; used by makeCursorFetchFunction etc. */
|
|
280
|
-
declare interface OffsetLimitNumber {
|
|
281
|
-
/** 偏移量。Offset. */
|
|
282
|
-
offset: number;
|
|
283
|
-
/** 每页条数。Limit. */
|
|
284
|
-
limit: number;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/** 字符串游标分页参数(用于 makeStringCursorFetchFunction 等)。String cursor pagination params; used by makeStringCursorFetchFunction etc. */
|
|
288
|
-
declare interface OffsetLimitString {
|
|
289
|
-
/** 游标(字符串)。Cursor (string). */
|
|
290
|
-
offset: string;
|
|
291
|
-
/** 每页条数。Limit. */
|
|
292
|
-
limit: number;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/** 仅允许 "normal" | "suspense",请使用 NORMAL / SUSPENSE 避免拼写错误。Only "normal" | "suspense"; use NORMAL / SUSPENSE to avoid typos. */
|
|
296
|
-
export declare type QueryMode = typeof NORMAL | typeof SUSPENSE;
|
|
297
|
-
|
|
298
|
-
/** 字符串游标无限查询 options。String-cursor infinite query options. */
|
|
299
|
-
export declare type StringInfiniteQueryOptions<T> = Omit<UseInfiniteQueryOptions<ListDTOWithNextCursor<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
300
|
-
|
|
301
|
-
/** Suspense 模式(useSuspenseQuery),由 React 挂起。Suspense mode (useSuspenseQuery); suspended by React. */
|
|
302
|
-
export declare const SUSPENSE: "suspense";
|
|
303
|
-
|
|
304
|
-
/** Suspense 无限查询 options。Suspense infinite query options. */
|
|
305
|
-
export declare type SuspenseInfiniteQueryOptions<T> = Omit<UseSuspenseInfiniteQueryOptions<ListDTOWithTotalNumber<T>, AxiosError, T[]>, "queryKey" | "queryFn" | "getNextPageParam" | "initialPageParam">;
|
|
306
|
-
|
|
307
|
-
/** 单条查询 Suspense options。Single-item suspense query options. */
|
|
308
|
-
export declare type SuspenseUnifiedQueryOptions<T> = Omit<UseSuspenseQueryOptions<T, AxiosError, T>, "queryKey" | "queryFn">;
|
|
309
|
-
|
|
310
|
-
/** 单条查询参数(options、postProcess + 业务参数)。Single-item query params (options, postProcess, and business params). */
|
|
311
|
-
export declare type UnifiedQueryParams<T> = {
|
|
312
|
-
options?: SuspenseUnifiedQueryOptions<T>;
|
|
313
|
-
postProcess?: (data: T) => void;
|
|
314
|
-
} & Record<string, unknown>;
|
|
315
|
-
|
|
316
1
|
export { }
|
package/dist/icons.d.ts
CHANGED
|
@@ -1,218 +1 @@
|
|
|
1
|
-
import { AlertCircle } from 'lucide-react';
|
|
2
|
-
import { ArrowLeft } from 'lucide-react';
|
|
3
|
-
import { ArrowRight } from 'lucide-react';
|
|
4
|
-
import { Ban } from 'lucide-react';
|
|
5
|
-
import { Bell } from 'lucide-react';
|
|
6
|
-
import { Box } from 'lucide-react';
|
|
7
|
-
import { Briefcase } from 'lucide-react';
|
|
8
|
-
import { Calendar } from 'lucide-react';
|
|
9
|
-
import { Camera } from 'lucide-react';
|
|
10
|
-
import { Check } from 'lucide-react';
|
|
11
|
-
import { CheckCircle } from 'lucide-react';
|
|
12
|
-
import { ChevronDown } from 'lucide-react';
|
|
13
|
-
import { ChevronLeft } from 'lucide-react';
|
|
14
|
-
import { ChevronRight } from 'lucide-react';
|
|
15
|
-
import { ChevronUp } from 'lucide-react';
|
|
16
|
-
import { Clock } from 'lucide-react';
|
|
17
|
-
import { Coffee } from 'lucide-react';
|
|
18
|
-
import { CreditCard } from 'lucide-react';
|
|
19
|
-
import { DollarSign } from 'lucide-react';
|
|
20
|
-
import { Edit } from 'lucide-react';
|
|
21
|
-
import { ExternalLink } from 'lucide-react';
|
|
22
|
-
import { Eye } from 'lucide-react';
|
|
23
|
-
import { EyeOff } from 'lucide-react';
|
|
24
|
-
import { FileText } from 'lucide-react';
|
|
25
|
-
import { Filter } from 'lucide-react';
|
|
26
|
-
import { FolderOpen } from 'lucide-react';
|
|
27
|
-
import { FolderPlus } from 'lucide-react';
|
|
28
|
-
import { Folders } from 'lucide-react';
|
|
29
|
-
import { FolderTree } from 'lucide-react';
|
|
30
|
-
import { Globe } from 'lucide-react';
|
|
31
|
-
import { GraduationCap } from 'lucide-react';
|
|
32
|
-
import { GripVertical } from 'lucide-react';
|
|
33
|
-
import { Hash } from 'lucide-react';
|
|
34
|
-
import { History as History_2 } from 'lucide-react';
|
|
35
|
-
import { Home } from 'lucide-react';
|
|
36
|
-
import { Image as Image_2 } from 'lucide-react';
|
|
37
|
-
import { Info } from 'lucide-react';
|
|
38
|
-
import { Languages } from 'lucide-react';
|
|
39
|
-
import { Layers } from 'lucide-react';
|
|
40
|
-
import { LayoutGrid } from 'lucide-react';
|
|
41
|
-
import { LayoutList } from 'lucide-react';
|
|
42
|
-
import { Leaf } from 'lucide-react';
|
|
43
|
-
import { List } from 'lucide-react';
|
|
44
|
-
import { Loader } from 'lucide-react';
|
|
45
|
-
import { Loader2 } from 'lucide-react';
|
|
46
|
-
import { Lock as Lock_2 } from 'lucide-react';
|
|
47
|
-
import { LockKeyhole } from 'lucide-react';
|
|
48
|
-
import { LogOut } from 'lucide-react';
|
|
49
|
-
import { LucideIcon } from 'lucide-react';
|
|
50
|
-
import { Mail } from 'lucide-react';
|
|
51
|
-
import { Menu } from 'lucide-react';
|
|
52
|
-
import { MessageCircle } from 'lucide-react';
|
|
53
|
-
import { Package } from 'lucide-react';
|
|
54
|
-
import { Pencil } from 'lucide-react';
|
|
55
|
-
import { Phone } from 'lucide-react';
|
|
56
|
-
import { Plus } from 'lucide-react';
|
|
57
|
-
import { Search } from 'lucide-react';
|
|
58
|
-
import { Settings } from 'lucide-react';
|
|
59
|
-
import { Shield } from 'lucide-react';
|
|
60
|
-
import { Tag } from 'lucide-react';
|
|
61
|
-
import { Trash2 } from 'lucide-react';
|
|
62
|
-
import { TrendingUp } from 'lucide-react';
|
|
63
|
-
import { Upload } from 'lucide-react';
|
|
64
|
-
import { User } from 'lucide-react';
|
|
65
|
-
import { UserCheck } from 'lucide-react';
|
|
66
|
-
import { UserPlus } from 'lucide-react';
|
|
67
|
-
import { UserRound } from 'lucide-react';
|
|
68
|
-
import { UserRoundSearch } from 'lucide-react';
|
|
69
|
-
import { UserX } from 'lucide-react';
|
|
70
|
-
import { Wand2 } from 'lucide-react';
|
|
71
|
-
import { X } from 'lucide-react';
|
|
72
|
-
import { XCircle } from 'lucide-react';
|
|
73
|
-
|
|
74
|
-
export { AlertCircle }
|
|
75
|
-
|
|
76
|
-
export { ArrowLeft }
|
|
77
|
-
|
|
78
|
-
export { ArrowRight }
|
|
79
|
-
|
|
80
|
-
export { Ban }
|
|
81
|
-
|
|
82
|
-
export { Bell }
|
|
83
|
-
|
|
84
|
-
export { Box }
|
|
85
|
-
|
|
86
|
-
export { Briefcase }
|
|
87
|
-
|
|
88
|
-
export { Calendar }
|
|
89
|
-
|
|
90
|
-
export { Camera }
|
|
91
|
-
|
|
92
|
-
export { Check }
|
|
93
|
-
|
|
94
|
-
export { CheckCircle }
|
|
95
|
-
|
|
96
|
-
export { ChevronDown }
|
|
97
|
-
|
|
98
|
-
export { ChevronLeft }
|
|
99
|
-
|
|
100
|
-
export { ChevronRight }
|
|
101
|
-
|
|
102
|
-
export { ChevronUp }
|
|
103
|
-
|
|
104
|
-
export { Clock }
|
|
105
|
-
|
|
106
|
-
export { Coffee }
|
|
107
|
-
|
|
108
|
-
export { CreditCard }
|
|
109
|
-
|
|
110
|
-
export { DollarSign }
|
|
111
|
-
|
|
112
|
-
export { Edit }
|
|
113
|
-
|
|
114
|
-
export { ExternalLink }
|
|
115
|
-
|
|
116
|
-
export { Eye }
|
|
117
|
-
|
|
118
|
-
export { EyeOff }
|
|
119
|
-
|
|
120
|
-
export { FileText }
|
|
121
|
-
|
|
122
|
-
export { Filter }
|
|
123
|
-
|
|
124
|
-
export { FolderOpen }
|
|
125
|
-
|
|
126
|
-
export { FolderPlus }
|
|
127
|
-
|
|
128
|
-
export { Folders }
|
|
129
|
-
|
|
130
|
-
export { FolderTree }
|
|
131
|
-
|
|
132
|
-
export { Globe }
|
|
133
|
-
|
|
134
|
-
export { GraduationCap }
|
|
135
|
-
|
|
136
|
-
export { GripVertical }
|
|
137
|
-
|
|
138
|
-
export { Hash }
|
|
139
|
-
|
|
140
|
-
export { History_2 as History }
|
|
141
|
-
|
|
142
|
-
export { Home }
|
|
143
|
-
|
|
144
|
-
export { Image_2 as Image }
|
|
145
|
-
|
|
146
|
-
export { Info }
|
|
147
|
-
|
|
148
|
-
export { Languages }
|
|
149
|
-
|
|
150
|
-
export { Layers }
|
|
151
|
-
|
|
152
|
-
export { LayoutGrid }
|
|
153
|
-
|
|
154
|
-
export { LayoutList }
|
|
155
|
-
|
|
156
|
-
export { Leaf }
|
|
157
|
-
|
|
158
|
-
export { List }
|
|
159
|
-
|
|
160
|
-
export { Loader }
|
|
161
|
-
|
|
162
|
-
export { Loader2 }
|
|
163
|
-
|
|
164
|
-
export { Lock_2 as Lock }
|
|
165
|
-
|
|
166
|
-
export { LockKeyhole }
|
|
167
|
-
|
|
168
|
-
export { LogOut }
|
|
169
|
-
|
|
170
|
-
export { LucideIcon }
|
|
171
|
-
|
|
172
|
-
export { Mail }
|
|
173
|
-
|
|
174
|
-
export { Menu }
|
|
175
|
-
|
|
176
|
-
export { MessageCircle }
|
|
177
|
-
|
|
178
|
-
export { Package }
|
|
179
|
-
|
|
180
|
-
export { Pencil }
|
|
181
|
-
|
|
182
|
-
export { Phone }
|
|
183
|
-
|
|
184
|
-
export { Plus }
|
|
185
|
-
|
|
186
|
-
export { Search }
|
|
187
|
-
|
|
188
|
-
export { Settings }
|
|
189
|
-
|
|
190
|
-
export { Shield }
|
|
191
|
-
|
|
192
|
-
export { Tag }
|
|
193
|
-
|
|
194
|
-
export { Trash2 }
|
|
195
|
-
|
|
196
|
-
export { TrendingUp }
|
|
197
|
-
|
|
198
|
-
export { Upload }
|
|
199
|
-
|
|
200
|
-
export { User }
|
|
201
|
-
|
|
202
|
-
export { UserCheck }
|
|
203
|
-
|
|
204
|
-
export { UserPlus }
|
|
205
|
-
|
|
206
|
-
export { UserRound }
|
|
207
|
-
|
|
208
|
-
export { UserRoundSearch }
|
|
209
|
-
|
|
210
|
-
export { UserX }
|
|
211
|
-
|
|
212
|
-
export { Wand2 }
|
|
213
|
-
|
|
214
|
-
export { X }
|
|
215
|
-
|
|
216
|
-
export { XCircle }
|
|
217
|
-
|
|
218
1
|
export { }
|
package/dist/languages.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languages.cjs","names":[],"sources":["../src/languages/hooks/useLanguageLabel.ts","../src/languages/hooks/useLayoutLabel.ts","../src/languages/hooks/usePreferenceLabel.ts","../src/languages/hooks/useThemeLabel.ts","../src/languages/languages/i18nResources.ts","../src/languages/utils/languageStorage.ts","../src/languages/utils/getLocalLanguage.ts","../src/languages/providers/index.tsx"],"sourcesContent":["/**\n * 返回 { getLanguageDisplayName },便于扩展;getLanguageDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getLanguageDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { LanguageEnum } from \"../types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getLanguageDisplayNameImpl(lang: LanguageEnum): string {\n return i18n.t(\"languageSwitcher.\" + lang, { ns: \"language\", defaultValue: lang });\n}\n\nexport function useLanguageLabel(): { getLanguageDisplayName: (lang: LanguageEnum) => string } {\n const getLanguageDisplayName = useCallback(getLanguageDisplayNameImpl, []);\n return useMemo(() => ({ getLanguageDisplayName }), [getLanguageDisplayName]);\n}\n\nexport { getLanguageDisplayNameImpl as getLanguageDisplayName };\n","/**\n * 返回 { getLayoutDisplayName },便于扩展;getLayoutDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getLayoutDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { LayoutModeEnum } from \"@/designs/layouts/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getLayoutDisplayNameImpl(mode: LayoutModeEnum): string {\n return i18n.t(\"layoutSwitcher.\" + mode, { ns: \"layout\", defaultValue: mode });\n}\n\nexport function useLayoutLabel(): { getLayoutDisplayName: (mode: LayoutModeEnum) => string } {\n const getLayoutDisplayName = useCallback(getLayoutDisplayNameImpl, []);\n return useMemo(() => ({ getLayoutDisplayName }), [getLayoutDisplayName]);\n}\n\nexport { getLayoutDisplayNameImpl as getLayoutDisplayName };\n","/**\n * 返回 { getPreferenceDisplayName }(Base 展示名),便于扩展;可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getPreferenceDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { BaseEnum } from \"@/themes/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getPreferenceDisplayNameImpl(base: BaseEnum): string {\n return i18n.t(\"baseSwitcher.\" + base, { ns: \"preference\", defaultValue: base });\n}\n\nexport function usePreferenceLabel(): { getPreferenceDisplayName: (base: BaseEnum) => string } {\n const getPreferenceDisplayName = useCallback(getPreferenceDisplayNameImpl, []);\n return useMemo(() => ({ getPreferenceDisplayName }), [getPreferenceDisplayName]);\n}\n\nexport { getPreferenceDisplayNameImpl as getPreferenceDisplayName };\n","/**\n * 返回 { getThemeDisplayName },便于扩展;getThemeDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getThemeDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { ThemeEnum } from \"@/themes/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getThemeDisplayNameImpl(theme: ThemeEnum): string {\n return i18n.t(\"themeSwitcher.\" + theme, { ns: \"theme\", defaultValue: theme });\n}\n\nexport function useThemeLabel(): { getThemeDisplayName: (theme: ThemeEnum) => string } {\n const getThemeDisplayName = useCallback(getThemeDisplayNameImpl, []);\n return useMemo(() => ({ getThemeDisplayName }), [getThemeDisplayName]);\n}\n\nexport { getThemeDisplayNameImpl as getThemeDisplayName };\n","/**\n * 文案包工厂:createI18nResources(resources, nameSpacesMap) 供用户自建 JSON 后生成 i18n 所需结构。\n * Bundle factory: createI18nResources(resources, nameSpacesMap) for building i18n structure from user JSON.\n */\nimport type { CreateI18nResourcesResult, LanguageEnum, NameSpacesMap, Resources } from \"../types\";\n\nimport i18n from \"./i18n\";\n\n/**\n * 由调用方传入 resources 和 nameSpacesMap,生成 i18n 所需的 RESOURCES、NAME_SPACES_MAP、NAME_SPACES。\n * Caller provides resources and nameSpacesMap; returns RESOURCES, NAME_SPACES_MAP, NAME_SPACES for i18n.\n *\n * @param resources - 各语言下的命名空间文案。Bundles per language.\n * @param nameSpacesMap - 命名空间 key → 命名空间字符串。Namespace key to string.\n */\nfunction createI18nResources(resources: Resources, nameSpacesMap: NameSpacesMap): CreateI18nResourcesResult {\n return {\n RESOURCES: resources,\n NAME_SPACES_MAP: nameSpacesMap,\n NAME_SPACES: Object.values(nameSpacesMap),\n };\n}\n\n/** 切换当前语言。Switch current language. */\nfunction changeLanguage(lng: LanguageEnum): void {\n i18n.changeLanguage(lng);\n}\n\nexport { createI18nResources, changeLanguage };\nexport type { CreateI18nResourcesResult, Resources, NameSpacesMap, NamespaceBundle } from \"../types\";\n","/**\n * 语言相关 localStorage 读写与移除,统一走 utils/lstorage;读写类型为 LanguageEnum。\n * Language localStorage get/set/remove via utils/lstorage; typed as LanguageEnum.\n */\nimport type { Nilable } from \"@/types/utils\";\nimport { getItem, removeItem, setItem } from \"@/utils/lstorage\";\n\nimport { LANGUAGE_STORAGE_KEY, LANGUAGE_VALUES, LanguageEnum } from \"../types\";\n\nexport function getLanguageStorage(): Nilable<LanguageEnum> {\n const raw = getItem(LANGUAGE_STORAGE_KEY);\n if (raw == null) return raw;\n return (LANGUAGE_VALUES as readonly string[]).includes(raw) ? (raw as LanguageEnum) : undefined;\n}\n\nexport function setLanguageStorage(value: LanguageEnum): void {\n setItem(LANGUAGE_STORAGE_KEY, value);\n}\n\nexport function removeLanguageStorage(): void {\n removeItem(LANGUAGE_STORAGE_KEY);\n}\n","/**\n * 获取本地语言:优先 localStorage,其次浏览器语言,最后默认语言。\n * Get local language: localStorage first, then navigator, then default.\n */\nimport { getLanguageStorage } from \"./languageStorage\";\nimport { DEFAULT_LANGUAGE, LanguageEnum } from \"../types\";\n\nexport function getLocalLanguage(): LanguageEnum {\n const stored = getLanguageStorage();\n if (stored != null) return stored;\n const nav = typeof navigator !== \"undefined\" ? navigator.language || navigator.languages?.[0] || \"\" : \"\";\n const lower = nav.toLowerCase();\n if (lower.startsWith(\"zh\")) return LanguageEnum.ZH;\n if (lower.startsWith(\"en\")) return LanguageEnum.EN;\n if (lower.startsWith(\"fr\")) return LanguageEnum.FR;\n return DEFAULT_LANGUAGE;\n}\n","/**\n * 语言提供者:首次渲染时同步初始化 i18n(保证内层 ModalProvider 等子组件 useTranslation 时已就绪),再用 useEffect 应用本地语言。\n * Language provider: inits i18n synchronously on first render so inner children (e.g. ModalProvider) have i18n ready; then useEffect applies getLocalLanguage.\n */\nimport type { LanguageProviderProps } from \"../types\";\n\nimport { memo, useEffect, useRef } from \"react\";\n\nimport i18n, { initI18n } from \"../languages/i18n\";\nimport { getLocalLanguage, setLanguageStorage } from \"../utils\";\n\nconst LanguageProvider = memo(({ children, bundles, fallbackLng, onLoadExtraBundles }: LanguageProviderProps) => {\n const hasInitialized = useRef(false);\n if (!hasInitialized.current) {\n initI18n({ bundles, fallbackLng, onLoadExtraBundles });\n hasInitialized.current = true;\n }\n\n useEffect(() => {\n const lng = getLocalLanguage();\n setLanguageStorage(lng);\n void i18n.changeLanguage(lng);\n }, []);\n\n return <>{children}</>;\n});\n\nLanguageProvider.displayName = \"LanguageProvider\";\nexport default LanguageProvider;\n"],"mappings":"oSAUA,SAAS,EAA2B,EAA4B,CAC9D,OAAO,EAAA,aAAK,EAAE,oBAAsB,EAAM,CAAE,GAAI,WAAY,aAAc,EAAM,EAGlF,SAAgB,GAA+E,CAC7F,MAAM,KAAA,EAAA,aAAqC,EAA4B,CAAA,CAAE,EACzE,SAAA,EAAA,SAAA,KAAsB,CAAE,uBAAA,CAAA,GAA2B,CAAC,CAAA,CAAuB,ECN7E,SAAS,EAAyB,EAA8B,CAC9D,OAAO,EAAA,aAAK,EAAE,kBAAoB,EAAM,CAAE,GAAI,SAAU,aAAc,EAAM,EAG9E,SAAgB,GAA6E,CAC3F,MAAM,KAAA,EAAA,aAAmC,EAA0B,CAAA,CAAE,EACrE,SAAA,EAAA,SAAA,KAAsB,CAAE,qBAAA,CAAA,GAAyB,CAAC,CAAA,CAAqB,ECNzE,SAAS,EAA6B,EAAwB,CAC5D,OAAO,EAAA,aAAK,EAAE,gBAAkB,EAAM,CAAE,GAAI,aAAc,aAAc,EAAM,EAGhF,SAAgB,GAA+E,CAC7F,MAAM,KAAA,EAAA,aAAuC,EAA8B,CAAA,CAAE,EAC7E,SAAA,EAAA,SAAA,KAAsB,CAAE,yBAAA,CAAA,GAA6B,CAAC,CAAA,CAAyB,ECNjF,SAAS,EAAwB,EAA0B,CACzD,OAAO,EAAA,aAAK,EAAE,iBAAmB,EAAO,CAAE,GAAI,QAAS,aAAc,EAAO,EAG9E,SAAgB,GAAuE,CACrF,MAAM,KAAA,EAAA,aAAkC,EAAyB,CAAA,CAAE,EACnE,SAAA,EAAA,SAAA,KAAsB,CAAE,oBAAA,CAAA,GAAwB,CAAC,CAAA,CAAoB,ECDvE,SAAS,EAAoB,EAAsB,EAAyD,CAC1G,MAAO,CACL,UAAW,EACX,gBAAiB,EACjB,YAAa,OAAO,OAAO,CAAA,GAK/B,SAAS,EAAe,EAAyB,CAC/C,EAAA,aAAK,eAAe,CAAA,EChBtB,SAAgB,GAA4C,CAC1D,MAAM,EAAM,EAAA,QAAQ,EAAA,oBAAA,EACpB,OAAI,GAAO,MACH,EAAA,gBAAsC,SAAS,CAAA,EAD/B,EAC8D,OAGxF,SAAgB,EAAmB,EAA2B,CAC5D,EAAA,QAAQ,EAAA,qBAAsB,CAAA,EAGhC,SAAgB,GAA8B,CAC5C,EAAA,WAAW,EAAA,oBAAA,ECbb,SAAgB,GAAiC,CAC/C,MAAM,EAAS,EAAA,EACf,GAAI,GAAU,KAAM,OAAO,EAE3B,MAAM,GADM,OAAO,UAAc,MAAc,UAAU,UAAY,UAAU,YAAY,CAAA,IAAM,IAC/E,YAAA,EAClB,OAAI,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GAC5C,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GAC5C,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GACzC,EAAA,iBCJT,IAAM,KAAA,EAAA,MAAA,CAAyB,CAAE,SAAA,EAAU,QAAA,EAAS,YAAA,EAAa,mBAAA,CAAA,IAAgD,CAC/G,MAAM,KAAA,EAAA,QAAwB,EAAA,EAC9B,OAAK,EAAe,UAClB,EAAA,SAAS,CAAE,QAAA,EAAS,YAAA,EAAa,mBAAA,EAAoB,EACrD,EAAe,QAAU,OAG3B,EAAA,WAAA,IAAgB,CACd,MAAM,EAAM,EAAA,EACZ,EAAmB,CAAA,EACd,EAAA,aAAK,eAAe,CAAA,GACxB,CAAA,CAAE,
|
|
1
|
+
{"version":3,"file":"languages.cjs","names":[],"sources":["../src/languages/hooks/useLanguageLabel.ts","../src/languages/hooks/useLayoutLabel.ts","../src/languages/hooks/usePreferenceLabel.ts","../src/languages/hooks/useThemeLabel.ts","../src/languages/languages/i18nResources.ts","../src/languages/utils/languageStorage.ts","../src/languages/utils/getLocalLanguage.ts","../src/languages/providers/index.tsx"],"sourcesContent":["/**\n * 返回 { getLanguageDisplayName },便于扩展;getLanguageDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getLanguageDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { LanguageEnum } from \"../types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getLanguageDisplayNameImpl(lang: LanguageEnum): string {\n return i18n.t(\"languageSwitcher.\" + lang, { ns: \"language\", defaultValue: lang });\n}\n\nexport function useLanguageLabel(): { getLanguageDisplayName: (lang: LanguageEnum) => string } {\n const getLanguageDisplayName = useCallback(getLanguageDisplayNameImpl, []);\n return useMemo(() => ({ getLanguageDisplayName }), [getLanguageDisplayName]);\n}\n\nexport { getLanguageDisplayNameImpl as getLanguageDisplayName };\n","/**\n * 返回 { getLayoutDisplayName },便于扩展;getLayoutDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getLayoutDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { LayoutModeEnum } from \"@/designs/layouts/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getLayoutDisplayNameImpl(mode: LayoutModeEnum): string {\n return i18n.t(\"layoutSwitcher.\" + mode, { ns: \"layout\", defaultValue: mode });\n}\n\nexport function useLayoutLabel(): { getLayoutDisplayName: (mode: LayoutModeEnum) => string } {\n const getLayoutDisplayName = useCallback(getLayoutDisplayNameImpl, []);\n return useMemo(() => ({ getLayoutDisplayName }), [getLayoutDisplayName]);\n}\n\nexport { getLayoutDisplayNameImpl as getLayoutDisplayName };\n","/**\n * 返回 { getPreferenceDisplayName }(Base 展示名),便于扩展;可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getPreferenceDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { BaseEnum } from \"@/themes/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getPreferenceDisplayNameImpl(base: BaseEnum): string {\n return i18n.t(\"baseSwitcher.\" + base, { ns: \"preference\", defaultValue: base });\n}\n\nexport function usePreferenceLabel(): { getPreferenceDisplayName: (base: BaseEnum) => string } {\n const getPreferenceDisplayName = useCallback(getPreferenceDisplayNameImpl, []);\n return useMemo(() => ({ getPreferenceDisplayName }), [getPreferenceDisplayName]);\n}\n\nexport { getPreferenceDisplayNameImpl as getPreferenceDisplayName };\n","/**\n * 返回 { getThemeDisplayName },便于扩展;getThemeDisplayName 可传给 SlideDownSwitcher 的 getDisplayName。\n * Returns { getThemeDisplayName } for extensibility; pass to SlideDownSwitcher getDisplayName.\n */\nimport type { ThemeEnum } from \"@/themes/types\";\n\nimport { useCallback, useMemo } from \"react\";\n\nimport i18n from \"../languages/i18n\";\n\nfunction getThemeDisplayNameImpl(theme: ThemeEnum): string {\n return i18n.t(\"themeSwitcher.\" + theme, { ns: \"theme\", defaultValue: theme });\n}\n\nexport function useThemeLabel(): { getThemeDisplayName: (theme: ThemeEnum) => string } {\n const getThemeDisplayName = useCallback(getThemeDisplayNameImpl, []);\n return useMemo(() => ({ getThemeDisplayName }), [getThemeDisplayName]);\n}\n\nexport { getThemeDisplayNameImpl as getThemeDisplayName };\n","/**\n * 文案包工厂:createI18nResources(resources, nameSpacesMap) 供用户自建 JSON 后生成 i18n 所需结构。\n * Bundle factory: createI18nResources(resources, nameSpacesMap) for building i18n structure from user JSON.\n */\nimport type { CreateI18nResourcesResult, LanguageEnum, NameSpacesMap, Resources } from \"../types\";\n\nimport i18n from \"./i18n\";\n\n/**\n * 由调用方传入 resources 和 nameSpacesMap,生成 i18n 所需的 RESOURCES、NAME_SPACES_MAP、NAME_SPACES。\n * Caller provides resources and nameSpacesMap; returns RESOURCES, NAME_SPACES_MAP, NAME_SPACES for i18n.\n *\n * @param resources - 各语言下的命名空间文案。Bundles per language.\n * @param nameSpacesMap - 命名空间 key → 命名空间字符串。Namespace key to string.\n */\nfunction createI18nResources(resources: Resources, nameSpacesMap: NameSpacesMap): CreateI18nResourcesResult {\n return {\n RESOURCES: resources,\n NAME_SPACES_MAP: nameSpacesMap,\n NAME_SPACES: Object.values(nameSpacesMap),\n };\n}\n\n/** 切换当前语言。Switch current language. */\nfunction changeLanguage(lng: LanguageEnum): void {\n i18n.changeLanguage(lng);\n}\n\nexport { createI18nResources, changeLanguage };\nexport type { CreateI18nResourcesResult, Resources, NameSpacesMap, NamespaceBundle } from \"../types\";\n","/**\n * 语言相关 localStorage 读写与移除,统一走 utils/lstorage;读写类型为 LanguageEnum。\n * Language localStorage get/set/remove via utils/lstorage; typed as LanguageEnum.\n */\nimport type { Nilable } from \"@/types/utils\";\nimport { getItem, removeItem, setItem } from \"@/utils/lstorage\";\n\nimport { LANGUAGE_STORAGE_KEY, LANGUAGE_VALUES, LanguageEnum } from \"../types\";\n\nexport function getLanguageStorage(): Nilable<LanguageEnum> {\n const raw = getItem(LANGUAGE_STORAGE_KEY);\n if (raw == null) return raw;\n return (LANGUAGE_VALUES as readonly string[]).includes(raw) ? (raw as LanguageEnum) : undefined;\n}\n\nexport function setLanguageStorage(value: LanguageEnum): void {\n setItem(LANGUAGE_STORAGE_KEY, value);\n}\n\nexport function removeLanguageStorage(): void {\n removeItem(LANGUAGE_STORAGE_KEY);\n}\n","/**\n * 获取本地语言:优先 localStorage,其次浏览器语言,最后默认语言。\n * Get local language: localStorage first, then navigator, then default.\n */\nimport { getLanguageStorage } from \"./languageStorage\";\nimport { DEFAULT_LANGUAGE, LanguageEnum } from \"../types\";\n\nexport function getLocalLanguage(): LanguageEnum {\n const stored = getLanguageStorage();\n if (stored != null) return stored;\n const nav = typeof navigator !== \"undefined\" ? navigator.language || navigator.languages?.[0] || \"\" : \"\";\n const lower = nav.toLowerCase();\n if (lower.startsWith(\"zh\")) return LanguageEnum.ZH;\n if (lower.startsWith(\"en\")) return LanguageEnum.EN;\n if (lower.startsWith(\"fr\")) return LanguageEnum.FR;\n return DEFAULT_LANGUAGE;\n}\n","/**\n * 语言提供者:首次渲染时同步初始化 i18n(保证内层 ModalProvider 等子组件 useTranslation 时已就绪),再用 useEffect 应用本地语言。\n * Language provider: inits i18n synchronously on first render so inner children (e.g. ModalProvider) have i18n ready; then useEffect applies getLocalLanguage.\n */\nimport type { LanguageProviderProps } from \"../types\";\n\nimport { memo, useEffect, useRef } from \"react\";\n\nimport i18n, { initI18n } from \"../languages/i18n\";\nimport { getLocalLanguage, setLanguageStorage } from \"../utils\";\n\nconst LanguageProvider = memo(({ children, bundles, fallbackLng, onLoadExtraBundles }: LanguageProviderProps) => {\n const hasInitialized = useRef(false);\n if (!hasInitialized.current) {\n initI18n({ bundles, fallbackLng, onLoadExtraBundles });\n hasInitialized.current = true;\n }\n\n useEffect(() => {\n const lng = getLocalLanguage();\n setLanguageStorage(lng);\n void i18n.changeLanguage(lng);\n }, []);\n\n return <>{children}</>;\n});\n\nLanguageProvider.displayName = \"LanguageProvider\";\nexport default LanguageProvider;\n"],"mappings":"oSAUA,SAAS,EAA2B,EAA4B,CAC9D,OAAO,EAAA,aAAK,EAAE,oBAAsB,EAAM,CAAE,GAAI,WAAY,aAAc,EAAM,EAGlF,SAAgB,GAA+E,CAC7F,MAAM,KAAA,EAAA,aAAqC,EAA4B,CAAA,CAAE,EACzE,SAAA,EAAA,SAAA,KAAsB,CAAE,uBAAA,CAAA,GAA2B,CAAC,CAAA,CAAuB,ECN7E,SAAS,EAAyB,EAA8B,CAC9D,OAAO,EAAA,aAAK,EAAE,kBAAoB,EAAM,CAAE,GAAI,SAAU,aAAc,EAAM,EAG9E,SAAgB,GAA6E,CAC3F,MAAM,KAAA,EAAA,aAAmC,EAA0B,CAAA,CAAE,EACrE,SAAA,EAAA,SAAA,KAAsB,CAAE,qBAAA,CAAA,GAAyB,CAAC,CAAA,CAAqB,ECNzE,SAAS,EAA6B,EAAwB,CAC5D,OAAO,EAAA,aAAK,EAAE,gBAAkB,EAAM,CAAE,GAAI,aAAc,aAAc,EAAM,EAGhF,SAAgB,GAA+E,CAC7F,MAAM,KAAA,EAAA,aAAuC,EAA8B,CAAA,CAAE,EAC7E,SAAA,EAAA,SAAA,KAAsB,CAAE,yBAAA,CAAA,GAA6B,CAAC,CAAA,CAAyB,ECNjF,SAAS,EAAwB,EAA0B,CACzD,OAAO,EAAA,aAAK,EAAE,iBAAmB,EAAO,CAAE,GAAI,QAAS,aAAc,EAAO,EAG9E,SAAgB,GAAuE,CACrF,MAAM,KAAA,EAAA,aAAkC,EAAyB,CAAA,CAAE,EACnE,SAAA,EAAA,SAAA,KAAsB,CAAE,oBAAA,CAAA,GAAwB,CAAC,CAAA,CAAoB,ECDvE,SAAS,EAAoB,EAAsB,EAAyD,CAC1G,MAAO,CACL,UAAW,EACX,gBAAiB,EACjB,YAAa,OAAO,OAAO,CAAA,GAK/B,SAAS,EAAe,EAAyB,CAC/C,EAAA,aAAK,eAAe,CAAA,EChBtB,SAAgB,GAA4C,CAC1D,MAAM,EAAM,EAAA,QAAQ,EAAA,oBAAA,EACpB,OAAI,GAAO,MACH,EAAA,gBAAsC,SAAS,CAAA,EAD/B,EAC8D,OAGxF,SAAgB,EAAmB,EAA2B,CAC5D,EAAA,QAAQ,EAAA,qBAAsB,CAAA,EAGhC,SAAgB,GAA8B,CAC5C,EAAA,WAAW,EAAA,oBAAA,ECbb,SAAgB,GAAiC,CAC/C,MAAM,EAAS,EAAA,EACf,GAAI,GAAU,KAAM,OAAO,EAE3B,MAAM,GADM,OAAO,UAAc,MAAc,UAAU,UAAY,UAAU,YAAY,CAAA,IAAM,IAC/E,YAAA,EAClB,OAAI,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GAC5C,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GAC5C,EAAM,WAAW,IAAA,EAAc,EAAA,aAAa,GACzC,EAAA,iBCJT,IAAM,KAAA,EAAA,MAAA,CAAyB,CAAE,SAAA,EAAU,QAAA,EAAS,YAAA,EAAa,mBAAA,CAAA,IAAgD,CAC/G,MAAM,KAAA,EAAA,QAAwB,EAAA,EAC9B,OAAK,EAAe,UAClB,EAAA,SAAS,CAAE,QAAA,EAAS,YAAA,EAAa,mBAAA,EAAoB,EACrD,EAAe,QAAU,OAG3B,EAAA,WAAA,IAAgB,CACd,MAAM,EAAM,EAAA,EACZ,EAAmB,CAAA,EACd,EAAA,aAAK,eAAe,CAAA,GACxB,CAAA,CAAE,KAEE,EAAA,KAAA,EAAA,SAAA,CAAG,SAAA,CAAA,CAAY,IAGxB,EAAiB,YAAc"}
|