iglooform 3.0.10 → 3.0.12
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/.dumi/tmp/dumi/theme/ContextWrapper.tsx +1 -1
- package/es/form/addable-section/index.d.ts +20 -0
- package/es/form/addable-section/index.js +6 -5
- package/es/form/element/index.d.ts +12 -0
- package/es/form/index.d.ts +4 -0
- package/es/form/section/index.d.ts +16 -0
- package/es/form-context.d.ts +28 -0
- package/es/free-form/addable-section/index.d.ts +19 -0
- package/es/free-form/addable-section/index.js +2 -2
- package/es/free-form/element/index.d.ts +11 -0
- package/es/free-form/index.d.ts +11 -0
- package/es/free-form/section/index.d.ts +13 -0
- package/es/modal/index.d.ts +31 -0
- package/es/types.d.ts +183 -0
- package/es/upload-photo/index.js +6 -3
- package/es/upload-photo/style/index.less +13 -0
- package/es/utils/form-utils.d.ts +77 -0
- package/es/utils/tools.d.ts +1 -1
- package/lib/form/addable-section/index.d.ts +20 -0
- package/lib/form/addable-section/index.js +6 -5
- package/lib/form/element/index.d.ts +12 -0
- package/lib/form/index.d.ts +4 -0
- package/lib/form/section/index.d.ts +16 -0
- package/lib/form-context.d.ts +28 -0
- package/lib/free-form/addable-section/index.d.ts +19 -0
- package/lib/free-form/addable-section/index.js +2 -2
- package/lib/free-form/element/index.d.ts +11 -0
- package/lib/free-form/index.d.ts +11 -0
- package/lib/free-form/section/index.d.ts +13 -0
- package/lib/modal/index.d.ts +31 -0
- package/lib/types.d.ts +183 -0
- package/lib/upload-photo/index.js +6 -3
- package/lib/upload-photo/style/index.less +13 -0
- package/lib/utils/form-utils.d.ts +77 -0
- package/lib/utils/tools.d.ts +1 -1
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export default function DumiContextWrapper() {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<SiteContext.Provider value={{
|
|
33
|
-
pkg: {"name":"iglooform","version":"3.0.
|
|
33
|
+
pkg: {"name":"iglooform","version":"3.0.12","license":"MIT"},
|
|
34
34
|
historyType: "browser",
|
|
35
35
|
entryExports,
|
|
36
36
|
demos,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface AddableSectionProps {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
config: FormItemConfig;
|
|
9
|
+
preview?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
12
|
+
max?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
initCount?: number;
|
|
15
|
+
addButtonText?: string;
|
|
16
|
+
addButtonIcon?: ReactNode;
|
|
17
|
+
description?: string | ReactNode;
|
|
18
|
+
}
|
|
19
|
+
declare const AddableSection: FC<AddableSectionProps>;
|
|
20
|
+
export default AddableSection;
|
|
@@ -29,10 +29,11 @@ var useBreakpoint = Grid.useBreakpoint;
|
|
|
29
29
|
var AddableSection = function AddableSection(_ref) {
|
|
30
30
|
var parentName = _ref.parentName,
|
|
31
31
|
config = _ref.config,
|
|
32
|
-
|
|
32
|
+
previewPropsFromInnerConfig = _ref.preview,
|
|
33
33
|
disabled = _ref.disabled,
|
|
34
34
|
setShowStepButton = _ref.setShowStepButton;
|
|
35
|
-
var
|
|
35
|
+
var formItemPreview = config.preview,
|
|
36
|
+
_config$elements = config.elements,
|
|
36
37
|
elements = _config$elements === void 0 ? [] : _config$elements,
|
|
37
38
|
name = config.name,
|
|
38
39
|
label = config.label,
|
|
@@ -51,6 +52,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
51
52
|
addButtonText = config.addButtonText,
|
|
52
53
|
addButtonIcon = config.addButtonIcon,
|
|
53
54
|
description = config.description;
|
|
55
|
+
var preview = previewPropsFromInnerConfig || formItemPreview;
|
|
54
56
|
var _useBreakpoint = useBreakpoint(),
|
|
55
57
|
md = _useBreakpoint.md;
|
|
56
58
|
var _useContext = useContext(LocaleContext),
|
|
@@ -130,7 +132,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
130
132
|
level: !md ? 'body1' : 'h3b',
|
|
131
133
|
wrapElement: "div",
|
|
132
134
|
children: label
|
|
133
|
-
})) : /*#__PURE__*/_jsx("div", {}), groupKeys.length > min && !preview && /*#__PURE__*/_jsx(Button, {
|
|
135
|
+
})) : /*#__PURE__*/_jsx("div", {}), groupKeys.length > min && !preview && !elementProps.disabled && /*#__PURE__*/_jsx(Button, {
|
|
134
136
|
type: "link",
|
|
135
137
|
className: "igloo-addable-section-label-remove",
|
|
136
138
|
onClick: function onClick() {
|
|
@@ -203,7 +205,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
203
205
|
whiteSpace: 'pre-wrap'
|
|
204
206
|
},
|
|
205
207
|
children: description
|
|
206
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
208
|
+
}), !elementProps.disabled && /*#__PURE__*/_jsx(Button, {
|
|
207
209
|
onClick: function onClick() {
|
|
208
210
|
return dispath({
|
|
209
211
|
type: 'add',
|
|
@@ -212,7 +214,6 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
212
214
|
},
|
|
213
215
|
className: "igloo-form-addable-section-button",
|
|
214
216
|
icon: addButtonIcon,
|
|
215
|
-
disabled: elementProps.disabled,
|
|
216
217
|
children: addButtonText || "".concat(formatMessage({
|
|
217
218
|
id: 'Add'
|
|
218
219
|
}), " ").concat(label)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
+
import './style';
|
|
4
|
+
interface ElementProps {
|
|
5
|
+
config: FormItemConfig;
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Element: FC<ElementProps>;
|
|
12
|
+
export default Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface SectionProps {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
config: FormItemConfig;
|
|
9
|
+
preview?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
collapsable?: boolean;
|
|
12
|
+
defaultCollapsed?: boolean;
|
|
13
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const Section: FC<SectionProps>;
|
|
16
|
+
export default Section;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormInstance } from 'antd/es/form';
|
|
3
|
+
import { FC, FormItemName, OCRHooks } from './types';
|
|
4
|
+
declare const _default: React.Context<{
|
|
5
|
+
form?: FormInstance<any> | undefined;
|
|
6
|
+
onCancel?(): void;
|
|
7
|
+
cancelText?: string | undefined;
|
|
8
|
+
submitText?: string | undefined;
|
|
9
|
+
previewText?: string | undefined;
|
|
10
|
+
nextText?: string | undefined;
|
|
11
|
+
continueText?: string | undefined;
|
|
12
|
+
validateMessages?: Object | undefined;
|
|
13
|
+
submitting?: boolean | undefined;
|
|
14
|
+
requiredMark?: boolean | undefined;
|
|
15
|
+
showSubmitButton?: boolean | undefined;
|
|
16
|
+
getScrollContainer: () => HTMLElement | Window | null;
|
|
17
|
+
registerDependencies: (name: FormItemName | FormItemName[], updater: Function) => void;
|
|
18
|
+
handleValuesChange(changedFields: any): any;
|
|
19
|
+
uploadApi?: string | undefined;
|
|
20
|
+
selectDatasourceApi?: string | undefined;
|
|
21
|
+
getRuleValidationApi?: string | undefined;
|
|
22
|
+
customizeComponents?: {
|
|
23
|
+
[name: string]: FC<{}>;
|
|
24
|
+
} | undefined;
|
|
25
|
+
ocrHooks?: OCRHooks | undefined;
|
|
26
|
+
validationCodeExtraParams?: Record<string, any> | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface AddableSectionProps extends FormItemConfig {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
preview?: boolean;
|
|
9
|
+
disabledFromParent?: boolean;
|
|
10
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
11
|
+
max?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
initCount?: number;
|
|
14
|
+
addButtonText?: string;
|
|
15
|
+
addButtonIcon?: ReactNode;
|
|
16
|
+
description?: string | ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare const AddableSection: FC<AddableSectionProps>;
|
|
19
|
+
export default AddableSection;
|
|
@@ -242,7 +242,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
242
242
|
level: !md ? 'body1' : 'h3b',
|
|
243
243
|
wrapElement: "div",
|
|
244
244
|
children: label
|
|
245
|
-
})) : /*#__PURE__*/_jsx("div", {}), groupKeys.length > min && !preview && /*#__PURE__*/_jsx(Button, {
|
|
245
|
+
})) : /*#__PURE__*/_jsx("div", {}), groupKeys.length > min && !preview && !elementProps.disabled && /*#__PURE__*/_jsx(Button, {
|
|
246
246
|
type: "link",
|
|
247
247
|
className: "igloo-addable-section-label-remove",
|
|
248
248
|
onClick: function onClick() {
|
|
@@ -287,7 +287,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
287
287
|
whiteSpace: 'pre-wrap'
|
|
288
288
|
},
|
|
289
289
|
children: description
|
|
290
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
290
|
+
}), !elementProps.disabled && /*#__PURE__*/_jsx(Button, {
|
|
291
291
|
onClick: function onClick() {
|
|
292
292
|
return dispath({
|
|
293
293
|
type: 'add',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
+
import './style';
|
|
4
|
+
interface ElementProps extends FormItemConfig {
|
|
5
|
+
parentName?: FormItemName;
|
|
6
|
+
preview?: boolean;
|
|
7
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
8
|
+
disabledFromParent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Element: FC<ElementProps>;
|
|
11
|
+
export default Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { Form } from 'antd';
|
|
3
|
+
import { FormBasicConfig } from '../types';
|
|
4
|
+
import './style';
|
|
5
|
+
interface FreeFormProps extends Omit<FormBasicConfig, 'config'> {
|
|
6
|
+
}
|
|
7
|
+
interface FreeFormType extends FC<PropsWithChildren<FreeFormProps>> {
|
|
8
|
+
useForm: typeof Form.useForm;
|
|
9
|
+
}
|
|
10
|
+
declare const FreeForm: FreeFormType;
|
|
11
|
+
export default FreeForm;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface SectionProps extends FormItemConfig {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
preview?: boolean;
|
|
9
|
+
disabledFromParent?: boolean;
|
|
10
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Section: FC<SectionProps>;
|
|
13
|
+
export default Section;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ModalFuncProps, ModalProps } from 'antd/lib/modal';
|
|
3
|
+
import { FormBasicConfig, FormItemConfig } from '../types';
|
|
4
|
+
import './style';
|
|
5
|
+
interface FormModalProps {
|
|
6
|
+
mode?: 'form' | 'normal';
|
|
7
|
+
formConfig?: FormItemConfig;
|
|
8
|
+
formProps?: {
|
|
9
|
+
locales?: FormBasicConfig['locales'];
|
|
10
|
+
initialValues?: FormBasicConfig['initialValues'];
|
|
11
|
+
validationCodeExtraParams?: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
onOk?: (values: any, fullValue: any) => any;
|
|
14
|
+
limitHeight?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ModalFuncReturn {
|
|
17
|
+
destroy: Function;
|
|
18
|
+
update: (props: ModalProps & ModalFuncProps & FormModalProps) => any;
|
|
19
|
+
}
|
|
20
|
+
type ModalFunction = (props: ModalProps & ModalFuncProps & FormModalProps) => ModalFuncReturn;
|
|
21
|
+
interface ModalType extends FC<ModalProps & ModalFuncProps & FormModalProps> {
|
|
22
|
+
confirm: ModalFunction;
|
|
23
|
+
info: ModalFunction;
|
|
24
|
+
warning: ModalFunction;
|
|
25
|
+
error: ModalFunction;
|
|
26
|
+
success: ModalFunction;
|
|
27
|
+
noFooter: ModalFunction;
|
|
28
|
+
destroyAll: Function;
|
|
29
|
+
}
|
|
30
|
+
declare const IglooModal: ModalType;
|
|
31
|
+
export default IglooModal;
|
package/es/types.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/// <reference path="../typings.d.ts" />
|
|
2
|
+
import { FormItemProps, FormInstance } from 'antd/es/form';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { NamePath } from 'rc-field-form/lib/interface';
|
|
5
|
+
import { CheckboxOptionType } from 'antd/es/checkbox';
|
|
6
|
+
import { SelectProps } from 'antd/es/select';
|
|
7
|
+
import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
|
|
8
|
+
export { Rule } from 'rc-field-form/lib/interface';
|
|
9
|
+
export interface OCRHooks {
|
|
10
|
+
microBlink?: {
|
|
11
|
+
initResult: {
|
|
12
|
+
error?: string;
|
|
13
|
+
failed: boolean;
|
|
14
|
+
};
|
|
15
|
+
recognize: ((file: File) => Promise<BlinkIdSingleSideRecognizerResult | null>) | null;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface OCRConfig {
|
|
20
|
+
microBlink?: {
|
|
21
|
+
licenseKey: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export type FormItemName = NamePath;
|
|
25
|
+
export interface FormBasicConfig {
|
|
26
|
+
config: FormItemConfig;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: Object;
|
|
29
|
+
locales?: {
|
|
30
|
+
cancelText?: string;
|
|
31
|
+
submitText?: string;
|
|
32
|
+
previewText?: string;
|
|
33
|
+
nextText?: string;
|
|
34
|
+
continueText?: string;
|
|
35
|
+
validateMessages?: Object;
|
|
36
|
+
};
|
|
37
|
+
initialValues?: any;
|
|
38
|
+
form?: FormInstance;
|
|
39
|
+
onCancel?(): void;
|
|
40
|
+
onSubmit?(values: Object, allValues?: Object): any;
|
|
41
|
+
requiredMark?: boolean;
|
|
42
|
+
showSubmitButton?: boolean;
|
|
43
|
+
getScrollContainer?: () => HTMLElement | null;
|
|
44
|
+
onFirstModified?: () => any;
|
|
45
|
+
uploadApi?: string;
|
|
46
|
+
selectDatasourceApi?: string;
|
|
47
|
+
validationRule?: string;
|
|
48
|
+
getRuleValidationApi?: string;
|
|
49
|
+
stepDirection?: 'vertical' | 'horizontal';
|
|
50
|
+
customizeComponents?: {
|
|
51
|
+
[name: string]: FC;
|
|
52
|
+
};
|
|
53
|
+
ocr?: OCRConfig;
|
|
54
|
+
validationCodeExtraParams?: Record<string, any>;
|
|
55
|
+
}
|
|
56
|
+
export type FormItemAssert = {
|
|
57
|
+
field: NamePath;
|
|
58
|
+
value?: any;
|
|
59
|
+
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled' | 'co-some' | 'co-every' | 'some-in' | 'every-in';
|
|
60
|
+
};
|
|
61
|
+
export type FormItemCopyValue = {
|
|
62
|
+
assert: FormItemAssert;
|
|
63
|
+
copyFrom: NamePath;
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type FormItemSelectValue = {
|
|
67
|
+
assert: FormItemAssert;
|
|
68
|
+
value: any;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
};
|
|
71
|
+
export interface FormItemExtraConfig extends FormItemProps {
|
|
72
|
+
elements?: FormItemConfig[];
|
|
73
|
+
required?: boolean;
|
|
74
|
+
requiredAsserts?: FormItemAssert[];
|
|
75
|
+
extraLabel?: any;
|
|
76
|
+
xl?: number;
|
|
77
|
+
md?: number;
|
|
78
|
+
xs?: number;
|
|
79
|
+
span?: number;
|
|
80
|
+
areaCode?: number | string | (number | string)[];
|
|
81
|
+
phoneNumber?: number | string;
|
|
82
|
+
mergeRules?: boolean;
|
|
83
|
+
dependencies?: NamePath[];
|
|
84
|
+
antdDependencies?: NamePath[];
|
|
85
|
+
asserts?: FormItemAssert[];
|
|
86
|
+
shouldRender?: (form?: FormInstance) => boolean;
|
|
87
|
+
ignore?: boolean;
|
|
88
|
+
copyValue?: FormItemCopyValue;
|
|
89
|
+
selectValue?: FormItemSelectValue[];
|
|
90
|
+
disabled?: boolean | FormItemAssert | FormItemAssert[];
|
|
91
|
+
halfRow?: boolean;
|
|
92
|
+
fullRow?: boolean;
|
|
93
|
+
limit?: number;
|
|
94
|
+
hideWhenPreview?: boolean;
|
|
95
|
+
hideWhenEdit?: boolean;
|
|
96
|
+
requiredMessage?: string | ReactNode;
|
|
97
|
+
showOptional?: boolean;
|
|
98
|
+
previewFormater?(value: any, form?: FormInstance): any;
|
|
99
|
+
handleNext?(values: any): any;
|
|
100
|
+
render?(preview: boolean, form?: FormInstance, value?: any, onChange?: (params: any) => any, setShowStepButton?: IglooComponentProps['setShowStepButton']): any;
|
|
101
|
+
locales?: {
|
|
102
|
+
[key: string]: string;
|
|
103
|
+
};
|
|
104
|
+
options?: (CheckboxOptionType & {
|
|
105
|
+
extraInfo?: {
|
|
106
|
+
content: any;
|
|
107
|
+
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
108
|
+
};
|
|
109
|
+
})[] | SelectProps['options'];
|
|
110
|
+
sendOtp?: (value: any) => any;
|
|
111
|
+
dependField?: FormItemName;
|
|
112
|
+
countDownSeconds?: number;
|
|
113
|
+
getButtonDisabledState?: (form: FormInstance) => boolean;
|
|
114
|
+
getPreviousDisabledState?: (form: FormInstance) => boolean;
|
|
115
|
+
handleUpload?(file: File): PromiseLike<string>;
|
|
116
|
+
withoutForm?: boolean;
|
|
117
|
+
disableEditButton?: boolean;
|
|
118
|
+
hidePreviewDivider?: boolean;
|
|
119
|
+
valueFormater?: (value: any) => any;
|
|
120
|
+
currentStep?: number;
|
|
121
|
+
subscribedFields?: FormItemName[];
|
|
122
|
+
description?: string | React.ReactNode;
|
|
123
|
+
dateLimitationType?: 'relative' | 'absolute';
|
|
124
|
+
absoluteRangeStart?: number;
|
|
125
|
+
absoluteRangeEnd?: number;
|
|
126
|
+
relativeRangeStart?: {
|
|
127
|
+
type: 'day' | 'month' | 'year';
|
|
128
|
+
quantity: number;
|
|
129
|
+
pattern?: string;
|
|
130
|
+
dependField?: NamePath;
|
|
131
|
+
};
|
|
132
|
+
relativeRangeEnd?: {
|
|
133
|
+
type: 'day' | 'month' | 'year';
|
|
134
|
+
quantity: number;
|
|
135
|
+
pattern?: string;
|
|
136
|
+
dependField?: NamePath;
|
|
137
|
+
};
|
|
138
|
+
validationCode?: {
|
|
139
|
+
code: string;
|
|
140
|
+
errorMessage: string;
|
|
141
|
+
}[];
|
|
142
|
+
length?: number;
|
|
143
|
+
minLength?: number;
|
|
144
|
+
maxLength?: number;
|
|
145
|
+
idType?: 'KTP' | 'NIK';
|
|
146
|
+
validationRule?: string;
|
|
147
|
+
shouldRenderCode?: string;
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
}
|
|
150
|
+
export interface FormItemConfig extends FormItemExtraConfig {
|
|
151
|
+
type?: string;
|
|
152
|
+
name?: NamePath;
|
|
153
|
+
label?: string | React.ReactNode;
|
|
154
|
+
previewLabel?: string | React.ReactNode;
|
|
155
|
+
labelProps?: any;
|
|
156
|
+
contentProps?: any;
|
|
157
|
+
ocr?: {
|
|
158
|
+
vender: string;
|
|
159
|
+
outputMap: {
|
|
160
|
+
field: string[];
|
|
161
|
+
source: string[];
|
|
162
|
+
}[];
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
|
|
166
|
+
export interface FC<P = {}> extends React.FunctionComponent<P> {
|
|
167
|
+
formItemPropsHandler?: FormItemPropsHandler;
|
|
168
|
+
isPreviewSupport?: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
|
|
171
|
+
useForm: () => FormInstance;
|
|
172
|
+
}
|
|
173
|
+
export interface IglooComponentProps {
|
|
174
|
+
validateField?: (nameList?: NamePath[]) => Promise<any>;
|
|
175
|
+
containerRef?: React.RefObject<any>;
|
|
176
|
+
setFieldError?(errorMsg?: string): void;
|
|
177
|
+
setFieldValue?(value?: any): void;
|
|
178
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
179
|
+
getFormInstance?: () => FormInstance;
|
|
180
|
+
locales?: {
|
|
181
|
+
[key: string]: string;
|
|
182
|
+
};
|
|
183
|
+
}
|
package/es/upload-photo/index.js
CHANGED
|
@@ -145,7 +145,9 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
145
145
|
id = props.id,
|
|
146
146
|
validateField = props.validateField,
|
|
147
147
|
_props$capture = props.capture,
|
|
148
|
-
capture = _props$capture === void 0 ? false : _props$capture
|
|
148
|
+
capture = _props$capture === void 0 ? false : _props$capture,
|
|
149
|
+
disabled = props.disabled;
|
|
150
|
+
console.log(props, 'props');
|
|
149
151
|
var _useContext2 = useContext(LocaleContext),
|
|
150
152
|
formatMessage = _useContext2.formatMessage;
|
|
151
153
|
var _useState = useState(isMobileAgent()),
|
|
@@ -575,7 +577,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
575
577
|
});
|
|
576
578
|
};
|
|
577
579
|
return /*#__PURE__*/_jsxs("div", {
|
|
578
|
-
className: classnames(prefix, className),
|
|
580
|
+
className: classnames(prefix, className, disabled ? "".concat(prefix, "-disabled") : ''),
|
|
579
581
|
id: id,
|
|
580
582
|
ref: DomRef,
|
|
581
583
|
children: [Boolean(descriptions || samples.length) && /*#__PURE__*/_jsx("div", {
|
|
@@ -614,6 +616,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
614
616
|
})]
|
|
615
617
|
})
|
|
616
618
|
}), /*#__PURE__*/_jsx("input", {
|
|
619
|
+
disabled: disabled,
|
|
617
620
|
id: uploadId,
|
|
618
621
|
type: "file",
|
|
619
622
|
style: {
|
|
@@ -654,7 +657,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
654
657
|
type = _ref9.type,
|
|
655
658
|
uid = _ref9.uid;
|
|
656
659
|
return /*#__PURE__*/_jsx(Badge, {
|
|
657
|
-
count: getBadge(status, index, limit),
|
|
660
|
+
count: disabled ? null : getBadge(status, index, limit),
|
|
658
661
|
children: /*#__PURE__*/_jsxs("div", {
|
|
659
662
|
className: classnames((_classnames5 = {}, _defineProperty(_classnames5, "".concat(prefix, "-content-container"), true), _defineProperty(_classnames5, "".concat(prefix, "-content-error"), status === 'failed'), _classnames5)),
|
|
660
663
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -159,6 +159,19 @@
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
.igloo-upload-photo-disabled {
|
|
163
|
+
color: rgba(0, 0, 0, 0.25);
|
|
164
|
+
cursor: not-allowed;
|
|
165
|
+
|
|
166
|
+
& label {
|
|
167
|
+
cursor: not-allowed !important;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
& .igloo-icon {
|
|
171
|
+
color: rgba(0, 0, 0, 0.25) !important;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
.ant-form-item-has-error .igloo-upload-photo-content-button {
|
|
163
176
|
border-color: @error-color;
|
|
164
177
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormInstance } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemExtraConfig, FormItemName, FormItemCopyValue, FormItemSelectValue, FormItemAssert, Rule } from '../types';
|
|
4
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
5
|
+
export declare const calcNamePath: (parentName: FormItemName | undefined, name: FormItemName | undefined) => any[];
|
|
6
|
+
export declare const testAssert: (form: FormInstance, assert: FormItemAssert) => boolean;
|
|
7
|
+
export declare const calcFormItemProps: (config: FormItemConfig, extraProps: FormItemExtraConfig, form?: FormInstance, parentName?: FormItemName, validationCodeExtraParams?: Record<string, any>) => {
|
|
8
|
+
colProps: {
|
|
9
|
+
span: number;
|
|
10
|
+
xs: number;
|
|
11
|
+
sm: number;
|
|
12
|
+
md: number;
|
|
13
|
+
halfRow: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
formItemProps: {
|
|
16
|
+
name: any[];
|
|
17
|
+
className: string | undefined;
|
|
18
|
+
initialValue: any;
|
|
19
|
+
copiedValue: {
|
|
20
|
+
copied: boolean;
|
|
21
|
+
value?: undefined;
|
|
22
|
+
disabled?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
copied: boolean;
|
|
25
|
+
value: any;
|
|
26
|
+
disabled: boolean | undefined;
|
|
27
|
+
};
|
|
28
|
+
selectedValue: {
|
|
29
|
+
selected: boolean;
|
|
30
|
+
value?: undefined;
|
|
31
|
+
disabled?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
selected: boolean;
|
|
34
|
+
value: any;
|
|
35
|
+
disabled: boolean | undefined;
|
|
36
|
+
};
|
|
37
|
+
normalize: ((value: any, prevValue: any, allValues: import("rc-field-form/lib/interface").Store) => any) | undefined;
|
|
38
|
+
rules: Rule[];
|
|
39
|
+
validateTrigger: any[];
|
|
40
|
+
label: import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
getValueFromEvent: ((...args: import("rc-field-form/lib/interface").EventArgs) => any) | undefined;
|
|
42
|
+
getValueProps: ((value: any) => Record<string, unknown>) | undefined;
|
|
43
|
+
extra: false | "" | 0 | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
44
|
+
help: React.ReactNode;
|
|
45
|
+
valuePropName: string | undefined;
|
|
46
|
+
messageVariables: {
|
|
47
|
+
label: string;
|
|
48
|
+
};
|
|
49
|
+
dependencies: any[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
elementProps: {
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
display: any;
|
|
55
|
+
previewFormater: ((value: any, form?: FormInstance<any> | undefined) => any) | undefined;
|
|
56
|
+
};
|
|
57
|
+
export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[], form?: FormInstance) => boolean;
|
|
58
|
+
export declare const calcCopyValue: (copyValue?: FormItemCopyValue, form?: FormInstance) => {
|
|
59
|
+
copied: boolean;
|
|
60
|
+
value?: undefined;
|
|
61
|
+
disabled?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
copied: boolean;
|
|
64
|
+
value: any;
|
|
65
|
+
disabled: boolean | undefined;
|
|
66
|
+
};
|
|
67
|
+
export declare const calcSelectValue: (selectValue?: FormItemSelectValue[], form?: FormInstance) => {
|
|
68
|
+
selected: boolean;
|
|
69
|
+
value?: undefined;
|
|
70
|
+
disabled?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
selected: boolean;
|
|
73
|
+
value: any;
|
|
74
|
+
disabled: boolean | undefined;
|
|
75
|
+
};
|
|
76
|
+
export declare const calcShouldRender: (name: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
|
|
77
|
+
export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
|
package/es/utils/tools.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const parseFileSize: (size: number) => string;
|
|
2
|
-
export declare function classifyType(type: string): "
|
|
2
|
+
export declare function classifyType(type: string): "video" | "image" | "pdf" | "unknown";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface AddableSectionProps {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
config: FormItemConfig;
|
|
9
|
+
preview?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
12
|
+
max?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
initCount?: number;
|
|
15
|
+
addButtonText?: string;
|
|
16
|
+
addButtonIcon?: ReactNode;
|
|
17
|
+
description?: string | ReactNode;
|
|
18
|
+
}
|
|
19
|
+
declare const AddableSection: FC<AddableSectionProps>;
|
|
20
|
+
export default AddableSection;
|
|
@@ -37,10 +37,11 @@ var useBreakpoint = _antd.Grid.useBreakpoint;
|
|
|
37
37
|
var AddableSection = function AddableSection(_ref) {
|
|
38
38
|
var parentName = _ref.parentName,
|
|
39
39
|
config = _ref.config,
|
|
40
|
-
|
|
40
|
+
previewPropsFromInnerConfig = _ref.preview,
|
|
41
41
|
disabled = _ref.disabled,
|
|
42
42
|
setShowStepButton = _ref.setShowStepButton;
|
|
43
|
-
var
|
|
43
|
+
var formItemPreview = config.preview,
|
|
44
|
+
_config$elements = config.elements,
|
|
44
45
|
elements = _config$elements === void 0 ? [] : _config$elements,
|
|
45
46
|
name = config.name,
|
|
46
47
|
label = config.label,
|
|
@@ -59,6 +60,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
59
60
|
addButtonText = config.addButtonText,
|
|
60
61
|
addButtonIcon = config.addButtonIcon,
|
|
61
62
|
description = config.description;
|
|
63
|
+
var preview = previewPropsFromInnerConfig || formItemPreview;
|
|
62
64
|
var _useBreakpoint = useBreakpoint(),
|
|
63
65
|
md = _useBreakpoint.md;
|
|
64
66
|
var _useContext = (0, _react.useContext)(_locale.LocaleContext),
|
|
@@ -138,7 +140,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
138
140
|
level: !md ? 'body1' : 'h3b',
|
|
139
141
|
wrapElement: "div",
|
|
140
142
|
children: label
|
|
141
|
-
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), groupKeys.length > min && !preview && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
143
|
+
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), groupKeys.length > min && !preview && !elementProps.disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
142
144
|
type: "link",
|
|
143
145
|
className: "igloo-addable-section-label-remove",
|
|
144
146
|
onClick: function onClick() {
|
|
@@ -211,7 +213,7 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
211
213
|
whiteSpace: 'pre-wrap'
|
|
212
214
|
},
|
|
213
215
|
children: description
|
|
214
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
216
|
+
}), !elementProps.disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
215
217
|
onClick: function onClick() {
|
|
216
218
|
return dispath({
|
|
217
219
|
type: 'add',
|
|
@@ -220,7 +222,6 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
220
222
|
},
|
|
221
223
|
className: "igloo-form-addable-section-button",
|
|
222
224
|
icon: addButtonIcon,
|
|
223
|
-
disabled: elementProps.disabled,
|
|
224
225
|
children: addButtonText || "".concat(formatMessage({
|
|
225
226
|
id: 'Add'
|
|
226
227
|
}), " ").concat(label)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
+
import './style';
|
|
4
|
+
interface ElementProps {
|
|
5
|
+
config: FormItemConfig;
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Element: FC<ElementProps>;
|
|
12
|
+
export default Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface SectionProps {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
config: FormItemConfig;
|
|
9
|
+
preview?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
collapsable?: boolean;
|
|
12
|
+
defaultCollapsed?: boolean;
|
|
13
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const Section: FC<SectionProps>;
|
|
16
|
+
export default Section;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormInstance } from 'antd/es/form';
|
|
3
|
+
import { FC, FormItemName, OCRHooks } from './types';
|
|
4
|
+
declare const _default: React.Context<{
|
|
5
|
+
form?: FormInstance<any> | undefined;
|
|
6
|
+
onCancel?(): void;
|
|
7
|
+
cancelText?: string | undefined;
|
|
8
|
+
submitText?: string | undefined;
|
|
9
|
+
previewText?: string | undefined;
|
|
10
|
+
nextText?: string | undefined;
|
|
11
|
+
continueText?: string | undefined;
|
|
12
|
+
validateMessages?: Object | undefined;
|
|
13
|
+
submitting?: boolean | undefined;
|
|
14
|
+
requiredMark?: boolean | undefined;
|
|
15
|
+
showSubmitButton?: boolean | undefined;
|
|
16
|
+
getScrollContainer: () => HTMLElement | Window | null;
|
|
17
|
+
registerDependencies: (name: FormItemName | FormItemName[], updater: Function) => void;
|
|
18
|
+
handleValuesChange(changedFields: any): any;
|
|
19
|
+
uploadApi?: string | undefined;
|
|
20
|
+
selectDatasourceApi?: string | undefined;
|
|
21
|
+
getRuleValidationApi?: string | undefined;
|
|
22
|
+
customizeComponents?: {
|
|
23
|
+
[name: string]: FC<{}>;
|
|
24
|
+
} | undefined;
|
|
25
|
+
ocrHooks?: OCRHooks | undefined;
|
|
26
|
+
validationCodeExtraParams?: Record<string, any> | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface AddableSectionProps extends FormItemConfig {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
preview?: boolean;
|
|
9
|
+
disabledFromParent?: boolean;
|
|
10
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
11
|
+
max?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
initCount?: number;
|
|
14
|
+
addButtonText?: string;
|
|
15
|
+
addButtonIcon?: ReactNode;
|
|
16
|
+
description?: string | ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare const AddableSection: FC<AddableSectionProps>;
|
|
19
|
+
export default AddableSection;
|
|
@@ -249,7 +249,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
249
249
|
level: !md ? 'body1' : 'h3b',
|
|
250
250
|
wrapElement: "div",
|
|
251
251
|
children: label
|
|
252
|
-
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), groupKeys.length > min && !preview && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
252
|
+
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}), groupKeys.length > min && !preview && !elementProps.disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
253
253
|
type: "link",
|
|
254
254
|
className: "igloo-addable-section-label-remove",
|
|
255
255
|
onClick: function onClick() {
|
|
@@ -294,7 +294,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
294
294
|
whiteSpace: 'pre-wrap'
|
|
295
295
|
},
|
|
296
296
|
children: description
|
|
297
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
297
|
+
}), !elementProps.disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
298
298
|
onClick: function onClick() {
|
|
299
299
|
return dispath({
|
|
300
300
|
type: 'add',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
+
import './style';
|
|
4
|
+
interface ElementProps extends FormItemConfig {
|
|
5
|
+
parentName?: FormItemName;
|
|
6
|
+
preview?: boolean;
|
|
7
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
8
|
+
disabledFromParent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Element: FC<ElementProps>;
|
|
11
|
+
export default Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { Form } from 'antd';
|
|
3
|
+
import { FormBasicConfig } from '../types';
|
|
4
|
+
import './style';
|
|
5
|
+
interface FreeFormProps extends Omit<FormBasicConfig, 'config'> {
|
|
6
|
+
}
|
|
7
|
+
interface FreeFormType extends FC<PropsWithChildren<FreeFormProps>> {
|
|
8
|
+
useForm: typeof Form.useForm;
|
|
9
|
+
}
|
|
10
|
+
declare const FreeForm: FreeFormType;
|
|
11
|
+
export default FreeForm;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemProps } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface SectionProps extends FormItemConfig {
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
formItemProps?: FormItemProps;
|
|
8
|
+
preview?: boolean;
|
|
9
|
+
disabledFromParent?: boolean;
|
|
10
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Section: FC<SectionProps>;
|
|
13
|
+
export default Section;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ModalFuncProps, ModalProps } from 'antd/lib/modal';
|
|
3
|
+
import { FormBasicConfig, FormItemConfig } from '../types';
|
|
4
|
+
import './style';
|
|
5
|
+
interface FormModalProps {
|
|
6
|
+
mode?: 'form' | 'normal';
|
|
7
|
+
formConfig?: FormItemConfig;
|
|
8
|
+
formProps?: {
|
|
9
|
+
locales?: FormBasicConfig['locales'];
|
|
10
|
+
initialValues?: FormBasicConfig['initialValues'];
|
|
11
|
+
validationCodeExtraParams?: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
onOk?: (values: any, fullValue: any) => any;
|
|
14
|
+
limitHeight?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ModalFuncReturn {
|
|
17
|
+
destroy: Function;
|
|
18
|
+
update: (props: ModalProps & ModalFuncProps & FormModalProps) => any;
|
|
19
|
+
}
|
|
20
|
+
type ModalFunction = (props: ModalProps & ModalFuncProps & FormModalProps) => ModalFuncReturn;
|
|
21
|
+
interface ModalType extends FC<ModalProps & ModalFuncProps & FormModalProps> {
|
|
22
|
+
confirm: ModalFunction;
|
|
23
|
+
info: ModalFunction;
|
|
24
|
+
warning: ModalFunction;
|
|
25
|
+
error: ModalFunction;
|
|
26
|
+
success: ModalFunction;
|
|
27
|
+
noFooter: ModalFunction;
|
|
28
|
+
destroyAll: Function;
|
|
29
|
+
}
|
|
30
|
+
declare const IglooModal: ModalType;
|
|
31
|
+
export default IglooModal;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/// <reference path="../typings.d.ts" />
|
|
2
|
+
import { FormItemProps, FormInstance } from 'antd/es/form';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { NamePath } from 'rc-field-form/lib/interface';
|
|
5
|
+
import { CheckboxOptionType } from 'antd/es/checkbox';
|
|
6
|
+
import { SelectProps } from 'antd/es/select';
|
|
7
|
+
import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
|
|
8
|
+
export { Rule } from 'rc-field-form/lib/interface';
|
|
9
|
+
export interface OCRHooks {
|
|
10
|
+
microBlink?: {
|
|
11
|
+
initResult: {
|
|
12
|
+
error?: string;
|
|
13
|
+
failed: boolean;
|
|
14
|
+
};
|
|
15
|
+
recognize: ((file: File) => Promise<BlinkIdSingleSideRecognizerResult | null>) | null;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface OCRConfig {
|
|
20
|
+
microBlink?: {
|
|
21
|
+
licenseKey: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export type FormItemName = NamePath;
|
|
25
|
+
export interface FormBasicConfig {
|
|
26
|
+
config: FormItemConfig;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: Object;
|
|
29
|
+
locales?: {
|
|
30
|
+
cancelText?: string;
|
|
31
|
+
submitText?: string;
|
|
32
|
+
previewText?: string;
|
|
33
|
+
nextText?: string;
|
|
34
|
+
continueText?: string;
|
|
35
|
+
validateMessages?: Object;
|
|
36
|
+
};
|
|
37
|
+
initialValues?: any;
|
|
38
|
+
form?: FormInstance;
|
|
39
|
+
onCancel?(): void;
|
|
40
|
+
onSubmit?(values: Object, allValues?: Object): any;
|
|
41
|
+
requiredMark?: boolean;
|
|
42
|
+
showSubmitButton?: boolean;
|
|
43
|
+
getScrollContainer?: () => HTMLElement | null;
|
|
44
|
+
onFirstModified?: () => any;
|
|
45
|
+
uploadApi?: string;
|
|
46
|
+
selectDatasourceApi?: string;
|
|
47
|
+
validationRule?: string;
|
|
48
|
+
getRuleValidationApi?: string;
|
|
49
|
+
stepDirection?: 'vertical' | 'horizontal';
|
|
50
|
+
customizeComponents?: {
|
|
51
|
+
[name: string]: FC;
|
|
52
|
+
};
|
|
53
|
+
ocr?: OCRConfig;
|
|
54
|
+
validationCodeExtraParams?: Record<string, any>;
|
|
55
|
+
}
|
|
56
|
+
export type FormItemAssert = {
|
|
57
|
+
field: NamePath;
|
|
58
|
+
value?: any;
|
|
59
|
+
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled' | 'co-some' | 'co-every' | 'some-in' | 'every-in';
|
|
60
|
+
};
|
|
61
|
+
export type FormItemCopyValue = {
|
|
62
|
+
assert: FormItemAssert;
|
|
63
|
+
copyFrom: NamePath;
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type FormItemSelectValue = {
|
|
67
|
+
assert: FormItemAssert;
|
|
68
|
+
value: any;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
};
|
|
71
|
+
export interface FormItemExtraConfig extends FormItemProps {
|
|
72
|
+
elements?: FormItemConfig[];
|
|
73
|
+
required?: boolean;
|
|
74
|
+
requiredAsserts?: FormItemAssert[];
|
|
75
|
+
extraLabel?: any;
|
|
76
|
+
xl?: number;
|
|
77
|
+
md?: number;
|
|
78
|
+
xs?: number;
|
|
79
|
+
span?: number;
|
|
80
|
+
areaCode?: number | string | (number | string)[];
|
|
81
|
+
phoneNumber?: number | string;
|
|
82
|
+
mergeRules?: boolean;
|
|
83
|
+
dependencies?: NamePath[];
|
|
84
|
+
antdDependencies?: NamePath[];
|
|
85
|
+
asserts?: FormItemAssert[];
|
|
86
|
+
shouldRender?: (form?: FormInstance) => boolean;
|
|
87
|
+
ignore?: boolean;
|
|
88
|
+
copyValue?: FormItemCopyValue;
|
|
89
|
+
selectValue?: FormItemSelectValue[];
|
|
90
|
+
disabled?: boolean | FormItemAssert | FormItemAssert[];
|
|
91
|
+
halfRow?: boolean;
|
|
92
|
+
fullRow?: boolean;
|
|
93
|
+
limit?: number;
|
|
94
|
+
hideWhenPreview?: boolean;
|
|
95
|
+
hideWhenEdit?: boolean;
|
|
96
|
+
requiredMessage?: string | ReactNode;
|
|
97
|
+
showOptional?: boolean;
|
|
98
|
+
previewFormater?(value: any, form?: FormInstance): any;
|
|
99
|
+
handleNext?(values: any): any;
|
|
100
|
+
render?(preview: boolean, form?: FormInstance, value?: any, onChange?: (params: any) => any, setShowStepButton?: IglooComponentProps['setShowStepButton']): any;
|
|
101
|
+
locales?: {
|
|
102
|
+
[key: string]: string;
|
|
103
|
+
};
|
|
104
|
+
options?: (CheckboxOptionType & {
|
|
105
|
+
extraInfo?: {
|
|
106
|
+
content: any;
|
|
107
|
+
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
108
|
+
};
|
|
109
|
+
})[] | SelectProps['options'];
|
|
110
|
+
sendOtp?: (value: any) => any;
|
|
111
|
+
dependField?: FormItemName;
|
|
112
|
+
countDownSeconds?: number;
|
|
113
|
+
getButtonDisabledState?: (form: FormInstance) => boolean;
|
|
114
|
+
getPreviousDisabledState?: (form: FormInstance) => boolean;
|
|
115
|
+
handleUpload?(file: File): PromiseLike<string>;
|
|
116
|
+
withoutForm?: boolean;
|
|
117
|
+
disableEditButton?: boolean;
|
|
118
|
+
hidePreviewDivider?: boolean;
|
|
119
|
+
valueFormater?: (value: any) => any;
|
|
120
|
+
currentStep?: number;
|
|
121
|
+
subscribedFields?: FormItemName[];
|
|
122
|
+
description?: string | React.ReactNode;
|
|
123
|
+
dateLimitationType?: 'relative' | 'absolute';
|
|
124
|
+
absoluteRangeStart?: number;
|
|
125
|
+
absoluteRangeEnd?: number;
|
|
126
|
+
relativeRangeStart?: {
|
|
127
|
+
type: 'day' | 'month' | 'year';
|
|
128
|
+
quantity: number;
|
|
129
|
+
pattern?: string;
|
|
130
|
+
dependField?: NamePath;
|
|
131
|
+
};
|
|
132
|
+
relativeRangeEnd?: {
|
|
133
|
+
type: 'day' | 'month' | 'year';
|
|
134
|
+
quantity: number;
|
|
135
|
+
pattern?: string;
|
|
136
|
+
dependField?: NamePath;
|
|
137
|
+
};
|
|
138
|
+
validationCode?: {
|
|
139
|
+
code: string;
|
|
140
|
+
errorMessage: string;
|
|
141
|
+
}[];
|
|
142
|
+
length?: number;
|
|
143
|
+
minLength?: number;
|
|
144
|
+
maxLength?: number;
|
|
145
|
+
idType?: 'KTP' | 'NIK';
|
|
146
|
+
validationRule?: string;
|
|
147
|
+
shouldRenderCode?: string;
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
}
|
|
150
|
+
export interface FormItemConfig extends FormItemExtraConfig {
|
|
151
|
+
type?: string;
|
|
152
|
+
name?: NamePath;
|
|
153
|
+
label?: string | React.ReactNode;
|
|
154
|
+
previewLabel?: string | React.ReactNode;
|
|
155
|
+
labelProps?: any;
|
|
156
|
+
contentProps?: any;
|
|
157
|
+
ocr?: {
|
|
158
|
+
vender: string;
|
|
159
|
+
outputMap: {
|
|
160
|
+
field: string[];
|
|
161
|
+
source: string[];
|
|
162
|
+
}[];
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
|
|
166
|
+
export interface FC<P = {}> extends React.FunctionComponent<P> {
|
|
167
|
+
formItemPropsHandler?: FormItemPropsHandler;
|
|
168
|
+
isPreviewSupport?: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
|
|
171
|
+
useForm: () => FormInstance;
|
|
172
|
+
}
|
|
173
|
+
export interface IglooComponentProps {
|
|
174
|
+
validateField?: (nameList?: NamePath[]) => Promise<any>;
|
|
175
|
+
containerRef?: React.RefObject<any>;
|
|
176
|
+
setFieldError?(errorMsg?: string): void;
|
|
177
|
+
setFieldValue?(value?: any): void;
|
|
178
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
179
|
+
getFormInstance?: () => FormInstance;
|
|
180
|
+
locales?: {
|
|
181
|
+
[key: string]: string;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
@@ -149,7 +149,9 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
149
149
|
id = props.id,
|
|
150
150
|
validateField = props.validateField,
|
|
151
151
|
_props$capture = props.capture,
|
|
152
|
-
capture = _props$capture === void 0 ? false : _props$capture
|
|
152
|
+
capture = _props$capture === void 0 ? false : _props$capture,
|
|
153
|
+
disabled = props.disabled;
|
|
154
|
+
console.log(props, 'props');
|
|
153
155
|
var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
|
|
154
156
|
formatMessage = _useContext2.formatMessage;
|
|
155
157
|
var _useState = (0, _react.useState)((0, _agentDetect.isMobileAgent)()),
|
|
@@ -579,7 +581,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
579
581
|
});
|
|
580
582
|
};
|
|
581
583
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
582
|
-
className: (0, _classnames6.default)(prefix, className),
|
|
584
|
+
className: (0, _classnames6.default)(prefix, className, disabled ? "".concat(prefix, "-disabled") : ''),
|
|
583
585
|
id: id,
|
|
584
586
|
ref: DomRef,
|
|
585
587
|
children: [Boolean(descriptions || samples.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -618,6 +620,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
618
620
|
})]
|
|
619
621
|
})
|
|
620
622
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
623
|
+
disabled: disabled,
|
|
621
624
|
id: uploadId,
|
|
622
625
|
type: "file",
|
|
623
626
|
style: {
|
|
@@ -658,7 +661,7 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
658
661
|
type = _ref9.type,
|
|
659
662
|
uid = _ref9.uid;
|
|
660
663
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Badge, {
|
|
661
|
-
count: getBadge(status, index, limit),
|
|
664
|
+
count: disabled ? null : getBadge(status, index, limit),
|
|
662
665
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
663
666
|
className: (0, _classnames6.default)((_classnames5 = {}, _defineProperty(_classnames5, "".concat(prefix, "-content-container"), true), _defineProperty(_classnames5, "".concat(prefix, "-content-error"), status === 'failed'), _classnames5)),
|
|
664
667
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -159,6 +159,19 @@
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
.igloo-upload-photo-disabled {
|
|
163
|
+
color: rgba(0, 0, 0, 0.25);
|
|
164
|
+
cursor: not-allowed;
|
|
165
|
+
|
|
166
|
+
& label {
|
|
167
|
+
cursor: not-allowed !important;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
& .igloo-icon {
|
|
171
|
+
color: rgba(0, 0, 0, 0.25) !important;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
.ant-form-item-has-error .igloo-upload-photo-content-button {
|
|
163
176
|
border-color: @error-color;
|
|
164
177
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormInstance } from 'antd/es/form';
|
|
3
|
+
import { FormItemConfig, FormItemExtraConfig, FormItemName, FormItemCopyValue, FormItemSelectValue, FormItemAssert, Rule } from '../types';
|
|
4
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
5
|
+
export declare const calcNamePath: (parentName: FormItemName | undefined, name: FormItemName | undefined) => any[];
|
|
6
|
+
export declare const testAssert: (form: FormInstance, assert: FormItemAssert) => boolean;
|
|
7
|
+
export declare const calcFormItemProps: (config: FormItemConfig, extraProps: FormItemExtraConfig, form?: FormInstance, parentName?: FormItemName, validationCodeExtraParams?: Record<string, any>) => {
|
|
8
|
+
colProps: {
|
|
9
|
+
span: number;
|
|
10
|
+
xs: number;
|
|
11
|
+
sm: number;
|
|
12
|
+
md: number;
|
|
13
|
+
halfRow: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
formItemProps: {
|
|
16
|
+
name: any[];
|
|
17
|
+
className: string | undefined;
|
|
18
|
+
initialValue: any;
|
|
19
|
+
copiedValue: {
|
|
20
|
+
copied: boolean;
|
|
21
|
+
value?: undefined;
|
|
22
|
+
disabled?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
copied: boolean;
|
|
25
|
+
value: any;
|
|
26
|
+
disabled: boolean | undefined;
|
|
27
|
+
};
|
|
28
|
+
selectedValue: {
|
|
29
|
+
selected: boolean;
|
|
30
|
+
value?: undefined;
|
|
31
|
+
disabled?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
selected: boolean;
|
|
34
|
+
value: any;
|
|
35
|
+
disabled: boolean | undefined;
|
|
36
|
+
};
|
|
37
|
+
normalize: ((value: any, prevValue: any, allValues: import("rc-field-form/lib/interface").Store) => any) | undefined;
|
|
38
|
+
rules: Rule[];
|
|
39
|
+
validateTrigger: any[];
|
|
40
|
+
label: import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
getValueFromEvent: ((...args: import("rc-field-form/lib/interface").EventArgs) => any) | undefined;
|
|
42
|
+
getValueProps: ((value: any) => Record<string, unknown>) | undefined;
|
|
43
|
+
extra: false | "" | 0 | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
44
|
+
help: React.ReactNode;
|
|
45
|
+
valuePropName: string | undefined;
|
|
46
|
+
messageVariables: {
|
|
47
|
+
label: string;
|
|
48
|
+
};
|
|
49
|
+
dependencies: any[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
elementProps: {
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
display: any;
|
|
55
|
+
previewFormater: ((value: any, form?: FormInstance<any> | undefined) => any) | undefined;
|
|
56
|
+
};
|
|
57
|
+
export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[], form?: FormInstance) => boolean;
|
|
58
|
+
export declare const calcCopyValue: (copyValue?: FormItemCopyValue, form?: FormInstance) => {
|
|
59
|
+
copied: boolean;
|
|
60
|
+
value?: undefined;
|
|
61
|
+
disabled?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
copied: boolean;
|
|
64
|
+
value: any;
|
|
65
|
+
disabled: boolean | undefined;
|
|
66
|
+
};
|
|
67
|
+
export declare const calcSelectValue: (selectValue?: FormItemSelectValue[], form?: FormInstance) => {
|
|
68
|
+
selected: boolean;
|
|
69
|
+
value?: undefined;
|
|
70
|
+
disabled?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
selected: boolean;
|
|
73
|
+
value: any;
|
|
74
|
+
disabled: boolean | undefined;
|
|
75
|
+
};
|
|
76
|
+
export declare const calcShouldRender: (name: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
|
|
77
|
+
export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
|
package/lib/utils/tools.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const parseFileSize: (size: number) => string;
|
|
2
|
-
export declare function classifyType(type: string): "
|
|
2
|
+
export declare function classifyType(type: string): "video" | "image" | "pdf" | "unknown";
|