react-toolkits 2.27.0 → 2.27.2

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 (82) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/index.d.ts +148 -30
  3. package/lib/index.js +3 -1446
  4. package/lib/index.js.map +1 -1
  5. package/locale/context.js +1 -7
  6. package/locale/context.js.map +1 -1
  7. package/locale/en_GB.js +1 -94
  8. package/locale/en_GB.js.map +1 -1
  9. package/locale/hooks.js +1 -20
  10. package/locale/hooks.js.map +1 -1
  11. package/locale/index.js +1 -2
  12. package/locale/ja_JP.js +1 -94
  13. package/locale/ja_JP.js.map +1 -1
  14. package/locale/ko_KR.js +1 -94
  15. package/locale/ko_KR.js.map +1 -1
  16. package/locale/zh_CN.js +1 -94
  17. package/locale/zh_CN.js.map +1 -1
  18. package/package.json +3 -4
  19. package/lib/chunk-56C2GQCB.js +0 -2
  20. package/lib/chunk-56C2GQCB.js.map +0 -1
  21. package/lib/chunk-6SMI25Y3.js +0 -19
  22. package/lib/chunk-6SMI25Y3.js.map +0 -1
  23. package/lib/chunk-7XR7V6IS.js +0 -2
  24. package/lib/chunk-7XR7V6IS.js.map +0 -1
  25. package/lib/chunk-AFURMXX2.js +0 -2
  26. package/lib/chunk-AFURMXX2.js.map +0 -1
  27. package/lib/chunk-COONHXCY.js +0 -2
  28. package/lib/chunk-COONHXCY.js.map +0 -1
  29. package/lib/chunk-DBYHBFI6.js +0 -206
  30. package/lib/chunk-DBYHBFI6.js.map +0 -1
  31. package/lib/chunk-JJR5NJTU.js +0 -75
  32. package/lib/chunk-JJR5NJTU.js.map +0 -1
  33. package/lib/chunk-LUVKLLW7.js +0 -2
  34. package/lib/chunk-LUVKLLW7.js.map +0 -1
  35. package/lib/chunk-M2C4DTSM.js +0 -46
  36. package/lib/chunk-M2C4DTSM.js.map +0 -1
  37. package/lib/chunk-NEOHLVWG.js +0 -2
  38. package/lib/chunk-NEOHLVWG.js.map +0 -1
  39. package/lib/chunk-O7INKFFW.js +0 -161
  40. package/lib/chunk-O7INKFFW.js.map +0 -1
  41. package/lib/chunk-Q6MAXVON.js +0 -2
  42. package/lib/chunk-Q6MAXVON.js.map +0 -1
  43. package/lib/chunk-QEUTBIBK.js +0 -125
  44. package/lib/chunk-QEUTBIBK.js.map +0 -1
  45. package/lib/chunk-R72QFX5M.js +0 -495
  46. package/lib/chunk-R72QFX5M.js.map +0 -1
  47. package/lib/chunk-TYMPX257.js +0 -268
  48. package/lib/chunk-TYMPX257.js.map +0 -1
  49. package/lib/chunk-UICHZXQP.js +0 -3
  50. package/lib/chunk-UICHZXQP.js.map +0 -1
  51. package/lib/chunk-WFRMJYD3.js +0 -2
  52. package/lib/chunk-WFRMJYD3.js.map +0 -1
  53. package/lib/chunk-Z7GW3RVV.js +0 -658
  54. package/lib/chunk-Z7GW3RVV.js.map +0 -1
  55. package/lib/createMenuItem-7R7QR4R6.js +0 -83
  56. package/lib/createMenuItem-7R7QR4R6.js.map +0 -1
  57. package/lib/createMenuItem-A3ES4CDV.js +0 -2
  58. package/lib/createMenuItem-A3ES4CDV.js.map +0 -1
  59. package/lib/menuItemList-BUUJMOU7.js +0 -129
  60. package/lib/menuItemList-BUUJMOU7.js.map +0 -1
  61. package/lib/menuItemList-YFQB4BCS.js +0 -2
  62. package/lib/menuItemList-YFQB4BCS.js.map +0 -1
  63. package/lib/roleDetail-H2X34J57.js +0 -2
  64. package/lib/roleDetail-H2X34J57.js.map +0 -1
  65. package/lib/roleDetail-IP654MAU.js +0 -72
  66. package/lib/roleDetail-IP654MAU.js.map +0 -1
  67. package/lib/roleList-QMAYO4MG.js +0 -161
  68. package/lib/roleList-QMAYO4MG.js.map +0 -1
  69. package/lib/roleList-UCMHN5NJ.js +0 -2
  70. package/lib/roleList-UCMHN5NJ.js.map +0 -1
  71. package/lib/updateMenuItem-NUYWRAV5.js +0 -2
  72. package/lib/updateMenuItem-NUYWRAV5.js.map +0 -1
  73. package/lib/updateMenuItem-SZVEK3TL.js +0 -106
  74. package/lib/updateMenuItem-SZVEK3TL.js.map +0 -1
  75. package/lib/userDetail-6XMOY3I4.js +0 -2
  76. package/lib/userDetail-6XMOY3I4.js.map +0 -1
  77. package/lib/userDetail-MPTJGRMY.js +0 -118
  78. package/lib/userDetail-MPTJGRMY.js.map +0 -1
  79. package/lib/userList-3WABI7V4.js +0 -2
  80. package/lib/userList-3WABI7V4.js.map +0 -1
  81. package/lib/userList-KXYDP7V5.js +0 -166
  82. package/lib/userList-KXYDP7V5.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.27.2
