@douyinfe/semi-foundation 2.75.1-alpha.1 → 2.76.0-alpha.5
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/chat/chat.scss +1 -0
- package/chat/foundation.ts +29 -0
- package/chat/inputboxFoundation.ts +2 -2
- package/datePicker/monthFoundation.ts +2 -6
- package/form/interface.ts +91 -42
- package/jsonViewer/foundation.ts +9 -10
- package/jsonViewer/jsonViewer.scss +1 -1
- package/lib/cjs/calendar/eventUtil.d.ts +1 -1
- package/lib/cjs/chat/chat.css +1 -0
- package/lib/cjs/chat/chat.scss +1 -0
- package/lib/cjs/chat/foundation.d.ts +10 -1
- package/lib/cjs/chat/foundation.js +26 -0
- package/lib/cjs/chat/inputboxFoundation.js +3 -2
- package/lib/cjs/colorPicker/DataPartFoundation.d.ts +1 -1
- package/lib/cjs/colorPicker/foundation.d.ts +1 -1
- package/lib/cjs/colorPicker/utils/split.d.ts +1 -1
- package/lib/cjs/datePicker/constants.js +3 -0
- package/lib/cjs/datePicker/monthFoundation.d.ts +2 -6
- package/lib/cjs/form/foundation.d.ts +5 -5
- package/lib/cjs/form/interface.d.ts +23 -20
- package/lib/cjs/image/previewInnerFoundation.d.ts +0 -1
- package/lib/cjs/jsonViewer/foundation.d.ts +3 -2
- package/lib/cjs/jsonViewer/foundation.js +3 -8
- package/lib/cjs/jsonViewer/jsonViewer.css +1 -1
- package/lib/cjs/jsonViewer/jsonViewer.scss +1 -1
- package/lib/cjs/navigation/constants.js +3 -0
- package/lib/cjs/navigation/navigation.css +40 -0
- package/lib/cjs/navigation/navigation.scss +31 -0
- package/lib/cjs/pincode/foundation.d.ts +1 -1
- package/lib/cjs/resizable/group/index.d.ts +0 -1
- package/lib/cjs/resizable/utils.d.ts +3 -3
- package/lib/cjs/select/foundation.d.ts +1 -1
- package/lib/cjs/slider/foundation.d.ts +15 -15
- package/lib/cjs/slider/foundation.js +3 -1
- package/lib/cjs/timePicker/ComboxFoundation.js +2 -1
- package/lib/cjs/tooltip/constants.js +1 -0
- package/lib/cjs/utils/date-fns-extra.js +9 -1
- package/lib/cjs/utils/keyCode.js +25 -0
- package/lib/cjs/utils/object.d.ts +1 -1
- package/lib/es/calendar/eventUtil.d.ts +1 -1
- package/lib/es/chat/chat.css +1 -0
- package/lib/es/chat/chat.scss +1 -0
- package/lib/es/chat/foundation.d.ts +10 -1
- package/lib/es/chat/foundation.js +26 -0
- package/lib/es/chat/inputboxFoundation.js +3 -2
- package/lib/es/colorPicker/DataPartFoundation.d.ts +1 -1
- package/lib/es/colorPicker/foundation.d.ts +1 -1
- package/lib/es/colorPicker/utils/split.d.ts +1 -1
- package/lib/es/datePicker/constants.js +3 -0
- package/lib/es/datePicker/monthFoundation.d.ts +2 -6
- package/lib/es/form/foundation.d.ts +5 -5
- package/lib/es/form/interface.d.ts +23 -20
- package/lib/es/image/previewInnerFoundation.d.ts +0 -1
- package/lib/es/jsonViewer/foundation.d.ts +3 -2
- package/lib/es/jsonViewer/foundation.js +3 -8
- package/lib/es/jsonViewer/jsonViewer.css +1 -1
- package/lib/es/jsonViewer/jsonViewer.scss +1 -1
- package/lib/es/navigation/constants.js +3 -0
- package/lib/es/navigation/navigation.css +40 -0
- package/lib/es/navigation/navigation.scss +31 -0
- package/lib/es/pincode/foundation.d.ts +1 -1
- package/lib/es/resizable/group/index.d.ts +0 -1
- package/lib/es/resizable/utils.d.ts +3 -3
- package/lib/es/select/foundation.d.ts +1 -1
- package/lib/es/slider/foundation.d.ts +15 -15
- package/lib/es/slider/foundation.js +3 -1
- package/lib/es/timePicker/ComboxFoundation.js +2 -1
- package/lib/es/tooltip/constants.js +1 -0
- package/lib/es/utils/date-fns-extra.js +9 -1
- package/lib/es/utils/keyCode.js +25 -0
- package/lib/es/utils/object.d.ts +1 -1
- package/navigation/navigation.scss +31 -0
- package/package.json +4 -4
- package/timePicker/ComboxFoundation.ts +2 -1
- package/utils/object.ts +1 -1
package/chat/chat.scss
CHANGED
package/chat/foundation.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface Message {
|
|
|
36
36
|
[x: string]: any
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export interface EnableUploadProps {
|
|
40
|
+
pasteUpload?: boolean;
|
|
41
|
+
dragUpload?: boolean;
|
|
42
|
+
clickUpload?: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
export interface ChatAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
40
46
|
getContainerRef: () => HTMLDivElement;
|
|
41
47
|
setWheelScroll: (flag: boolean) => void;
|
|
@@ -312,5 +318,28 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
|
|
|
312
318
|
this._adapter.setUploadAreaVisible(false);
|
|
313
319
|
});
|
|
314
320
|
}
|
|
321
|
+
|
|
322
|
+
getUploadProps = (uploadProps?: boolean | EnableUploadProps) => {
|
|
323
|
+
if (Object.prototype.toString.call(uploadProps) === '[object Object]') {
|
|
324
|
+
const { dragUpload = true, clickUpload = true, pasteUpload = true } = uploadProps as EnableUploadProps;
|
|
325
|
+
return {
|
|
326
|
+
dragUpload: dragUpload,
|
|
327
|
+
clickUpload: clickUpload,
|
|
328
|
+
pasteUpload: pasteUpload
|
|
329
|
+
};
|
|
330
|
+
} else if (typeof uploadProps === 'boolean') {
|
|
331
|
+
return {
|
|
332
|
+
dragUpload: uploadProps,
|
|
333
|
+
clickUpload: uploadProps,
|
|
334
|
+
pasteUpload: uploadProps
|
|
335
|
+
};
|
|
336
|
+
} else {
|
|
337
|
+
return {
|
|
338
|
+
dragUpload: true,
|
|
339
|
+
clickUpload: true,
|
|
340
|
+
pasteUpload: true
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
315
344
|
}
|
|
316
345
|
|
|
@@ -78,9 +78,9 @@ export default class InputBoxFoundation <P = Record<string, any>, S = Record<str
|
|
|
78
78
|
|
|
79
79
|
onPaste = (e: any) => {
|
|
80
80
|
const items = e.clipboardData?.items;
|
|
81
|
-
const { manualUpload } = this.getProps();
|
|
81
|
+
const { manualUpload, pasteUpload } = this.getProps();
|
|
82
82
|
let files = [];
|
|
83
|
-
if (items) {
|
|
83
|
+
if (pasteUpload && items) {
|
|
84
84
|
for (const it of items) {
|
|
85
85
|
const file = it.getAsFile();
|
|
86
86
|
file && files.push(it.getAsFile());
|
|
@@ -19,8 +19,8 @@ export interface MonthFoundationProps {
|
|
|
19
19
|
disabledDate: (day: Date, options?: { rangeStart: string; rangeEnd: string }) => boolean;
|
|
20
20
|
weeksRowNum: number;
|
|
21
21
|
onWeeksRowNumChange: (weeksRowNum: number) => void;
|
|
22
|
-
renderDate: () =>
|
|
23
|
-
renderFullDate: () =>
|
|
22
|
+
renderDate: (dayNumber: number, fullDate: string) => React.ReactNode;
|
|
23
|
+
renderFullDate: (dayNumber: number, fullDate: string, dayStatus: any) => React.ReactNode;
|
|
24
24
|
hoverDay: string; // Real-time hover date
|
|
25
25
|
startDateOffset: () => void;
|
|
26
26
|
endDateOffset: () => void;
|
|
@@ -35,10 +35,6 @@ export type MonthDayInfo = {
|
|
|
35
35
|
dayNumber: number;
|
|
36
36
|
dayNumberFull?: string;
|
|
37
37
|
fullDate: string
|
|
38
|
-
} | {
|
|
39
|
-
dayNumber: string;
|
|
40
|
-
dayNumberFull?: string;
|
|
41
|
-
fullDate: string
|
|
42
38
|
};
|
|
43
39
|
|
|
44
40
|
export interface MonthInfo {
|
package/form/interface.ts
CHANGED
|
@@ -38,56 +38,106 @@ export interface setValuesConfig {
|
|
|
38
38
|
isOverride: boolean
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// FieldPath 类型定义,用于生成对象字段的路径字符串
|
|
42
|
-
export type FieldPath<T> = T extends object ? {
|
|
43
|
-
// 遍历对象的每个键 K
|
|
44
|
-
[K in keyof T]: T[K] extends object
|
|
45
|
-
// 如果键 K 对应的值是对象,则生成嵌套路径(递归调用 FieldPath)
|
|
46
|
-
? `${string & K}.${FieldPath<T[K]>}` | `${string & K}`
|
|
47
|
-
// 否则,仅生成当前键的路径
|
|
48
|
-
: `${string & K}`;
|
|
49
|
-
}[keyof T]
|
|
50
|
-
: never;
|
|
51
|
-
|
|
52
|
-
// FieldPathValue 类型定义,用于从路径字符串中推导出实际的类型
|
|
53
|
-
export type FieldPathValue<T, P extends FieldPath<T>> =
|
|
54
|
-
// 如果路径字符串 P 包含嵌套路径(使用模板字符串类型进行匹配)
|
|
55
|
-
P extends `${infer K}.${infer Rest}`
|
|
56
|
-
? K extends keyof T
|
|
57
|
-
// 递归解析嵌套路径,逐层深入对象结构
|
|
58
|
-
? Rest extends FieldPath<T[K]>
|
|
59
|
-
? FieldPathValue<T[K], Rest>
|
|
60
|
-
: never
|
|
61
|
-
: never
|
|
62
|
-
// 如果路径字符串 P 是顶层键
|
|
63
|
-
: P extends keyof T
|
|
64
|
-
? T[P]
|
|
65
|
-
: never;
|
|
66
|
-
|
|
67
41
|
export type ScrollToErrorOptions<K> = {
|
|
68
42
|
field?: K;
|
|
69
43
|
index?: number;
|
|
70
44
|
scrollOpts?: ScrollIntoViewOptions
|
|
71
45
|
}
|
|
72
46
|
|
|
47
|
+
// 支持 array[index] 和 array.index 两种形式
|
|
48
|
+
type ArrayIndexPath<K extends string | number, U> =
|
|
49
|
+
| `${K}[${number}]` // 支持 array[index]
|
|
50
|
+
| `${K}[${number}].${FieldPath<U>}` // 支持 array[index].child
|
|
51
|
+
| `${K}.${number}` // 支持 array.index
|
|
52
|
+
| `${K}.${number}.${FieldPath<U>}`; // 支持 array.index.child
|
|
53
|
+
|
|
54
|
+
// FieldPath 类型定义,支持对象和数组字段路径
|
|
55
|
+
// export type FieldPath<T> = T extends Array<infer U>
|
|
56
|
+
// ? | `${number}` // 如果是数组,支持数字索引(如 `[0]`)
|
|
57
|
+
// | `${number}.${FieldPath<U>}` // 支持数组嵌套路径(如 `[0].field`)
|
|
58
|
+
// : T extends object
|
|
59
|
+
// ? {
|
|
60
|
+
// [K in keyof T]: K extends string
|
|
61
|
+
// ? T[K] extends Array<infer U> | object
|
|
62
|
+
// ? | `${K}`
|
|
63
|
+
// | `${K}.${FieldPath<T[K]>}`
|
|
64
|
+
// | ArrayIndexPath<K, U>
|
|
65
|
+
// : `${K}` // 只允许键路径
|
|
66
|
+
// : never;
|
|
67
|
+
// }[keyof T]
|
|
68
|
+
// : never;
|
|
69
|
+
|
|
70
|
+
// FieldPath 类型定义,支持对象和数组字段路径
|
|
71
|
+
export type FieldPath<T> = T extends Array<infer U>
|
|
72
|
+
? `${number}` | `${number}.${FieldPath<Exclude<U, undefined>>}`
|
|
73
|
+
: T extends object ? {
|
|
74
|
+
[K in keyof T]: K extends string
|
|
75
|
+
? Exclude<T[K], undefined> extends Date
|
|
76
|
+
? `${K}`
|
|
77
|
+
: T[K] extends Array<infer U> | object | undefined
|
|
78
|
+
? `${K}` |
|
|
79
|
+
`${K}.${FieldPath<T[K]>}` |
|
|
80
|
+
ArrayIndexPath<K, U>
|
|
81
|
+
: `${K}`
|
|
82
|
+
: never;
|
|
83
|
+
}[keyof T]
|
|
84
|
+
: never;
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export type FieldPathValue<T, P extends string> =
|
|
88
|
+
ArrayFieldPathValue<T, P> |
|
|
89
|
+
(P extends `${infer K}.${infer Rest}`
|
|
90
|
+
? K extends keyof T
|
|
91
|
+
? FieldPathValue<Exclude<T[K], undefined>, Rest> // 添加 undefined过滤,避免用户 tsconfig strictNullChecks 为 true 时,无法正确推断
|
|
92
|
+
: never
|
|
93
|
+
: P extends keyof T
|
|
94
|
+
? T[P]
|
|
95
|
+
: never);
|
|
96
|
+
|
|
97
|
+
type ArrayFieldPathValue<T, P extends string> =
|
|
98
|
+
P extends `${infer K}[${infer I}]${infer Rest}`
|
|
99
|
+
? K extends keyof T
|
|
100
|
+
? T[K] extends Array<infer U>
|
|
101
|
+
? I extends `${number}`
|
|
102
|
+
? Rest extends ''
|
|
103
|
+
? U // 索引路径
|
|
104
|
+
: Rest extends `.${infer RestPath}`
|
|
105
|
+
? FieldPathValue<U, RestPath> // 嵌套路径
|
|
106
|
+
: never
|
|
107
|
+
: never
|
|
108
|
+
: never
|
|
109
|
+
: never
|
|
110
|
+
: never;
|
|
111
|
+
|
|
112
|
+
// FieldPathValue 类型定义,支持从路径字符串中推导数组和对象的值
|
|
113
|
+
// export type FieldPathValue<T, P extends string> =
|
|
114
|
+
// ArrayFieldPathValue<T, P> // 处理数组路径
|
|
115
|
+
// | (P extends `${infer K}.${infer Rest}`
|
|
116
|
+
// ? K extends keyof T
|
|
117
|
+
// ? FieldPathValue<Exclude<T[K], undefined>, Rest> // 添加 undefined过滤,避免用户 tsconfig strictNullChecks 为 true 时,无法正确推断
|
|
118
|
+
// : never
|
|
119
|
+
// : P extends keyof T
|
|
120
|
+
// ? T[P]
|
|
121
|
+
// : never);
|
|
122
|
+
|
|
73
123
|
// use object replace Record<string, any>, fix issue 933
|
|
74
|
-
export interface BaseFormApi<
|
|
124
|
+
export interface BaseFormApi<FormValuesType extends object = any> {
|
|
75
125
|
/** get value of field */
|
|
76
|
-
getValue: <
|
|
126
|
+
getValue: <F extends FieldPath<FormValuesType>>(field?: F) => FieldPathValue<FormValuesType, F>;
|
|
77
127
|
/** set value of field */
|
|
78
|
-
setValue: <
|
|
128
|
+
setValue: <F extends FieldPath<FormValuesType>>(field: F, newFieldValue: any) => void;
|
|
79
129
|
/** get error of field */
|
|
80
|
-
getError: <
|
|
130
|
+
getError: <F extends FieldPath<FormValuesType>>(field: F) => any;
|
|
81
131
|
/** set error of field */
|
|
82
|
-
setError: <
|
|
132
|
+
setError: <F extends FieldPath<FormValuesType>>(field: F, fieldError: any) => void;
|
|
83
133
|
/** get touched of field */
|
|
84
|
-
getTouched: <
|
|
134
|
+
getTouched: <F extends FieldPath<FormValuesType>>(field: F) => boolean;
|
|
85
135
|
/** set touch of field */
|
|
86
|
-
setTouched: <
|
|
136
|
+
setTouched: <F extends FieldPath<FormValuesType>>(field: F, fieldTouch: boolean) => void;
|
|
87
137
|
/** judge field exist */
|
|
88
|
-
getFieldExist: <
|
|
138
|
+
getFieldExist: <F extends FieldPath<FormValuesType>>(field: F) => boolean;
|
|
89
139
|
/** get formState of form */
|
|
90
|
-
getFormState: () => FormState<
|
|
140
|
+
getFormState: () => FormState<FormValuesType extends object ? FormValuesType : object>;
|
|
91
141
|
/** get formProps of form */
|
|
92
142
|
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
93
143
|
/** submit form manual */
|
|
@@ -95,14 +145,14 @@ export interface BaseFormApi<T extends object = any> {
|
|
|
95
145
|
/** reset form manual */
|
|
96
146
|
reset: (fields?: Array<string>) => void;
|
|
97
147
|
/** trigger validate manual */
|
|
98
|
-
validate: <K extends keyof
|
|
99
|
-
getInitValue: <
|
|
148
|
+
validate: <K extends keyof FormValuesType, Params extends Array<K>, V extends Params[number]>(fields?: Params) => Promise<{ [R in V]: [R] }>;
|
|
149
|
+
getInitValue: <F extends FieldPath<FormValuesType>>(field: F) => any;
|
|
100
150
|
getInitValues: () => any;
|
|
101
|
-
getValues: () =>
|
|
151
|
+
getValues: () => FormValuesType;
|
|
102
152
|
/** set value of multiple fields */
|
|
103
|
-
setValues: (fieldsValue: Partial<
|
|
104
|
-
scrollToField: <
|
|
105
|
-
scrollToError: <
|
|
153
|
+
setValues: (fieldsValue: Partial<FormValuesType>, config?: setValuesConfig) => void;
|
|
154
|
+
scrollToField: <F extends FieldPath<FormValuesType>>(field: F, scrollConfig?: ScrollIntoViewOptions) => void;
|
|
155
|
+
scrollToError: <F extends FieldPath<FormValuesType>>(config?: ScrollToErrorOptions<F>) => void
|
|
106
156
|
}
|
|
107
157
|
|
|
108
158
|
export interface CallOpts {
|
|
@@ -139,7 +189,6 @@ export interface InternalFieldApi {
|
|
|
139
189
|
reset: () => void;
|
|
140
190
|
validate: (val: any, opts: CallOpts) => Promise<unknown>
|
|
141
191
|
}
|
|
142
|
-
|
|
143
192
|
export interface FieldStaff {
|
|
144
193
|
field: string;
|
|
145
194
|
fieldApi: InternalFieldApi;
|
package/jsonViewer/foundation.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import { JsonViewer, JsonViewerOptions } from '@douyinfe/semi-json-viewer-core';
|
|
3
|
-
import BaseFoundation, { DefaultAdapter
|
|
2
|
+
import { JsonViewer, JsonViewerOptions, CustomRenderRule } from '@douyinfe/semi-json-viewer-core';
|
|
3
|
+
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
4
4
|
|
|
5
|
-
export type { JsonViewerOptions };
|
|
5
|
+
export type { JsonViewerOptions, CustomRenderRule };
|
|
6
6
|
export interface JsonViewerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
7
7
|
getEditorRef: () => HTMLElement;
|
|
8
8
|
getSearchRef: () => HTMLInputElement;
|
|
9
9
|
notifyChange: (value: string) => void;
|
|
10
10
|
notifyHover: (value: string, el: HTMLElement) => HTMLElement | undefined;
|
|
11
11
|
setSearchOptions: (key: string) => void;
|
|
12
|
-
showSearchBar: () => void
|
|
12
|
+
showSearchBar: () => void;
|
|
13
|
+
notifyCustomRender: (customRenderMap: Map<HTMLElement, any>) => void
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
@@ -23,6 +24,9 @@ class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
23
24
|
const props = this.getProps();
|
|
24
25
|
const editorRef = this._adapter.getEditorRef();
|
|
25
26
|
this.jsonViewer = new JsonViewer(editorRef, props.value, props.options);
|
|
27
|
+
this.jsonViewer.emitter.on('customRender', (e) => {
|
|
28
|
+
this._adapter.notifyCustomRender(e.customRenderMap);
|
|
29
|
+
});
|
|
26
30
|
this.jsonViewer.layout();
|
|
27
31
|
this.jsonViewer.emitter.on('contentChanged', (e) => {
|
|
28
32
|
this._adapter.notifyChange(this.jsonViewer?.getModel().getValue());
|
|
@@ -30,12 +34,7 @@ class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
30
34
|
this.search(this._adapter.getSearchRef().value);
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
|
-
|
|
34
|
-
const el = this._adapter.notifyHover(e.value, e.target);
|
|
35
|
-
if (el) {
|
|
36
|
-
this.jsonViewer.emitter.emit('renderHoverNode', { el });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
37
|
+
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
search(searchText: string) {
|
|
@@ -65,7 +65,7 @@ export declare const parseEvent: (event: EventObject) => any[];
|
|
|
65
65
|
* @returns {map}
|
|
66
66
|
* convert events array to may, use datestring as key
|
|
67
67
|
*/
|
|
68
|
-
export declare const convertEventsArrToMap: (arr: EventObject[], key:
|
|
68
|
+
export declare const convertEventsArrToMap: (arr: EventObject[], key: "start" | "date", func: (val: Date) => Date, displayValue?: Date) => Map<any, any>;
|
|
69
69
|
/**
|
|
70
70
|
* @returns {arr}
|
|
71
71
|
* filter out event that is not in the date range
|
package/lib/cjs/chat/chat.css
CHANGED
package/lib/cjs/chat/chat.scss
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
3
2
|
export interface Content {
|
|
4
3
|
type: 'text' | 'image_url' | 'file_url';
|
|
@@ -25,6 +24,11 @@ export interface Message {
|
|
|
25
24
|
status?: 'loading' | 'incomplete' | 'complete' | 'error';
|
|
26
25
|
[x: string]: any;
|
|
27
26
|
}
|
|
27
|
+
export interface EnableUploadProps {
|
|
28
|
+
pasteUpload?: boolean;
|
|
29
|
+
dragUpload?: boolean;
|
|
30
|
+
clickUpload?: boolean;
|
|
31
|
+
}
|
|
28
32
|
export interface ChatAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
29
33
|
getContainerRef: () => HTMLDivElement;
|
|
30
34
|
setWheelScroll: (flag: boolean) => void;
|
|
@@ -76,4 +80,9 @@ export default class ChatFoundation<P = Record<string, any>, S = Record<string,
|
|
|
76
80
|
handleContainerDragOver: (e: any) => void;
|
|
77
81
|
handleContainerDrop: (e: any) => void;
|
|
78
82
|
handleContainerDragLeave: (e: any) => void;
|
|
83
|
+
getUploadProps: (uploadProps?: boolean | EnableUploadProps) => {
|
|
84
|
+
dragUpload: boolean;
|
|
85
|
+
clickUpload: boolean;
|
|
86
|
+
pasteUpload: boolean;
|
|
87
|
+
};
|
|
79
88
|
}
|
|
@@ -276,6 +276,32 @@ class ChatFoundation extends _foundation.default {
|
|
|
276
276
|
this._adapter.setUploadAreaVisible(false);
|
|
277
277
|
});
|
|
278
278
|
};
|
|
279
|
+
this.getUploadProps = uploadProps => {
|
|
280
|
+
if (Object.prototype.toString.call(uploadProps) === '[object Object]') {
|
|
281
|
+
const {
|
|
282
|
+
dragUpload = true,
|
|
283
|
+
clickUpload = true,
|
|
284
|
+
pasteUpload = true
|
|
285
|
+
} = uploadProps;
|
|
286
|
+
return {
|
|
287
|
+
dragUpload: dragUpload,
|
|
288
|
+
clickUpload: clickUpload,
|
|
289
|
+
pasteUpload: pasteUpload
|
|
290
|
+
};
|
|
291
|
+
} else if (typeof uploadProps === 'boolean') {
|
|
292
|
+
return {
|
|
293
|
+
dragUpload: uploadProps,
|
|
294
|
+
clickUpload: uploadProps,
|
|
295
|
+
pasteUpload: uploadProps
|
|
296
|
+
};
|
|
297
|
+
} else {
|
|
298
|
+
return {
|
|
299
|
+
dragUpload: true,
|
|
300
|
+
clickUpload: true,
|
|
301
|
+
pasteUpload: true
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
};
|
|
279
305
|
}
|
|
280
306
|
}
|
|
281
307
|
exports.default = ChatFoundation;
|
|
@@ -96,10 +96,11 @@ class InputBoxFoundation extends _foundation.default {
|
|
|
96
96
|
var _a;
|
|
97
97
|
const items = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.items;
|
|
98
98
|
const {
|
|
99
|
-
manualUpload
|
|
99
|
+
manualUpload,
|
|
100
|
+
pasteUpload
|
|
100
101
|
} = this.getProps();
|
|
101
102
|
let files = [];
|
|
102
|
-
if (items) {
|
|
103
|
+
if (pasteUpload && items) {
|
|
103
104
|
for (const it of items) {
|
|
104
105
|
const file = it.getAsFile();
|
|
105
106
|
file && files.push(it.getAsFile());
|
|
@@ -23,6 +23,6 @@ declare class DataPartFoundation extends BaseFoundation<DataPartAdapter<DataPart
|
|
|
23
23
|
getValueByInputValue: (value: string) => string | false | HsvaColor | RgbaColor;
|
|
24
24
|
handlePickValueWithStraw: () => Promise<void>;
|
|
25
25
|
handleInputValueChange: (value: string) => void;
|
|
26
|
-
handleFormatChange: (format: DataPartBaseState[
|
|
26
|
+
handleFormatChange: (format: DataPartBaseState["format"]) => void;
|
|
27
27
|
}
|
|
28
28
|
export default DataPartFoundation;
|
|
@@ -36,7 +36,7 @@ declare class ColorPickerFoundation extends BaseFoundation<ColorPickerAdapter<Co
|
|
|
36
36
|
handleChangeH: (currentColor: ColorValue, newH: number) => void;
|
|
37
37
|
handleChangeA: (currentColor: ColorValue, newAlpha: number) => void;
|
|
38
38
|
getCurrentColor: () => any;
|
|
39
|
-
handleChange: (color: HsvaColor | RgbaColor | string, format:
|
|
39
|
+
handleChange: (color: HsvaColor | RgbaColor | string, format: "hex" | "rgba" | "hsva") => void;
|
|
40
40
|
handleAlphaChangeByHandle: (newAlpha: {
|
|
41
41
|
a: number;
|
|
42
42
|
}) => void;
|
|
@@ -58,7 +58,10 @@ const strings = exports.strings = Object.assign({
|
|
|
58
58
|
}, formatToken);
|
|
59
59
|
const numbers = exports.numbers = {
|
|
60
60
|
WEEK_START_ON: 0,
|
|
61
|
+
// Take the day of the week as the first day of the week, 0 for Sunday, 1 for Monday, and so on
|
|
61
62
|
WEEK_HEIGHT: 36,
|
|
63
|
+
// Date per line height 36px
|
|
62
64
|
SPACING: _constants2.numbers.SPACING,
|
|
65
|
+
// Floating distance trigger interval
|
|
63
66
|
SPACING_INSET_INPUT: 1
|
|
64
67
|
};
|
|
@@ -17,8 +17,8 @@ export interface MonthFoundationProps {
|
|
|
17
17
|
}) => boolean;
|
|
18
18
|
weeksRowNum: number;
|
|
19
19
|
onWeeksRowNumChange: (weeksRowNum: number) => void;
|
|
20
|
-
renderDate: () =>
|
|
21
|
-
renderFullDate: () =>
|
|
20
|
+
renderDate: (dayNumber: number, fullDate: string) => React.ReactNode;
|
|
21
|
+
renderFullDate: (dayNumber: number, fullDate: string, dayStatus: any) => React.ReactNode;
|
|
22
22
|
hoverDay: string;
|
|
23
23
|
startDateOffset: () => void;
|
|
24
24
|
endDateOffset: () => void;
|
|
@@ -32,10 +32,6 @@ export type MonthDayInfo = {
|
|
|
32
32
|
dayNumber: number;
|
|
33
33
|
dayNumberFull?: string;
|
|
34
34
|
fullDate: string;
|
|
35
|
-
} | {
|
|
36
|
-
dayNumber: string;
|
|
37
|
-
dayNumberFull?: string;
|
|
38
|
-
fullDate: string;
|
|
39
35
|
};
|
|
40
36
|
export interface MonthInfo {
|
|
41
37
|
weeks: Array<MonthDayInfo[]>;
|
|
@@ -63,13 +63,13 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
63
63
|
updateStateValue: (field: string, value: any, opts: CallOpts, callback?: () => void) => void;
|
|
64
64
|
updateStateError: (field: string, error: any, opts: CallOpts, callback?: () => void) => void;
|
|
65
65
|
updateStateTouched: (field: string, isTouched: boolean, opts?: CallOpts, callback?: () => void) => void;
|
|
66
|
-
getValue: (field: string, opts?: CallOpts) => any;
|
|
66
|
+
getValue: (field: string | undefined, opts?: CallOpts) => any;
|
|
67
67
|
getError: (field?: string) => any;
|
|
68
|
-
getTouched: (field?: string) => boolean | Record<string, any
|
|
68
|
+
getTouched: (field?: string) => boolean | Record<string, any> | undefined;
|
|
69
69
|
getInitValues: () => any;
|
|
70
70
|
getInitValue: (field?: string) => any;
|
|
71
|
-
getFormProps: (keys?: string
|
|
72
|
-
getField: (field: string) => FieldStaff;
|
|
71
|
+
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
72
|
+
getField: (field: string) => FieldStaff | undefined;
|
|
73
73
|
registerArrayField: (arrayFieldPath: string, val: any) => void;
|
|
74
74
|
unRegisterArrayField: (arrayField: string) => void;
|
|
75
75
|
getArrayField: (arrayField: string) => ArrayFieldStaff;
|
|
@@ -103,6 +103,6 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
103
103
|
getFieldExist(field: string): boolean;
|
|
104
104
|
_autoScroll(timeout?: boolean | number): void;
|
|
105
105
|
_getErrorFieldAndScroll(scrollOpts?: ScrollIntoViewOptions | boolean): void;
|
|
106
|
-
scrollToField(field: string, scrollOpts?: ScrollIntoViewOptions
|
|
106
|
+
scrollToField(field: string, scrollOpts?: ScrollIntoViewOptions): void;
|
|
107
107
|
scrollToError(config?: ScrollToErrorOpts): void;
|
|
108
108
|
}
|
|
@@ -33,32 +33,34 @@ export interface FormState<T extends Record<string, any> = any> {
|
|
|
33
33
|
export interface setValuesConfig {
|
|
34
34
|
isOverride: boolean;
|
|
35
35
|
}
|
|
36
|
-
export type FieldPath<T> = T extends object ? {
|
|
37
|
-
[K in keyof T]: T[K] extends object ? `${string & K}.${FieldPath<T[K]>}` | `${string & K}` : `${string & K}`;
|
|
38
|
-
}[keyof T] : never;
|
|
39
|
-
export type FieldPathValue<T, P extends FieldPath<T>> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends FieldPath<T[K]> ? FieldPathValue<T[K], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
40
36
|
export type ScrollToErrorOptions<K> = {
|
|
41
37
|
field?: K;
|
|
42
38
|
index?: number;
|
|
43
39
|
scrollOpts?: ScrollIntoViewOptions;
|
|
44
40
|
};
|
|
45
|
-
|
|
41
|
+
type ArrayIndexPath<K extends string | number, U> = `${K}[${number}]` | `${K}[${number}].${FieldPath<U>}` | `${K}.${number}` | `${K}.${number}.${FieldPath<U>}`;
|
|
42
|
+
export type FieldPath<T> = T extends Array<infer U> ? `${number}` | `${number}.${FieldPath<Exclude<U, undefined>>}` : T extends object ? {
|
|
43
|
+
[K in keyof T]: K extends string ? Exclude<T[K], undefined> extends Date ? `${K}` : T[K] extends Array<infer U> | object | undefined ? `${K}` | `${K}.${FieldPath<T[K]>}` | ArrayIndexPath<K, U> : `${K}` : never;
|
|
44
|
+
}[keyof T] : never;
|
|
45
|
+
export type FieldPathValue<T, P extends string> = ArrayFieldPathValue<T, P> | (P extends `${infer K}.${infer Rest}` ? K extends keyof T ? FieldPathValue<Exclude<T[K], undefined>, Rest> : never : P extends keyof T ? T[P] : never);
|
|
46
|
+
type ArrayFieldPathValue<T, P extends string> = P extends `${infer K}[${infer I}]${infer Rest}` ? K extends keyof T ? T[K] extends Array<infer U> ? I extends `${number}` ? Rest extends '' ? U : Rest extends `.${infer RestPath}` ? FieldPathValue<U, RestPath> : never : never : never : never : never;
|
|
47
|
+
export interface BaseFormApi<FormValuesType extends object = any> {
|
|
46
48
|
/** get value of field */
|
|
47
|
-
getValue: <
|
|
49
|
+
getValue: <F extends FieldPath<FormValuesType>>(field?: F) => FieldPathValue<FormValuesType, F>;
|
|
48
50
|
/** set value of field */
|
|
49
|
-
setValue: <
|
|
51
|
+
setValue: <F extends FieldPath<FormValuesType>>(field: F, newFieldValue: any) => void;
|
|
50
52
|
/** get error of field */
|
|
51
|
-
getError: <
|
|
53
|
+
getError: <F extends FieldPath<FormValuesType>>(field: F) => any;
|
|
52
54
|
/** set error of field */
|
|
53
|
-
setError: <
|
|
55
|
+
setError: <F extends FieldPath<FormValuesType>>(field: F, fieldError: any) => void;
|
|
54
56
|
/** get touched of field */
|
|
55
|
-
getTouched: <
|
|
57
|
+
getTouched: <F extends FieldPath<FormValuesType>>(field: F) => boolean;
|
|
56
58
|
/** set touch of field */
|
|
57
|
-
setTouched: <
|
|
59
|
+
setTouched: <F extends FieldPath<FormValuesType>>(field: F, fieldTouch: boolean) => void;
|
|
58
60
|
/** judge field exist */
|
|
59
|
-
getFieldExist: <
|
|
61
|
+
getFieldExist: <F extends FieldPath<FormValuesType>>(field: F) => boolean;
|
|
60
62
|
/** get formState of form */
|
|
61
|
-
getFormState: () => FormState<
|
|
63
|
+
getFormState: () => FormState<FormValuesType extends object ? FormValuesType : object>;
|
|
62
64
|
/** get formProps of form */
|
|
63
65
|
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
64
66
|
/** submit form manual */
|
|
@@ -66,16 +68,16 @@ export interface BaseFormApi<T extends object = any> {
|
|
|
66
68
|
/** reset form manual */
|
|
67
69
|
reset: (fields?: Array<string>) => void;
|
|
68
70
|
/** trigger validate manual */
|
|
69
|
-
validate: <K extends keyof
|
|
70
|
-
[R in V]:
|
|
71
|
+
validate: <K extends keyof FormValuesType, Params extends Array<K>, V extends Params[number]>(fields?: Params) => Promise<{
|
|
72
|
+
[R in V]: [R];
|
|
71
73
|
}>;
|
|
72
|
-
getInitValue: <
|
|
74
|
+
getInitValue: <F extends FieldPath<FormValuesType>>(field: F) => any;
|
|
73
75
|
getInitValues: () => any;
|
|
74
|
-
getValues: () =>
|
|
76
|
+
getValues: () => FormValuesType;
|
|
75
77
|
/** set value of multiple fields */
|
|
76
|
-
setValues: (fieldsValue: Partial<
|
|
77
|
-
scrollToField: <
|
|
78
|
-
scrollToError: <
|
|
78
|
+
setValues: (fieldsValue: Partial<FormValuesType>, config?: setValuesConfig) => void;
|
|
79
|
+
scrollToField: <F extends FieldPath<FormValuesType>>(field: F, scrollConfig?: ScrollIntoViewOptions) => void;
|
|
80
|
+
scrollToError: <F extends FieldPath<FormValuesType>>(config?: ScrollToErrorOptions<F>) => void;
|
|
79
81
|
}
|
|
80
82
|
export interface CallOpts {
|
|
81
83
|
[x: string]: any;
|
|
@@ -136,3 +138,4 @@ export interface FormUpdaterContextType {
|
|
|
136
138
|
getArrayField: (arrayField: string) => ArrayFieldStaff;
|
|
137
139
|
updateArrayField: (arrayField: string, updateValue: any) => void;
|
|
138
140
|
}
|
|
141
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
3
2
|
export type RatioType = "adaptation" | "realSize";
|
|
4
3
|
export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { JsonViewer, JsonViewerOptions } from '@douyinfe/semi-json-viewer-core';
|
|
1
|
+
import { JsonViewer, JsonViewerOptions, CustomRenderRule } from '@douyinfe/semi-json-viewer-core';
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
|
-
export type { JsonViewerOptions };
|
|
3
|
+
export type { JsonViewerOptions, CustomRenderRule };
|
|
4
4
|
export interface JsonViewerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
5
5
|
getEditorRef: () => HTMLElement;
|
|
6
6
|
getSearchRef: () => HTMLInputElement;
|
|
@@ -8,6 +8,7 @@ export interface JsonViewerAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
8
8
|
notifyHover: (value: string, el: HTMLElement) => HTMLElement | undefined;
|
|
9
9
|
setSearchOptions: (key: string) => void;
|
|
10
10
|
showSearchBar: () => void;
|
|
11
|
+
notifyCustomRender: (customRenderMap: Map<HTMLElement, any>) => void;
|
|
11
12
|
}
|
|
12
13
|
declare class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
13
14
|
constructor(adapter: JsonViewerAdapter);
|
|
@@ -16,6 +16,9 @@ class JsonViewerFoundation extends _foundation.default {
|
|
|
16
16
|
const props = this.getProps();
|
|
17
17
|
const editorRef = this._adapter.getEditorRef();
|
|
18
18
|
this.jsonViewer = new _semiJsonViewerCore.JsonViewer(editorRef, props.value, props.options);
|
|
19
|
+
this.jsonViewer.emitter.on('customRender', e => {
|
|
20
|
+
this._adapter.notifyCustomRender(e.customRenderMap);
|
|
21
|
+
});
|
|
19
22
|
this.jsonViewer.layout();
|
|
20
23
|
this.jsonViewer.emitter.on('contentChanged', e => {
|
|
21
24
|
var _a;
|
|
@@ -24,14 +27,6 @@ class JsonViewerFoundation extends _foundation.default {
|
|
|
24
27
|
this.search(this._adapter.getSearchRef().value);
|
|
25
28
|
}
|
|
26
29
|
});
|
|
27
|
-
this.jsonViewer.emitter.on('hoverNode', e => {
|
|
28
|
-
const el = this._adapter.notifyHover(e.value, e.target);
|
|
29
|
-
if (el) {
|
|
30
|
-
this.jsonViewer.emitter.emit('renderHoverNode', {
|
|
31
|
-
el
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
30
|
}
|
|
36
31
|
search(searchText) {
|
|
37
32
|
var _a;
|