iglooform 2.4.28 → 2.4.31
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/es/filter/checkBox.d.ts +1 -0
- package/es/filter/checkBox.js +5 -1
- package/es/filter/index.d.ts +3 -0
- package/es/filter/index.js +17 -5
- package/es/filter/radioBox.d.ts +1 -0
- package/es/filter/radioBox.js +4 -2
- package/es/filter/rangePicker.d.ts +1 -0
- package/es/filter/rangePicker.js +2 -0
- package/es/form/element/index.js +8 -5
- package/es/form/index.js +4 -2
- package/es/form-context.d.ts +1 -0
- package/es/free-form/addable-section/index.js +1 -1
- package/es/free-form/index.js +4 -2
- package/es/select/attached-select.d.ts +10 -2
- package/es/select/attached-select.js +186 -83
- package/es/types.d.ts +3 -1
- package/es/upload-photo/index.js +4 -5
- package/lib/filter/checkBox.d.ts +1 -0
- package/lib/filter/checkBox.js +5 -1
- package/lib/filter/index.d.ts +3 -0
- package/lib/filter/index.js +17 -5
- package/lib/filter/radioBox.d.ts +1 -0
- package/lib/filter/radioBox.js +4 -2
- package/lib/filter/rangePicker.d.ts +1 -0
- package/lib/filter/rangePicker.js +2 -0
- package/lib/form/element/index.js +8 -5
- package/lib/form/index.js +4 -2
- package/lib/form-context.d.ts +1 -0
- package/lib/free-form/addable-section/index.js +1 -1
- package/lib/free-form/index.js +4 -2
- package/lib/select/attached-select.d.ts +10 -2
- package/lib/select/attached-select.js +188 -83
- package/lib/types.d.ts +3 -1
- package/lib/upload-photo/index.js +4 -5
- package/package.json +1 -1
package/es/filter/checkBox.d.ts
CHANGED
package/es/filter/checkBox.js
CHANGED
|
@@ -50,6 +50,7 @@ var CratetCheckBoxFilter = function CratetCheckBoxFilter(props) {
|
|
|
50
50
|
_props$chooseed = props.chooseed,
|
|
51
51
|
chooseed = _props$chooseed === void 0 ? [] : _props$chooseed,
|
|
52
52
|
disabled = props.disabled,
|
|
53
|
+
_onChange = props.onChange,
|
|
53
54
|
_props$valueConfirm = props.valueConfirm,
|
|
54
55
|
valueConfirm = _props$valueConfirm === void 0 ? function () {} : _props$valueConfirm;
|
|
55
56
|
var timeKey = new Date();
|
|
@@ -83,6 +84,7 @@ var CratetCheckBoxFilter = function CratetCheckBoxFilter(props) {
|
|
|
83
84
|
}), allChoose ? _jsx("span", {
|
|
84
85
|
className: "igloo-form-filter-drop-down-container-content-group-title-action",
|
|
85
86
|
onClick: function onClick() {
|
|
87
|
+
typeof _onChange === 'function' && _onChange([]);
|
|
86
88
|
valueConfirm({
|
|
87
89
|
type: optionKey,
|
|
88
90
|
value: []
|
|
@@ -98,6 +100,7 @@ var CratetCheckBoxFilter = function CratetCheckBoxFilter(props) {
|
|
|
98
100
|
}) : _jsx("span", {
|
|
99
101
|
className: "igloo-form-filter-drop-down-container-content-group-title-action",
|
|
100
102
|
onClick: function onClick() {
|
|
103
|
+
typeof _onChange === 'function' && _onChange(allCanChoose);
|
|
101
104
|
valueConfirm({
|
|
102
105
|
type: optionKey,
|
|
103
106
|
value: allCanChoose
|
|
@@ -117,7 +120,8 @@ var CratetCheckBoxFilter = function CratetCheckBoxFilter(props) {
|
|
|
117
120
|
width: '100%'
|
|
118
121
|
},
|
|
119
122
|
onChange: function onChange(e) {
|
|
120
|
-
|
|
123
|
+
typeof _onChange === 'function' && _onChange(e);
|
|
124
|
+
valueConfirm({
|
|
121
125
|
type: optionKey,
|
|
122
126
|
value: e
|
|
123
127
|
});
|
package/es/filter/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface IFrameConfig {
|
|
|
23
23
|
canNotDelete?: boolean;
|
|
24
24
|
tagTitle?: (value?: any) => string;
|
|
25
25
|
render?: (value: any, onChange: any) => ReactNode;
|
|
26
|
+
onChange?: any;
|
|
26
27
|
}
|
|
27
28
|
export interface IFilterProps {
|
|
28
29
|
initValue?: {
|
|
@@ -44,6 +45,8 @@ export interface IFilterProps {
|
|
|
44
45
|
searchInputDefault?: string | number;
|
|
45
46
|
searchWithFilter?: boolean;
|
|
46
47
|
inputOnly?: boolean;
|
|
48
|
+
beforeOpenFilter?: any;
|
|
49
|
+
resetCallBack?: any;
|
|
47
50
|
}
|
|
48
51
|
declare const FilterComponent: (props: IFilterProps) => JSX.Element;
|
|
49
52
|
export default FilterComponent;
|
package/es/filter/index.js
CHANGED
|
@@ -355,7 +355,9 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
355
355
|
searchWithFilter = _props$searchWithFilt === void 0 ? false : _props$searchWithFilt,
|
|
356
356
|
searchInputDefault = props.searchInputDefault,
|
|
357
357
|
initValue = props.initValue,
|
|
358
|
-
inputOnly = props.inputOnly
|
|
358
|
+
inputOnly = props.inputOnly,
|
|
359
|
+
beforeOpenFilter = props.beforeOpenFilter,
|
|
360
|
+
resetCallBack = props.resetCallBack;
|
|
359
361
|
var filterTitle = props.filterTitle,
|
|
360
362
|
_props$filterItems = props.filterItems,
|
|
361
363
|
filterItems = _props$filterItems === void 0 ? [] : _props$filterItems; // id controller
|
|
@@ -635,7 +637,8 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
635
637
|
format = _item$format2 === void 0 ? defaultFormat : _item$format2,
|
|
636
638
|
dateRangeConfig = item.dateRangeConfig,
|
|
637
639
|
render = item.render,
|
|
638
|
-
tagTitle = item.tagTitle
|
|
640
|
+
tagTitle = item.tagTitle,
|
|
641
|
+
onChangeProps = item.onChange;
|
|
639
642
|
|
|
640
643
|
switch (type) {
|
|
641
644
|
case 'customize':
|
|
@@ -671,7 +674,8 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
671
674
|
onFocus: invisibleRef.current,
|
|
672
675
|
dateRangeConfig: dateRangeConfig,
|
|
673
676
|
pickerOpenStatus: dataPickerOpenStatus[key],
|
|
674
|
-
setPickerOpenStatus: setPickerOpenStatus
|
|
677
|
+
setPickerOpenStatus: setPickerOpenStatus,
|
|
678
|
+
onChange: onChangeProps
|
|
675
679
|
}, key);
|
|
676
680
|
|
|
677
681
|
case 'mult':
|
|
@@ -683,7 +687,8 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
683
687
|
allSelected: optionsAllSelected[key],
|
|
684
688
|
chooseed: optionsChanged[key],
|
|
685
689
|
disabled: disabled,
|
|
686
|
-
valueConfirm: dispatchOptionsChange
|
|
690
|
+
valueConfirm: dispatchOptionsChange,
|
|
691
|
+
onChange: onChangeProps
|
|
687
692
|
}, key);
|
|
688
693
|
|
|
689
694
|
case 'single':
|
|
@@ -694,7 +699,8 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
694
699
|
optionKey: key,
|
|
695
700
|
chooseed: optionsChanged[key],
|
|
696
701
|
disabled: disabled,
|
|
697
|
-
valueConfirm: dispatchOptionsChange
|
|
702
|
+
valueConfirm: dispatchOptionsChange,
|
|
703
|
+
onChange: onChangeProps
|
|
698
704
|
}, key);
|
|
699
705
|
}
|
|
700
706
|
})]
|
|
@@ -705,6 +711,7 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
705
711
|
},
|
|
706
712
|
children: [_jsx("span", {
|
|
707
713
|
onClick: function onClick() {
|
|
714
|
+
typeof resetCallBack === 'function' && resetCallBack(_objectSpread({}, defaultOptions));
|
|
708
715
|
setTimeout(function () {
|
|
709
716
|
setTimeRangeType(-1);
|
|
710
717
|
dispatchOptionsChange({
|
|
@@ -1045,6 +1052,11 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
1045
1052
|
visible: dropVisible,
|
|
1046
1053
|
onVisibleChange: function onVisibleChange(visible) {
|
|
1047
1054
|
setDropVisible(visible);
|
|
1055
|
+
|
|
1056
|
+
if (visible) {
|
|
1057
|
+
typeof beforeOpenFilter === 'function' && beforeOpenFilter(_objectSpread({}, confirmed));
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1048
1060
|
setTimeout(function () {
|
|
1049
1061
|
if (dropVisible) {
|
|
1050
1062
|
setTimeRangeType(confirmedTimeRange);
|
package/es/filter/radioBox.d.ts
CHANGED
package/es/filter/radioBox.js
CHANGED
|
@@ -15,7 +15,8 @@ var CreateRadioBoxFilter = function CreateRadioBoxFilter(props) {
|
|
|
15
15
|
configList = props.configList,
|
|
16
16
|
disabled = props.disabled,
|
|
17
17
|
valueConfirm = props.valueConfirm,
|
|
18
|
-
chooseed = props.chooseed
|
|
18
|
+
chooseed = props.chooseed,
|
|
19
|
+
_onChange = props.onChange;
|
|
19
20
|
return _jsxs("div", {
|
|
20
21
|
className: "igloo-form-filter-drop-down-container-content-group",
|
|
21
22
|
children: [_jsx("div", {
|
|
@@ -27,7 +28,8 @@ var CreateRadioBoxFilter = function CreateRadioBoxFilter(props) {
|
|
|
27
28
|
}), _jsx(_Radio.Group, {
|
|
28
29
|
value: chooseed,
|
|
29
30
|
onChange: function onChange(e) {
|
|
30
|
-
|
|
31
|
+
typeof _onChange === 'function' && _onChange(e.target.value);
|
|
32
|
+
valueConfirm({
|
|
31
33
|
type: optionKey,
|
|
32
34
|
value: e.target.value
|
|
33
35
|
});
|
package/es/filter/rangePicker.js
CHANGED
|
@@ -44,6 +44,7 @@ var CreateRangePickerFilter = function CreateRangePickerFilter(props) {
|
|
|
44
44
|
dateRangeConfig = _props$dateRangeConfi === void 0 ? {} : _props$dateRangeConfi,
|
|
45
45
|
_props$pickerOpenStat = props.pickerOpenStatus,
|
|
46
46
|
pickerOpenStatus = _props$pickerOpenStat === void 0 ? false : _props$pickerOpenStat,
|
|
47
|
+
onChange = props.onChange,
|
|
47
48
|
setPickerOpenStatus = props.setPickerOpenStatus;
|
|
48
49
|
var RangePicker = _DatePicker.RangePicker;
|
|
49
50
|
|
|
@@ -83,6 +84,7 @@ var CreateRangePickerFilter = function CreateRangePickerFilter(props) {
|
|
|
83
84
|
type: optionKey,
|
|
84
85
|
value: [timeValueRef.current.startTime, timeValueRef.current.endTime]
|
|
85
86
|
});
|
|
87
|
+
typeof onChange === 'function' && onChange([timeValueRef.current.startTime, timeValueRef.current.endTime]);
|
|
86
88
|
setPickerOpenStatus({
|
|
87
89
|
type: optionKey,
|
|
88
90
|
value: false
|
package/es/form/element/index.js
CHANGED
|
@@ -238,11 +238,7 @@ var Element = function Element(_ref) {
|
|
|
238
238
|
hideWhenEdit = elementProps.hideWhenEdit,
|
|
239
239
|
otherElementProps = _objectWithoutProperties(elementProps, _excluded2);
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return hideWhenEdit || !display ? null : _jsx(_Col, _objectSpread(_objectSpread({}, restColProps), {}, {
|
|
241
|
+
var component = _jsx(_Col, _objectSpread(_objectSpread({}, restColProps), {}, {
|
|
246
242
|
className: "igloo-form-item",
|
|
247
243
|
children: _jsx("div", {
|
|
248
244
|
style: {
|
|
@@ -261,6 +257,13 @@ var Element = function Element(_ref) {
|
|
|
261
257
|
}))
|
|
262
258
|
})
|
|
263
259
|
}));
|
|
260
|
+
|
|
261
|
+
if (preview) {
|
|
262
|
+
if (hideWhenPreview) return null;
|
|
263
|
+
return component;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return hideWhenEdit || !display ? null : component;
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
if (!display) return null;
|
package/es/form/index.js
CHANGED
|
@@ -60,7 +60,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
60
60
|
} : _props$getScrollConta,
|
|
61
61
|
_props$onFirstModifie = props.onFirstModified,
|
|
62
62
|
onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie,
|
|
63
|
-
uploadApi = props.uploadApi
|
|
63
|
+
uploadApi = props.uploadApi,
|
|
64
|
+
selectDatasourceApi = props.selectDatasourceApi;
|
|
64
65
|
|
|
65
66
|
var _Form$useForm = _Form.useForm(),
|
|
66
67
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -239,7 +240,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
239
240
|
showSubmitButton: showSubmitButton,
|
|
240
241
|
getScrollContainer: getScrollContainer,
|
|
241
242
|
registerDependencies: registerDependencies,
|
|
242
|
-
uploadApi: uploadApi
|
|
243
|
+
uploadApi: uploadApi,
|
|
244
|
+
selectDatasourceApi: selectDatasourceApi
|
|
243
245
|
}, locales),
|
|
244
246
|
children: _jsxs(_Form, {
|
|
245
247
|
form: form,
|
package/es/form-context.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ declare const _default: React.Context<{
|
|
|
16
16
|
getScrollContainer: () => HTMLElement | Window | null;
|
|
17
17
|
registerDependencies: (name: FormItemName | FormItemName[], updater: Function) => void;
|
|
18
18
|
uploadApi?: string | undefined;
|
|
19
|
+
selectDatasourceApi?: string | undefined;
|
|
19
20
|
}>;
|
|
20
21
|
export default _default;
|
|
@@ -201,7 +201,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
201
201
|
return children.map(function (c, index) {
|
|
202
202
|
var _c$type;
|
|
203
203
|
|
|
204
|
-
if (['Igloo_Free_Form_Item', 'Igloo_Free_Form_Section', '
|
|
204
|
+
if (['Igloo_Free_Form_Item', 'Igloo_Free_Form_Section', 'Igloo_Free_Form_AddableSection'].includes(c === null || c === void 0 ? void 0 : (_c$type = c.type) === null || _c$type === void 0 ? void 0 : _c$type.displayName)) {
|
|
205
205
|
return /*#__PURE__*/cloneElement(c, _objectSpread(_objectSpread({
|
|
206
206
|
key: index
|
|
207
207
|
}, c.props), {}, {
|
package/es/free-form/index.js
CHANGED
|
@@ -55,7 +55,8 @@ var FreeForm = function FreeForm(props) {
|
|
|
55
55
|
} : _props$getScrollConta,
|
|
56
56
|
_props$onFirstModifie = props.onFirstModified,
|
|
57
57
|
onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie,
|
|
58
|
-
uploadApi = props.uploadApi
|
|
58
|
+
uploadApi = props.uploadApi,
|
|
59
|
+
selectDatasourceApi = props.selectDatasourceApi;
|
|
59
60
|
|
|
60
61
|
var _Form$useForm = _Form.useForm(),
|
|
61
62
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -196,7 +197,8 @@ var FreeForm = function FreeForm(props) {
|
|
|
196
197
|
showSubmitButton: showSubmitButton,
|
|
197
198
|
getScrollContainer: getScrollContainer,
|
|
198
199
|
registerDependencies: registerDependencies,
|
|
199
|
-
uploadApi: uploadApi
|
|
200
|
+
uploadApi: uploadApi,
|
|
201
|
+
selectDatasourceApi: selectDatasourceApi
|
|
200
202
|
}, locales),
|
|
201
203
|
children: _jsx(_Form, {
|
|
202
204
|
form: form,
|
|
@@ -2,11 +2,19 @@ import { SelectProps, SelectValue } from 'antd/es/select';
|
|
|
2
2
|
import { FC, IglooComponentProps } from '../types';
|
|
3
3
|
import { FormInstance } from 'antd/es/form';
|
|
4
4
|
import './style';
|
|
5
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
5
6
|
export declare const Option: import("rc-select/lib/Option").OptionFC, OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
|
|
6
7
|
declare type Props = SelectProps<SelectValue> & IglooComponentProps & {
|
|
7
8
|
getOptions?: (form: FormInstance) => any[];
|
|
8
9
|
multiple?: boolean;
|
|
9
10
|
clearWhenOptionsUpdated?: boolean;
|
|
11
|
+
optionGroups?: {
|
|
12
|
+
parentKey: string;
|
|
13
|
+
options: Props['options'];
|
|
14
|
+
}[];
|
|
15
|
+
datasourceKey?: string;
|
|
16
|
+
datasourceApi?: string;
|
|
17
|
+
dependField?: NamePath;
|
|
10
18
|
};
|
|
11
19
|
declare type OptionType = typeof Option;
|
|
12
20
|
declare type OptGroupType = typeof OptGroup;
|
|
@@ -14,5 +22,5 @@ interface IglooSelectType extends FC<Props> {
|
|
|
14
22
|
Option: OptionType;
|
|
15
23
|
OptGroup: OptGroupType;
|
|
16
24
|
}
|
|
17
|
-
declare const
|
|
18
|
-
export default
|
|
25
|
+
declare const AttachedSelect: IglooSelectType;
|
|
26
|
+
export default AttachedSelect;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import "antd/es/select/style";
|
|
2
2
|
import _Select from "antd/es/select";
|
|
3
|
-
var _excluded = ["
|
|
3
|
+
var _excluded = ["value", "className", "placeholder", "onDropdownVisibleChange", "showSearch", "filterOption", "optionFilterProp", "multiple", "options"],
|
|
4
|
+
_excluded2 = ["options", "optionGroups", "getOptions", "datasourceKey", "dependField", "children", "clearWhenOptionsUpdated"];
|
|
5
|
+
|
|
6
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
11
|
|
|
5
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
13
|
|
|
@@ -40,28 +47,27 @@ import { ArrowDownOutlined, ArrowUpOutlined, SearchOutlined } from 'iglooicon';
|
|
|
40
47
|
import classnames from 'classnames';
|
|
41
48
|
import Checkbox from '../checkbox';
|
|
42
49
|
import LocaleContext from '../locale/locale-context';
|
|
50
|
+
import FormContext from '../form-context';
|
|
43
51
|
import Button from '../button';
|
|
44
52
|
import Input from '../input';
|
|
45
53
|
import './style';
|
|
54
|
+
import invariant from 'invariant';
|
|
46
55
|
var Option = _Select.Option,
|
|
47
56
|
OptGroup = _Select.OptGroup;
|
|
48
57
|
export { Option, OptGroup };
|
|
49
58
|
|
|
50
59
|
var IglooSelect = function IglooSelect(_ref) {
|
|
51
|
-
var
|
|
52
|
-
getOptionsProp = _ref.getOptions,
|
|
53
|
-
valueProp = _ref.value,
|
|
60
|
+
var valueProp = _ref.value,
|
|
54
61
|
className = _ref.className,
|
|
55
62
|
placeholder = _ref.placeholder,
|
|
56
63
|
_ref$onDropdownVisibl = _ref.onDropdownVisibleChange,
|
|
57
64
|
onDropdownVisibleChange = _ref$onDropdownVisibl === void 0 ? function () {} : _ref$onDropdownVisibl,
|
|
58
|
-
children = _ref.children,
|
|
59
65
|
showSearch = _ref.showSearch,
|
|
60
66
|
filterOption = _ref.filterOption,
|
|
61
67
|
optionFilterProp = _ref.optionFilterProp,
|
|
62
68
|
multiple = _ref.multiple,
|
|
63
|
-
_ref$
|
|
64
|
-
|
|
69
|
+
_ref$options = _ref.options,
|
|
70
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
65
71
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
66
72
|
|
|
67
73
|
var _useContext = useContext(LocaleContext),
|
|
@@ -77,86 +83,25 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
77
83
|
selectedOptions = _useState4[0],
|
|
78
84
|
setSelectedOptions = _useState4[1];
|
|
79
85
|
|
|
86
|
+
var _useState5 = useState(options),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
displayOptions = _useState6[0],
|
|
89
|
+
setDisplay = _useState6[1];
|
|
90
|
+
|
|
80
91
|
useEffect(function () {
|
|
81
92
|
typeof rest.onChange === 'function' && valueProp !== selected && rest.onChange(selected, selectedOptions);
|
|
82
93
|
}, [selected]);
|
|
83
94
|
useEffect(function () {
|
|
84
95
|
setSelected(valueProp);
|
|
85
96
|
}, [valueProp]);
|
|
86
|
-
|
|
87
|
-
var getOptions = function getOptions() {
|
|
88
|
-
var getFormInstance = rest.getFormInstance;
|
|
89
|
-
var form = typeof getFormInstance === 'function' && getFormInstance();
|
|
90
|
-
|
|
91
|
-
if (!form) {
|
|
92
|
-
if (!children || typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') return [];
|
|
93
|
-
return Array.isArray(children) ? children.map(function (child) {
|
|
94
|
-
return {
|
|
95
|
-
label: child.props.children,
|
|
96
|
-
value: child.props.value
|
|
97
|
-
};
|
|
98
|
-
}) : [{
|
|
99
|
-
label: children.props.children,
|
|
100
|
-
value: children.props.value
|
|
101
|
-
}];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var options = typeof getOptionsProp === 'function' && getOptionsProp(form);
|
|
105
|
-
return options || [];
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
var options = optionsProp || getOptions();
|
|
109
|
-
|
|
110
|
-
var _useState5 = useState(options),
|
|
111
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
112
|
-
originOptions = _useState6[0],
|
|
113
|
-
setOriginOptions = _useState6[1];
|
|
114
|
-
|
|
115
|
-
var _useState7 = useState(options),
|
|
116
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
117
|
-
displayOptions = _useState8[0],
|
|
118
|
-
setDisplay = _useState8[1];
|
|
119
|
-
|
|
120
97
|
useEffect(function () {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!updateOptions) {
|
|
124
|
-
for (var i = 0; i < options.length; i++) {
|
|
125
|
-
var newOption = options[i];
|
|
126
|
-
var originOption = originOptions[i];
|
|
127
|
-
|
|
128
|
-
if (newOption.label !== originOption.label || newOption.value !== originOption.value) {
|
|
129
|
-
updateOptions = true;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (updateOptions) {
|
|
136
|
-
setOriginOptions(options);
|
|
137
|
-
setDisplay(options);
|
|
138
|
-
var setFieldValue = rest.setFieldValue;
|
|
139
|
-
|
|
140
|
-
if (clearWhenOptionsUpdated) {
|
|
141
|
-
typeof setFieldValue === 'function' && setFieldValue();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
98
|
+
setDisplay(options);
|
|
144
99
|
}, [options]);
|
|
145
|
-
useEffect(function () {
|
|
146
|
-
var setFieldValue = rest.setFieldValue;
|
|
147
|
-
var foundValue = originOptions.find(function (option) {
|
|
148
|
-
return Array.isArray(valueProp) ? valueProp.includes(option.value) : option.value === valueProp;
|
|
149
|
-
});
|
|
150
100
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var _useState9 = useState(false),
|
|
157
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
158
|
-
dropVisible = _useState10[0],
|
|
159
|
-
setDropVisible = _useState10[1];
|
|
101
|
+
var _useState7 = useState(false),
|
|
102
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
103
|
+
dropVisible = _useState8[0],
|
|
104
|
+
setDropVisible = _useState8[1];
|
|
160
105
|
|
|
161
106
|
var handleDropDownVisibleChange = function handleDropDownVisibleChange(open) {
|
|
162
107
|
typeof onDropdownVisibleChange === 'function' && onDropdownVisibleChange(open);
|
|
@@ -165,7 +110,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
165
110
|
|
|
166
111
|
var handleSearch = function handleSearch(e) {
|
|
167
112
|
var value = e.target.value;
|
|
168
|
-
var filteredOptions =
|
|
113
|
+
var filteredOptions = options.filter(function (option) {
|
|
169
114
|
var _option$label, _option$label$toStrin;
|
|
170
115
|
|
|
171
116
|
return Boolean(option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : (_option$label$toStrin = _option$label.toString()) === null || _option$label$toStrin === void 0 ? void 0 : _option$label$toStrin.includes(value));
|
|
@@ -347,10 +292,168 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
347
292
|
});
|
|
348
293
|
};
|
|
349
294
|
|
|
350
|
-
|
|
295
|
+
var AttachedSelect = function AttachedSelect(_ref11) {
|
|
296
|
+
var options = _ref11.options,
|
|
297
|
+
optionGroups = _ref11.optionGroups,
|
|
298
|
+
getOptions = _ref11.getOptions,
|
|
299
|
+
datasourceKey = _ref11.datasourceKey,
|
|
300
|
+
dependField = _ref11.dependField,
|
|
301
|
+
children = _ref11.children,
|
|
302
|
+
_ref11$clearWhenOptio = _ref11.clearWhenOptionsUpdated,
|
|
303
|
+
clearWhenOptionsUpdated = _ref11$clearWhenOptio === void 0 ? false : _ref11$clearWhenOptio,
|
|
304
|
+
rest = _objectWithoutProperties(_ref11, _excluded2);
|
|
305
|
+
|
|
306
|
+
var _useState9 = useState(options || []),
|
|
307
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
308
|
+
_options = _useState10[0],
|
|
309
|
+
setOptions = _useState10[1];
|
|
310
|
+
|
|
311
|
+
var _useContext2 = useContext(FormContext),
|
|
312
|
+
selectDatasourceApi = _useContext2.selectDatasourceApi;
|
|
313
|
+
|
|
314
|
+
var getFormInstance = rest.getFormInstance;
|
|
315
|
+
var form = typeof getFormInstance === 'function' && getFormInstance();
|
|
316
|
+
var dependFieldValue = form && dependField && form.getFieldValue(dependField);
|
|
317
|
+
var optionsFromGetOptions = typeof getOptions === 'function' && form && getOptions(form);
|
|
318
|
+
invariant(datasourceKey && selectDatasourceApi || !datasourceKey, 'Please provide selectDatasourceApi in Form props');
|
|
319
|
+
useEffect(function () {
|
|
320
|
+
var calcOptions = /*#__PURE__*/function () {
|
|
321
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
322
|
+
var group, query, api, rst, _yield$rst$json, data;
|
|
323
|
+
|
|
324
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
325
|
+
while (1) {
|
|
326
|
+
switch (_context.prev = _context.next) {
|
|
327
|
+
case 0:
|
|
328
|
+
if (!Array.isArray(options)) {
|
|
329
|
+
_context.next = 2;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return _context.abrupt("return", options);
|
|
334
|
+
|
|
335
|
+
case 2:
|
|
336
|
+
if (!(Array.isArray(children) || _typeof(children) === 'object')) {
|
|
337
|
+
_context.next = 4;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return _context.abrupt("return", Array.isArray(children) ? children.map(function (child) {
|
|
342
|
+
return {
|
|
343
|
+
label: child.props.children,
|
|
344
|
+
value: child.props.value
|
|
345
|
+
};
|
|
346
|
+
}) : [{
|
|
347
|
+
label: children.props.children,
|
|
348
|
+
value: children.props.value
|
|
349
|
+
}]);
|
|
350
|
+
|
|
351
|
+
case 4:
|
|
352
|
+
if (!Array.isArray(optionsFromGetOptions)) {
|
|
353
|
+
_context.next = 6;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return _context.abrupt("return", optionsFromGetOptions);
|
|
358
|
+
|
|
359
|
+
case 6:
|
|
360
|
+
if (!optionGroups) {
|
|
361
|
+
_context.next = 10;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (!dependFieldValue) {
|
|
366
|
+
_context.next = 10;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
group = optionGroups.find(function (_ref13) {
|
|
371
|
+
var parentKey = _ref13.parentKey;
|
|
372
|
+
return Array.isArray(dependFieldValue) ? dependFieldValue.includes(parentKey) : parentKey === dependFieldValue;
|
|
373
|
+
});
|
|
374
|
+
return _context.abrupt("return", (group === null || group === void 0 ? void 0 : group.options) || []);
|
|
375
|
+
|
|
376
|
+
case 10:
|
|
377
|
+
if (!(selectDatasourceApi && datasourceKey)) {
|
|
378
|
+
_context.next = 27;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
query = Array.isArray(dependFieldValue) ? dependFieldValue.map(function (v) {
|
|
383
|
+
return "parent=".concat(v);
|
|
384
|
+
}).join('&') : dependFieldValue ? "parent=".concat(dependFieldValue) : '';
|
|
385
|
+
api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
|
|
386
|
+
_context.prev = 13;
|
|
387
|
+
_context.next = 16;
|
|
388
|
+
return fetch(query ? "".concat(api, "?").concat(query) : api);
|
|
389
|
+
|
|
390
|
+
case 16:
|
|
391
|
+
rst = _context.sent;
|
|
392
|
+
_context.next = 19;
|
|
393
|
+
return rst.json();
|
|
394
|
+
|
|
395
|
+
case 19:
|
|
396
|
+
_yield$rst$json = _context.sent;
|
|
397
|
+
data = _yield$rst$json.data;
|
|
398
|
+
return _context.abrupt("return", data || []);
|
|
399
|
+
|
|
400
|
+
case 24:
|
|
401
|
+
_context.prev = 24;
|
|
402
|
+
_context.t0 = _context["catch"](13);
|
|
403
|
+
return _context.abrupt("return", []);
|
|
404
|
+
|
|
405
|
+
case 27:
|
|
406
|
+
return _context.abrupt("return", []);
|
|
407
|
+
|
|
408
|
+
case 28:
|
|
409
|
+
case "end":
|
|
410
|
+
return _context.stop();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}, _callee, null, [[13, 24]]);
|
|
414
|
+
}));
|
|
415
|
+
|
|
416
|
+
return function calcOptions() {
|
|
417
|
+
return _ref12.apply(this, arguments);
|
|
418
|
+
};
|
|
419
|
+
}();
|
|
420
|
+
|
|
421
|
+
var compareOptions = function compareOptions(newOptions) {
|
|
422
|
+
var updateOptions = _options.length !== newOptions.length;
|
|
423
|
+
|
|
424
|
+
if (!updateOptions) {
|
|
425
|
+
for (var i = 0; i < _options.length; i++) {
|
|
426
|
+
var newOption = _options[i];
|
|
427
|
+
var originOption = newOptions[i];
|
|
428
|
+
|
|
429
|
+
if (newOption.label !== originOption.label || newOption.value !== originOption.value) {
|
|
430
|
+
updateOptions = true;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (updateOptions) {
|
|
437
|
+
setOptions(newOptions);
|
|
438
|
+
var setFieldValue = rest.setFieldValue;
|
|
439
|
+
|
|
440
|
+
if (clearWhenOptionsUpdated) {
|
|
441
|
+
typeof setFieldValue === 'function' && setFieldValue();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
calcOptions().then(compareOptions);
|
|
447
|
+
}, [options, optionGroups, dependFieldValue, optionsFromGetOptions]);
|
|
448
|
+
return _jsx(IglooSelect, _objectSpread({
|
|
449
|
+
options: _options
|
|
450
|
+
}, rest));
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
AttachedSelect.formItemPropsHandler = function (config) {
|
|
351
454
|
return {};
|
|
352
455
|
};
|
|
353
456
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
export default
|
|
457
|
+
AttachedSelect.Option = Option;
|
|
458
|
+
AttachedSelect.OptGroup = OptGroup;
|
|
459
|
+
export default AttachedSelect;
|
package/es/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { FormItemProps, FormInstance } from 'antd/es/form';
|
|
4
4
|
import { NamePath } from 'rc-field-form/lib/interface';
|
|
5
5
|
import { CheckboxOptionType } from 'antd/es/checkbox';
|
|
6
|
+
import { SelectProps } from 'antd/es/select';
|
|
6
7
|
export declare type FormItemName = NamePath;
|
|
7
8
|
export interface FormBasicConfig {
|
|
8
9
|
className?: string;
|
|
@@ -25,6 +26,7 @@ export interface FormBasicConfig {
|
|
|
25
26
|
getScrollContainer?: () => HTMLElement | null;
|
|
26
27
|
onFirstModified?: () => any;
|
|
27
28
|
uploadApi?: string;
|
|
29
|
+
selectDatasourceApi?: string;
|
|
28
30
|
}
|
|
29
31
|
export declare type FormItemAssert = {
|
|
30
32
|
field: NamePath;
|
|
@@ -79,7 +81,7 @@ export interface FormItemExtraConfig extends FormItemProps {
|
|
|
79
81
|
content: any;
|
|
80
82
|
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
81
83
|
};
|
|
82
|
-
})[];
|
|
84
|
+
})[] | SelectProps['options'];
|
|
83
85
|
sendOtp?: (value: any) => any;
|
|
84
86
|
dependField?: FormItemName;
|
|
85
87
|
countDownSeconds?: number;
|