iglooform 3.2.3 → 3.2.5

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.
@@ -1,20 +1,20 @@
1
1
  import { useMemo, useContext } from 'react';
2
2
  import Button from "../button";
3
- import Radio, { RadioGroup, RadioGroupWithOther } from "../radio";
4
- import Input, { PhoneNumber, Amount, Email, Password, InputNumber, TextArea, InputDate, CreditCard, Otp, ExpiryDate, InputId } from "../input";
5
- import DatePicker, { IglooBuddhistDatePicker as BuddhistDatePicker, IglooRangePicker as RangePicker, IglooWeekPicker as WeekPicker, IglooMonthPicker as MonthPicker } from "../date-picker";
3
+ import Checkbox, { CheckboxGroup } from "../checkbox";
6
4
  import Confirmation from "../confirmation";
5
+ import DatePicker, { IglooBuddhistDatePicker as BuddhistDatePicker, IglooRangePicker as RangePicker, IglooWeekPicker as WeekPicker, IglooMonthPicker as MonthPicker } from "../date-picker";
6
+ import Declaration from "../declaration";
7
+ import formContext from "../form-context";
8
+ import Input, { PhoneNumber, Amount, Email, Password, InputNumber, TextArea, InputDate, CreditCard, Otp, ExpiryDate, InputId } from "../input";
9
+ import OCR from "../ocr";
10
+ import Radio, { RadioGroup, RadioGroupWithOther } from "../radio";
11
+ import SearchBox from "../search-box";
7
12
  import { AttachedSelect as Select, TimeSelect } from "../select";
8
- import Checkbox, { CheckboxGroup } from "../checkbox";
13
+ import Typography from "../typography";
9
14
  import Upload from "../upload";
10
- import Declaration from "../declaration";
11
- import Divider from "./divider";
12
15
  import UploadPhoto from "../upload-photo";
16
+ import Divider from "./divider";
13
17
  import RenderElement from "./render";
14
- import Typography from "../typography";
15
- import SearchBox from "../search-box";
16
- import formContext from "../form-context";
17
- import OCR from "../ocr";
18
18
  var elementMap = {
19
19
  Input: Input,
20
20
  PhoneNumber: PhoneNumber,
@@ -74,6 +74,6 @@ export declare const calcSelectValue: (selectValue?: FormItemSelectValue[], form
74
74
  disabled: boolean | undefined;
75
75
  };
76
76
  export declare const calcShouldRender: (name: NamePath, parentName: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
77
- export declare const calcAutomaticCalculate: (name: NamePath, parentName: NamePath, automaticCalcCode?: string, form?: FormInstance) => undefined;
77
+ export declare const automaticCalculate: (name: NamePath, parentName: NamePath, automaticCalcCode?: string, form?: FormInstance) => void;
78
78
  export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
79
79
  export declare const calcAddableSectionAssertField: (name: any[], field: FormItemAssert['field'], index: number, elements: FormItemConfig[] | React.ReactElement[]) => any;
@@ -23,7 +23,7 @@ import invariant from 'invariant';
23
23
  import Typography from "../typography";
24
24
  import FormattedMessage from "../locale/formatted-message";
25
25
  import moment from 'dayjs';
26
- import { get } from 'lodash';
26
+ import { get, isEqual } from 'lodash';
27
27
  import { jsx as _jsx } from "react/jsx-runtime";
28
28
  import { jsxs as _jsxs } from "react/jsx-runtime";
29
29
  export var calcNamePath = function calcNamePath(parentName, name) {
@@ -226,7 +226,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
226
226
  Object.keys(_objectSpread(_objectSpread({}, extraRest), rest)).forEach(function (key) {
227
227
  elementProps[key.replace('element-', '')] = rest[key];
228
228
  });
229
- elementProps.disabled = calcDisabled(disabled, form, disabledCode, name, parentName) || copiedValue.disabled || selectedValue.disabled;
229
+ elementProps.disabled = enableAutomaticCalc || calcDisabled(disabled, form, disabledCode, name, parentName) || copiedValue.disabled || selectedValue.disabled;
230
230
  if (dateLimitationType) {
231
231
  var rangeStart;
232
232
  var rangeEnd;
@@ -323,7 +323,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
323
323
  })));
324
324
  }
