@zat-design/sisyphus-react 3.6.5-beta.1 → 3.6.5-beta.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.
- package/es/ProAction/index.js +4 -4
- package/es/ProDownload/index.d.ts +1 -1
- package/es/ProEditTable/components/ActionButton/index.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/BaseTable.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/BaseTable.js +75 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +7 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.js +90 -0
- package/es/ProEditTable/components/RcTable/VirtualTable1.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/VirtualTable1.js +86 -0
- package/es/ProEditTable/components/RcTable/index.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/index.js +6 -0
- package/es/ProEditTable/components/RenderField/index.d.ts +1 -1
- package/es/ProEditTable/components/RenderField/index.js +26 -18
- package/es/ProEditTable/components/RenderToolbar/index.d.ts +3 -2
- package/es/ProEditTable/components/RenderToolbar/index.js +2 -2
- package/es/ProEditTable/components/Summary/index.d.ts +1 -1
- package/es/ProEditTable/index.js +33 -55
- package/es/ProEditTable/propsType.d.ts +6 -0
- package/es/ProEditTable/utils/config.d.ts +1 -1
- package/es/ProEditTable/utils/config.js +2 -2
- package/es/ProEditTable/utils/tools.js +3 -3
- package/es/ProEnum/components/Group.d.ts +1 -1
- package/es/ProEnum/components/Tag.d.ts +1 -1
- package/es/ProEnum/index.d.ts +2 -2
- package/es/ProEnum/utils/eventCenter.js +1 -2
- package/es/ProEnum/utils/getEnumLabel.d.ts +1 -1
- package/es/ProForm/components/base/Input/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProCascader/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProCascader/index.js +7 -7
- package/es/ProForm/components/old/InputRange/index.d.ts +1 -1
- package/es/ProForm/components/old/InputWithSuffix/index.d.ts +1 -1
- package/es/ProForm/components/old/ProAddress/index.d.ts +1 -2
- package/es/ProForm/components/old/ProRangeBox/index.d.ts +1 -2
- package/es/ProForm/index.d.ts +3 -2
- package/es/ProForm/index.js +3 -17
- package/es/ProForm/utils/index.js +14 -10
- package/es/ProForm/utils/useShouldUpdate.js +9 -1
- package/es/ProForm/utils/useWatch.d.ts +7 -0
- package/es/ProForm/utils/useWatch.js +77 -0
- package/es/ProIcon/utils/index.js +4 -3
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +3 -3
- package/es/ProLayout/components/ProCollapse/index.d.ts +1 -1
- package/es/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/es/ProLayout/index.d.ts +4 -4
- package/es/ProLayout/utils/index.js +9 -9
- package/es/ProSelect/components/AdaptiveTooltip.d.ts +1 -1
- package/es/ProSelect/index.d.ts +1 -1
- package/es/ProStep/components/Anchor/index.d.ts +1 -1
- package/es/ProStep/components/Item/index.d.ts +1 -1
- package/es/ProStep/components/Step/index.d.ts +1 -1
- package/es/ProStep/index.d.ts +2 -2
- package/es/ProTable/components/ResizableLine/index.d.ts +1 -1
- package/es/ProTable/components/TableResizable/index.d.ts +1 -1
- package/es/ProTable/index.d.ts +1 -1
- package/es/ProTable/utils.js +4 -4
- package/es/ProTabs/components/Card/index.d.ts +1 -1
- package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/es/ProThemeTools/index.d.ts +1 -1
- package/es/ProTooltip/index.d.ts +1 -1
- package/es/ProTree/components/CloseIcon.d.ts +1 -2
- package/es/ProTree/components/List.d.ts +1 -1
- package/es/ProTree/components/ProTree.d.ts +1 -1
- package/es/ProTree/components/ProTreeSelect/index.d.ts +1 -1
- package/es/ProTree/components/ProTreeSelect/index.js +33 -22
- package/es/ProTree/components/SearchTitle.d.ts +1 -1
- package/es/ProTree/components/Tree.d.ts +1 -1
- package/es/ProTree/components/Tree.js +3 -3
- package/es/ProTree/index.d.ts +1 -1
- package/es/ProTree/utils.js +12 -11
- package/es/ProTreeModal/components/Cascader.d.ts +1 -1
- package/es/ProTreeModal/components/CloseIcon.d.ts +1 -2
- package/es/ProTreeModal/components/SearchTitle.d.ts +1 -1
- package/es/ProTreeModal/components/Tree.js +6 -6
- package/es/ProTreeModal/components/Trigger.d.ts +1 -1
- package/es/ProTreeModal/index.d.ts +1 -1
- package/es/ProTreeModal/utils.js +12 -11
- package/es/ProUpload/components/DraggableUploadListItem.d.ts +1 -1
- package/lib/ProAction/index.js +4 -4
- package/lib/ProDownload/index.d.ts +1 -1
- package/lib/ProEditTable/components/ActionButton/index.d.ts +1 -1
- package/lib/ProEditTable/components/RcTable/BaseTable.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/BaseTable.js +81 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.d.ts +7 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +96 -0
- package/lib/ProEditTable/components/RcTable/VirtualTable1.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/VirtualTable1.js +93 -0
- package/lib/ProEditTable/components/RcTable/index.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/index.js +27 -0
- package/lib/ProEditTable/components/RenderField/index.d.ts +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +26 -18
- package/lib/ProEditTable/components/RenderToolbar/index.d.ts +3 -2
- package/lib/ProEditTable/components/RenderToolbar/index.js +3 -2
- package/lib/ProEditTable/components/Summary/index.d.ts +1 -1
- package/lib/ProEditTable/index.js +32 -52
- package/lib/ProEditTable/propsType.d.ts +6 -0
- package/lib/ProEditTable/utils/config.d.ts +1 -1
- package/lib/ProEditTable/utils/config.js +2 -2
- package/lib/ProEditTable/utils/tools.js +3 -3
- package/lib/ProEnum/components/Group.d.ts +1 -1
- package/lib/ProEnum/components/Tag.d.ts +1 -1
- package/lib/ProEnum/index.d.ts +2 -2
- package/lib/ProEnum/utils/eventCenter.js +1 -2
- package/lib/ProEnum/utils/getEnumLabel.d.ts +1 -1
- package/lib/ProForm/components/base/Input/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProCascader/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProCascader/index.js +7 -7
- package/lib/ProForm/components/old/InputRange/index.d.ts +1 -1
- package/lib/ProForm/components/old/InputWithSuffix/index.d.ts +1 -1
- package/lib/ProForm/components/old/ProAddress/index.d.ts +1 -2
- package/lib/ProForm/components/old/ProRangeBox/index.d.ts +1 -2
- package/lib/ProForm/index.d.ts +3 -2
- package/lib/ProForm/index.js +2 -16
- package/lib/ProForm/utils/index.js +10 -10
- package/lib/ProForm/utils/useShouldUpdate.js +9 -1
- package/lib/ProForm/utils/useWatch.d.ts +7 -0
- package/lib/ProForm/utils/useWatch.js +87 -0
- package/lib/ProIcon/utils/index.js +3 -3
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +1 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +3 -3
- package/lib/ProLayout/components/ProCollapse/index.d.ts +1 -1
- package/lib/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/lib/ProLayout/components/ProHeader/components/Copy/index.d.ts +1 -1
- package/lib/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/lib/ProLayout/index.d.ts +4 -4
- package/lib/ProLayout/utils/index.js +9 -9
- package/lib/ProSelect/components/AdaptiveTooltip.d.ts +1 -1
- package/lib/ProSelect/index.d.ts +1 -1
- package/lib/ProStep/components/Anchor/index.d.ts +1 -1
- package/lib/ProStep/components/Item/index.d.ts +1 -1
- package/lib/ProStep/components/Step/index.d.ts +1 -1
- package/lib/ProStep/index.d.ts +2 -2
- package/lib/ProTable/components/ResizableLine/index.d.ts +1 -1
- package/lib/ProTable/components/TableResizable/index.d.ts +1 -1
- package/lib/ProTable/index.d.ts +1 -1
- package/lib/ProTable/utils.js +4 -4
- package/lib/ProTabs/components/Card/index.d.ts +1 -1
- package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/lib/ProThemeTools/index.d.ts +1 -1
- package/lib/ProTooltip/index.d.ts +1 -1
- package/lib/ProTree/components/CloseIcon.d.ts +1 -2
- package/lib/ProTree/components/List.d.ts +1 -1
- package/lib/ProTree/components/ProTree.d.ts +1 -1
- package/lib/ProTree/components/ProTreeSelect/index.d.ts +1 -1
- package/lib/ProTree/components/ProTreeSelect/index.js +33 -22
- package/lib/ProTree/components/SearchTitle.d.ts +1 -1
- package/lib/ProTree/components/Tree.d.ts +1 -1
- package/lib/ProTree/components/Tree.js +3 -3
- package/lib/ProTree/index.d.ts +1 -1
- package/lib/ProTree/utils.js +11 -11
- package/lib/ProTreeModal/components/Cascader.d.ts +1 -1
- package/lib/ProTreeModal/components/CloseIcon.d.ts +1 -2
- package/lib/ProTreeModal/components/SearchTitle.d.ts +1 -1
- package/lib/ProTreeModal/components/Tree.js +6 -6
- package/lib/ProTreeModal/components/Trigger.d.ts +1 -1
- package/lib/ProTreeModal/index.d.ts +1 -1
- package/lib/ProTreeModal/utils.js +11 -11
- package/lib/ProUpload/components/DraggableUploadListItem.d.ts +1 -1
- package/package.json +3 -2
|
@@ -23,9 +23,10 @@ var _components = require("./components");
|
|
|
23
23
|
var _ProForm = _interopRequireDefault(require("../ProForm"));
|
|
24
24
|
var _empty = _interopRequireDefault(require("../assets/empty.png"));
|
|
25
25
|
var _locale = _interopRequireWildcard(require("../locale"));
|
|
26
|
-
var
|
|
26
|
+
var _RcTable = require("./components/RcTable");
|
|
27
|
+
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
|
|
27
28
|
var ProEditTable = function ProEditTable(_ref, ref) {
|
|
28
|
-
var _resetProps$id, _resetProps$id$split, _themeConfig$data2
|
|
29
|
+
var _resetProps$id, _resetProps$id$split, _themeConfig$data2;
|
|
29
30
|
var value = _ref.value,
|
|
30
31
|
onChange = _ref.onChange,
|
|
31
32
|
onDrag = _ref.onDrag,
|
|
@@ -35,6 +36,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
35
36
|
mode = _ref.mode,
|
|
36
37
|
stripe = _ref.stripe,
|
|
37
38
|
draggable = _ref.draggable,
|
|
39
|
+
virtual = _ref.virtual,
|
|
38
40
|
disabled = _ref.disabled,
|
|
39
41
|
insertType = _ref.insertType,
|
|
40
42
|
emptyBtnText = _ref.emptyBtnText,
|
|
@@ -327,62 +329,39 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
327
329
|
rowSelection: renderRowSelection()
|
|
328
330
|
});
|
|
329
331
|
} : summary;
|
|
332
|
+
var TableComponent = draggable ? _RcTable.DraggableTable : virtual ? _RcTable.VirtualTable1 : _RcTable.BaseTable;
|
|
330
333
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
331
334
|
children: [(0, _jsxRuntime.jsxs)(_antd.ConfigProvider, {
|
|
332
335
|
renderEmpty: (value === null || value === void 0 ? void 0 : value.length) ? undefined : empty,
|
|
333
|
-
children: [(0, _jsxRuntime.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
ref: tableRef,
|
|
336
|
+
children: [(0, _jsxRuntime.jsx)(TableComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), {}, {
|
|
337
|
+
draggableProps: {
|
|
338
|
+
onChange: onChange,
|
|
339
|
+
onDrag: onDrag,
|
|
340
|
+
draggable: draggable
|
|
341
|
+
},
|
|
342
|
+
tableProps: {
|
|
343
|
+
value: value,
|
|
344
|
+
headerRender: headerRender,
|
|
345
|
+
tableRef: tableRef,
|
|
344
346
|
className: _className,
|
|
345
|
-
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
346
347
|
columns: _columns,
|
|
347
|
-
|
|
348
|
+
renderRowSelection: renderRowSelection,
|
|
348
349
|
rowClassName: _rowClassName,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
current: page.pageNum,
|
|
365
|
-
pageSize: page.pageSize,
|
|
366
|
-
showSizeChanger: false,
|
|
367
|
-
showQuickJumper: true,
|
|
368
|
-
total: value === null || value === void 0 ? void 0 : value.length,
|
|
369
|
-
showTotal: function showTotal(total) {
|
|
370
|
-
var _locale$ProEditTable;
|
|
371
|
-
if (!total) return;
|
|
372
|
-
return (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProEditTable = _locale.default.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
373
|
-
total: total
|
|
374
|
-
});
|
|
375
|
-
},
|
|
376
|
-
onChange: handlePageChange
|
|
377
|
-
}, pagination) : false,
|
|
378
|
-
rowKey: "rowKey",
|
|
379
|
-
scroll: {
|
|
380
|
-
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
381
|
-
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
382
|
-
},
|
|
383
|
-
summary: _summary
|
|
384
|
-
}))]
|
|
385
|
-
}), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
350
|
+
disabled: disabled,
|
|
351
|
+
virtualKey: virtualKey,
|
|
352
|
+
editingKeys: editingKeys,
|
|
353
|
+
isHideCheckBox: isHideCheckBox,
|
|
354
|
+
rowDraggable: rowDraggable,
|
|
355
|
+
pagination: pagination,
|
|
356
|
+
scroll: scroll,
|
|
357
|
+
summary: _summary,
|
|
358
|
+
page: page,
|
|
359
|
+
formatMessage: _locale.formatMessage,
|
|
360
|
+
locale: _locale.default,
|
|
361
|
+
handlePageChange: handlePageChange,
|
|
362
|
+
empty: empty
|
|
363
|
+
}
|
|
364
|
+
})), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
386
365
|
ref: affixRef
|
|
387
366
|
}, _toolbarSticky), {}, {
|
|
388
367
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
@@ -415,6 +394,7 @@ ForwardProEditTable.defaultProps = {
|
|
|
415
394
|
toolbarProps: [],
|
|
416
395
|
disabled: false,
|
|
417
396
|
draggable: false,
|
|
397
|
+
virtual: false,
|
|
418
398
|
stripe: true,
|
|
419
399
|
emptyBtnText: _locale.default.ProEditTable.clickAdd,
|
|
420
400
|
onlyOneLineMsg: _locale.default.ProEditTable.onlyOneLineMsg,
|
|
@@ -100,6 +100,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
|
100
100
|
hiddenNames?: NamePath[] | NamePath[][];
|
|
101
101
|
rules?: ProRule[] | RulesFn<T>;
|
|
102
102
|
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
|
|
103
|
+
validateTrigger?: string | string[];
|
|
103
104
|
[key: string]: any;
|
|
104
105
|
}
|
|
105
106
|
export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
|
|
@@ -191,6 +192,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
191
192
|
* @default -
|
|
192
193
|
*/
|
|
193
194
|
draggable?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* @description 是否开启虚拟列表(scroll,x,y必须为固定值)
|
|
197
|
+
* @default -
|
|
198
|
+
*/
|
|
199
|
+
virtual?: boolean;
|
|
194
200
|
/**
|
|
195
201
|
* @description 空列表状态时,自定义添加按钮
|
|
196
202
|
* @default 点击添加
|
|
@@ -9,7 +9,7 @@ export declare const defaultBtnNameMap: {
|
|
|
9
9
|
custom: any;
|
|
10
10
|
};
|
|
11
11
|
export declare const iconMap: {
|
|
12
|
-
add: JSX.Element;
|
|
12
|
+
add: import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
};
|
|
14
14
|
export declare const defaultSingleActionKeys: string[];
|
|
15
15
|
export declare const defaultMultipleActionKeys: string[];
|
|
@@ -173,7 +173,7 @@ var actions = exports.actions = {
|
|
|
173
173
|
},
|
|
174
174
|
add: function () {
|
|
175
175
|
var _add = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(_ref5) {
|
|
176
|
-
var _tableRef$current$
|
|
176
|
+
var _tableRef$current, _tableRef$current$chi, _tableRef$current$chi2;
|
|
177
177
|
var result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, _ref5$prefixCls, prefixCls, nextData, rowKey, addData, nextEditingKeys;
|
|
178
178
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
179
179
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -206,7 +206,7 @@ var actions = exports.actions = {
|
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
form.setFieldValue(name, nextData);
|
|
209
|
-
(_tableRef$current
|
|
209
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$chi = _tableRef$current.children) === null || _tableRef$current$chi === void 0 ? void 0 : (_tableRef$current$chi2 = _tableRef$current$chi.scrollTo) === null || _tableRef$current$chi2 === void 0 ? void 0 : _tableRef$current$chi2.call(_tableRef$current$chi, {
|
|
210
210
|
top: insertType === 'before' ? -10000 : 10000,
|
|
211
211
|
behavior: 'smooth'
|
|
212
212
|
});
|
|
@@ -12,14 +12,14 @@ var getRandom = exports.getRandom = function getRandom() {
|
|
|
12
12
|
};
|
|
13
13
|
// 深层次对比两个对象且取出来差异值
|
|
14
14
|
var difference = exports.difference = function difference(object, base) {
|
|
15
|
-
var
|
|
15
|
+
var _changes = function changes(object, base) {
|
|
16
16
|
return (0, _lodash.transform)(object, function (result, value, key) {
|
|
17
17
|
if (!(0, _lodash.isEqual)(value, base[key])) {
|
|
18
|
-
result[key] = (0, _lodash.isObject)(value) && (0, _lodash.isObject)(base[key]) ?
|
|
18
|
+
result[key] = (0, _lodash.isObject)(value) && (0, _lodash.isObject)(base[key]) ? _changes(value, base[key]) : value;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
return
|
|
22
|
+
return _changes(object, base);
|
|
23
23
|
};
|
|
24
24
|
// 数组字段循环校验,解决validateFields无法批量校验的问题
|
|
25
25
|
var customValidate = exports.customValidate = function customValidate(validateKeys, form, rowName) {
|
|
@@ -6,5 +6,5 @@ interface Props extends Pick<ProEnum, 'id' | 'value' | 'onChange' | 'dataSource'
|
|
|
6
6
|
allowClear?: boolean;
|
|
7
7
|
button?: boolean;
|
|
8
8
|
}
|
|
9
|
-
declare const Group: (props: Props) => JSX.Element;
|
|
9
|
+
declare const Group: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export default Group;
|
|
@@ -3,5 +3,5 @@ interface Props extends Pick<ProEnum, 'id' | 'value' | 'onChange' | 'dataSource'
|
|
|
3
3
|
fieldValue: string;
|
|
4
4
|
fieldLabel: string;
|
|
5
5
|
}
|
|
6
|
-
declare const ProEnumTag: (props: Props) => JSX.Element;
|
|
6
|
+
declare const ProEnumTag: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default ProEnumTag;
|
package/lib/ProEnum/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import useEnum from './hooks/useEnum';
|
|
|
2
2
|
import { ProEnumProps } from './propsType';
|
|
3
3
|
import './style/index.less';
|
|
4
4
|
declare const ProEnum: {
|
|
5
|
-
(props: ProEnumProps): JSX.Element;
|
|
6
|
-
getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => JSX.Element;
|
|
5
|
+
(props: ProEnumProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
useEnum: typeof useEnum;
|
|
8
8
|
};
|
|
9
9
|
export default ProEnum;
|
|
@@ -10,7 +10,7 @@ var SimpleEventCenter = /*#__PURE__*/function () {
|
|
|
10
10
|
this.events = void 0;
|
|
11
11
|
this.events = new Map();
|
|
12
12
|
}
|
|
13
|
-
(0, _createClass2.default)(SimpleEventCenter, [{
|
|
13
|
+
return (0, _createClass2.default)(SimpleEventCenter, [{
|
|
14
14
|
key: "subscribe",
|
|
15
15
|
value: function subscribe(eventName, callback) {
|
|
16
16
|
if (!this.events.has(eventName)) {
|
|
@@ -37,6 +37,5 @@ var SimpleEventCenter = /*#__PURE__*/function () {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}]);
|
|
40
|
-
return SimpleEventCenter;
|
|
41
40
|
}(); // 将 eventCenter 实例添加到 window 对象上
|
|
42
41
|
window.eventCenter = new SimpleEventCenter();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => JSX.Element;
|
|
1
|
+
declare const getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default getEnumLabel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ProCascaderProps } from './propsType';
|
|
3
|
-
declare const _default: import("react").MemoExoticComponent<(props: ProCascaderProps) => JSX.Element>;
|
|
3
|
+
declare const _default: import("react").MemoExoticComponent<(props: ProCascaderProps) => import("react/jsx-runtime").JSX.Element>;
|
|
4
4
|
export default _default;
|
|
@@ -28,9 +28,9 @@ var defaultFieldNames = {
|
|
|
28
28
|
value: 'code',
|
|
29
29
|
children: 'children'
|
|
30
30
|
};
|
|
31
|
-
var
|
|
31
|
+
var _filterDataSource = function filterDataSource(dataSource, level, fieldNames) {
|
|
32
32
|
return dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
33
|
-
return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, item), {}, (0, _defineProperty2.default)({}, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children', level === 1 ? [] :
|
|
33
|
+
return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, item), {}, (0, _defineProperty2.default)({}, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children', level === 1 ? [] : _filterDataSource(item === null || item === void 0 ? void 0 : item[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'], level - 1, fieldNames)));
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
var getViewLabel = function getViewLabel(_ref) {
|
|
@@ -94,7 +94,7 @@ var ProCascader = function ProCascader(props) {
|
|
|
94
94
|
enumDataSource = _ref5$ === void 0 ? [] : _ref5$;
|
|
95
95
|
var realDataSource = (0, _react.useMemo)(function () {
|
|
96
96
|
var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
|
|
97
|
-
var result = isAddressMode && realLevel === 2 ?
|
|
97
|
+
var result = isAddressMode && realLevel === 2 ? _filterDataSource(innerDataSource, level, fieldNames) : innerDataSource;
|
|
98
98
|
return (0, _index.transformDataName)(result, fieldNames);
|
|
99
99
|
}, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
|
|
100
100
|
var _useRequest = (0, _objectSpread3.default)({}, useRequest),
|
|
@@ -129,7 +129,7 @@ var ProCascader = function ProCascader(props) {
|
|
|
129
129
|
value: fieldNames.value,
|
|
130
130
|
children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
|
|
131
131
|
});
|
|
132
|
-
serviceData = isAddressMode && realLevel === 2 ?
|
|
132
|
+
serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
|
|
133
133
|
setServiceData(serviceData);
|
|
134
134
|
case 9:
|
|
135
135
|
case "end":
|
|
@@ -194,7 +194,7 @@ var ProCascader = function ProCascader(props) {
|
|
|
194
194
|
})) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
|
|
195
195
|
return !!item;
|
|
196
196
|
})) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
|
|
197
|
-
var
|
|
197
|
+
var _findSelectedOptions = function findSelectedOptions(options, value) {
|
|
198
198
|
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
199
199
|
var _value = value !== null && value !== void 0 ? value : [];
|
|
200
200
|
// 基准情况:如果 value 数组为空,且 path 不为空,说明找到了完整的路径
|
|
@@ -213,7 +213,7 @@ var ProCascader = function ProCascader(props) {
|
|
|
213
213
|
if (foundOption) {
|
|
214
214
|
// 如果找到了匹配的选项,并且还有更多的 value 需要匹配,递归地在子选项中查找
|
|
215
215
|
if (_value.length > 1 && foundOption.children) {
|
|
216
|
-
return
|
|
216
|
+
return _findSelectedOptions(foundOption.children, _value.slice(1), [].concat((0, _toConsumableArray2.default)(path), [foundOption]));
|
|
217
217
|
}
|
|
218
218
|
// 如果没有更多的 value 需要匹配,返回当前选项(以及之前的路径)
|
|
219
219
|
return [].concat((0, _toConsumableArray2.default)(path), [foundOption]);
|
|
@@ -221,7 +221,7 @@ var ProCascader = function ProCascader(props) {
|
|
|
221
221
|
// 如果没有在当前层级的选项中找到匹配的 value,返回 null
|
|
222
222
|
return null;
|
|
223
223
|
};
|
|
224
|
-
var _selectedOptions =
|
|
224
|
+
var _selectedOptions = _findSelectedOptions(service ? serviceData : realDataSource, addressValue);
|
|
225
225
|
var handleAddressChange = function handleAddressChange(e) {
|
|
226
226
|
var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
|
|
227
227
|
if (onChange) {
|
|
@@ -12,5 +12,5 @@ export interface InputRangeProps {
|
|
|
12
12
|
isPositiveInteger?: boolean;
|
|
13
13
|
precision?: number;
|
|
14
14
|
}
|
|
15
|
-
declare const InputRange: ({ value, onChange, min, max, group, disabled, precision, isPositiveInteger, }: InputRangeProps) => JSX.Element;
|
|
15
|
+
declare const InputRange: ({ value, onChange, min, max, group, disabled, precision, isPositiveInteger, }: InputRangeProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export default InputRange;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ProAddressPropsType } from './propsTypes';
|
|
3
2
|
export declare const transferAddressInfoToRegion: () => {
|
|
4
3
|
normalize: (value: any) => {
|
|
@@ -24,5 +23,5 @@ export declare const transferAddressInfoToRegion: () => {
|
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
|
-
export declare function ProAddress({ ...props }: ProAddressPropsType): JSX.Element;
|
|
26
|
+
export declare function ProAddress({ ...props }: ProAddressPropsType): import("react/jsx-runtime").JSX.Element;
|
|
28
27
|
export default ProAddress;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ProRangeBoxPropsType } from './propsType';
|
|
3
|
-
export default function ProRangeBox({ configOption }: ProRangeBoxPropsType): JSX.Element;
|
|
2
|
+
export default function ProRangeBox({ configOption }: ProRangeBoxPropsType): import("react/jsx-runtime").JSX.Element;
|
package/lib/ProForm/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormInstance } from 'antd';
|
|
2
2
|
import React, { ForwardRefRenderFunction } from 'react';
|
|
3
3
|
import { FormProviderProps } from 'antd/es/form/context';
|
|
4
4
|
import { ProFormProps } from './propsType';
|
|
5
5
|
import { useForm } from './utils/useForm';
|
|
6
|
+
import useWatch from './utils/useWatch';
|
|
6
7
|
interface IProForm<T = any> extends ForwardRefRenderFunction<FormInstance<T>, ProFormProps<T>> {
|
|
7
8
|
useForm: typeof useForm;
|
|
8
|
-
useWatch: typeof
|
|
9
|
+
useWatch: typeof useWatch;
|
|
9
10
|
[key: string]: any;
|
|
10
11
|
}
|
|
11
12
|
declare const ProFormForward: IProForm;
|
package/lib/ProForm/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var _index = require("./utils/index");
|
|
|
24
24
|
var _useForm3 = require("./utils/useForm");
|
|
25
25
|
var _useFieldProps = require("./utils/useFieldProps");
|
|
26
26
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
27
|
+
var _useWatch = _interopRequireDefault(require("./utils/useWatch"));
|
|
27
28
|
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError", "optimize"];
|
|
28
29
|
var ProForm = function ProForm(props, ref) {
|
|
29
30
|
var _forms$formKey, _localStorage, _ref;
|
|
@@ -274,22 +275,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
274
275
|
// @ts-ignore
|
|
275
276
|
var ProFormForward = /*#__PURE__*/(0, _react.forwardRef)(ProForm);
|
|
276
277
|
ProFormForward.useForm = _useForm3.useForm;
|
|
277
|
-
ProFormForward.useWatch =
|
|
278
|
-
if ((0, _lodash.isString)(watchValue)) {
|
|
279
|
-
var watchValues = [watchValue];
|
|
280
|
-
watchValues.forEach(function (item) {
|
|
281
|
-
_antd.Form.useWatch(item, form);
|
|
282
|
-
});
|
|
283
|
-
return form.getFieldsValue(watchValues);
|
|
284
|
-
}
|
|
285
|
-
if (watchValue.length) {
|
|
286
|
-
watchValue.forEach(function (item) {
|
|
287
|
-
_antd.Form.useWatch(item, form);
|
|
288
|
-
});
|
|
289
|
-
return form.getFieldsValue(watchValue);
|
|
290
|
-
}
|
|
291
|
-
return _antd.Form.useWatch([], form);
|
|
292
|
-
};
|
|
278
|
+
ProFormForward.useWatch = _useWatch.default;
|
|
293
279
|
var ProFormProvider = exports.ProFormProvider = function ProFormProvider(props) {
|
|
294
280
|
var onFormChange = props.onFormChange,
|
|
295
281
|
onFormFinish = props.onFormFinish,
|
|
@@ -139,7 +139,7 @@ var splitNameStr = exports.splitNameStr = function splitNameStr(name) {
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
// 过滤掉字段名中包含 '-' 的字段
|
|
142
|
-
var
|
|
142
|
+
var _filterInternalFields = exports.filterInternalFields = function filterInternalFields(values, optimize) {
|
|
143
143
|
if (optimize) {
|
|
144
144
|
return values;
|
|
145
145
|
}
|
|
@@ -153,20 +153,20 @@ var filterInternalFields = exports.filterInternalFields = function filterInterna
|
|
|
153
153
|
}
|
|
154
154
|
if (Array.isArray(nextValues)) {
|
|
155
155
|
return nextValues.map(function (item) {
|
|
156
|
-
return
|
|
156
|
+
return _filterInternalFields(item);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
if ((0, _lodash.isObject)(nextValues)) {
|
|
160
160
|
var result = {};
|
|
161
161
|
Object.keys(nextValues).forEach(function (key) {
|
|
162
162
|
if (key.includes('-')) return;
|
|
163
|
-
result[key] =
|
|
163
|
+
result[key] = _filterInternalFields(nextValues[key]);
|
|
164
164
|
});
|
|
165
165
|
return result;
|
|
166
166
|
}
|
|
167
167
|
return nextValues;
|
|
168
168
|
};
|
|
169
|
-
var
|
|
169
|
+
var _getAllNamePath = exports.getAllNamePath = function getAllNamePath(object) {
|
|
170
170
|
var currentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
171
171
|
var keys = Object.keys(object);
|
|
172
172
|
var resultKeys = [];
|
|
@@ -180,7 +180,7 @@ var getAllNamePath = exports.getAllNamePath = function getAllNamePath(object) {
|
|
|
180
180
|
}
|
|
181
181
|
// 深度获取对象key
|
|
182
182
|
if ((0, _lodash.isObject)(value)) {
|
|
183
|
-
resultKeys.concat(
|
|
183
|
+
resultKeys.concat(_getAllNamePath(value, [].concat((0, _toConsumableArray2.default)(currentPath), [key])));
|
|
184
184
|
}
|
|
185
185
|
resultKeys.push([].concat((0, _toConsumableArray2.default)(currentPath), [key]));
|
|
186
186
|
});
|
|
@@ -371,7 +371,7 @@ var customEqualForFun = exports.customEqualForFun = function customEqualForFun(v
|
|
|
371
371
|
/**
|
|
372
372
|
* 查询数据中是否包含rowKey
|
|
373
373
|
*/
|
|
374
|
-
var
|
|
374
|
+
var _hasRowKey = exports.hasRowKey = function hasRowKey(obj) {
|
|
375
375
|
if ((0, _typeof2.default)(obj) !== 'object' || obj === null) {
|
|
376
376
|
return false;
|
|
377
377
|
}
|
|
@@ -381,7 +381,7 @@ var hasRowKey = exports.hasRowKey = function hasRowKey(obj) {
|
|
|
381
381
|
return true;
|
|
382
382
|
}
|
|
383
383
|
return keys.some(function (key) {
|
|
384
|
-
return
|
|
384
|
+
return _hasRowKey(obj[key]);
|
|
385
385
|
});
|
|
386
386
|
};
|
|
387
387
|
/**
|
|
@@ -397,7 +397,7 @@ var view = exports.view = function view(obj) {
|
|
|
397
397
|
return true;
|
|
398
398
|
}
|
|
399
399
|
return keys.some(function (key) {
|
|
400
|
-
return
|
|
400
|
+
return _hasRowKey(obj[key]);
|
|
401
401
|
});
|
|
402
402
|
};
|
|
403
403
|
/**
|
|
@@ -433,7 +433,7 @@ var deleteForPath = exports.deleteForPath = function deleteForPath(values, nameP
|
|
|
433
433
|
* @param value 选中值
|
|
434
434
|
* @returns {}
|
|
435
435
|
*/
|
|
436
|
-
var
|
|
436
|
+
var _findOptionByValue = exports.findOptionByValue = function findOptionByValue(treeData, value, fieldNames) {
|
|
437
437
|
if ((0, _lodash.isObject)(value)) {
|
|
438
438
|
return value;
|
|
439
439
|
}
|
|
@@ -443,7 +443,7 @@ var findOptionByValue = exports.findOptionByValue = function findOptionByValue(t
|
|
|
443
443
|
return (0, _lodash.omit)(node, ['children', fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]);
|
|
444
444
|
}
|
|
445
445
|
if (node.children) {
|
|
446
|
-
var foundNode =
|
|
446
|
+
var foundNode = _findOptionByValue(node[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'], value, fieldNames);
|
|
447
447
|
if (foundNode) {
|
|
448
448
|
return (0, _lodash.omit)(foundNode, ['children', fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]);
|
|
449
449
|
}
|
|
@@ -29,6 +29,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
29
29
|
names = formItemProps.names,
|
|
30
30
|
dependencies = formItemProps.dependencies;
|
|
31
31
|
var timerRef = (0, _react.useRef)();
|
|
32
|
+
var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
|
|
32
33
|
var showRef = (0, _react.useRef)();
|
|
33
34
|
var disabledRef = (0, _react.useRef)();
|
|
34
35
|
var requiredRef = (0, _react.useRef)();
|
|
@@ -165,17 +166,24 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
165
166
|
}) : fieldProps;
|
|
166
167
|
// 清值防抖 多次刷新时以最后一次为准
|
|
167
168
|
if (clearNotShow !== false && (name || names)) {
|
|
169
|
+
// 当show为其他变为false的时候记录一次需要清值
|
|
170
|
+
if (_show !== showRef.current && _show === false) {
|
|
171
|
+
needClear.current = true;
|
|
172
|
+
}
|
|
168
173
|
if (_show === false) {
|
|
169
174
|
clearTimeout(timerRef.current);
|
|
170
175
|
timerRef.current = setTimeout(function () {
|
|
176
|
+
if (needClear.current !== true) return;
|
|
171
177
|
if (Array.isArray(names)) {
|
|
172
178
|
form.resetFields(names);
|
|
173
179
|
} else {
|
|
174
180
|
var clearName = formItemProps.namePath ? formItemProps.namePath.slice(0, -1).concat(formItemProps.name) : formItemProps.name;
|
|
175
181
|
form.resetFields([clearName]);
|
|
176
182
|
}
|
|
177
|
-
|
|
183
|
+
needClear.current = false;
|
|
184
|
+
}, 300);
|
|
178
185
|
} else {
|
|
186
|
+
needClear.current = false;
|
|
179
187
|
clearTimeout(timerRef.current);
|
|
180
188
|
}
|
|
181
189
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InternalNamePath, FormInstance, NamePath } from 'rc-field-form/es/interface';
|
|
2
|
+
export declare function toArray<T>(value?: T | T[] | null): T[];
|
|
3
|
+
export declare function getNamePath(path: NamePath | null): InternalNamePath;
|
|
4
|
+
export declare function stringify(value: any): string | number;
|
|
5
|
+
declare function useWatch(dependencies: string, form?: FormInstance, wait?: number): any;
|
|
6
|
+
declare function useWatch(dependencies: NamePath[], form?: FormInstance, wait?: number): any[];
|
|
7
|
+
export default useWatch;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
exports.getNamePath = getNamePath;
|
|
9
|
+
exports.stringify = stringify;
|
|
10
|
+
exports.toArray = toArray;
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
var _FieldContext = require("rc-field-form/es/FieldContext");
|
|
14
|
+
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
|
|
15
|
+
var _react = require("react");
|
|
16
|
+
function toArray(value) {
|
|
17
|
+
if (value === undefined || value === null) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return Array.isArray(value) ? value : [value];
|
|
21
|
+
}
|
|
22
|
+
function getNamePath(path) {
|
|
23
|
+
return toArray(path);
|
|
24
|
+
}
|
|
25
|
+
function stringify(value) {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.stringify(value);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
return Math.random();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// 创建之后namepath就不可变
|
|
33
|
+
var useWatchWarning = process.env.NODE_ENV !== 'production' ? function (namePath) {
|
|
34
|
+
var fullyStr = JSON.stringify(namePath);
|
|
35
|
+
var nameStrRef = (0, _react.useRef)(fullyStr);
|
|
36
|
+
(0, _warning.default)(nameStrRef.current === fullyStr, '`useWatch` is not support dynamic `namePath`. Please provide static instead.');
|
|
37
|
+
} : function () {};
|
|
38
|
+
function useWatch(dependencies, form, wait) {
|
|
39
|
+
var isSingle = typeof dependencies === 'string';
|
|
40
|
+
var _useState = (0, _react.useState)({}),
|
|
41
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
|
+
value = _useState2[0],
|
|
43
|
+
setValue = _useState2[1];
|
|
44
|
+
var valueStr = (0, _react.useMemo)(function () {
|
|
45
|
+
return stringify(value);
|
|
46
|
+
}, [value]);
|
|
47
|
+
var valueStrRef = (0, _react.useRef)(valueStr);
|
|
48
|
+
valueStrRef.current = valueStr;
|
|
49
|
+
var formInstance = form;
|
|
50
|
+
var isValidForm = formInstance && formInstance._init;
|
|
51
|
+
var _dependencies = isSingle ? [dependencies] : dependencies;
|
|
52
|
+
var namePaths = _dependencies === null || _dependencies === void 0 ? void 0 : _dependencies.map(function (item) {
|
|
53
|
+
return getNamePath(item);
|
|
54
|
+
});
|
|
55
|
+
var namePathsRef = (0, _react.useRef)(namePaths);
|
|
56
|
+
namePathsRef.current = namePaths;
|
|
57
|
+
useWatchWarning(namePaths);
|
|
58
|
+
(0, _react.useEffect)(function () {
|
|
59
|
+
if (!isValidForm) return;
|
|
60
|
+
var getFieldsValue = formInstance.getFieldsValue,
|
|
61
|
+
getInternalHooks = formInstance.getInternalHooks;
|
|
62
|
+
var _getInternalHooks = getInternalHooks(_FieldContext.HOOK_MARK),
|
|
63
|
+
registerWatch = _getInternalHooks.registerWatch;
|
|
64
|
+
var callback = function callback() {
|
|
65
|
+
var newValue = getFieldsValue(_dependencies);
|
|
66
|
+
var nextValueStr = stringify(newValue);
|
|
67
|
+
// Compare stringify in case it's nest object
|
|
68
|
+
if (valueStrRef.current !== nextValueStr) {
|
|
69
|
+
valueStrRef.current = nextValueStr;
|
|
70
|
+
setValue(getFieldsValue(_dependencies));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
// 增加防抖
|
|
74
|
+
if (wait) {
|
|
75
|
+
callback = (0, _lodash.debounce)(callback, wait);
|
|
76
|
+
}
|
|
77
|
+
var cancelRegister = registerWatch(callback);
|
|
78
|
+
var initialValue = getFieldsValue(_dependencies);
|
|
79
|
+
setValue(initialValue);
|
|
80
|
+
return cancelRegister;
|
|
81
|
+
},
|
|
82
|
+
// We do not need re-register since namePath content is the same
|
|
83
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
+
[isValidForm]);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
var _default = exports.default = useWatch;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.recurseGetNodes = exports.onBeforeInjection = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _config = require("../config");
|
|
10
|
-
var
|
|
10
|
+
var _recurseGetNodes = exports.recurseGetNodes = function recurseGetNodes(type, node, queue) {
|
|
11
11
|
switch (type) {
|
|
12
12
|
// 渐变
|
|
13
13
|
case 'gradation':
|
|
@@ -26,7 +26,7 @@ var recurseGetNodes = exports.recurseGetNodes = function recurseGetNodes(type, n
|
|
|
26
26
|
}
|
|
27
27
|
if (node.childNodes) {
|
|
28
28
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
29
|
-
|
|
29
|
+
_recurseGetNodes(type, node.childNodes[i], queue);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
};
|
|
@@ -56,7 +56,7 @@ var onBeforeInjection = exports.onBeforeInjection = function onBeforeInjection(_
|
|
|
56
56
|
// 目前只支持处理渐变及fill填充
|
|
57
57
|
var types = Reflect.ownKeys(nodeMap !== null && nodeMap !== void 0 ? nodeMap : {});
|
|
58
58
|
types.forEach(function (typeKey) {
|
|
59
|
-
|
|
59
|
+
_recurseGetNodes(typeKey, svg, nodeMap[typeKey]);
|
|
60
60
|
});
|
|
61
61
|
if ((gradList === null || gradList === void 0 ? void 0 : gradList.length) > 0) {
|
|
62
62
|
nodeMap.gradation.forEach(function (item, index) {
|