4
+
5
+ ### Patch Changes
6
+
7
+ - de255b8: fix: enhance game API usage and pagination handling in InfiniteList
8
+
9
+ ## 2.27.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 908ad9e: refactor: update visibility store implementation and improve InfiniteList component
14
+
3
15
  ## 2.27.0
4
16
 
5
17
  ### Minor Changes
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  import { AnyObject } from 'antd/es/_util/type';
8
8
  import { TableProps } from 'antd/es/table';
9
9
  import * as zustand from 'zustand';
10
+ import { StateCreator } from 'zustand';
10
11
  import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
11
12
  import { Merge } from 'ts-essentials';
12
13
  import * as _tanstack_react_query from '@tanstack/react-query';
@@ -59,63 +60,172 @@ interface HighlightProps extends PropsWithChildren {
59
60
  }
60
61
  declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
61
62
 
63
+ /**
64
+ * 无限列表的载荷数据
65
+ * @template Values 表单值的类型
66
+ */
62
67
  interface InfiniteListPayload<Values = any> {
68
+ /** 当前页码(仅用于表单状态,实际分页参数通过 pageParam 传递) */
63
69
  page?: number;
70
+ /** 表单筛选条件 */
64
71
  filters?: Values;
65
72
  }
73
+ /**
74
+ * 缓存配置
75
+ */
66
76
  interface CacheConfig$1 {
77
+ /** 缓存时间(毫秒),数据在缓存中保留的时间 */
67
78
  cacheTime?: number;
79
+ /** 过期时间(毫秒),数据在过期前被认为是新鲜的 */
68
80
  staleTime?: number;
69
81
  }
82
+ /**
83
+ * HTTP 请求方法
84
+ */
70
85
  type HttpMethod$1 = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
71
- type RequestBodyResolver<Values = any> = FormData | Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: any) => FormData | Record<string | number, any>);
72
- type RequestParamsResolver<Values = any> = Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: any) => Record<string | number, any>);
73
- interface InfiniteListRequestConfig<Values = any> extends CacheConfig$1 {
86
+ /**
87
+ * 分页参数类型,支持多种分页方式:
88
+ * - number: 页码分页
89
+ * - string: 游标分页(cursor)
90
+ * - object: 复杂分页参数对象
91
+ * - undefined: 无下一页
92
+ */
93
+ type PageParam = number | string | Record<string, any> | undefined;
94
+ /**
95
+ * 请求体解析器
96
+ * 可以是静态值,也可以是动态函数
97
+ * @template Values 表单值的类型
98
+ * @template PageParamType 分页参数的类型(可能是 undefined,表示第一页)
99
+ */
100
+ type RequestBodyResolver<Values = any, PageParamType = PageParam> = FormData | Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => FormData | Record<string | number, any>);
101
+ /**
102
+ * 请求参数解析器(用于 URL 查询参数)
103
+ * 可以是静态值,也可以是动态函数
104
+ * @template Values 表单值的类型
105
+ * @template PageParamType 分页参数的类型(可能是 undefined,表示第一页)
106
+ */
107
+ type RequestParamsResolver<Values = any, PageParamType = PageParam> = Record<string | number, any> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => Record<string | number, any>);
108
+ /**
109
+ * 无限列表请求配置
110
+ * @template Values 表单值的类型
111
+ * @template PageParamType 分页参数的类型
112
+ */
113
+ interface InfiniteListRequestConfig<Values = any, PageParamType = PageParam> extends CacheConfig$1 {
114
+ /** 请求 URL */
74
115
  url: string;
116
+ /** HTTP 请求方法,默认为 GET */
75
117
  method?: HttpMethod$1;
76
- body?: RequestBodyResolver<Values>;
77
- searchParams?: RequestParamsResolver<Values>;
78
- params?: RequestParamsResolver<Values>;
118
+ /** 请求体(用于 POST、PUT、PATCH、DELETE 等方法) */
119
+ body?: RequestBodyResolver<Values, PageParamType>;
120
+ /** URL 查询参数 */
121
+ searchParams?: RequestParamsResolver<Values, PageParamType>;
122
+ /** 请求头,可以是静态对象或动态函数 */
79
123
  headers?: Record<string, string> | ((form: FormInstance<Values>) => Record<string, string>);
80
124
  }