325
325
  if (enableAutomaticCalc) {
326
- calcAutomaticCalculate(name, parentName, automaticCalcCode, form);
326
+ automaticCalculate(name, parentName, automaticCalcCode, form);
327
327
  }
328
328
  return {
329
329
  colProps: {
@@ -530,13 +530,12 @@ export var calcShouldRender = function calcShouldRender(name, parentName) {
530
530
  }
531
531
  return true;
532
532
  };
533
- export var calcAutomaticCalculate = function calcAutomaticCalculate(name, parentName, automaticCalcCode, form) {
534
- if (!form) return undefined;
535
- if (automaticCalcCode) {
533
+ export var automaticCalculate = function automaticCalculate(name, parentName, automaticCalcCode, form) {
534
+ if (form && automaticCalcCode) {
536
535
  var calcValue = undefined;
537
- var fn = eval(automaticCalcCode);
538
- if (typeof fn === 'function') {
539
- try {
536
+ try {
537
+ var fn = eval(automaticCalcCode);
538
+ if (typeof fn === 'function') {
540
539
  var value = form.getFieldValue(name);
541
540
  var values = form.getFieldsValue(true);
542
541
  calcValue = fn(value, values, {
@@ -546,12 +545,15 @@ export var calcAutomaticCalculate = function calcAutomaticCalculate(name, parent
546
545
  name: name,
547
546
  parentName: parentName
548
547
  });
549
- } catch (_unused4) {}
548
+ }
549
+ } catch (_unused4) {}
550
+ if (form && !isEqual(form === null || form === void 0 ? void 0 : form.getFieldValue(name), calcValue)) {
551
+ form.setFields([{
552
+ name: name,
553
+ value: calcValue
554
+ }]);
555
+ form.validateFields([name]);
550
556
  }
551
- form.setFields([{
552
- name: name,
553
- value: calcValue
554
- }]);
555
557
  }
556
558
  };
557
559
  export var getRuleValidation = /*#__PURE__*/function () {
@@ -7,21 +7,21 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = require("react");
9
9
  var _button = _interopRequireDefault(require("../button"));
10
- var _radio = _interopRequireWildcard(require("../radio"));
11
- var _input = _interopRequireWildcard(require("../input"));
12
- var _datePicker = _interopRequireWildcard(require("../date-picker"));
10
+ var _checkbox = _interopRequireWildcard(require("../checkbox"));
13
11
  var _confirmation = _interopRequireDefault(require("../confirmation"));
12
+ var _datePicker = _interopRequireWildcard(require("../date-picker"));
13
+ var _declaration = _interopRequireDefault(require("../declaration"));
14
+ var _formContext = _interopRequireDefault(require("../form-context"));
15
+ var _input = _interopRequireWildcard(require("../input"));
16
+ var _ocr = _interopRequireDefault(require("../ocr"));
17
+ var _radio = _interopRequireWildcard(require("../radio"));
18
+ var _searchBox = _interopRequireDefault(require("../search-box"));
14
19
  var _select = require("../select");
15
- var _checkbox = _interopRequireWildcard(require("../checkbox"));
20
+ var _typography = _interopRequireDefault(require("../typography"));
16
21
  var _upload = _interopRequireDefault(require("../upload"));
17
- var _declaration = _interopRequireDefault(require("../declaration"));
18
- var _divider = _interopRequireDefault(require("./divider"));
19
22
  var _uploadPhoto = _interopRequireDefault(require("../upload-photo"));
23
+ var _divider = _interopRequireDefault(require("./divider"));
20
24
  var _render = _interopRequireDefault(require("./render"));
21
- var _typography = _interopRequireDefault(require("../typography"));
22
- var _searchBox = _interopRequireDefault(require("../search-box"));
23
- var _formContext = _interopRequireDefault(require("../form-context"));
24
- var _ocr = _interopRequireDefault(require("../ocr"));
25
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -74,6 +74,6 @@ export declare const calcSelectValue: (selectValue?: FormItemSelectValue[], form
74
74
  disabled: boolean | undefined;
75
75
  };
76
76
  export declare const calcShouldRender: (name: NamePath, parentName: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance) => boolean) | undefined, shouldRenderCode?: string, form?: FormInstance) => any;
77
- export declare const calcAutomaticCalculate: (name: NamePath, parentName: NamePath, automaticCalcCode?: string, form?: FormInstance) => undefined;
77
+ export declare const automaticCalculate: (name: NamePath, parentName: NamePath, automaticCalcCode?: string, form?: FormInstance) => void;
78
78
  export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
79
79
  export declare const calcAddableSectionAssertField: (name: any[], field: FormItemAssert['field'], index: number, elements: FormItemConfig[] | React.ReactElement[]) => any;
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.testAssert = exports.getRuleValidation = exports.calcShouldRender = exports.calcSelectValue = exports.calcNamePath = exports.calcFormItemProps = exports.calcDisabled = exports.calcCopyValue = exports.calcAutomaticCalculate = exports.calcAddableSectionAssertField = void 0;
7
+ exports.testAssert = exports.getRuleValidation = exports.calcShouldRender = exports.calcSelectValue = exports.calcNamePath = exports.calcFormItemProps = exports.calcDisabled = exports.calcCopyValue = exports.calcAddableSectionAssertField = exports.automaticCalculate = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _invariant = _interopRequireDefault(require("invariant"));
10
10
  var _typography = _interopRequireDefault(require("../typography"));
@@ -234,7 +234,7 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
234
234
  Object.keys(_objectSpread(_objectSpread({}, extraRest), rest)).forEach(function (key) {
235
235
  elementProps[key.replace('element-', '')] = rest[key];
236
236
  });
237
- elementProps.disabled = calcDisabled(disabled, form, disabledCode, name, parentName) || copiedValue.disabled || selectedValue.disabled;
237
+ elementProps.disabled = enableAutomaticCalc || calcDisabled(disabled, form, disabledCode, name, parentName) || copiedValue.disabled || selectedValue.disabled;
238
238
  if (dateLimitationType) {
239
239
  var rangeStart;
240
240
  var rangeEnd;
@@ -331,7 +331,7 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
331
331
  })));
332
332
  }
