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