81
- type InfiniteListRequestConfigType<Values = any> = InfiniteListRequestConfig<Values> | ((payload: InfiniteListPayload<Values>, pageParam: any) => InfiniteListRequestConfig<Values>);
82
- declare enum InfiniteListAction {
83
- Confirm = 0,
84
- Reset = 1,
85
- LoadMore = 2,
86
- Init = 3
87
- }
88
- interface InfiniteListDataAdapter<Item = any, Values = any, Data = any> {
125
+ /**
126
+ * 无限列表请求配置类型
127
+ * 可以是静态配置,也可以是动态函数
128
+ * @template Values 表单值的类型
129
+ * @template PageParamType 分页参数的类型
130
+ */
131
+ type InfiniteListRequestConfigType<Values = any, PageParamType = PageParam> = InfiniteListRequestConfig<Values, PageParamType> | ((payload: InfiniteListPayload<Values>, pageParam: PageParamType | undefined) => InfiniteListRequestConfig<Values, PageParamType>);
132
+ /**
133
+ * 数据适配器,用于转换和适配后端返回的数据格式
134
+ * @template Item 列表项类型
135
+ * @template Values 表单值类型
136
+ * @template Data 后端返回的数据类型
137
+ * @template PageParamType 分页参数的类型
138
+ */
139
+ interface InfiniteListDataAdapter<Item = any, Values = any, Data = any, PageParamType = PageParam> {
140
+ /**
141
+ * 从后端数据中提取列表项
142
+ * @param data 所有已加载的页面数据
143
+ * @param form 表单实例
144
+ * @returns 提取的列表项数组
145
+ */
89
146
  items?: (data: Data[] | undefined, form: FormInstance<Values>) => Item[] | undefined;
147
+ /**
148
+ * 判断是否还有更多数据
149
+ * @param lastPage 最后一页的数据
150
+ * @param allPages 所有已加载的页面数据
151
+ * @returns 是否还有更多数据
152
+ */
90
153
  hasMore?: (lastPage: Data | undefined, allPages: Data[]) => boolean;
91
- nextPageParam?: (lastPage: Data | undefined, allPages: Data[], pageParam: any) => any;
154
+ /**
155
+ * 计算下一页的分页参数
156
+ * @param lastPage 最后一页的数据
157
+ * @param allPages 所有已加载的页面数据
158
+ * @param pageParam 当前的分页参数
159
+ * @returns 下一页的分页参数,返回 undefined 表示没有下一页
160
+ */
161
+ nextPageParam?: (lastPage: Data | undefined, allPages: Data[], pageParam: PageParamType) => PageParamType | undefined;
92
162
  }
163
+ /**
164
+ * InfiniteList 组件的引用对象,提供外部访问的 API
165
+ * @template Item 列表项类型
166
+ * @template Values 表单值类型
167
+ * @template Data 后端返回的数据类型
168
+ */
93
169
  interface InfiniteListRef<Item = any, Values = any, Data = any> {
170
+ /** 所有已加载的页面数据 */
94
171
  data: Data[] | undefined;
172
+ /** 处理后的列表数据源 */
95
173
  dataSource: Item[] | undefined;
174
+ /** 表单实例 */
96
175
  form: FormInstance<Values>;
176
+ /** 重新获取数据 */
97
177
  refetch: () => void;
178
+ /** 获取下一页数据 */
98
179
  fetchNextPage: () => void;
180
+ /** 是否还有下一页 */
99
181
  hasNextPage: boolean;
182
+ /** 是否正在获取下一页 */
100
183
  isFetchingNextPage: boolean;
101
184
  }
102
- interface InfiniteListProps<Item, Values, Data> extends Omit<TableProps<Item>, 'pagination' | 'dataSource' | 'loading' | 'footer'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
185
+ /**
186
+ * InfiniteList 组件的属性
187
+ * @template Item 列表项类型
188
+ * @template Values 表单值类型
189
+ * @template Data 后端返回的数据类型
190
+ * @template PageParamType 分页参数的类型
191
+ */
192
+ interface InfiniteListProps<Item, Values, Data, PageParamType = PageParam> extends Omit<TableProps<Item>, 'pagination' | 'dataSource' | 'loading' | 'footer'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
193
+ /** 唯一标识符,用于在 store 中区分不同的列表实例 */
103
194
  identifier?: string;
195
+ /** 权限代码,用于权限控制 */
104
196
  code?: string;
197
+ /** 表单实例,如果不提供则内部创建 */
105
198
  form?: FormInstance<Values>;
199
+ /** 自动刷新间隔(毫秒),0 表示不自动刷新 */
106
200
  refreshInterval?: number;
107
- request: InfiniteListRequestConfigType<Values>;
201
+ /** 请求配置,可以是静态配置或动态函数 */
202
+ request: InfiniteListRequestConfigType<Values, PageParamType>;
203
+ /** 表格额外内容,可以是静态内容或动态函数 */
108
204
  tableExtra?: ReactNode | ((form: FormInstance<Values>, data?: Data[]) => ReactNode);
205
+ /** 自定义表单渲染函数 */
109
206
  renderForm?: (form: FormInstance<Values>) => ReactElement;
110
- afterSuccess?: (action: InfiniteListAction, form: FormInstance<Values>, data?: Data[]) => void;
111
- afterError?: (error: Error, action: InfiniteListAction, form: FormInstance<Values>) => void;
112
- dataAdapter?: InfiniteListDataAdapter<Item, Values, Data>;
113
- initialPageParam?: any;
207
+ /** 请求成功后的回调 */
208
+ afterSuccess?: (form: FormInstance<Values>, data?: Data[]) => void;
209
+ /** 请求失败后的回调 */
210
+ afterError?: (error: Error, form: FormInstance<Values>) => void;
211
+ /** 数据适配器,用于转换后端数据格式 */
212
+ dataAdapter?: InfiniteListDataAdapter<Item, Values, Data, PageParamType>;
213
+ /** 初始分页参数,默认为 0 */
214
+ initialPageParam?: PageParamType;
215
+ /** 表格底部内容,可以是静态内容或动态函数 */
114
216
  footer?: (data: Data[] | undefined) => ReactNode;
115
217
  }