333
333
  if (enableAutomaticCalc) {
334
- calcAutomaticCalculate(name, parentName, automaticCalcCode, form);
334
+ automaticCalculate(name, parentName, automaticCalcCode, form);
335
335
  }
336
336
  return {
337
337
  colProps: {
@@ -543,13 +543,12 @@ var calcShouldRender = function calcShouldRender(name, parentName) {
543
543
  return true;
544
544
  };
545
545
  exports.calcShouldRender = calcShouldRender;
546
- var calcAutomaticCalculate = function calcAutomaticCalculate(name, parentName, automaticCalcCode, form) {
547
- if (!form) return undefined;
548
- if (automaticCalcCode) {
546
+ var automaticCalculate = function automaticCalculate(name, parentName, automaticCalcCode, form) {
547
+ if (form && automaticCalcCode) {
549
548
  var calcValue = undefined;
550
- var fn = eval(automaticCalcCode);
551
- if (typeof fn === 'function') {
552
- try {
549
+ try {
550
+ var fn = eval(automaticCalcCode);
551
+ if (typeof fn === 'function') {
553
552
  var value = form.getFieldValue(name);
554
553
  var values = form.getFieldsValue(true);
555
554
  calcValue = fn(value, values, {
@@ -559,15 +558,18 @@ var calcAutomaticCalculate = function calcAutomaticCalculate(name, parentName, a
559
558
  name: name,
560
559
  parentName: parentName
561
560
  });
562
- } catch (_unused4) {}
561
+ }
562
+ } catch (_unused4) {}
563
+ if (form && !(0, _lodash.isEqual)(form === null || form === void 0 ? void 0 : form.getFieldValue(name), calcValue)) {
564
+ form.setFields([{
565
+ name: name,
566
+ value: calcValue
567
+ }]);
568
+ form.validateFields([name]);
563
569
  }
564
- form.setFields([{
565
- name: name,
566
- value: calcValue
567
- }]);
568
570
  }
569
571
  };
570
- exports.calcAutomaticCalculate = calcAutomaticCalculate;
572
+ exports.automaticCalculate = automaticCalculate;
571
573
  var getRuleValidation = /*#__PURE__*/function () {
572
574
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, rule, values) {
573
575
  var lang,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",
package/es/types.d.ts DELETED
@@ -1,187 +0,0 @@
1
- /// <reference path="../typings.d.ts" />
2
- import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
3
- import { FormItemProps, FormInstance } from 'antd/es/form';
4
- import { ReactNode } from 'react';
5
- import { NamePath } from 'rc-field-form/lib/interface';
6
- import { CheckboxOptionType } from 'antd/es/checkbox';
7
- import { SelectProps } from 'antd/es/select';
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
- warningOnly?: boolean;
142
- }[];
143
- length?: number;
144
- minLength?: number;
145
- maxLength?: number;
146
- idType?: 'KTP' | 'NIK';
147
- validationRule?: string;
148
- shouldRenderCode?: string;
149
- disabledCode?: string;
150
- automaticCalcCode?: string;
151
- enableAutomaticCalc?: boolean;
152
- [key: string]: any;
153
- }
154
- export interface FormItemConfig extends FormItemExtraConfig {
155
- type?: string;
156
- name?: NamePath;
157
- label?: string | React.ReactNode;
158
- previewLabel?: string | React.ReactNode;
159
- labelProps?: any;
160
- contentProps?: any;
161
- ocr?: {
162
- vender: string;
163
- outputMap: {
164
- field: string[];
165
- source: string[];
166
- }[];
167
- };
168
- }
169
- export type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
170
- export interface FC<P = {}> extends React.FunctionComponent<P> {
171
- formItemPropsHandler?: FormItemPropsHandler;
172
- isPreviewSupport?: boolean;
173
- }
174
- export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
175
- useForm: () => FormInstance;
176
- }
177
- export interface IglooComponentProps {
178
- validateField?: (nameList?: NamePath[]) => Promise<any>;
179
- containerRef?: React.RefObject<any>;
180
- setFieldError?(errorMsg?: string): void;
181
- setFieldValue?(value?: any): void;
182
- setShowStepButton?: (showButton: boolean) => void;
183
- getFormInstance?: () => FormInstance;
184
- locales?: {
185
- [key: string]: string;
186
- };
187
- }
@@ -1,3 +0,0 @@
1
- import { IglooComponentProps } from '../types';
2
- declare const _default: (keyof IglooComponentProps)[];
3
- export default _default;
package/lib/types.d.ts DELETED
@@ -1,187 +0,0 @@
1
- /// <reference path="../typings.d.ts" />
2
- import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
3
- import { FormItemProps, FormInstance } from 'antd/es/form';
4
- import { ReactNode } from 'react';
5
- import { NamePath } from 'rc-field-form/lib/interface';
6
- import { CheckboxOptionType } from 'antd/es/checkbox';
7
- import { SelectProps } from 'antd/es/select';
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
- warningOnly?: boolean;
142
- }[];
143
- length?: number;
144
- minLength?: number;
145
- maxLength?: number;
146
- idType?: 'KTP' | 'NIK';
147
- validationRule?: string;
148
- shouldRenderCode?: string;
149
- disabledCode?: string;
150
- automaticCalcCode?: string;
151
- enableAutomaticCalc?: boolean;
152
- [key: string]: any;
153
- }
154
- export interface FormItemConfig extends FormItemExtraConfig {
155
- type?: string;
156
- name?: NamePath;
157
- label?: string | React.ReactNode;
158
- previewLabel?: string | React.ReactNode;
159
- labelProps?: any;
160
- contentProps?: any;
161
- ocr?: {
162
- vender: string;
163
- outputMap: {
164
- field: string[];
165
- source: string[];
166
- }[];
167
- };
168
- }
169
- export type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
170
- export interface FC<P = {}> extends React.FunctionComponent<P> {
171
- formItemPropsHandler?: FormItemPropsHandler;
172
- isPreviewSupport?: boolean;
173
- }
174
- export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
175
- useForm: () => FormInstance;
176
- }
177
- export interface IglooComponentProps {
178
- validateField?: (nameList?: NamePath[]) => Promise<any>;
179
- containerRef?: React.RefObject<any>;
180
- setFieldError?(errorMsg?: string): void;
181
- setFieldValue?(value?: any): void;
182
- setShowStepButton?: (showButton: boolean) => void;
183
- getFormInstance?: () => FormInstance;
184
- locales?: {
185
- [key: string]: string;
186
- };
187
- }
@@ -1,3 +0,0 @@
1
- import { IglooComponentProps } from '../types';
2
- declare const _default: (keyof IglooComponentProps)[];
3
- export default _default;