forked from shesha-io/shesha-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.tsx
More file actions
133 lines (117 loc) · 3.93 KB
/
models.tsx
File metadata and controls
133 lines (117 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { FormIdentifier, IEntityReferenceDto } from "@/index";
import { IDataColumnsProps } from "@/providers/datatableColumnsConfigurator/models";
import { Key, MutableRefObject, ReactNode } from "react";
import { GroupingItem, ISortingItem } from "@/providers/dataTable/interfaces";
import { SizeType } from "antd/lib/config-provider/SizeContext";
/**
* Converts array of strings into IDataColumnsProps array
* @param fields - array of strings
* @returns IDataColumnsProps array
*/
export function getColumns(fields: string[]): IDataColumnsProps[] {
return (fields ?? []).map((field, index) => {
return {
id: `${index}`,
columnType: 'data',
caption: '',
sortOrder: index,
isVisible: true,
itemType: 'item',
propertyName: field,
allowSorting: false,
};
});
}
export type AutocompleteDataSourceType = 'entitiesList' | 'url';
export type QueryParamFunc = (searchText: string, selected: any[]) => object;
export type FilterSelectedFunc = (value: any) => object;
export type KayValueFunc = (value: any, args: any) => string;
export type DisplayValueFunc = (value: any, args: any) => string;
export type OutcomeValueFunc = (value: any, args: any) => string | string[] | IEntityReferenceDto | IEntityReferenceDto[] | any;
export interface ISelectOption<TValue = any> {
// TODO: make generic
value: string | number;
label: string | React.ReactNode;
data: TValue;
color?: string;
icon?: string;
}
interface IQueryParamProp {
id: string;
param?: string;
value?: Key;
}
export interface IAutocompleteBaseProps {
disableRefresh?: MutableRefObject<boolean>;
uid: string;
onChange?: (value: any) => void;
onSearch?: (searchText: string) => void;
value?: any;
/** Type of entity */
entityType?: string;
/** Data source type */
dataSourceType: AutocompleteDataSourceType;
/** Data source URL (required for dataSourceType === 'url', alternative for dataSourceType === 'entitiesList') */
dataSourceUrl?: string;
/** Placeholder */
placeholder?: string;
/** Hide border */
hideBorder?: boolean;
/** A property used as label */
displayPropName?: string;
/** A property used as key/value */
keyPropName?: string;
/** Permanent filter (json logig) */
filter?: object;
/** Read only */
readOnly?: boolean;
/** Disable text search */
disableSearch?: boolean;
/** Selection mode */
mode?: 'single' | 'multiple';
/** Fields to fetch */
fields?: string[];
/** Query params, applicable only for dataSourceType === 'url' */
queryParams?: IQueryParamProp[];
/** Quickview setting */
/** Use Quickview */
quickviewEnabled?: boolean;
/** Form path */
quickviewFormPath?: FormIdentifier;
/** A property used as label, шf empty, the displayPropName field is used. */
quickviewDisplayPropertyName?: string;
/** Get Entity details Url */
quickviewGetEntityUrl?: string;
/** Quickview form width */
quickviewWidth?: number;
/** Not found content */
notFoundContent?: ReactNode;
/** Style */
style?: React.CSSProperties;
/** Filter (json logic) that used for filter selected values */
filterKeysFunc?: FilterSelectedFunc | null | undefined;
/** Function for get key (string) from value (outcome value format) */
keyValueFunc?: KayValueFunc | null | undefined;
/** Function for get label from item (received from the backend)*/
displayValueFunc?: DisplayValueFunc | null | undefined;
/** Function for get value (outcome value format) from item (received from the backend) */
outcomeValueFunc?: OutcomeValueFunc | null | undefined;
/** Sorting */
sorting?: ISortingItem[];
/** Grouping */
grouping?: GroupingItem;
/** Size */
size?: SizeType;
allowFreeText?: boolean;
allowClear?: boolean;
// not implemented
defaultValue?: any | any[];
// need to review (not used)
allowInherited?: boolean;
/**
* @deprecated
*/
typeShortAlias?: string;
}
export interface IAutocompleteProps extends Omit<IAutocompleteBaseProps, 'uid'> {
}