forked from shesha-io/shesha-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.ts
More file actions
70 lines (61 loc) · 2.15 KB
/
models.ts
File metadata and controls
70 lines (61 loc) · 2.15 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
import { SizeType } from 'antd/lib/config-provider/SizeContext';
import { LabeledValue, SelectProps } from 'antd/lib/select';
import { IReferenceListIdentifier } from '@/interfaces/referenceList';
import { CSSProperties, Key } from 'react';
import { ReferenceListItemDto } from '@/apis/referenceList';
import { IReadOnly } from '@/interfaces/readOnly';
export type IncomeValueFunc = (value: any, args: any) => string;
export type OutcomeValueFunc = (value: any, args: any) => string | string[] | any;
export type ItemFunc = (value: any, args: any) => ISelectOption<any>;
export interface IGenericRefListDropDownProps<TValue = any> extends IRefListDropDownProps<TValue> {
/**
* Get CustomLabeledValue from value
*/
getLabeledValue: (value: TValue, options: ISelectOption<TValue>[]) => CustomLabeledValue<TValue>;
/**
* Get option from an item fetched from the back-end
*/
getOptionFromFetchedItem: (fetchedItem: ReferenceListItemDto, args?: any) => ISelectOption<TValue>;
incomeValueFunc: IncomeValueFunc;
outcomeValueFunc: OutcomeValueFunc;
}
export interface IRefListDropDownProps<TValue = any> extends Omit<SelectProps<any>, 'onChange'>, IReadOnly {
/**
* Reference List identifier
*/
referenceListId: IReferenceListIdentifier;
/**
* How large should the button be?
*/
filters?: number[];
width?: number;
style?: CSSProperties;
tagStyle?: CSSProperties;
showIcon?: boolean;
solidColor?: boolean;
showItemName?: boolean;
base?: string;
value?: TValue | TValue[];
ignoredValues?: number[];
disabledValues?: number[];
size?: SizeType;
displayStyle?: 'tags' | 'text';
onChange?: (value: TValue | TValue[]) => void;
enableStyleOnReadonly?: boolean;
}
export interface IRefListDropDownOption {
children?: string;
key: string;
value?: Key;
}
export interface ISelectOption<TValue = any> {
// TODO: make generic
value: string | number;
label: string | React.ReactNode;
data: TValue;
disabled?: boolean;
color?: string;
icon?: string;
description?: string;
}
export type CustomLabeledValue<TValue = any> = LabeledValue & { data: TValue };