iglooform 3.7.7 → 3.7.9
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/checkbox/index.d.ts +24 -0
- package/es/form/addable-section/index.d.ts +20 -0
- package/es/form/element/index.js +6 -3
- package/es/form/element/style/index.less +4 -0
- package/es/form/index.d.ts +4 -0
- package/es/free-form/addable-section/index.d.ts +19 -0
- package/es/free-form/element/index.js +6 -3
- package/es/free-form/element/style/index.less +7 -3
- package/es/free-form/index.d.ts +11 -0
- package/es/types.d.ts +1 -0
- package/es/upload-photo/index.js +13 -2
- package/es/utils/option-utils.d.ts +29 -0
- package/lib/checkbox/index.d.ts +24 -0
- package/lib/form/addable-section/index.d.ts +20 -0
- package/lib/form/element/index.js +6 -3
- package/lib/form/element/style/index.less +4 -0
- package/lib/form/index.d.ts +4 -0
- package/lib/free-form/addable-section/index.d.ts +19 -0
- package/lib/free-form/element/index.js +6 -3
- package/lib/free-form/element/style/index.less +7 -3
- package/lib/free-form/index.d.ts +11 -0
- package/lib/types.d.ts +1 -0
- package/lib/upload-photo/index.js +13 -2
- package/lib/utils/option-utils.d.ts +29 -0
- 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.7.
|
|
33
|
+
pkg: {"name":"iglooform","version":"3.7.8","license":"MIT"},
|
|
34
34
|
historyType: "browser",
|
|
35
35
|
entryExports,
|
|
36
36
|
demos,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckboxProps, CheckboxGroupProps } from 'antd/es/checkbox';
|
|
3
|
+
import { FC, IglooComponentProps } from '../types';
|
|
4
|
+
import { ComponentProps } from '../utils/option-utils';
|
|
5
|
+
import { DefaultOptionType } from 'rc-select/lib/Select';
|
|
6
|
+
import './style';
|
|
7
|
+
interface Props extends IglooComponentProps, CheckboxProps {
|
|
8
|
+
}
|
|
9
|
+
export interface Option extends DefaultOptionType {
|
|
10
|
+
extraInfo?: {
|
|
11
|
+
content: any;
|
|
12
|
+
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface IProps extends IglooComponentProps, Omit<CheckboxGroupProps, 'options'>, ComponentProps {
|
|
16
|
+
className?: string;
|
|
17
|
+
radioType?: string;
|
|
18
|
+
options: Option[];
|
|
19
|
+
preview?: boolean;
|
|
20
|
+
mutuallyExclusions?: Record<string, string[]>;
|
|
21
|
+
}
|
|
22
|
+
declare const IglooCheckbox: FC<Props>;
|
|
23
|
+
export default IglooCheckbox;
|
|
24
|
+
export declare const CheckboxGroup: FC<import("react").PropsWithChildren<import("../utils/option-utils").HOCProps & IProps>>;
|
|
@@ -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;
|
package/es/form/element/index.js
CHANGED
|
@@ -264,7 +264,7 @@ var Element = function Element(_ref) {
|
|
|
264
264
|
'igloo-element-preview-hide': config.hideWhenPreview,
|
|
265
265
|
'igloo-element-preview-hide-divider': config.hidePreviewDivider
|
|
266
266
|
}),
|
|
267
|
-
children: /*#__PURE__*/
|
|
267
|
+
children: /*#__PURE__*/_jsxs(Form.Item, _objectSpread(_objectSpread({}, omit(formItemProps, ['copiedValue', 'selectedValue'])), {}, {
|
|
268
268
|
labelCol: {
|
|
269
269
|
span: 24
|
|
270
270
|
},
|
|
@@ -272,7 +272,7 @@ var Element = function Element(_ref) {
|
|
|
272
272
|
span: 24
|
|
273
273
|
},
|
|
274
274
|
label: null,
|
|
275
|
-
children: /*#__PURE__*/_jsxs(Row, {
|
|
275
|
+
children: [/*#__PURE__*/_jsxs(Row, {
|
|
276
276
|
className: "igloo-element-preview-item",
|
|
277
277
|
gutter: {
|
|
278
278
|
md: 32,
|
|
@@ -311,7 +311,10 @@ var Element = function Element(_ref) {
|
|
|
311
311
|
children: renderPreviewValue()
|
|
312
312
|
})]
|
|
313
313
|
})]
|
|
314
|
-
})
|
|
314
|
+
}), config.showExtraWhenPreview && /*#__PURE__*/_jsx("div", {
|
|
315
|
+
className: "igloo-element-preview-extra",
|
|
316
|
+
children: formItemProps.extra
|
|
317
|
+
})]
|
|
315
318
|
}))
|
|
316
319
|
});
|
|
317
320
|
}
|
|
@@ -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;
|
|
@@ -199,7 +199,7 @@ var Element = function Element(props) {
|
|
|
199
199
|
'igloo-freeform-element-preview-hide': props.hideWhenPreview,
|
|
200
200
|
'igloo-freeform-element-preview-hide-divider': props.hidePreviewDivider
|
|
201
201
|
}),
|
|
202
|
-
children: /*#__PURE__*/
|
|
202
|
+
children: /*#__PURE__*/_jsxs(Form.Item, _objectSpread(_objectSpread({}, omit(formItemProps, ['copiedValue', 'selectedValue'])), {}, {
|
|
203
203
|
labelCol: {
|
|
204
204
|
span: 24
|
|
205
205
|
},
|
|
@@ -207,7 +207,7 @@ var Element = function Element(props) {
|
|
|
207
207
|
span: 24
|
|
208
208
|
},
|
|
209
209
|
label: null,
|
|
210
|
-
children: /*#__PURE__*/_jsxs(Row, {
|
|
210
|
+
children: [/*#__PURE__*/_jsxs(Row, {
|
|
211
211
|
className: "igloo-freeform-element-preview-item",
|
|
212
212
|
gutter: {
|
|
213
213
|
md: 32,
|
|
@@ -246,7 +246,10 @@ var Element = function Element(props) {
|
|
|
246
246
|
children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
|
|
247
247
|
})]
|
|
248
248
|
})]
|
|
249
|
-
})
|
|
249
|
+
}), rest.showExtraWhenPreview && /*#__PURE__*/_jsx("div", {
|
|
250
|
+
className: "igloo-freeform-element-preview-extra",
|
|
251
|
+
children: formItemProps.extra
|
|
252
|
+
})]
|
|
250
253
|
}))
|
|
251
254
|
});
|
|
252
255
|
}
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
.igloo-freeform-element-preview-item {
|
|
13
13
|
.igloo-freeform-element-preview-label {
|
|
14
|
-
color:
|
|
14
|
+
color: @icon-color;
|
|
15
15
|
line-height: 24px;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.igloo-freeform-element-preview-value {
|
|
19
|
-
color:
|
|
19
|
+
color: @text-color;
|
|
20
20
|
white-space: pre-wrap;
|
|
21
21
|
word-break: break-word;
|
|
22
22
|
line-height: 24px;
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
.igloo-freeform-element-preview-extra {
|
|
36
|
+
margin-top: 6px;
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
.ant-form-item-explain-error {
|
|
36
40
|
margin-top: 0;
|
|
37
41
|
margin-left: calc(~'50%' + 16px);
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
width: 100%;
|
|
96
100
|
|
|
97
101
|
.igloo-freeform-label-text {
|
|
98
|
-
color:
|
|
102
|
+
color: @icon-color;
|
|
99
103
|
font-size: 16px;
|
|
100
104
|
line-height: 24px;
|
|
101
105
|
|
|
@@ -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;
|
package/es/types.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ export interface FormItemExtraConfig extends FormItemProps {
|
|
|
95
95
|
limit?: number;
|
|
96
96
|
hideWhenPreview?: boolean;
|
|
97
97
|
hideWhenEdit?: boolean;
|
|
98
|
+
showExtraWhenPreview?: boolean;
|
|
98
99
|
requiredMessage?: string | ReactNode;
|
|
99
100
|
showOptional?: boolean;
|
|
100
101
|
previewFormater?(value: any, form?: FormInstance): any;
|
package/es/upload-photo/index.js
CHANGED
|
@@ -84,6 +84,8 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
84
84
|
var limitNumError = useRef();
|
|
85
85
|
var DomRef = useRef();
|
|
86
86
|
var dataUrlRef = useRef([]);
|
|
87
|
+
var isValueSyncRef = useRef(false);
|
|
88
|
+
var isFirstRenderRef = useRef(true);
|
|
87
89
|
var _useContext = useContext(FormContext),
|
|
88
90
|
uploadApi = _useContext.uploadApi;
|
|
89
91
|
invariant(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
|
|
@@ -196,7 +198,8 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
196
198
|
return _ref3.apply(this, arguments);
|
|
197
199
|
};
|
|
198
200
|
}())).then(function () {
|
|
199
|
-
|
|
201
|
+
isValueSyncRef.current = true;
|
|
202
|
+
setFiles(_files);
|
|
200
203
|
});
|
|
201
204
|
};
|
|
202
205
|
useEffect(function () {
|
|
@@ -212,13 +215,21 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
212
215
|
mapFilesFromValue(newUrls);
|
|
213
216
|
}
|
|
214
217
|
} else if (!value && files.length > 0) {
|
|
215
|
-
|
|
218
|
+
isValueSyncRef.current = true;
|
|
216
219
|
setFiles([]);
|
|
217
220
|
setMasks([]);
|
|
218
221
|
}
|
|
219
222
|
}, [value]);
|
|
220
223
|
useEffect(function () {
|
|
221
224
|
if (!value && !files.length) return;
|
|
225
|
+
if (isFirstRenderRef.current) {
|
|
226
|
+
isFirstRenderRef.current = false;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (isValueSyncRef.current) {
|
|
230
|
+
isValueSyncRef.current = false;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
222
233
|
if (files.length) {
|
|
223
234
|
var hasProcessing = files.find(function (f) {
|
|
224
235
|
return f.status === 'progress';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { FC, IglooComponentProps } from '../types';
|
|
3
|
+
import { FormInstance } from 'antd/es/form';
|
|
4
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
5
|
+
import { SelectProps, SelectValue } from 'antd/es/select';
|
|
6
|
+
export declare const compareOptions: (newOptions: any[], oldOptions?: any[]) => boolean;
|
|
7
|
+
export declare const compareSelected: (newValue: any | any[], oldValue: any | any[]) => boolean;
|
|
8
|
+
type Options = SelectProps<SelectValue>['options'];
|
|
9
|
+
export interface HOCProps extends IglooComponentProps {
|
|
10
|
+
options?: Options;
|
|
11
|
+
onSearch?: any;
|
|
12
|
+
getOptions?: (form: FormInstance) => any[];
|
|
13
|
+
optionGroups?: {
|
|
14
|
+
parentKey: string;
|
|
15
|
+
options: Options;
|
|
16
|
+
}[];
|
|
17
|
+
datasourceFilters?: string[];
|
|
18
|
+
datasourceKey?: string;
|
|
19
|
+
datasourceApi?: string;
|
|
20
|
+
dependField?: NamePath;
|
|
21
|
+
passCompareOptions?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ComponentProps extends IglooComponentProps {
|
|
24
|
+
options?: Options;
|
|
25
|
+
clearWhenOptionsUpdated?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function optionsHOC<T>(Component: FC<T>): FC<PropsWithChildren<HOCProps & T>>;
|
|
28
|
+
export declare function previewSelectedOptions(options: Options, value: any): any;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckboxProps, CheckboxGroupProps } from 'antd/es/checkbox';
|
|
3
|
+
import { FC, IglooComponentProps } from '../types';
|
|
4
|
+
import { ComponentProps } from '../utils/option-utils';
|
|
5
|
+
import { DefaultOptionType } from 'rc-select/lib/Select';
|
|
6
|
+
import './style';
|
|
7
|
+
interface Props extends IglooComponentProps, CheckboxProps {
|
|
8
|
+
}
|
|
9
|
+
export interface Option extends DefaultOptionType {
|
|
10
|
+
extraInfo?: {
|
|
11
|
+
content: any;
|
|
12
|
+
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface IProps extends IglooComponentProps, Omit<CheckboxGroupProps, 'options'>, ComponentProps {
|
|
16
|
+
className?: string;
|
|
17
|
+
radioType?: string;
|
|
18
|
+
options: Option[];
|
|
19
|
+
preview?: boolean;
|
|
20
|
+
mutuallyExclusions?: Record<string, string[]>;
|
|
21
|
+
}
|
|
22
|
+
declare const IglooCheckbox: FC<Props>;
|
|
23
|
+
export default IglooCheckbox;
|
|
24
|
+
export declare const CheckboxGroup: FC<import("react").PropsWithChildren<import("../utils/option-utils").HOCProps & IProps>>;
|
|
@@ -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;
|
|
@@ -270,7 +270,7 @@ var Element = function Element(_ref) {
|
|
|
270
270
|
'igloo-element-preview-hide': config.hideWhenPreview,
|
|
271
271
|
'igloo-element-preview-hide-divider': config.hidePreviewDivider
|
|
272
272
|
}),
|
|
273
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
273
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form.Item, _objectSpread(_objectSpread({}, (0, _omit.default)(formItemProps, ['copiedValue', 'selectedValue'])), {}, {
|
|
274
274
|
labelCol: {
|
|
275
275
|
span: 24
|
|
276
276
|
},
|
|
@@ -278,7 +278,7 @@ var Element = function Element(_ref) {
|
|
|
278
278
|
span: 24
|
|
279
279
|
},
|
|
280
280
|
label: null,
|
|
281
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Row, {
|
|
281
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Row, {
|
|
282
282
|
className: "igloo-element-preview-item",
|
|
283
283
|
gutter: {
|
|
284
284
|
md: 32,
|
|
@@ -317,7 +317,10 @@ var Element = function Element(_ref) {
|
|
|
317
317
|
children: renderPreviewValue()
|
|
318
318
|
})]
|
|
319
319
|
})]
|
|
320
|
-
})
|
|
320
|
+
}), config.showExtraWhenPreview && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
321
|
+
className: "igloo-element-preview-extra",
|
|
322
|
+
children: formItemProps.extra
|
|
323
|
+
})]
|
|
321
324
|
}))
|
|
322
325
|
});
|
|
323
326
|
}
|
|
@@ -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;
|
|
@@ -205,7 +205,7 @@ var Element = function Element(props) {
|
|
|
205
205
|
'igloo-freeform-element-preview-hide': props.hideWhenPreview,
|
|
206
206
|
'igloo-freeform-element-preview-hide-divider': props.hidePreviewDivider
|
|
207
207
|
}),
|
|
208
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
208
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form.Item, _objectSpread(_objectSpread({}, (0, _omit.default)(formItemProps, ['copiedValue', 'selectedValue'])), {}, {
|
|
209
209
|
labelCol: {
|
|
210
210
|
span: 24
|
|
211
211
|
},
|
|
@@ -213,7 +213,7 @@ var Element = function Element(props) {
|
|
|
213
213
|
span: 24
|
|
214
214
|
},
|
|
215
215
|
label: null,
|
|
216
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Row, {
|
|
216
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Row, {
|
|
217
217
|
className: "igloo-freeform-element-preview-item",
|
|
218
218
|
gutter: {
|
|
219
219
|
md: 32,
|
|
@@ -252,7 +252,10 @@ var Element = function Element(props) {
|
|
|
252
252
|
children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
|
|
253
253
|
})]
|
|
254
254
|
})]
|
|
255
|
-
})
|
|
255
|
+
}), rest.showExtraWhenPreview && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
256
|
+
className: "igloo-freeform-element-preview-extra",
|
|
257
|
+
children: formItemProps.extra
|
|
258
|
+
})]
|
|
256
259
|
}))
|
|
257
260
|
});
|
|
258
261
|
}
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
.igloo-freeform-element-preview-item {
|
|
13
13
|
.igloo-freeform-element-preview-label {
|
|
14
|
-
color:
|
|
14
|
+
color: @icon-color;
|
|
15
15
|
line-height: 24px;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.igloo-freeform-element-preview-value {
|
|
19
|
-
color:
|
|
19
|
+
color: @text-color;
|
|
20
20
|
white-space: pre-wrap;
|
|
21
21
|
word-break: break-word;
|
|
22
22
|
line-height: 24px;
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
.igloo-freeform-element-preview-extra {
|
|
36
|
+
margin-top: 6px;
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
.ant-form-item-explain-error {
|
|
36
40
|
margin-top: 0;
|
|
37
41
|
margin-left: calc(~'50%' + 16px);
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
width: 100%;
|
|
96
100
|
|
|
97
101
|
.igloo-freeform-label-text {
|
|
98
|
-
color:
|
|
102
|
+
color: @icon-color;
|
|
99
103
|
font-size: 16px;
|
|
100
104
|
line-height: 24px;
|
|
101
105
|
|
|
@@ -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;
|
package/lib/types.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ export interface FormItemExtraConfig extends FormItemProps {
|
|
|
95
95
|
limit?: number;
|
|
96
96
|
hideWhenPreview?: boolean;
|
|
97
97
|
hideWhenEdit?: boolean;
|
|
98
|
+
showExtraWhenPreview?: boolean;
|
|
98
99
|
requiredMessage?: string | ReactNode;
|
|
99
100
|
showOptional?: boolean;
|
|
100
101
|
previewFormater?(value: any, form?: FormInstance): any;
|
|
@@ -88,6 +88,8 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
88
88
|
var limitNumError = (0, _react.useRef)();
|
|
89
89
|
var DomRef = (0, _react.useRef)();
|
|
90
90
|
var dataUrlRef = (0, _react.useRef)([]);
|
|
91
|
+
var isValueSyncRef = (0, _react.useRef)(false);
|
|
92
|
+
var isFirstRenderRef = (0, _react.useRef)(true);
|
|
91
93
|
var _useContext = (0, _react.useContext)(_formContext.default),
|
|
92
94
|
uploadApi = _useContext.uploadApi;
|
|
93
95
|
(0, _invariant.default)(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
|
|
@@ -200,7 +202,8 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
200
202
|
return _ref3.apply(this, arguments);
|
|
201
203
|
};
|
|
202
204
|
}())).then(function () {
|
|
203
|
-
|
|
205
|
+
isValueSyncRef.current = true;
|
|
206
|
+
setFiles(_files);
|
|
204
207
|
});
|
|
205
208
|
};
|
|
206
209
|
(0, _react.useEffect)(function () {
|
|
@@ -216,13 +219,21 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
216
219
|
mapFilesFromValue(newUrls);
|
|
217
220
|
}
|
|
218
221
|
} else if (!value && files.length > 0) {
|
|
219
|
-
|
|
222
|
+
isValueSyncRef.current = true;
|
|
220
223
|
setFiles([]);
|
|
221
224
|
setMasks([]);
|
|
222
225
|
}
|
|
223
226
|
}, [value]);
|
|
224
227
|
(0, _react.useEffect)(function () {
|
|
225
228
|
if (!value && !files.length) return;
|
|
229
|
+
if (isFirstRenderRef.current) {
|
|
230
|
+
isFirstRenderRef.current = false;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (isValueSyncRef.current) {
|
|
234
|
+
isValueSyncRef.current = false;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
226
237
|
if (files.length) {
|
|
227
238
|
var hasProcessing = files.find(function (f) {
|
|
228
239
|
return f.status === 'progress';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { FC, IglooComponentProps } from '../types';
|
|
3
|
+
import { FormInstance } from 'antd/es/form';
|
|
4
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
5
|
+
import { SelectProps, SelectValue } from 'antd/es/select';
|
|
6
|
+
export declare const compareOptions: (newOptions: any[], oldOptions?: any[]) => boolean;
|
|
7
|
+
export declare const compareSelected: (newValue: any | any[], oldValue: any | any[]) => boolean;
|
|
8
|
+
type Options = SelectProps<SelectValue>['options'];
|
|
9
|
+
export interface HOCProps extends IglooComponentProps {
|
|
10
|
+
options?: Options;
|
|
11
|
+
onSearch?: any;
|
|
12
|
+
getOptions?: (form: FormInstance) => any[];
|
|
13
|
+
optionGroups?: {
|
|
14
|
+
parentKey: string;
|
|
15
|
+
options: Options;
|
|
16
|
+
}[];
|
|
17
|
+
datasourceFilters?: string[];
|
|
18
|
+
datasourceKey?: string;
|
|
19
|
+
datasourceApi?: string;
|
|
20
|
+
dependField?: NamePath;
|
|
21
|
+
passCompareOptions?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ComponentProps extends IglooComponentProps {
|
|
24
|
+
options?: Options;
|
|
25
|
+
clearWhenOptionsUpdated?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function optionsHOC<T>(Component: FC<T>): FC<PropsWithChildren<HOCProps & T>>;
|
|
28
|
+
export declare function previewSelectedOptions(options: Options, value: any): any;
|
|
29
|
+
export {};
|