@vef-framework/shared 1.0.135 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README +15 -0
  2. package/dist/cjs/color/color-ops.cjs +76 -0
  3. package/dist/cjs/color/index.cjs +24 -0
  4. package/dist/cjs/color/name.cjs +49 -0
  5. package/dist/cjs/color/palette.cjs +126 -0
  6. package/dist/cjs/constants/color-names.cjs +1580 -0
  7. package/dist/cjs/constants/color-palettes.cjs +372 -0
  8. package/dist/cjs/constants/index.cjs +14 -0
  9. package/dist/cjs/index.cjs +339 -0
  10. package/dist/cjs/types/color.cjs +3 -0
  11. package/dist/cjs/types/common.cjs +3 -0
  12. package/dist/cjs/types/deep-keys.cjs +3 -0
  13. package/dist/cjs/types/index.cjs +7 -0
  14. package/dist/cjs/utils/chrono.cjs +139 -0
  15. package/dist/cjs/utils/equal.cjs +175 -0
  16. package/dist/cjs/utils/error.cjs +60 -0
  17. package/dist/cjs/utils/event.cjs +62 -0
  18. package/dist/cjs/utils/format.cjs +31 -0
  19. package/dist/cjs/utils/function.cjs +49 -0
  20. package/dist/cjs/utils/id.cjs +38 -0
  21. package/dist/cjs/utils/index.cjs +86 -0
  22. package/dist/cjs/utils/key.cjs +34 -0
  23. package/dist/cjs/utils/lib.cjs +234 -0
  24. package/dist/cjs/utils/object.cjs +20 -0
  25. package/dist/cjs/utils/path.cjs +63 -0
  26. package/dist/cjs/utils/pinyin.cjs +53 -0
  27. package/dist/cjs/utils/security.cjs +44 -0
  28. package/dist/cjs/utils/string.cjs +13 -0
  29. package/dist/cjs/utils/task.cjs +17 -0
  30. package/dist/cjs/utils/tree.cjs +262 -0
  31. package/dist/cjs/utils/zod.cjs +14 -0
  32. package/dist/es/color/color-ops.js +62 -0
  33. package/dist/es/color/index.js +4 -0
  34. package/dist/es/color/name.js +45 -0
  35. package/dist/es/color/palette.js +122 -0
  36. package/dist/es/constants/color-names.js +1575 -0
  37. package/dist/es/constants/color-palettes.js +367 -0
  38. package/dist/es/constants/index.js +3 -0
  39. package/dist/es/index.js +30 -0
  40. package/dist/es/types/color.js +1 -0
  41. package/dist/es/types/common.js +1 -0
  42. package/dist/es/types/deep-keys.js +1 -0
  43. package/dist/es/types/index.js +4 -0
  44. package/dist/es/utils/chrono.js +121 -0
  45. package/dist/es/utils/equal.js +170 -0
  46. package/dist/es/utils/error.js +33 -0
  47. package/dist/es/utils/event.js +57 -0
  48. package/dist/es/utils/format.js +26 -0
  49. package/dist/es/utils/function.js +41 -0
  50. package/dist/es/utils/id.js +34 -0
  51. package/dist/es/utils/index.js +18 -0
  52. package/dist/es/utils/key.js +30 -0
  53. package/dist/es/utils/lib.js +10 -0
  54. package/dist/es/utils/object.js +16 -0
  55. package/dist/es/utils/path.js +49 -0
  56. package/dist/es/utils/pinyin.js +47 -0
  57. package/dist/es/utils/security.js +39 -0
  58. package/dist/es/utils/string.js +9 -0
  59. package/dist/es/utils/task.js +13 -0
  60. package/dist/es/utils/tree.js +252 -0
  61. package/dist/es/utils/zod.js +6 -0
  62. package/dist/types/color/color-ops.d.ts +84 -0
  63. package/dist/types/color/index.d.ts +3 -0
  64. package/dist/types/color/name.d.ts +7 -0
  65. package/dist/types/color/palette.d.ts +8 -0
  66. package/dist/types/constants/color-names.d.ts +11 -0
  67. package/dist/types/constants/color-palettes.d.ts +823 -0
  68. package/dist/types/constants/index.d.ts +2 -0
  69. package/dist/types/index.d.ts +4 -0
  70. package/dist/types/types/color.d.ts +73 -0
  71. package/dist/types/types/common.d.ts +25 -0
  72. package/dist/types/types/deep-keys.d.ts +9 -0
  73. package/dist/types/types/index.d.ts +3 -0
  74. package/dist/types/utils/chrono.d.ts +162 -0
  75. package/dist/types/utils/equal.d.ts +16 -0
  76. package/dist/types/utils/error.d.ts +38 -0
  77. package/dist/types/utils/event.d.ts +68 -0
  78. package/dist/types/utils/format.d.ts +33 -0
  79. package/dist/types/utils/function.d.ts +59 -0
  80. package/{types → dist/types/utils}/id.d.ts +2 -2
  81. package/dist/types/utils/index.d.ts +17 -0
  82. package/dist/types/utils/key.d.ts +7 -0
  83. package/dist/types/utils/lib.d.ts +5 -0
  84. package/dist/types/utils/object.d.ts +9 -0
  85. package/dist/types/utils/path.d.ts +76 -0
  86. package/dist/types/utils/pinyin.d.ts +41 -0
  87. package/dist/types/utils/security.d.ts +18 -0
  88. package/dist/types/utils/string.d.ts +7 -0
  89. package/dist/types/utils/task.d.ts +6 -0
  90. package/dist/types/utils/tree.d.ts +208 -0
  91. package/dist/types/utils/zod.d.ts +1 -0
  92. package/package.json +58 -56
  93. package/README.md +0 -25
  94. package/cjs/color.cjs +0 -2
  95. package/cjs/constants.cjs +0 -2
  96. package/cjs/context.cjs +0 -2
  97. package/cjs/dom.cjs +0 -2
  98. package/cjs/error.cjs +0 -2
  99. package/cjs/event.cjs +0 -2
  100. package/cjs/expression.cjs +0 -2
  101. package/cjs/function.cjs +0 -2
  102. package/cjs/id.cjs +0 -2
  103. package/cjs/index.cjs +0 -2
  104. package/cjs/json.cjs +0 -2
  105. package/cjs/module.cjs +0 -2
  106. package/cjs/path.cjs +0 -2
  107. package/cjs/pinyin.cjs +0 -2
  108. package/cjs/security.cjs +0 -2
  109. package/cjs/store.cjs +0 -2
  110. package/cjs/styles.cjs +0 -2
  111. package/cjs/temporal.cjs +0 -2
  112. package/cjs/theme-variables.cjs +0 -2
  113. package/cjs/types.cjs +0 -2
  114. package/cjs/utils.cjs +0 -2
  115. package/cjs/validation.cjs +0 -2
  116. package/cjs/yaml.cjs +0 -2
  117. package/cjs/zod.cjs +0 -2
  118. package/esm/color.js +0 -2
  119. package/esm/constants.js +0 -2
  120. package/esm/context.js +0 -2
  121. package/esm/dom.js +0 -2
  122. package/esm/error.js +0 -2
  123. package/esm/event.js +0 -2
  124. package/esm/expression.js +0 -2
  125. package/esm/function.js +0 -2
  126. package/esm/id.js +0 -2
  127. package/esm/index.js +0 -2
  128. package/esm/json.js +0 -2
  129. package/esm/module.js +0 -2
  130. package/esm/path.js +0 -2
  131. package/esm/pinyin.js +0 -2
  132. package/esm/security.js +0 -2
  133. package/esm/store.js +0 -2
  134. package/esm/styles.js +0 -2
  135. package/esm/temporal.js +0 -2
  136. package/esm/theme-variables.js +0 -2
  137. package/esm/types.js +0 -2
  138. package/esm/utils.js +0 -2
  139. package/esm/validation.js +0 -2
  140. package/esm/yaml.js +0 -2
  141. package/esm/zod.js +0 -2
  142. package/types/color.d.ts +0 -7
  143. package/types/constants.d.ts +0 -28
  144. package/types/context.d.ts +0 -21
  145. package/types/dom.d.ts +0 -9
  146. package/types/error.d.ts +0 -16
  147. package/types/event.d.ts +0 -6
  148. package/types/expression.d.ts +0 -23
  149. package/types/function.d.ts +0 -8
  150. package/types/index.d.ts +0 -23
  151. package/types/json.d.ts +0 -7
  152. package/types/module.d.ts +0 -7
  153. package/types/path.d.ts +0 -43
  154. package/types/pinyin.d.ts +0 -14
  155. package/types/security.d.ts +0 -16
  156. package/types/store.d.ts +0 -78
  157. package/types/styles.d.ts +0 -21
  158. package/types/temporal.d.ts +0 -18
  159. package/types/theme-variables.d.ts +0 -348
  160. package/types/types.d.ts +0 -905
  161. package/types/utils.d.ts +0 -77
  162. package/types/validation.d.ts +0 -38
  163. package/types/yaml.d.ts +0 -7
  164. package/types/zod.d.ts +0 -6