116
- declare const InfiniteList: <Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any>(props: InfiniteListProps<Item, Values, Data> & {
218
+ /**
219
+ * InfiniteList 组件
220
+ * @template Item 列表项类型
221
+ * @template Values 表单值类型
222
+ * @template Data 后端返回的数据类型
223
+ * @template PageParamType 分页参数的类型
224
+ */
225
+ declare function InfiniteListComponent<Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any, PageParamType = PageParam>(props: InfiniteListProps<Item, Values, Data, PageParamType> & {
117
226
  ref?: Ref<InfiniteListRef<Item, Values, Data>>;
118
- }) => ReactElement;
227
+ }): ReactElement;
228
+ declare const InfiniteList: typeof InfiniteListComponent;
119
229
 
120
230
  type InfiniteQueryRefetchFunction = () => void | Promise<unknown>;
121
231
  type InfiniteQueryFetchNextPageFunction = () => void | Promise<unknown>;
@@ -620,11 +730,11 @@ interface VisibilityState {
620
730
  cleanup: (uuid: number) => void;
621
731
  }
622
732
  /**
623
- * 创建一个可见性管理的 Zustand store
624
- * 用于管理 Modal、Drawer 等组件的显示/隐藏状态
625
- * 每次调用都会创建一个独立的 store 实例,确保不同组件间的状态隔离
733
+ * 创建可见性管理的 Zustand store 配置
734
+ * 这是一个纯函数,返回 store 的配置对象
735
+ * 使用函数形式延迟执行,避免模块初始化顺序问题
626
736
  */
