@kilnonedre/foundation 0.0.1-alpha.2 → 0.0.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 (3) hide show
  1. package/dist/index.d.ts +310 -51
  2. package/dist/index.js +2802 -182
  3. package/package.json +45 -4
package/dist/index.d.ts CHANGED
@@ -1,15 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { z } from 'zod';
3
+ import { ColumnDef } from '@tanstack/react-table';
4
+ import { Control, FieldValues, ControllerRenderProps, ControllerFieldState } from 'react-hook-form';
4
5
  import { ClassValue } from 'clsx';
5
-
6
- declare const EnumEntityStatus: {
7
- readonly ACTIVE: "ACTIVE";
8
- readonly INACTIVE: "INACTIVE";
9
- readonly DELETED: "DELETED";
10
- };
11
- type EnumEntityStatus = (typeof EnumEntityStatus)[keyof typeof EnumEntityStatus];
12
- declare const EnumEntityStatusLabel: Record<EnumEntityStatus, string>;
6
+ import { z } from 'zod';
13
7
 
14
8
  declare const EnumApprovalStatus: {
15
9
  readonly PENDING: "PENDING";
@@ -20,21 +14,21 @@ declare const EnumApprovalStatus: {
20
14
  type EnumApprovalStatus = (typeof EnumApprovalStatus)[keyof typeof EnumApprovalStatus];
21
15
  declare const EnumApprovalStatusLabel: Record<EnumApprovalStatus, string>;
22
16
 
23
- declare const EnumPublishMethod: {
24
- readonly IMMEDIATE: "IMMEDIATE";
25
- readonly SCHEDULED: "SCHEDULED";
26
- readonly WAREHOUSE: "WAREHOUSE";
17
+ declare const EnumApprovalView: {
18
+ readonly ALL: "ALL";
19
+ readonly SUBMITTED_BY_ME: "SUBMITTED_BY_ME";
20
+ readonly ASSIGNED_TO_ME: "ASSIGNED_TO_ME";
27
21
  };
28
- type EnumPublishMethod = (typeof EnumPublishMethod)[keyof typeof EnumPublishMethod];
29
- declare const EnumPublishMethodLabel: Record<EnumPublishMethod, string>;
22
+ type EnumApprovalView = (typeof EnumApprovalView)[keyof typeof EnumApprovalView];
23
+ declare const EnumApprovalViewLabel: Record<EnumApprovalView, string>;
30
24
 
31
- declare const EnumStorageMethod: {
32
- readonly COLD: "COLD";
33
- readonly FROZEN: "FROZEN";
34
- readonly NORMAL: "NORMAL";
25
+ declare const EnumEntityStatus: {
26
+ readonly ACTIVE: "ACTIVE";
27
+ readonly INACTIVE: "INACTIVE";
28
+ readonly DELETED: "DELETED";
35
29
  };
36
- type EnumStorageMethod = (typeof EnumStorageMethod)[keyof typeof EnumStorageMethod];
37
- declare const EnumStorageMethodLabel: Record<EnumStorageMethod, string>;
30
+ type EnumEntityStatus = (typeof EnumEntityStatus)[keyof typeof EnumEntityStatus];
31
+ declare const EnumEntityStatusLabel: Record<EnumEntityStatus, string>;
38
32
 
39
33
  declare const EnumFormMode: {
40
34
  readonly VIEW: "VIEW";
@@ -45,13 +39,20 @@ declare const EnumFormMode: {
45
39
  type EnumFormMode = (typeof EnumFormMode)[keyof typeof EnumFormMode];
46
40
  declare const EnumFormModeLabel: Record<EnumFormMode, string>;
47
41
 
48
- declare const EnumApprovalView: {
49
- readonly ALL: "ALL";
50
- readonly SUBMITTED_BY_ME: "SUBMITTED_BY_ME";
51
- readonly ASSIGNED_TO_ME: "ASSIGNED_TO_ME";
42
+ declare const EnumGenderType: {
43
+ readonly MALE: "MALE";
44
+ readonly FEMALE: "FEMALE";
45
+ readonly UNKNOWN: "UNKNOWN";
52
46
  };
53
- type EnumApprovalView = (typeof EnumApprovalView)[keyof typeof EnumApprovalView];
54
- declare const EnumApprovalViewLabel: Record<EnumApprovalView, string>;
47
+ type EnumGenderType = (typeof EnumGenderType)[keyof typeof EnumGenderType];
48
+ declare const EnumGenderTypeLabel: Record<EnumGenderType, string>;
49
+
50
+ declare const EnumMapProvider: {
51
+ readonly AMAP: "AMAP";
52
+ readonly TENCENT: "TENCENT";
53
+ };
54
+ type EnumMapProvider = (typeof EnumMapProvider)[keyof typeof EnumMapProvider];
55
+ declare const EnumMapProviderLabel: Record<EnumMapProvider, string>;
55
56
 
56
57
  declare const EnumOrderStatus: {
57
58
  readonly CREATED: "CREATED";
@@ -65,20 +66,13 @@ declare const EnumOrderStatus: {
65
66
  type EnumOrderStatus = (typeof EnumOrderStatus)[keyof typeof EnumOrderStatus];
66
67
  declare const EnumOrderStatusLabel: Record<EnumOrderStatus, string>;
67
68
 
68
- declare const EnumMapProvider: {
69
- readonly AMAP: "AMAP";
70
- readonly TENCENT: "TENCENT";
71
- };
72
- type EnumMapProvider = (typeof EnumMapProvider)[keyof typeof EnumMapProvider];
73
- declare const EnumMapProviderLabel: Record<EnumMapProvider, string>;
74
-
75
- declare const EnumGenderType: {
76
- readonly MALE: "MALE";
77
- readonly FEMALE: "FEMALE";
78
- readonly UNKNOWN: "UNKNOWN";
69
+ declare const EnumPublishMethod: {
70
+ readonly IMMEDIATE: "IMMEDIATE";
71
+ readonly SCHEDULED: "SCHEDULED";
72
+ readonly WAREHOUSE: "WAREHOUSE";
79
73
  };
80
- type EnumGenderType = (typeof EnumGenderType)[keyof typeof EnumGenderType];
81
- declare const EnumGenderTypeLabel: Record<EnumGenderType, string>;
74
+ type EnumPublishMethod = (typeof EnumPublishMethod)[keyof typeof EnumPublishMethod];
75
+ declare const EnumPublishMethodLabel: Record<EnumPublishMethod, string>;
82
76
 
83
77
  declare const EnumSemanticColor: {
84
78
  readonly PRIMARY: "PRIMARY";
@@ -92,6 +86,14 @@ declare const EnumSemanticColor: {
92
86
  type EnumSemanticColor = (typeof EnumSemanticColor)[keyof typeof EnumSemanticColor];
93
87
  declare const EnumSemanticColorLabel: Record<EnumSemanticColor, string>;
94
88
 
89
+ declare const EnumStorageMethod: {
90
+ readonly COLD: "COLD";
91
+ readonly FROZEN: "FROZEN";
92
+ readonly NORMAL: "NORMAL";
93
+ };
94
+ type EnumStorageMethod = (typeof EnumStorageMethod)[keyof typeof EnumStorageMethod];
95
+ declare const EnumStorageMethodLabel: Record<EnumStorageMethod, string>;
96
+
95
97
  declare const EnumVariant: {
96
98
  readonly SOLID: "SOLID";
97
99
  readonly OUTLINE: "OUTLINE";
@@ -100,7 +102,26 @@ declare const EnumVariant: {
100
102
  type EnumVariant = (typeof EnumVariant)[keyof typeof EnumVariant];
101
103
  declare const EnumVariantLabel: Record<EnumVariant, string>;
102
104
 
103
- interface ConfigProp {
105
+ type SemanticColorToken = {
106
+ bg: string;
107
+ text: string;
108
+ border: string;
109
+ hoverBg: string;
110
+ hoverText: string;
111
+ focusRing: string;
112
+ };
113
+ declare const getSemanticColor: (semanticColor: EnumSemanticColor, variant: EnumVariant) => SemanticColorToken;
114
+
115
+ interface ConfigProp$e {
116
+ semanticColor?: EnumSemanticColor;
117
+ variant?: EnumVariant;
118
+ children?: ReactNode;
119
+ className?: string;
120
+ }
121
+
122
+ declare const Badge: ({ semanticColor, variant, children, className, }: ConfigProp$e) => react_jsx_runtime.JSX.Element;
123
+
124
+ interface ConfigProp$d {
104
125
  semanticColor?: EnumSemanticColor;
105
126
  variant?: EnumVariant;
106
127
  children?: ReactNode;
@@ -108,23 +129,265 @@ interface ConfigProp {
108
129
  onClick?: () => void;
109
130
  disabled?: boolean;
110
131
  loading?: boolean;
111
- size?: "default" | "sm" | "lg" | "icon" | null;
112
- type?: "button" | "submit" | "reset";
132
+ size?: 'default' | 'sm' | 'lg' | 'icon' | null;
133
+ type?: 'button' | 'submit' | 'reset';
113
134
  }
114
135
 
115
- declare const Button: ({ semanticColor, variant, children, className, onClick, disabled, type, size, loading, }: ConfigProp) => react_jsx_runtime.JSX.Element;
136
+ declare const Button: ({ semanticColor, variant, children, className, onClick, disabled, type, size, loading, }: ConfigProp$d) => react_jsx_runtime.JSX.Element;
116
137
 
117
- declare const boolToText: (bool: boolean) => "是" | "否";
138
+ type UUID = `${string}-${string}-${string}-${string}-${string}`;
118
139
 
119
- declare const formatDecimal: (value: number | string | null | undefined, digits?: number) => string;
140
+ interface CommonObject {
141
+ id: UUID;
142
+ url: string;
143
+ }
120
144
 
121
145
  interface CommonOption {
122
146
  value: string;
123
147
  label: string;
124
148
  }
125
149
 
150
+ interface ConfigProp$c {
151
+ options: Array<CommonOption>;
152
+ value?: string | null;
153
+ onChange: (_v: string) => void;
154
+ }
155
+
156
+ declare const CheckboxSingleList: (props: ConfigProp$c) => react_jsx_runtime.JSX.Element;
157
+
158
+ interface ConfigListRespT<T> {
159
+ items: Array<T>;
160
+ pageInfo: {
161
+ page: number;
162
+ size: number;
163
+ totalElement: number;
164
+ totalPage: number;
165
+ };
166
+ }
167
+
168
+ interface ConfigApiRespT<T> {
169
+ code: string;
170
+ data: T;
171
+ msg: string;
172
+ }
173
+
174
+ type SearchbarCtx = {
175
+ filters: Record<string, unknown>;
176
+ setFilters: (_updater: (_prev: Record<string, unknown>) => Record<string, unknown>) => void;
177
+ search: () => void;
178
+ reset: () => void;
179
+ };
180
+ type AdvancedFilterCtx = {
181
+ draftFilters: Record<string, unknown>;
182
+ setDraftFilters: (_updater: (_prev: Record<string, unknown>) => Record<string, unknown>) => void;
183
+ };
184
+ type ConfigProp$b<T, P> = {
185
+ columns: Array<ColumnDef<T>>;
186
+ renderList: (_params: P) => Promise<ConfigApiRespT<ConfigListRespT<T>>>;
187
+ getRowId?: (_row: T) => string;
188
+ keyword?: string;
189
+ filters?: Record<string, unknown>;
190
+ onFiltersChange?: (_filters: Record<string, unknown>) => void;
191
+ searchbar?: (_ctx: SearchbarCtx) => ReactNode;
192
+ advancedFilter?: (_ctx: AdvancedFilterCtx) => ReactNode;
193
+ toolbar?: (_ctx: {
194
+ refresh: () => void;
195
+ }) => ReactNode;
196
+ meta?: Record<string, unknown>;
197
+ navigate?: (_id: UUID) => void;
198
+ };
199
+
200
+ interface ConfigProp$a {
201
+ id?: string;
202
+ mode: EnumFormMode;
203
+ children: ReactNode;
204
+ open: boolean;
205
+ bodyHeight?: string | number;
206
+ limitHeight?: boolean;
207
+ onEdit: () => void;
208
+ renderBody: () => ReactNode;
209
+ renderFooter: () => ReactNode;
210
+ onSubmit: () => void;
211
+ onOpenChange: (_nextOpen: boolean) => void;
212
+ }
213
+
214
+ declare const TableFormDialog: (props: ConfigProp$a) => react_jsx_runtime.JSX.Element;
215
+
216
+ interface ConfigProp$9 {
217
+ totalPage: number;
218
+ size: number;
219
+ sizeList: Array<number>;
220
+ currentPage: number;
221
+ onUpdateCurrentPage: (_page: number) => void;
222
+ onUpdateSize: (_size: number) => void;
223
+ }
224
+
225
+ declare const TablePagination: (props: ConfigProp$9) => react_jsx_runtime.JSX.Element;
226
+
227
+ declare const DataTable: <T, P>(props: ConfigProp$b<T, P>) => react_jsx_runtime.JSX.Element;
228
+
229
+ interface ConfigProp$8 {
230
+ children: ReactNode;
231
+ title?: string;
232
+ content?: ReactNode;
233
+ confirmText?: string;
234
+ cancelText?: string;
235
+ onConfirm?: () => void | Promise<void>;
236
+ }
237
+
238
+ declare const Dialog: (props: ConfigProp$8) => react_jsx_runtime.JSX.Element;
239
+
240
+ interface ConfigProp$7<T> {
241
+ columns: Array<ColumnDef<T>>;
242
+ list?: Array<T>;
243
+ enableRowSelection?: boolean;
244
+ getRowId?: (_row: T) => string;
245
+ meta?: Record<string, unknown>;
246
+ navigate?: (_id: UUID) => void;
247
+ }
248
+
249
+ declare const DisplayTable: <T>(props: ConfigProp$7<T>) => react_jsx_runtime.JSX.Element;
250
+
251
+ interface ConfigCascaderOption {
252
+ label: string;
253
+ value: string;
254
+ disabled?: boolean;
255
+ children?: Array<ConfigCascaderOption>;
256
+ }
257
+ interface ConfigDropdownCascaderMultiProp {
258
+ options: Array<ConfigCascaderOption>;
259
+ value?: Array<string>;
260
+ placeholder?: string;
261
+ onValueChange?: (_values: Array<string>, _selected: Array<{
262
+ option: ConfigCascaderOption;
263
+ path: Array<ConfigCascaderOption>;
264
+ }>) => void;
265
+ }
266
+ interface ConfigDropdownCascaderSingleProp {
267
+ options: Array<ConfigCascaderOption>;
268
+ value?: string;
269
+ placeholder?: string;
270
+ onValueChange?: (_value: string, _selected: {
271
+ option: ConfigCascaderOption;
272
+ path: Array<ConfigCascaderOption>;
273
+ }) => void;
274
+ }
275
+
276
+ declare const DropdownCascaderMulti: ({ value, ...props }: ConfigDropdownCascaderMultiProp) => react_jsx_runtime.JSX.Element;
277
+
278
+ declare const DropdownCascader: (props: ConfigDropdownCascaderSingleProp) => react_jsx_runtime.JSX.Element;
279
+
280
+ interface ConfigProp$6 {
281
+ id: string;
282
+ name: string;
283
+ required?: boolean;
284
+ tip?: string;
285
+ control: Control<FieldValues>;
286
+ mode?: EnumFormMode;
287
+ label?: string;
288
+ children: (_params: {
289
+ field: ControllerRenderProps<FieldValues, string>;
290
+ fieldState: ControllerFieldState;
291
+ id: string;
292
+ }) => ReactNode;
293
+ }
294
+
295
+ declare const FieldController: ({ required, ...props }: ConfigProp$6) => react_jsx_runtime.JSX.Element;
296
+
297
+ interface ConfigProp$5 {
298
+ className?: string;
299
+ children: ReactNode;
300
+ }
301
+
302
+ declare const FieldGroup: (props: ConfigProp$5) => react_jsx_runtime.JSX.Element;
303
+
304
+ interface ConfigProp$4 {
305
+ id: string;
306
+ name: string;
307
+ required?: boolean;
308
+ mode: EnumFormMode;
309
+ label?: string;
310
+ invalid?: boolean;
311
+ error?: string;
312
+ children?: ReactNode;
313
+ }
314
+
315
+ declare const FieldPlain: ({ required, mode, ...props }: ConfigProp$4) => react_jsx_runtime.JSX.Element;
316
+
317
+ interface ConfigProp$3 {
318
+ id?: string;
319
+ name: string;
320
+ value?: string | number | null;
321
+ placeholder?: string;
322
+ required?: boolean;
323
+ render?: ReactNode;
324
+ }
325
+
326
+ declare const FieldText: ({ id, name, value, placeholder, required, render, }: ConfigProp$3) => react_jsx_runtime.JSX.Element;
327
+
328
+ interface ConfigProp$2 {
329
+ value: string;
330
+ onValueChange: (_val: string) => void;
331
+ onLabelChange?: (_val: string) => void;
332
+ invalid: boolean;
333
+ optionList: Array<CommonOption>;
334
+ }
335
+
336
+ declare const FormSelect: (props: ConfigProp$2) => react_jsx_runtime.JSX.Element;
337
+
338
+ interface ConfigProp$1 {
339
+ value?: Date;
340
+ onChange: (_value?: Date) => void;
341
+ id?: string;
342
+ disabled?: boolean;
343
+ datePlaceholder?: string;
344
+ timePlaceholder?: string;
345
+ }
346
+
347
+ declare const FormTimePicker: (props: ConfigProp$1) => react_jsx_runtime.JSX.Element;
348
+
349
+ interface ConfigProps {
350
+ value?: Array<string>;
351
+ onChange?: (_ids: string[]) => void;
352
+ className?: string;
353
+ disabled?: boolean;
354
+ multiple?: boolean;
355
+ readonly?: boolean;
356
+ maxSizeKb?: number;
357
+ upload: (_formData: FormData) => Promise<ConfigApiRespT<CommonObject>>;
358
+ read: (_id: string) => Promise<ConfigApiRespT<CommonObject>>;
359
+ onError?: (_message: string) => void;
360
+ }
361
+
362
+ declare const MediaUploader: ({ value, ...props }: ConfigProps) => react_jsx_runtime.JSX.Element;
363
+
364
+ declare const Provider: ({ children }: {
365
+ children: React.ReactNode;
366
+ }) => react_jsx_runtime.JSX.Element;
367
+
368
+ interface ConfigProp {
369
+ children: ReactNode;
370
+ className?: ClassValue;
371
+ }
372
+
373
+ declare const Text: (props: ConfigProp) => react_jsx_runtime.JSX.Element;
374
+
375
+ declare const boolToText: (bool: boolean) => "是" | "否";
376
+
377
+ declare function cn(...inputs: ClassValue[]): string;
378
+
379
+ declare const formatDateTime: (value: string | Date | number | null | undefined, format?: string) => string;
380
+
126
381
  declare const enumToOptions: <T extends string>(enumObj: Record<string, T>, labelMap: Record<T, string>) => Array<CommonOption>;
127
382
 
383
+ declare const formatDecimal: (value: number | string | null | undefined, digits?: number) => string;
384
+
385
+ declare const genUuid: () => UUID;
386
+
387
+ declare const isEmpty: (v: unknown) => boolean;
388
+
389
+ declare const isFormData: (object: object | undefined) => boolean;
390
+
128
391
  declare const isValidEmail: (string: string) => boolean;
129
392
 
130
393
  declare const isValidURL: (string: string) => boolean;
@@ -159,8 +422,4 @@ declare const zCoerceNumberOptional: (label: string, min?: number, max?: number)
159
422
  declare const zDecimal: (label: string, min?: number, max?: number) => z.ZodString;
160
423
  declare const zDecimalOptional: (label: string, min?: number, max?: number) => z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
161
424
 
162
- declare const formatDateTime: (value: string | Date | number | null | undefined, format?: string) => string;
163
-
164
- declare function cn(...inputs: ClassValue[]): string;
165
-
166
- export { Button, type CommonOption, EnumApprovalStatus, EnumApprovalStatusLabel, EnumApprovalView, EnumApprovalViewLabel, EnumEntityStatus, EnumEntityStatusLabel, EnumFormMode, EnumFormModeLabel, EnumGenderType, EnumGenderTypeLabel, EnumMapProvider, EnumMapProviderLabel, EnumOrderStatus, EnumOrderStatusLabel, EnumPublishMethod, EnumPublishMethodLabel, EnumSemanticColor, EnumSemanticColorLabel, EnumStorageMethod, EnumStorageMethodLabel, EnumVariant, EnumVariantLabel, boolToText, cn, emptyToUndefined, enumToOptions, enumValues, formatDateTime, formatDecimal, isValidEmail, isValidURL, zBool, zCoerceNumber, zCoerceNumberOptional, zDate, zDateOptional, zDecimal, zDecimalOptional, zEmail, zEnumNullable, zEnumNullableOptional, zEnumNullableRequired, zEnumOptional, zEnumRequired, zId, zIdCard, zIdCardOptional, zIds, zImageId, zImageIdRequired, zImageIds, zImageIdsOptional, zNumber, zNumberOptional, zPhone, zTextOptional, zTextRequired, zTexts };
425
+ export { Badge, Button, CheckboxSingleList, type CommonObject, type CommonOption, DataTable, Dialog, DisplayTable, DropdownCascader, DropdownCascaderMulti, EnumApprovalStatus, EnumApprovalStatusLabel, EnumApprovalView, EnumApprovalViewLabel, EnumEntityStatus, EnumEntityStatusLabel, EnumFormMode, EnumFormModeLabel, EnumGenderType, EnumGenderTypeLabel, EnumMapProvider, EnumMapProviderLabel, EnumOrderStatus, EnumOrderStatusLabel, EnumPublishMethod, EnumPublishMethodLabel, EnumSemanticColor, EnumSemanticColorLabel, EnumStorageMethod, EnumStorageMethodLabel, EnumVariant, EnumVariantLabel, FieldController, FieldGroup, FieldPlain, FieldText, FormSelect, FormTimePicker, MediaUploader, Provider, type SemanticColorToken, TableFormDialog, TablePagination, Text, type UUID, boolToText, cn, emptyToUndefined, enumToOptions, enumValues, formatDateTime, formatDecimal, genUuid, getSemanticColor, isEmpty, isFormData, isValidEmail, isValidURL, zBool, zCoerceNumber, zCoerceNumberOptional, zDate, zDateOptional, zDecimal, zDecimalOptional, zEmail, zEnumNullable, zEnumNullableOptional, zEnumNullableRequired, zEnumOptional, zEnumRequired, zId, zIdCard, zIdCardOptional, zIds, zImageId, zImageIdRequired, zImageIds, zImageIdsOptional, zNumber, zNumberOptional, zPhone, zTextOptional, zTextRequired, zTexts };