@enableai-base/grid-layout 1.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.
- package/dist/grid-layout.cjs.js +3645 -0
- package/dist/grid-layout.cjs.prod.js +3645 -0
- package/dist/grid-layout.css +667 -0
- package/dist/grid-layout.d.ts +410 -0
- package/dist/grid-layout.esm-bundler.mjs +1772 -0
- package/index.js +7 -0
- package/index.node.js +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UploadFunction, FileInfo, LinkEditorProps, SelectProps } from '@enableai-base/ui';
|
|
3
|
+
import ReactGridLayout, { Layout } from 'react-grid-layout';
|
|
4
|
+
export { Layout } from 'react-grid-layout';
|
|
5
|
+
import React$1, { FC as FC$1, ReactNode, CSSProperties, MouseEventHandler, InputHTMLAttributes, SetStateAction, ChangeEvent } from 'react';
|
|
6
|
+
import { MenuProps, FormInstance, DrawerProps, InputProps } from 'antd';
|
|
7
|
+
import { MenuInfo, FeatureValues, ColumnDefine, DateFormatType, NumberFormatType, FilterColumnData, ToolConfig, TableConfig } from '@enableai-base/core';
|
|
8
|
+
import { FileInfo as FileInfo$1 } from 'packages/ui/src/upload-list/type';
|
|
9
|
+
import { Dayjs } from 'dayjs';
|
|
10
|
+
import { UploadListProps } from 'antd/es/upload';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ObjectURLManager 类用于创建并管理对象 URL。
|
|
14
|
+
* - 可以为 Blob 或 MediaSource 创建对象 URL并跟踪生成的 URL。
|
|
15
|
+
* - 支持批量撤销已创建的对象 URL。
|
|
16
|
+
*/
|
|
17
|
+
export declare class ObjectURLManager {
|
|
18
|
+
private store;
|
|
19
|
+
/**
|
|
20
|
+
* 为指定的 Blob 或 MediaSource 创建对象 URL 并存储。
|
|
21
|
+
*
|
|
22
|
+
* @param {Blob | MediaSource} obj - 需要创建对象 URL 的数据对象。
|
|
23
|
+
* @returns {string} 创建的对象 URL。
|
|
24
|
+
*/
|
|
25
|
+
create(obj: Blob | MediaSource): string;
|
|
26
|
+
/**
|
|
27
|
+
* 撤销所有已创建的对象 URL,释放内存。
|
|
28
|
+
*/
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type AttachmentPreviewProps = {
|
|
33
|
+
/**
|
|
34
|
+
* 资源路径,后端存储的S3路径 /path/to/s3
|
|
35
|
+
*/
|
|
36
|
+
path: string;
|
|
37
|
+
s3PathParser: (path: string) => Promise<string>;
|
|
38
|
+
};
|
|
39
|
+
export declare const AttachmentPreview: FC<AttachmentPreviewProps>;
|
|
40
|
+
|
|
41
|
+
export type AttachmentEditorProps = {
|
|
42
|
+
value?: {
|
|
43
|
+
name: string;
|
|
44
|
+
path: string;
|
|
45
|
+
}[];
|
|
46
|
+
onChange?: (value: Required<AttachmentEditorProps>['value']) => void;
|
|
47
|
+
s3PathParser: (path: string) => Promise<string>;
|
|
48
|
+
uploadFunction: UploadFunction;
|
|
49
|
+
onPreview?: (file: FileInfo) => void;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare const AttachmentEditor: FC<AttachmentEditorProps>;
|
|
53
|
+
|
|
54
|
+
export type DashboardItemStore = Layout[];
|
|
55
|
+
export type DashboardProps = {
|
|
56
|
+
dashboardData?: DashboardItemStore;
|
|
57
|
+
children?: ReactNode;
|
|
58
|
+
cols?: number;
|
|
59
|
+
gapX?: number;
|
|
60
|
+
gapY?: number;
|
|
61
|
+
rowHeight?: number;
|
|
62
|
+
onLayoutChange?: (layout: Layout[]) => void;
|
|
63
|
+
mode?: 'editable' | 'view';
|
|
64
|
+
onDrop?: ReactGridLayout.CoreProps['onDrop'];
|
|
65
|
+
droppingItem?: ReactGridLayout.CoreProps['droppingItem'];
|
|
66
|
+
};
|
|
67
|
+
export declare const Dashboard: FC$1<DashboardProps>;
|
|
68
|
+
|
|
69
|
+
type LayoutItem = {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
w: number;
|
|
73
|
+
h: number;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* 自动计算一个新 item 可以放置的位置
|
|
77
|
+
* @param layout 当前布局项数组
|
|
78
|
+
* @param newW 新组件宽度
|
|
79
|
+
* @param newH 新组件高度
|
|
80
|
+
* @param cols 网格总列数(默认12)
|
|
81
|
+
*/
|
|
82
|
+
export declare function findAvailablePosition(layout: LayoutItem[], newW: number, newH: number, cols?: number): {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* 自动计算生成一个虚线框的Base64图片
|
|
88
|
+
* @param width 当前布局宽度
|
|
89
|
+
* @param height 当前布局高度
|
|
90
|
+
* @param x 虚线结束点x
|
|
91
|
+
* @param y 虚线结束点y
|
|
92
|
+
* @param padding 虚线绘制的padding
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateCrossDashedBase64(width: number, height: number, x: number, y: number, padding?: number): string | undefined;
|
|
95
|
+
|
|
96
|
+
type DashboardItemProps = {
|
|
97
|
+
id: string;
|
|
98
|
+
title?: string | ReactNode;
|
|
99
|
+
isActive?: boolean;
|
|
100
|
+
menuItems?: MenuProps['items'];
|
|
101
|
+
children?: ReactNode;
|
|
102
|
+
className?: string;
|
|
103
|
+
style?: CSSProperties;
|
|
104
|
+
mode?: 'editable' | 'view';
|
|
105
|
+
onMouseDown?: MouseEventHandler<HTMLElement>;
|
|
106
|
+
onMouseUp?: MouseEventHandler<HTMLElement>;
|
|
107
|
+
onSelect?: (e: React$1.MouseEvent<HTMLElement>, selectedId: string) => void;
|
|
108
|
+
onMenuClick?: (info: MenuInfo, selectedId: string) => void;
|
|
109
|
+
};
|
|
110
|
+
declare const _default: React$1.ForwardRefExoticComponent<DashboardItemProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
111
|
+
|
|
112
|
+
export type DetailsDrawerProps = {
|
|
113
|
+
isOpen?: boolean;
|
|
114
|
+
width?: number | string;
|
|
115
|
+
placement?: 'left' | 'right';
|
|
116
|
+
className?: string;
|
|
117
|
+
form?: FormInstance<FeatureValues>;
|
|
118
|
+
initialValues: FeatureValues;
|
|
119
|
+
onChange: (changed: FeatureValues) => void;
|
|
120
|
+
onPreview?: (value: FileInfo$1) => void;
|
|
121
|
+
columnsData: ColumnDefine[];
|
|
122
|
+
historyNode: ReactNode;
|
|
123
|
+
defaultActiveKey?: string;
|
|
124
|
+
onClick?: (e: React.MouseEvent, columnId: string) => void;
|
|
125
|
+
onClose: () => void;
|
|
126
|
+
uploadFunction: UploadFunction;
|
|
127
|
+
} & DrawerProps;
|
|
128
|
+
export declare const DetailsDrawer: FC<DetailsDrawerProps>;
|
|
129
|
+
|
|
130
|
+
export declare const useDetailsDrawerContext: () => {
|
|
131
|
+
uploadFunction: UploadFunction;
|
|
132
|
+
columnsData: ColumnDefine[];
|
|
133
|
+
onClick: ((e: React.MouseEvent, columnId: string) => void) | undefined;
|
|
134
|
+
onPreview: ((value: FileInfo$1) => void) | undefined;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
type DrawerFormProps = {
|
|
138
|
+
form?: FormInstance<FeatureValues>;
|
|
139
|
+
initialValues: FeatureValues;
|
|
140
|
+
columnsData: ColumnDefine[];
|
|
141
|
+
onChange: (values: FeatureValues) => void;
|
|
142
|
+
loading?: boolean;
|
|
143
|
+
};
|
|
144
|
+
export declare const DrawerForm: FC<DrawerFormProps>;
|
|
145
|
+
|
|
146
|
+
type DrawerTitleProps = {
|
|
147
|
+
onClose: () => void;
|
|
148
|
+
isLast?: boolean;
|
|
149
|
+
isNext?: boolean;
|
|
150
|
+
onLastClick?: () => void;
|
|
151
|
+
onNextClick?: () => void;
|
|
152
|
+
};
|
|
153
|
+
export declare const DrawerTitle: FC<DrawerTitleProps>;
|
|
154
|
+
|
|
155
|
+
type FeatureRowFieldsProps = {
|
|
156
|
+
currentColumn: ColumnDefine;
|
|
157
|
+
};
|
|
158
|
+
export declare const FeatureRowFields: FC<FeatureRowFieldsProps>;
|
|
159
|
+
|
|
160
|
+
type Person = {
|
|
161
|
+
id: string;
|
|
162
|
+
name?: string;
|
|
163
|
+
avatar?: string;
|
|
164
|
+
role?: string;
|
|
165
|
+
mobile?: string;
|
|
166
|
+
status?: string;
|
|
167
|
+
};
|
|
168
|
+
type FormAvatarProps = {
|
|
169
|
+
value?: Person[];
|
|
170
|
+
request?: (id: string) => Promise<any>;
|
|
171
|
+
};
|
|
172
|
+
export declare const FormAvatar: FC<FormAvatarProps>;
|
|
173
|
+
|
|
174
|
+
export type ProFormDateTimeFormatProps = {
|
|
175
|
+
value?: Dayjs;
|
|
176
|
+
onChange?: (value?: string) => void;
|
|
177
|
+
format?: DateFormatType;
|
|
178
|
+
placeholder?: string;
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
};
|
|
181
|
+
export declare const FormDateTimePicker: React.FC<ProFormDateTimeFormatProps>;
|
|
182
|
+
|
|
183
|
+
type ProFormNumberFormatProps = {
|
|
184
|
+
value?: number | string;
|
|
185
|
+
onChange?: (value?: number) => void;
|
|
186
|
+
format?: NumberFormatType;
|
|
187
|
+
placeholder?: string;
|
|
188
|
+
disabled?: boolean;
|
|
189
|
+
};
|
|
190
|
+
export declare const FormInputNumber: React.FC<ProFormNumberFormatProps>;
|
|
191
|
+
|
|
192
|
+
export type JsonEditorProps = {
|
|
193
|
+
value: string;
|
|
194
|
+
dark: boolean;
|
|
195
|
+
disabled?: boolean;
|
|
196
|
+
onChange?: (value?: string) => void;
|
|
197
|
+
};
|
|
198
|
+
export declare const JsonEditor: FC<JsonEditorProps>;
|
|
199
|
+
|
|
200
|
+
export declare const FormJsonEditor: FC<JsonEditorProps>;
|
|
201
|
+
|
|
202
|
+
export declare const FormLinkEdit: FC<LinkEditorProps>;
|
|
203
|
+
|
|
204
|
+
export declare const FormMultiSelect: FC<SelectProps>;
|
|
205
|
+
|
|
206
|
+
export declare const FormSingleSelect: FC<SelectProps>;
|
|
207
|
+
|
|
208
|
+
type ProFormDurationTextProps = InputProps & {
|
|
209
|
+
value?: number;
|
|
210
|
+
onChange?: (value: number) => void;
|
|
211
|
+
};
|
|
212
|
+
export declare const FormTimeLen: React.FC<ProFormDurationTextProps>;
|
|
213
|
+
|
|
214
|
+
type FormUploadProps = Omit<UploadListProps, 'uploadFunction'> & {
|
|
215
|
+
format?: 'image' | 'document' | 'video';
|
|
216
|
+
onPreview?: (file: FileInfo) => void;
|
|
217
|
+
};
|
|
218
|
+
export declare const FormUpload: FC<FormUploadProps>;
|
|
219
|
+
|
|
220
|
+
type FeatureRowFieldProps = {
|
|
221
|
+
columnId: string;
|
|
222
|
+
columnsData: ColumnDefine[];
|
|
223
|
+
};
|
|
224
|
+
export declare const FeatureRowField: FC<FeatureRowFieldProps>;
|
|
225
|
+
|
|
226
|
+
export type FeatureFieldsProps = {
|
|
227
|
+
columnId: string;
|
|
228
|
+
featureValue: FeatureValues;
|
|
229
|
+
onChange: (value: FeatureValues) => void;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
type RowLabelProps = {
|
|
233
|
+
columnData: ColumnDefine;
|
|
234
|
+
icon?: ReactNode;
|
|
235
|
+
};
|
|
236
|
+
export declare const RowLabel: FC<RowLabelProps>;
|
|
237
|
+
|
|
238
|
+
type PointData$2 = {
|
|
239
|
+
x: number;
|
|
240
|
+
y: number;
|
|
241
|
+
};
|
|
242
|
+
type SearchModalProps = {
|
|
243
|
+
offsetParent: HTMLElement | null;
|
|
244
|
+
position: PointData$2;
|
|
245
|
+
isOpen?: boolean;
|
|
246
|
+
searchValue?: InputHTMLAttributes<HTMLInputElement>['value'] | bigint;
|
|
247
|
+
isLoading?: boolean;
|
|
248
|
+
width?: number;
|
|
249
|
+
placeholder?: string;
|
|
250
|
+
searchTotal?: number;
|
|
251
|
+
suffix?: ReactNode;
|
|
252
|
+
onClose?: () => void;
|
|
253
|
+
onPositionChange: (data: SetStateAction<PointData$2>) => void;
|
|
254
|
+
onSearchChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
255
|
+
onPageChange?: (current: number) => void;
|
|
256
|
+
};
|
|
257
|
+
export declare const SearchModal: FC<SearchModalProps>;
|
|
258
|
+
|
|
259
|
+
export declare enum FilterOperator {
|
|
260
|
+
EQUAl = "equal",
|
|
261
|
+
NOT_EQUAL = "not_equal",
|
|
262
|
+
LIKE = "like",
|
|
263
|
+
NOT_LIKE = "not_like",
|
|
264
|
+
EMPTY = "empty",
|
|
265
|
+
NOT_EMPTY = "not_empty",
|
|
266
|
+
BETWEEN = "between",
|
|
267
|
+
GREATER_THAN = "greater_than",
|
|
268
|
+
GREATER_THAN_OR_EQUAL = "greater_than_or_equal",
|
|
269
|
+
LESS_THAN = "less_than",
|
|
270
|
+
LESS_THAN_OR_EQUAL = "less_than_or_equal"
|
|
271
|
+
}
|
|
272
|
+
/** 表单值类型 */
|
|
273
|
+
export type FilterItem = {
|
|
274
|
+
columnId: string;
|
|
275
|
+
operator: FilterOperator;
|
|
276
|
+
value?: string | number | string[] | [start: Dayjs | undefined, end: Dayjs | undefined];
|
|
277
|
+
};
|
|
278
|
+
export interface FilterFormValues {
|
|
279
|
+
filterType?: 'all' | 'any';
|
|
280
|
+
filters: FilterItem[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
type PointData$1 = {
|
|
284
|
+
x: number;
|
|
285
|
+
y: number;
|
|
286
|
+
};
|
|
287
|
+
export type FilterModalProps = {
|
|
288
|
+
offsetParent: HTMLElement | null;
|
|
289
|
+
initialValues?: FilterFormValues;
|
|
290
|
+
columnData: FilterColumnData[];
|
|
291
|
+
tools: ToolConfig[];
|
|
292
|
+
position: PointData$1;
|
|
293
|
+
isOpen?: boolean;
|
|
294
|
+
width?: number;
|
|
295
|
+
onClose?: () => void;
|
|
296
|
+
onPositionChange: (data: SetStateAction<PointData$1>) => void;
|
|
297
|
+
onValuesChange?: (values: FilterFormValues) => void;
|
|
298
|
+
};
|
|
299
|
+
export declare const FilterModal: FC<FilterModalProps>;
|
|
300
|
+
|
|
301
|
+
interface TableFilterFormProps {
|
|
302
|
+
tools: ToolConfig[];
|
|
303
|
+
columnData: FilterColumnData[];
|
|
304
|
+
initialValues?: FilterFormValues;
|
|
305
|
+
onValuesChange?: (values: FilterFormValues) => void;
|
|
306
|
+
}
|
|
307
|
+
export declare const TableFilterForm: FC<TableFilterFormProps>;
|
|
308
|
+
|
|
309
|
+
export declare enum Operator {
|
|
310
|
+
EQUAL = "equal",
|
|
311
|
+
NOT_EQUAL = "not_equal",
|
|
312
|
+
GREATER_THAN = "greater_than",
|
|
313
|
+
GREATER_THAN_OR_EQUAL = "greater_than_or_equal",
|
|
314
|
+
LESS_THAN = "less_than",
|
|
315
|
+
LESS_THAN_OR_EQUAL = "less_than_or_equal",
|
|
316
|
+
BEFORE = "before",
|
|
317
|
+
AFTER = "after",
|
|
318
|
+
LIKE = "like",
|
|
319
|
+
NOT_LIKE = "not_like",
|
|
320
|
+
EMPTY = "empty",
|
|
321
|
+
NOT_EMPTY = "not_empty"
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export declare const getDateRangeByOption: (type: string, operator: Operator) => [Dayjs | undefined, Dayjs | undefined] | undefined;
|
|
325
|
+
export declare const getDateBySpecific: (value: Dayjs, operator: Operator) => [Dayjs | undefined, Dayjs | undefined];
|
|
326
|
+
|
|
327
|
+
export type BaseFilterValueProps = {
|
|
328
|
+
form: FormInstance<any>;
|
|
329
|
+
columnId: string;
|
|
330
|
+
listIndex: number;
|
|
331
|
+
tableConfig: TableConfig;
|
|
332
|
+
columnConfig: FilterColumnData;
|
|
333
|
+
operator: string;
|
|
334
|
+
};
|
|
335
|
+
export type FilterValueProps = {
|
|
336
|
+
value: FeatureValues['value'];
|
|
337
|
+
onChange: (value: FeatureValues['value']) => void;
|
|
338
|
+
} & BaseFilterValueProps;
|
|
339
|
+
export declare const FilterValue: FC<BaseFilterValueProps>;
|
|
340
|
+
|
|
341
|
+
export declare const FilterDatePicker: FC<FilterValueProps>;
|
|
342
|
+
|
|
343
|
+
export declare const FilterDateSelect: FC<FilterValueProps>;
|
|
344
|
+
|
|
345
|
+
export declare const FilterFileSelect: FC<FilterValueProps>;
|
|
346
|
+
|
|
347
|
+
type FilterGroupProps = {
|
|
348
|
+
form: FormInstance<any>;
|
|
349
|
+
columnId: string;
|
|
350
|
+
columnData: FilterColumnData[];
|
|
351
|
+
listIndex: number;
|
|
352
|
+
tools: ToolConfig[];
|
|
353
|
+
operator: any;
|
|
354
|
+
};
|
|
355
|
+
export declare const FilterGroup: FC<FilterGroupProps>;
|
|
356
|
+
|
|
357
|
+
export declare const FilterInput: FC<FilterValueProps>;
|
|
358
|
+
|
|
359
|
+
export declare const FilterNumber: FC<FilterValueProps>;
|
|
360
|
+
|
|
361
|
+
export declare const FilterPeopleSelect: FC<FilterValueProps>;
|
|
362
|
+
|
|
363
|
+
export declare const FilterSelect: FC<FilterValueProps>;
|
|
364
|
+
|
|
365
|
+
type FilterTitleProps = {
|
|
366
|
+
filterCount: number;
|
|
367
|
+
};
|
|
368
|
+
export declare const FilterTitle: FC<FilterTitleProps>;
|
|
369
|
+
|
|
370
|
+
export type FilterTypeSelectProps = {
|
|
371
|
+
value: FeatureValues['value'];
|
|
372
|
+
onChange: (value: FeatureValues['value']) => void;
|
|
373
|
+
} & BaseFilterValueProps;
|
|
374
|
+
export declare const FilterTypeSelect: FC<FilterTypeSelectProps>;
|
|
375
|
+
|
|
376
|
+
export type DateOptionValue = 'specific' | 'today' | 'tomorrow' | 'yesterday' | 'this_week' | 'last_week' | 'this_month' | 'last_month' | 'last_7_days' | 'next_7_days' | 'last_30_days' | 'next_30_days';
|
|
377
|
+
export declare const dateValues: string[];
|
|
378
|
+
export declare function resolveDateRange(value: DateOptionValue, now?: Dayjs): [Dayjs, Dayjs] | undefined;
|
|
379
|
+
|
|
380
|
+
type PointData = {
|
|
381
|
+
x: number;
|
|
382
|
+
y: number;
|
|
383
|
+
};
|
|
384
|
+
export type MenuItems = Required<MenuProps>['items'];
|
|
385
|
+
export type TableMenuModalProps = {
|
|
386
|
+
offsetParent: HTMLElement | null;
|
|
387
|
+
position: PointData;
|
|
388
|
+
menuItems: MenuItems;
|
|
389
|
+
isOpen?: boolean;
|
|
390
|
+
width?: number;
|
|
391
|
+
onClose?: () => void;
|
|
392
|
+
onClick?: MenuProps['onClick'];
|
|
393
|
+
onPositionChange: (data: SetStateAction<PointData>) => void;
|
|
394
|
+
};
|
|
395
|
+
export declare const TableMenuModal: FC<TableMenuModalProps>;
|
|
396
|
+
|
|
397
|
+
type Position = {
|
|
398
|
+
x: number;
|
|
399
|
+
y: number;
|
|
400
|
+
};
|
|
401
|
+
type AdjustOptions = {
|
|
402
|
+
left?: boolean;
|
|
403
|
+
right?: boolean;
|
|
404
|
+
top?: boolean;
|
|
405
|
+
bottom?: boolean;
|
|
406
|
+
};
|
|
407
|
+
export declare function adjustPositionToViewport(position: Position, modalRect: DOMRect, options?: AdjustOptions): Position;
|
|
408
|
+
export declare const useModalPosition: (contentRef: React.RefObject<HTMLElement | null>, position: Position, setPosition: (position: Position) => void, adjustOptions?: AdjustOptions) => void;
|
|
409
|
+
|
|
410
|
+
export { _default as DashboardItem, };
|