627
- declare function createVisibilityStore(): zustand.UseBoundStore<zustand.StoreApi<VisibilityState>>;
737
+ declare function createVisibilityStoreConfig(): StateCreator<VisibilityState, [], [], VisibilityState>;
628
738
 
629
739
  declare const generateId: () => number;
630
740
 
@@ -636,7 +746,11 @@ declare const generateId: () => number;
636
746
  */
637
747
  declare const mixedStorage: StateStorage;
638
748
 
639
- declare const useDrawerStore: zustand.UseBoundStore<zustand.StoreApi<VisibilityState>>;
749
+ /**
750
+ * Drawer store hook
751
+ * 使用 lazy initialization 确保 create 函数在调用时已经准备好
752
+ */
753
+ declare function useDrawerStore(): VisibilityState;
640
754
 
641
755
  interface UseModalOperation {
642
756
  hide: () => void;
@@ -674,7 +788,11 @@ interface UseFormModalReturn<Values extends AnyObject, ExtraValues> {
674
788
  }
675
789
  declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues = Record<string, unknown>>(props: UseFormModalProps<Values, ExtraValues>): UseFormModalReturn<Values, ExtraValues>;
676
790
 
677
- declare const useModalStore: zustand.UseBoundStore<zustand.StoreApi<VisibilityState>>;
791
+ /**
792
+ * Modal store hook
793
+ * 使用 lazy initialization 确保 create 函数在调用时已经准备好
794
+ */
795
+ declare function useModalStore(): VisibilityState;
678
796
 
679
797
  declare const _default$1: react_jsx_runtime.JSX.Element;
680
798
 
@@ -883,4 +1001,4 @@ declare function useAuth(code?: string | string[], config?: Options): {
883
1001
  declare function useMenuList(): _tanstack_react_query.UseQueryResult<MenuListItem[], Error>;
884
1002
  declare const useGames: () => _tanstack_react_query.UseQueryResult<Game[], Error>;
885
1003
 
886
- export { APP_ID_HEADER, AuthButton, type AuthButtonProps, type CacheConfig$1 as CacheConfig, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, GameSelect, type GameSelectConfig, type GameSelectProps, type HeaderExtra, type HeaderExtraConfig, Highlight, type HighlightProps, type HttpMethod$1 as HttpMethod, InfiniteList, InfiniteListAction, type InfiniteListPayload, type InfiniteListProps, type InfiniteListRef, type InfiniteListRequestConfig, type InfiniteListRequestConfigType, Layout, type LayoutProps, Logo, type LogoProps, type MenuListItem, Nav, type NavItem, type NavigationConfig, NotFound, OperationLogList, type Permission, PermissionMode, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, type RecursivePartial, RequireAuth, type RequireAuthProps, _default$2 as RequireGame, type RouteMatchRule, SSO_URL, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseFormDrawerProps, type UseFormModalProps, UserDropdown, type VisibilityState, WILDCARD, createVisibilityStore, generateId, _default$1 as menu, mixedStorage, _default as permission, useAuth, useDrawer, useDrawerStore, useFormDrawer, useFormModal, useGames, useInfiniteListStore, useMenuList, useModal, useModalStore, useQueryListStore, useToolkitsStore };
1004
+ export { APP_ID_HEADER, AuthButton, type AuthButtonProps, type CacheConfig$1 as CacheConfig, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, GameSelect, type GameSelectConfig, type GameSelectProps, type HeaderExtra, type HeaderExtraConfig, Highlight, type HighlightProps, type HttpMethod$1 as HttpMethod, InfiniteList, type InfiniteListDataAdapter, type InfiniteListPayload, type InfiniteListProps, type InfiniteListRef, type InfiniteListRequestConfig, type InfiniteListRequestConfigType, Layout, type LayoutProps, Logo, type LogoProps, type MenuListItem, Nav, type NavItem, type NavigationConfig, NotFound, OperationLogList, type Permission, PermissionMode, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, type RecursivePartial, RequireAuth, type RequireAuthProps, _default$2 as RequireGame, type RouteMatchRule, SSO_URL, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseFormDrawerProps, type UseFormModalProps, UserDropdown, type VisibilityState, WILDCARD, createVisibilityStoreConfig, generateId, _default$1 as menu, mixedStorage, _default as permission, useAuth, useDrawer, useDrawerStore, useFormDrawer, useFormModal, useGames, useInfiniteListStore, useMenuList, useModal, useModalStore, useQueryListStore, useToolkitsStore };