iglooform 3.0.10 → 3.0.11

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.
@@ -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;
@@ -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,4 @@
1
+ import { Form as FormType } from '../types';
2
+ import './style';
3
+ declare const ExportedForm: FormType;
4
+ export default ExportedForm;
@@ -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;
@@ -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
+ }
@@ -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>;
@@ -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;
@@ -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,4 @@
1
+ import { Form as FormType } from '../types';
2
+ import './style';
3
+ declare const ExportedForm: FormType;
4
+ export default ExportedForm;
@@ -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;
@@ -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
+ }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",