package/types/types.d.ts DELETED
@@ -1,905 +0,0 @@
1
- import type { Variant } from "antd/es/config-provider";
2
- import type { RuleObject } from "antd/es/form";
3
- import type { JSONSchema7, JSONSchema7Array, JSONSchema7Definition, JSONSchema7Object, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version } from "json-schema";
4
- import type { ComponentType, CSSProperties, ReactNode } from "react";
5
- import type { EmptyObject, Except, IfAny, IfEmptyObject, IfNever, IfNull, IfUnknown, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, NonEmptyObject, NonEmptyTuple, PartialDeep, SetOptional, SetRequired, UnionToIntersection, UnionToTuple } from "type-fest";
6
- import type { RefetchOptions, UseQueryOptions } from "../../core/src/api/api-client";
7
- import type { defaultColorTypes, semanticColorTypes } from "./constants";
8
- import type { VefError } from "./error";
9
- export type { JSONSchema7, JSONSchema7Array, JSONSchema7Definition, JSONSchema7Object, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version, };
10
- export type { EmptyObject, Except, IfAny, IfEmptyObject, IfNever, IfNull, IfUnknown, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, NonEmptyObject, NonEmptyTuple, PartialDeep, SetOptional, SetRequired, UnionToIntersection, UnionToTuple, };
11
- /**
12
- * The style props of the component
13
- */
14
- export interface StyleProps {
15
- className?: string;
16
- style?: CSSProperties;
17
- }
18
- /**
19
- * The children props of the component
20
- */
21
- export interface ChildrenProps {
22
- children?: ReactNode;
23
- }
24
- export type MaybeNullish<T> = T | null | undefined;
25
- export type MaybeUndefined<T> = T | undefined;
26
- export type MaybeNull<T> = T | null;
27
- export type MaybeArray<T> = T | T[];
28
- export type MaybePromise<T> = T | Promise<T>;
29
- export type Handler = () => void;
30
- export type Provider<T> = () => T;
31
- export type Consumer<T> = (value: T) => void;
32
- export type ConsumerOptional<T> = (value?: T) => void;
33
- export type BiConsumer<T, U> = (value1: T, value2: U) => void;
34
- export type BiConsumerOptional<T, U> = (value1?: T, value2?: U) => void;
35
- export type BiConsumerOptional1<T, U> = (value1: T, value2?: U) => void;
36
- export type TriConsumer<T, U, V> = (value1: T, value2: U, value3: V) => void;
37
- export type TriConsumerOptional<T, U, V> = (value1?: T, value2?: U, value3?: V) => void;
38
- export type TriConsumerOptional1<T, U, V> = (value1: T, value2: U, value3?: V) => void;
39
- export type TriConsumerOptional2<T, U, V> = (value1: T, value2?: U, value3?: V) => void;
40
- export type QuadConsumer<T, U, V, W> = (value1: T, value2: U, value3: V, value4: W) => void;
41
- export type QuadConsumerOptional<T, U, V, W> = (value1?: T, value2?: U, value3?: V, value4?: W) => void;
42
- export type QuadConsumerOptional1<T, U, V, W> = (value1: T, value2: U, value3: V, value4?: W) => void;
43
- export type QuadConsumerOptional2<T, U, V, W> = (value1: T, value2: U, value3?: V, value4?: W) => void;
44
- export type QuadConsumerOptional3<T, U, V, W> = (value1: T, value2?: U, value3?: V, value4?: W) => void;
45
- export type Mapper<T, R> = (value: T) => R;
46
- export type MapperOptional<T, R> = (value?: T) => R;
47
- export type BiMapper<T, U, R> = (value1: T, value2: U) => R;
48
- export type BiMapperOptional<T, U, R> = (value1?: T, value2?: U) => R;
49
- export type BiMapperOptional1<T, U, R> = (value1: T, value2?: U) => R;
50
- export type TriMapper<T, U, V, R> = (value1: T, value2: U, value3: V) => R;
51
- export type TriMapperOptional<T, U, V, R> = (value1?: T, value2?: U, value3?: V) => R;
52
- export type TriMapperOptional1<T, U, V, R> = (value1: T, value2: U, value3?: V) => R;
53
- export type TriMapperOptional2<T, U, V, R> = (value1: T, value2?: U, value3?: V) => R;
54
- export type QuadMapper<T, U, V, W, R> = (value1: T, value2: U, value3: V, value4: W) => R;
55
- export type QuadMapperOptional<T, U, V, W, R> = (value1?: T, value2?: U, value3?: V, value4?: W) => R;
56
- export type QuadMapperOptional1<T, U, V, W, R> = (value1: T, value2: U, value3: V, value4?: W) => R;
57
- export type QuadMapperOptional2<T, U, V, W, R> = (value1: T, value2: U, value3?: V, value4?: W) => R;
58
- export type QuadMapperOptional3<T, U, V, W, R> = (value1: T, value2?: U, value3?: V, value4?: W) => R;
59
- export type Predicate<T> = Mapper<T, boolean>;
60
- export type BiPredicate<T, U> = BiMapper<T, U, boolean>;
61
- export type TriPredicate<T, U, V> = TriMapper<T, U, V, boolean>;
62
- export type QuadPredicate<T, U, V, W> = QuadMapper<T, U, V, W, boolean>;
63
- export type Private<T> = {
64
- [K in keyof T as K extends `_${string}` ? K : never]: T[K];
65
- };
66
- export type Override<T, U> = Omit<T, keyof U> & U;
67
- export type DeepPartial<T> = PartialDeep<T, {
68
- recurseIntoArrays: true;
69
- }>;
70
- export type StringKey<T extends ObjectType> = keyof T & string;
71
- export type GenericFunction<A extends any[] = any[], R = any> = (...args: A) => R;
72
- export type AnyFunction = GenericFunction;
73
- export type VoidAnyFunction = GenericFunction<any[], void>;
74
- export type ReturnAnyFunction<T = any> = GenericFunction<any[], T>;
75
- export type ArrayElementType<T extends unknown[]> = T extends Array<infer E> ? E : never;
76
- export type NonEmptyArray<T> = [T, ...T[]];
77
- export type Permutation<T, K = T> = [T] extends [never] ? [] : K extends T ? [K, ...Permutation<Exclude<T, K>>] : never;
78
- /**
79
- * The default color types
80
- */
81
- export type DefaultColorType = typeof defaultColorTypes[number];
82
- /**
83
- * The semantic color types
84
- */
85
- export type SemanticColorType = typeof semanticColorTypes[number];
86
- /**
87
- * The color types
88
- */
89
- export type ColorType = DefaultColorType | SemanticColorType;
90
- /**
91
- * The object value type
92
- */
93
- export type ObjectValue = {
94
- [key in string]: AnyValue;
95
- } & {
96
- [key in string]: AnyValue | undefined;
97
- };
98
- /**
99
- * The array value type
100
- */
101
- export type ArrayValue = AnyValue[] | readonly AnyValue[];
102
- /**
103
- * The primitive value type
104
- */
105
- export type PrimitiveValue = JsonPrimitive | undefined;
106
- /**
107
- * The any value type
108
- */
109
- export type AnyValue = ObjectValue | ArrayValue | PrimitiveValue;
110
- /**
111
- * The id value type
112
- */
113
- export type IdValue = string;
114
- /**
115
- * The key value type
116
- */
117
- export type KeyValue = string | number;
118
- /**
119
- * The length value type
120
- */
121
- export type LengthValue = number | string;
122
- /**
123
- * The object type.
124
- */
125
- export type ObjectType = object & Record<string, any>;
126
- /**
127
- * The value type.
128
- */
129
- export type ValueType<T, M extends boolean = false> = M extends true ? T[] : T;
130
- /**
131
- * The gap size type.
132
- */
133
- export type GapSize<T extends CSSProperties["gap"] = CSSProperties["gap"]> = LiteralUnion<Size, T>;
134
- /**
135
- * The gap type.
136
- */
137
- export type GapType<T extends CSSProperties["gap"] = CSSProperties["gap"]> = GapSize<T> | [GapSize<T>, GapSize<T>];
138
- /**
139
- * The expression.
140
- */
141
- export interface Expression {
142
- /**
143
- * The string expression.
144
- */
145
- expression: string;
146
- }
147
- /**
148
- * The maybe computed value.
149
- */
150
- export type MaybeComputed<T, F extends ReturnAnyFunction<T>> = T | F | Expression;
151
- /**
152
- * The query params with keyword.
153
- */
154
- export type QueryParamsWithKeyword<P extends ObjectType, K extends string = "keyword"> = P & {
155
- [key in K]?: string;
156
- };
157
- /**
158
- * The query params with values.
159
- */
160
- export type QueryParamsWithValues<P extends ObjectType, K extends string = "ids"> = P & {
161
- [key in K]?: IdValue[];
162
- };
163
- /**
164
- * The response of API.
165
- */
166
- export interface ApiResponse<T = unknown> {
167
- readonly code: number;
168
- readonly message: string;
169
- readonly data: T;
170
- }
171
- interface QueryBaseResult<T = unknown> {
172
- readonly isPending: boolean;
173
- readonly isSuccess: boolean;
174
- readonly isError: boolean;
175
- readonly isLoadingError: boolean;
176
- readonly isRefetchError: boolean;
177
- readonly isLoading: boolean;
178
- readonly isFetching: boolean;
179
- readonly isRefetching: boolean;
180
- readonly isPlaceholderData: boolean;
181
- readonly isStale: boolean;
182
- readonly error: MaybeUndefined<VefError>;
183
- readonly data: MaybeUndefined<T>;
184
- readonly refetch: MapperOptional<RefetchOptions, Promise<QueryRefetchResult<T>>>;
185
- }
186
- interface QueryPendingResult<T = unknown> extends QueryBaseResult<T> {
187
- readonly isPending: true;
188
- readonly isSuccess: false;
189
- readonly isError: false;
190
- readonly isLoadingError: false;
191
- readonly isRefetchError: false;
192
- readonly error: undefined;
193
- readonly data: undefined;
194
- }
195
- interface QueryLoadingResult<T = unknown> extends QueryBaseResult<T> {
196
- readonly isPending: true;
197
- readonly isLoading: true;
198
- readonly isSuccess: false;
199
- readonly isError: false;
200
- readonly isLoadingError: false;
201
- readonly isRefetchError: false;
202
- readonly error: undefined;
203
- readonly data: undefined;
204
- }
205
- interface QueryLoadingErrorResult<T = unknown> extends QueryBaseResult<T> {
206
- readonly isPending: false;
207
- readonly isLoading: false;
208
- readonly isSuccess: false;
209
- readonly isError: true;
210
- readonly isLoadingError: true;
211
- readonly isRefetchError: false;
212
- readonly error: VefError;
213
- readonly data: undefined;
214
- }
215
- interface QueryRefetchErrorResult<T = unknown> extends QueryBaseResult<T> {
216
- readonly isPending: false;
217
- readonly isLoading: false;
218
- readonly isSuccess: false;
219
- readonly isError: true;
220
- readonly isLoadingError: false;
221
- readonly isRefetchError: true;
222
- readonly error: VefError;
223
- readonly data: T;
224
- }
225
- interface QuerySuccessResult<T = unknown> extends QueryBaseResult<T> {
226
- readonly isPending: false;
227
- readonly isLoading: false;
228
- readonly isSuccess: true;
229
- readonly isError: false;
230
- readonly isLoadingError: false;
231
- readonly isRefetchError: false;
232
- readonly error: undefined;
233
- readonly data: T;
234
- }
235
- /**
236
- * The result of query.
237
- */
238
- export type QueryResult<T = unknown> = QueryPendingResult<T> | QueryLoadingResult<T> | QueryLoadingErrorResult<T> | QueryRefetchErrorResult<T> | QuerySuccessResult<T>;
239
- /**
240
- * The suspense query result.
241
- */
242
- export type SuspenseQueryResult<T = unknown> = Pick<QuerySuccessResult<T>, "data" | "refetch">;
243
- interface QueryRefetchResultBase<T = unknown> {
244
- readonly isSuccess: boolean;
245
- readonly isError: boolean;
246
- readonly error: MaybeUndefined<VefError>;
247
- readonly data: MaybeUndefined<T>;
248
- }
249
- interface QueryRefetchResultError<T = unknown> extends QueryRefetchResultBase<T> {
250
- readonly isSuccess: false;
251
- readonly isError: true;
252
- readonly error: VefError;
253
- readonly data: undefined;
254
- }
255
- interface QueryRefetchResultSuccess<T = unknown> extends QueryRefetchResultBase<T> {
256
- readonly isSuccess: true;
257
- readonly isError: false;
258
- readonly error: undefined;
259
- readonly data: T;
260
- }
261
- /**
262
- * The result of refetch.
263
- */
264
- export type QueryRefetchResult<T = unknown> = QueryRefetchResultError<T> | QueryRefetchResultSuccess<T>;
265
- interface MutationBaseResult<T = unknown, R = unknown> {
266
- readonly isIdle: boolean;
267
- readonly isPending: boolean;
268
- readonly isSuccess: boolean;
269
- readonly isError: boolean;
270
- readonly message: MaybeUndefined<string>;
271
- readonly error: MaybeUndefined<VefError>;
272
- readonly data: MaybeUndefined<R>;
273
- readonly mutate: (values: T) => Promise<ApiResponse<R>>;
274
- }
275
- type MutationIdleResult<T = unknown, R = unknown> = {
276
- readonly isIdle: true;
277
- readonly isPending: false;
278
- readonly isSuccess: false;
279
- readonly isError: false;
280
- readonly message: undefined;
281
- readonly error: undefined;
282
- readonly data: undefined;
283
- } & MutationBaseResult<T, R>;
284
- interface MutationPendingResult<T = unknown, R = unknown> extends MutationBaseResult<T, R> {
285
- readonly isIdle: false;
286
- readonly isPending: true;
287
- readonly isSuccess: false;
288
- readonly isError: false;
289
- readonly message: undefined;
290
- readonly error: undefined;
291
- readonly data: undefined;
292
- }
293
- interface MutationErrorResult<T = unknown, R = unknown> extends MutationBaseResult<T, R> {
294
- readonly isIdle: false;
295
- readonly isPending: false;
296
- readonly isSuccess: false;
297
- readonly isError: true;
298
- readonly message: undefined;
299
- readonly error: VefError;
300
- readonly data: undefined;
301
- }
302
- interface MutationSuccessResult<T = unknown, R = unknown> extends MutationBaseResult<T, R> {
303
- readonly isIdle: false;
304
- readonly isPending: false;
305
- readonly isSuccess: true;
306
- readonly isError: false;
307
- readonly message: string;
308
- readonly error: undefined;
309
- readonly data: R;
310
- }
311
- /**
312
- * The result of mutation.
313
- */
314
- export type MutationResult<T = unknown, R = unknown> = MutationIdleResult<T, R> | MutationPendingResult<T, R> | MutationErrorResult<T, R> | MutationSuccessResult<T, R>;
315
- /**
316
- * The options of the API.
317
- */
318
- export interface ApiOptions {
319
- /**
320
- * The request signal.
321
- */
322
- signal?: AbortSignal;
323
- }
324
- /**
325
- * The API interface.
326
- */
327
- export interface Api<T = unknown, R = unknown> {
328
- /**
329
- * The key of the API.
330
- */
331
- readonly key: string;
332
- /**
333
- * The API function.
334
- *
335
- * @param args - The arguments.
336
- * @param options - The options.
337
- * @returns The API response.
338
- */
339
- (args: T, options?: ApiOptions): Promise<ApiResponse<R>>;
340
- }
341
- /**
342
- * The query API interface.
343
- */
344
- export interface QueryApi<T = unknown, R = unknown> extends Api<T, R> {
345
- /**
346
- * The use API query hook.
347
- */
348
- readonly useQuery: BiMapperOptional1<T, UseQueryOptions<R>, QueryResult<R>>;
349
- /**
350
- * The use API query hook.
351
- */
352
- readonly useSuspenseQuery: BiMapperOptional1<T, Except<UseQueryOptions<R>, "enabled" | "placeholderData">, SuspenseQueryResult<R>>;
353
- /**
354
- * The fetch API query function.
355
- */
356
- readonly fetchQuery: BiMapperOptional1<T, Pick<UseQueryOptions<R>, "initialData" | "staleTime">, Promise<R>>;
357
- /**
358
- * The get API query data function.
359
- */
360
- readonly getQueryData: MapperOptional<Partial<T>, MaybeUndefined<ApiResponse<R>>>;
361
- /**
362
- * The get API queries data function.
363
- */
364
- readonly getQueriesData: MapperOptional<Partial<T>, Array<[T, MaybeUndefined<ApiResponse<R>>]>>;
365
- /**
366
- * The set API query data function.
367
- */
368
- readonly setQueryData: BiConsumerOptional1<MaybeUndefined<ApiResponse<R> | Mapper<MaybeUndefined<ApiResponse<R>>, MaybeUndefined<ApiResponse<R>>>>, Partial<T>>;
369
- /**
370
- * The ensure API query data function.
371
- */
372
- readonly ensureQueryData: BiMapperOptional1<T, Pick<UseQueryOptions<R>, "initialData">, Promise<R>>;
373
- /**
374
- * The remove API queries function.
375
- */
376
- readonly removeQueries: ConsumerOptional<Partial<T>>;
377
- /**
378
- * The cancel API queries function.
379
- */
380
- readonly cancelQueries: MapperOptional<Partial<T>, Promise<void>>;
381
- /**
382
- * The reset API queries function.
383
- */
384
- readonly resetQueries: MapperOptional<Partial<T>, Promise<void>>;
385
- /**
386
- * The refetch API queries function.
387
- */
388
- readonly refetchQueries: MapperOptional<Partial<T>, Promise<void>>;
389
- /**
390
- * The invalidate API queries function.
391
- */
392
- readonly invalidateQueries: MapperOptional<Partial<T>, Promise<void>>;
393
- /**
394
- * The is fetching function.
395
- */
396
- readonly isFetching: MapperOptional<Partial<T>, boolean>;
397
- /**
398
- * The use is fetching hook.
399
- */
400
- readonly useIsFetching: MapperOptional<Partial<T>, boolean>;
401
- }
402
- /**
403
- * The mutation API interface.
404
- */
405
- export interface MutationApi<T = unknown, R = unknown> extends Api<T, R> {
406
- /**
407
- * The related queries of the mutation.
408
- */
409
- readonly relatedQueries: QueryApi[];
410
- /**
411
- * The use API mutation hook.
412
- */
413
- readonly useMutation: Provider<MutationResult<T, R>>;
414
- /**
415
- * The refetch related queries function.
416
- */
417
- readonly refetchRelatedQueries: Provider<Promise<void>>;
418
- /**
419
- * The invalidate related queries function.
420
- */
421
- readonly invalidateRelatedQueries: Provider<Promise<void>>;
422
- /**
423
- * The is mutating function.
424
- */
425
- readonly isMutating: Provider<boolean>;
426
- /**
427
- * The use is mutating hook.
428
- */
429
- readonly useIsMutating: Provider<boolean>;
430
- }
431
- /**
432
- * The params of the data dictionary query API.
433
- */
434
- export interface DataDictionaryParams {
435
- /**
436
- * The key of the data dictionary.
437
- */
438
- key: string;
439
- }
440
- /**
441
- * The query API for the data dictionary.
442
- */
443
- export type DataDictionaryApi = Readonly<QueryApi<DataDictionaryParams, DataOption[]>>;
444
- /**
445
- * The values of the login form.
446
- */
447
- export interface LoginValues {
448
- /**
449
- * The account of the login.
450
- */
451
- account: string;
452
- /**
453
- * The password of the login.
454
- */
455
- password: string;
456
- }
457
- /**
458
- * The result of the login.
459
- */
460
- export interface LoginResult extends AuthenticatedToken {
461
- }
462
- /**
463
- * The login API.
464
- */
465
- export type LoginApi = Readonly<MutationApi<LoginValues, LoginResult>>;
466
- /**
467
- * The logout API.
468
- */
469
- export type LogoutApi = Readonly<MutationApi<void>>;
470
- /**
471
- * The fetch authenticated user API.
472
- */
473
- export type FetchAuthenticatedUserApi = Readonly<QueryApi<void, AuthenticatedUser>>;
474
- /**
475
- * The permission checker.
476
- */
477
- export type PermissionChecker = Mapper<string, boolean>;
478
- /**
479
- * The data option.
480
- */
481
- export type DataOption<T extends DataOption<T> = PureDataOption> = {
482
- /**
483
- * The label of the option.
484
- */
485
- label?: ReactNode;
486
- /**
487
- * The value of the option.
488
- */
489
- value?: IdValue;
490
- /**
491
- * Whether the option is disabled.
492
- */
493
- disabled?: boolean;
494
- /**
495
- * The description of the option.
496
- */
497
- description?: ReactNode;
498
- /**
499
- * The text of the label.
500
- */
501
- labelText?: string;
502
- /**
503
- * The text of the description.
504
- */
505
- descriptionText?: string;
506
- /**
507
- * The children of the option.
508
- */
509
- children?: T[];
510
- } & Record<string, any>;
511
- /**
512
- * The pure data option.
513
- */
514
- export interface PureDataOption extends DataOption<PureDataOption> {
515
- }
516
- /**
517
- * The normalized data option.
518
- */
519
- export type NormalizedDataOption<T extends DataOption<T> = PureDataOption> = Except<DataOption<T>, "children"> & Required<Pick<DataOption<T>, "label" | "value" | "disabled">> & {
520
- /**
521
- * The children of the option.
522
- */
523
- children?: Array<NormalizedDataOption<T>>;
524
- /**
525
- * The pinyin of the label.
526
- */
527
- labelPinyin?: string;
528
- /**
529
- * The pinyin of the description.
530
- */
531
- descriptionPinyin?: string;
532
- };
533
- /**
534
- * The size of the component.
535
- */
536
- export type Size = "tiny" | "small" | "medium" | "large" | "huge";
537
- /**
538
- * The basic size of the component.
539
- */
540
- export type BasicSize = "small" | "medium" | "large";
541
- /**
542
- * The dimensions of the component.
543
- */
544
- export interface Dimensions {
545
- /**
546
- * The width of the component.
547
- */
548
- width?: number;
549
- /**
550
- * The height of the component.
551
- */
552
- height?: number;
553
- }
554
- /**
555
- * The orientation of the component.
556
- */
557
- export type Orientation = "horizontal" | "vertical";
558
- /**
559
- * The query config.
560
- */
561
- export interface QueryConfig<D = AnyValue, P extends ObjectType = EmptyObject, R = D, A = Readonly<QueryApi<P, R>>, DT = D, PT = P, ET = boolean, KT = string> {
562
- /**
563
- * The data.
564
- */
565
- data?: DT;
566
- /**
567
- * The data dictionary key.
568
- */
569
- dataDictionaryKey?: KT;
570
- /**
571
- * The api.
572
- */
573
- api?: A;
574
- /**
575
- * The api params.
576
- */
577
- apiParams?: PT;
578
- /**
579
- * Whether to automatically run the api.
580
- */
581
- apiEnabled?: ET;
582
- /**
583
- * The time in milliseconds after data is considered stale.
584
- */
585
- staleTime?: number;
586
- /**
587
- * Whether to keep the previous data.
588
- * Only works for api.
589
- */
590
- keepPreviousData?: boolean;
591
- /**
592
- * The placeholder data.
593
- * Only works for api.
594
- */
595
- placeholderData?: D;
596
- /**
597
- * The callback function when the data is fetched.
598
- */
599
- onFetched?: Mapper<R, D>;
600
- }
601
- /**
602
- * The config for the data options.
603
- */
604
- export interface DataOptionConfig<K extends string = string> {
605
- /**
606
- * The field key of the label.
607
- */
608
- labelKey?: K;
609
- /**
610
- * The field key of the value.
611
- */
612
- valueKey?: K;
613
- /**
614
- * The field key of the disabled.
615
- */
616
- disabledKey?: K;
617
- /**
618
- * The field key of the description.
619
- */
620
- descriptionKey?: K;
621
- /**
622
- * The field key of the children.
623
- */
624
- childrenKey?: K;
625
- /**
626
- * Whether to default to the first option.
627
- */
628
- defaultToFirst?: boolean;
629
- }
630
- /**
631
- * The pagination params.
632
- */
633
- export interface PaginationParams {
634
- /**
635
- * The page number.
636
- */
637
- page?: number;
638
- /**
639
- * The page size.
640
- */
641
- size?: number;
642
- }
643
- /**
644
- * The result of the pagination.
645
- */
646
- export interface PaginationResult<T = ObjectValue> {
647
- /**
648
- * The total number of the data.
649
- */
650
- readonly total: number;
651
- /**
652
- * The items of the current page.
653
- */
654
- readonly items: T[];
655
- }
656
- /**
657
- * The align type.
658
- */
659
- export type Align = "left" | "center" | "right";
660
- /**
661
- * The position type.
662
- */
663
- export type Position = "left" | "center" | "right";
664
- /**
665
- * The placement type.
666
- */
667
- export type Placement = "top" | "right" | "bottom" | "left";
668
- /**
669
- * The maybe computed type used for the action button.
670
- */
671
- type ActionButtonMaybeComputed<C, T> = IfNever<C, T, T | Mapper<C, T>>;
672
- /**
673
- * The permission check mode.
674
- */
675
- export type PermissionCheckMode = "any" | "all";
676
- /**
677
- * The confirmation mode.
678
- */
679
- export type ConfirmationMode = "simple" | "detailed";
680
- /**
681
- * The variant of the form item.
682
- */
683
- export type FormItemVariant = Variant;
684
- /**
685
- * The action button.
686
- */
687
- export interface ActionButton<T = never> {
688
- /**
689
- * The key of the action button.
690
- */
691
- key: string;
692
- /**
693
- * The label of the action button.
694
- */
695
- label: string;
696
- /**
697
- * Whether the action button is disabled.
698
- */
699
- disabled?: ActionButtonMaybeComputed<T, boolean>;
700
- /**
701
- * Whether the action button is shown.
702
- */
703
- show?: ActionButtonMaybeComputed<T, boolean>;
704
- /**
705
- * The color of the action button.
706
- */
707
- color?: ColorType;
708
- /**
709
- * The icon of the action button.
710
- */
711
- icon?: ReactNode;
712
- /**
713
- * The permissions of the action button.
714
- */
715
- permissions?: string[];
716
- /**
717
- * The permission check mode of the action button.
718
- * Default is "any".
719
- */
720
- checkMode?: PermissionCheckMode;
721
- /**
722
- * Whether the action button requires confirmation.
723
- */
724
- requireConfirmation?: ActionButtonMaybeComputed<T, boolean>;
725
- /**
726
- * The confirmation mode of the action button.
727
- * Default is "simple".
728
- */
729
- confirmationMode?: ActionButtonMaybeComputed<T, ConfirmationMode>;
730
- /**
731
- * The confirmation title of the action button.
732
- */
733
- confirmationTitle?: ActionButtonMaybeComputed<T, ReactNode>;
734
- /**
735
- * The confirmation content of the action button.
736
- */
737
- confirmationContent?: ActionButtonMaybeComputed<T, ReactNode>;
738
- /**
739
- * The callback function when the action button is clicked.
740
- */
741
- onClick: Mapper<T, MaybePromise<void>>;
742
- }
743
- /**
744
- * The basic menu item.
745
- */
746
- export interface BasicMenuItem {
747
- /**
748
- * The type of the menu item.
749
- */
750
- type: "item";
751
- /**
752
- * The key of the menu item.
753
- */
754
- key: IdValue;
755
- /**
756
- * The label of the menu item.
757
- */
758
- label: string;
759
- /**
760
- * The icon of the menu item.
761
- */
762
- icon?: ReactNode;
763
- /**
764
- * Whether the menu item is disabled.
765
- */
766
- disabled?: boolean;
767
- /**
768
- * The extra content of the menu item.
769
- */
770
- extra?: ReactNode;
771
- }
772
- /**
773
- * The submenu item.
774
- */
775
- export interface SubmenuItem extends Except<BasicMenuItem, "type" | "extra"> {
776
- /**
777
- * The type of the menu item.
778
- */
779
- type: "submenu";
780
- /**
781
- * The children of the sub menu item.
782
- */
783
- children: MenuItem[];
784
- }
785
- /**
786
- * The group menu item.
787
- */
788
- export interface GroupMenuItem extends Pick<BasicMenuItem, "key" | "label"> {
789
- /**
790
- * The type of the menu item.
791
- */
792
- type: "group";
793
- /**
794
- * The children of the group menu item.
795
- */
796
- children: MenuItem[];
797
- }
798
- /**
799
- * The divider menu item.
800
- */
801
- export interface DividerMenuItem extends Pick<BasicMenuItem, "key"> {
802
- /**
803
- * The type of the menu item.
804
- */
805
- type: "divider";
806
- }
807
- /**
808
- * The menu item.
809
- */
810
- export type MenuItem = BasicMenuItem | SubmenuItem | GroupMenuItem | DividerMenuItem;
811
- /**
812
- * The key of the menu item.
813
- */
814
- export type MenuItemKey<T extends readonly MenuItem[]> = GetMenuItemKey<FlattenMenuItems<T>[number]>;
815
- type GetMenuItemKey<T extends MenuItem> = IfNever<T, string, T["key"]>;
816
- type FlattenMenuItems<T extends readonly MenuItem[]> = T extends readonly [infer F, ...infer R extends readonly MenuItem[]] ? F extends BasicMenuItem ? [F, ...FlattenMenuItems<R>] : F extends GroupMenuItem ? FlattenMenuItems<F["children"]> : F extends SubmenuItem ? FlattenMenuItems<F["children"]> : FlattenMenuItems<R> : [];
817
- /**
818
- * The validation rule.
819
- */
820
- export type ValidationRule = RuleObject;
821
- /**
822
- * The control options.
823
- */
824
- export interface ControlOptions<S extends boolean | MaybeComputed<boolean, ReturnAnyFunction<boolean>> = boolean, D extends boolean | MaybeComputed<boolean, ReturnAnyFunction<boolean>> = boolean> {
825
- /**
826
- * Whether to show the block.
827
- */
828
- show?: S;
829
- /**
830
- * Whether to disable the block.
831
- */
832
- disabled?: D;
833
- }
834
- /**
835
- * The maybe computed control options.
836
- */
837
- export type MaybeComputedControlOptions<F extends ReturnAnyFunction<boolean>> = ControlOptions<MaybeComputed<boolean, F>, MaybeComputed<boolean, F>>;
838
- /**
839
- * The authenticated token info.
840
- */
841
- export interface AuthenticatedToken {
842
- /**
843
- * The access token.
844
- */
845
- accessToken: string;
846
- /**
847
- * The refresh token.
848
- */
849
- refreshToken: string;
850
- }
851
- /**
852
- * The gender of the user.
853
- */
854
- export type Gender = "male" | "female";
855
- /**
856
- * The authenticated user.
857
- */
858
- export interface AuthenticatedUser {
859
- /**
860
- * The id of the user.
861
- */
862
- id: string;
863
- /**
864
- * The name of the user.
865
- */
866
- name: string;
867
- /**
868
- * The gender of the user.
869
- */
870
- gender?: Gender;
871
- /**
872
- * The avatar of the user.
873
- */
874
- avatar?: string;
875
- /**
876
- * The permissions of the user.
877
- */
878
- permissions: string[];
879
- /**
880
- * The authorized menu keys of the user.
881
- */
882
- menus: MenuItem[];
883
- }
884
- /**
885
- * The chart config.
886
- */
887
- /**
888
- * The chart config.
889
- */
890
- export type ChartConfig<K extends string = string> = {
891
- [key in K]: {
892
- /**
893
- * The label of the chart.
894
- */
895
- label?: ReactNode;
896
- /**
897
- * The icon of the chart.
898
- */
899
- icon?: ComponentType;
900
- /**
901
- * The color of the chart.
902
- */
903
- color?: string;
904
- };
905
- };