linkmore-design 1.1.8 → 1.1.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/CHANGELOG.md +1056 -9
- package/dist/Form/FormItem/index.d.ts +7 -1
- package/dist/Form/demos/ruleTime.d.ts +2 -0
- package/dist/LmUpload/UploadList/ItemPictureCard.d.ts +2 -1
- package/dist/LmUpload/components/Preview.d.ts +5 -0
- package/dist/LmUpload/wrapper/reducer.d.ts +4 -0
- package/dist/index.umd.js +245 -120
- package/dist/index.umd.min.js +8 -8
- package/es/Form/FormItem/index.d.ts +7 -1
- package/es/Form/FormItem/index.js +56 -13
- package/es/LmEditTable/EditTable.js +24 -21
- package/es/LmEditTable/util.js +4 -4
- package/es/LmTable/Table.js +8 -6
- package/es/LmTable/util.js +9 -5
- package/es/LmUpload/LmUpload.js +1 -0
- package/es/LmUpload/UploadList/ItemPictureCard.d.ts +2 -1
- package/es/LmUpload/UploadList/ItemPictureCard.js +16 -4
- package/es/LmUpload/UploadList/index.js +11 -7
- package/es/LmUpload/components/Preview.d.ts +5 -0
- package/es/LmUpload/components/Preview.js +43 -0
- package/es/LmUpload/wrapper/UploadWrapper.js +3 -0
- package/es/LmUpload/wrapper/reducer.d.ts +4 -0
- package/es/LmUpload/wrapper/reducer.js +12 -3
- package/lib/Form/FormItem/index.d.ts +7 -1
- package/lib/Form/FormItem/index.js +58 -14
- package/lib/LmEditTable/EditTable.js +24 -21
- package/lib/LmEditTable/util.js +4 -4
- package/lib/LmTable/Table.js +8 -6
- package/lib/LmTable/util.js +9 -5
- package/lib/LmUpload/LmUpload.js +1 -0
- package/lib/LmUpload/UploadList/ItemPictureCard.d.ts +2 -1
- package/lib/LmUpload/UploadList/ItemPictureCard.js +16 -4
- package/lib/LmUpload/UploadList/index.js +13 -7
- package/lib/LmUpload/components/Preview.d.ts +5 -0
- package/lib/LmUpload/components/Preview.js +55 -0
- package/lib/LmUpload/wrapper/UploadWrapper.js +4 -0
- package/lib/LmUpload/wrapper/reducer.d.ts +4 -0
- package/lib/LmUpload/wrapper/reducer.js +12 -3
- package/package.json +15 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FormInstance } from 'rc-field-form';
|
|
2
2
|
import type { FieldProps } from 'rc-field-form/lib/Field';
|
|
3
|
+
import type { Rule } from 'rc-field-form/lib/interface';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import useFormItemStatus from '../hooks/useFormItemStatus';
|
|
5
6
|
import type { FormItemInputProps } from '../FormItemInput';
|
|
@@ -9,7 +10,10 @@ export declare type ValidateStatus = typeof ValidateStatuses[number];
|
|
|
9
10
|
declare type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
|
|
10
11
|
declare type RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>;
|
|
11
12
|
declare type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
|
|
12
|
-
export
|
|
13
|
+
export declare type LmRule = Rule & {
|
|
14
|
+
time?: number;
|
|
15
|
+
};
|
|
16
|
+
export interface FormItemProps<Values = any> extends FormItemLabelProps, FormItemInputProps, Omit<RcFieldProps<Values>, 'rules'> {
|
|
13
17
|
prefixCls?: string;
|
|
14
18
|
noStyle?: boolean;
|
|
15
19
|
style?: React.CSSProperties;
|
|
@@ -25,6 +29,8 @@ export interface FormItemProps<Values = any> extends FormItemLabelProps, FormIte
|
|
|
25
29
|
tooltip?: LabelTooltipType;
|
|
26
30
|
/** @deprecated No need anymore */
|
|
27
31
|
fieldKey?: React.Key | React.Key[];
|
|
32
|
+
/** 变更 */
|
|
33
|
+
rules?: LmRule[];
|
|
28
34
|
errorPlacement?: string;
|
|
29
35
|
responsive?: boolean;
|
|
30
36
|
}
|
|
@@ -9,15 +9,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
13
|
|
|
16
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
15
|
|
|
16
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
+
|
|
18
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
19
|
+
|
|
18
20
|
var _rcFieldForm = require("rc-field-form");
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _useState7 = _interopRequireDefault(require("rc-util/lib/hooks/useState"));
|
|
21
23
|
|
|
22
24
|
var _ref2 = require("rc-util/lib/ref");
|
|
23
25
|
|
|
@@ -70,6 +72,31 @@ function genEmptyMeta() {
|
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
function getRuleTime(rules) {
|
|
76
|
+
if (!rules) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(rules),
|
|
81
|
+
_step;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
85
|
+
var rule = _step.value;
|
|
86
|
+
|
|
87
|
+
if (rule && (0, _typeof2.default)(rule) === 'object' && rule.time) {
|
|
88
|
+
return rule.time;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
_iterator.e(err);
|
|
93
|
+
} finally {
|
|
94
|
+
_iterator.f();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
73
100
|
function InternalFormItem(props) {
|
|
74
101
|
var name = props.name,
|
|
75
102
|
noStyle = props.noStyle,
|
|
@@ -85,6 +112,17 @@ function InternalFormItem(props) {
|
|
|
85
112
|
trigger = _props$trigger === void 0 ? 'onChange' : _props$trigger,
|
|
86
113
|
validateTrigger = props.validateTrigger,
|
|
87
114
|
hidden = props.hidden;
|
|
115
|
+
var timerRef = (0, React.useRef)(null);
|
|
116
|
+
|
|
117
|
+
var _useState = (0, _useState7.default)([]),
|
|
118
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
119
|
+
mergedErrors = _useState2[0],
|
|
120
|
+
setMergedErrors = _useState2[1];
|
|
121
|
+
|
|
122
|
+
var _useState3 = (0, _useState7.default)([]),
|
|
123
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
124
|
+
mergedWarnings = _useState4[0],
|
|
125
|
+
setMergedWarnings = _useState4[1];
|
|
88
126
|
|
|
89
127
|
var _useContext = (0, React.useContext)(_ConfigProvider.ConfigContext),
|
|
90
128
|
getPrefixCls = _useContext.getPrefixCls;
|
|
@@ -113,12 +151,12 @@ function InternalFormItem(props) {
|
|
|
113
151
|
setSubFieldErrors = _useFrameState2[1]; // >>>>> Current field errors
|
|
114
152
|
|
|
115
153
|
|
|
116
|
-
var
|
|
154
|
+
var _useState5 = (0, _useState7.default)(function () {
|
|
117
155
|
return genEmptyMeta();
|
|
118
156
|
}),
|
|
119
|
-
|
|
120
|
-
meta =
|
|
121
|
-
setMeta =
|
|
157
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
158
|
+
meta = _useState6[0],
|
|
159
|
+
setMeta = _useState6[1];
|
|
122
160
|
|
|
123
161
|
var onMetaChange = function onMetaChange(nextMeta) {
|
|
124
162
|
// This keyInfo is not correct when field is removed
|
|
@@ -171,19 +209,25 @@ function InternalFormItem(props) {
|
|
|
171
209
|
}; // >>>>> Get merged errors
|
|
172
210
|
|
|
173
211
|
|
|
174
|
-
|
|
212
|
+
(0, React.useEffect)(function () {
|
|
175
213
|
var errorList = (0, _toConsumableArray2.default)(meta.errors);
|
|
176
214
|
var warningList = (0, _toConsumableArray2.default)(meta.warnings);
|
|
177
215
|
Object.values(subFieldErrors).forEach(function (subFieldError) {
|
|
178
216
|
errorList.push.apply(errorList, (0, _toConsumableArray2.default)(subFieldError.errors || []));
|
|
179
217
|
warningList.push.apply(warningList, (0, _toConsumableArray2.default)(subFieldError.warnings || []));
|
|
180
218
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
219
|
+
setMergedErrors(errorList);
|
|
220
|
+
setMergedWarnings(warningList);
|
|
221
|
+
var time = getRuleTime(rules);
|
|
222
|
+
|
|
223
|
+
if (time) {
|
|
224
|
+
clearTimeout(timerRef.current);
|
|
225
|
+
timerRef.current = setTimeout(function () {
|
|
226
|
+
setMergedErrors([]);
|
|
227
|
+
setMergedWarnings([]);
|
|
228
|
+
}, time);
|
|
229
|
+
}
|
|
230
|
+
}, [subFieldErrors, meta.errors, meta.warnings]); // ===================== Children Ref =====================
|
|
187
231
|
|
|
188
232
|
var getItemRef = (0, _useItemRef.default)(); // ======================== Render ========================
|
|
189
233
|
|
|
@@ -766,13 +766,15 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
766
766
|
};
|
|
767
767
|
|
|
768
768
|
var onColSortEnd = function onColSortEnd(active, over) {
|
|
769
|
+
var _a;
|
|
770
|
+
|
|
769
771
|
var oldIndex = columns.findIndex(function (item) {
|
|
770
772
|
return item.dataIndex === active;
|
|
771
773
|
});
|
|
772
774
|
var newIndex = columns.findIndex(function (item) {
|
|
773
775
|
return item.dataIndex === over;
|
|
774
776
|
});
|
|
775
|
-
filterChange === null || filterChange === void 0 ? void 0 : filterChange((0, _sortable.arrayMove)(columns, oldIndex, newIndex).map(function (item, index) {
|
|
777
|
+
filterChange === null || filterChange === void 0 ? void 0 : filterChange((_a = (0, _sortable.arrayMove)(columns, oldIndex, newIndex)) === null || _a === void 0 ? void 0 : _a.map(function (item, index) {
|
|
776
778
|
return Object.assign(Object.assign({}, item), {
|
|
777
779
|
order: index
|
|
778
780
|
});
|
|
@@ -806,7 +808,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
806
808
|
dataSourceRef.current = dataSource;
|
|
807
809
|
|
|
808
810
|
if (sortOpen) {
|
|
809
|
-
var dataSourceKeys = dataSource.map(function (item) {
|
|
811
|
+
var dataSourceKeys = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
810
812
|
return item[_rowKey];
|
|
811
813
|
}).join(',');
|
|
812
814
|
var setCallBackFalgKeys = ((_a = sortDataSorceRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
@@ -850,12 +852,12 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
850
852
|
|
|
851
853
|
if ((preKeys === null || preKeys === void 0 ? void 0 : preKeys.length) > 1) {
|
|
852
854
|
var deeps = function deeps(children) {
|
|
853
|
-
children.forEach(function (item) {
|
|
855
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item) {
|
|
854
856
|
var _a;
|
|
855
857
|
|
|
856
858
|
if (preKeys.includes(item[_rowKey])) {
|
|
857
859
|
if (item[_rowKey] === row[_rowKey]) {
|
|
858
|
-
children.forEach(function (c) {
|
|
860
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (c) {
|
|
859
861
|
c[key] = value;
|
|
860
862
|
});
|
|
861
863
|
(_a = Object.keys(item)) === null || _a === void 0 ? void 0 : _a.forEach(function (v) {
|
|
@@ -870,7 +872,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
870
872
|
|
|
871
873
|
deeps(draft);
|
|
872
874
|
} else {
|
|
873
|
-
draft.forEach(function (item, index) {
|
|
875
|
+
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item, index) {
|
|
874
876
|
if (row[_rowKey] === item[_rowKey]) {
|
|
875
877
|
draft[index] = row;
|
|
876
878
|
} else {
|
|
@@ -881,7 +883,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
881
883
|
} else {
|
|
882
884
|
if ((preKeys === null || preKeys === void 0 ? void 0 : preKeys.length) > 1) {
|
|
883
885
|
var _deeps = function _deeps(children) {
|
|
884
|
-
children.forEach(function (item) {
|
|
886
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item) {
|
|
885
887
|
var _a;
|
|
886
888
|
|
|
887
889
|
if (preKeys.includes(item[_rowKey])) {
|
|
@@ -918,7 +920,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
918
920
|
|
|
919
921
|
var reWriteOriginSource = function reWriteOriginSource(rowKey, rowValue, dataIndex, nextValue) {
|
|
920
922
|
setDataSource(function (prevDataSource) {
|
|
921
|
-
return prevDataSource.map(function (item) {
|
|
923
|
+
return prevDataSource === null || prevDataSource === void 0 ? void 0 : prevDataSource.map(function (item) {
|
|
922
924
|
if ((0, _lodash.get)(item, rowKey) === rowValue) {
|
|
923
925
|
(0, _lodash.set)(item, dataIndex, nextValue);
|
|
924
926
|
}
|
|
@@ -937,10 +939,10 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
937
939
|
if (preKeys.length > 1) {
|
|
938
940
|
/** 说明删除的是children中的数据 */
|
|
939
941
|
var filter = function filter(data, key) {
|
|
940
|
-
var newData = data.filter(function (x) {
|
|
942
|
+
var newData = data === null || data === void 0 ? void 0 : data.filter(function (x) {
|
|
941
943
|
return x[_rowKey] !== key;
|
|
942
944
|
});
|
|
943
|
-
newData.forEach(function (x) {
|
|
945
|
+
newData === null || newData === void 0 ? void 0 : newData.forEach(function (x) {
|
|
944
946
|
if (x.children) {
|
|
945
947
|
var c = filter(x.children, key);
|
|
946
948
|
x.children = c;
|
|
@@ -988,13 +990,12 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
988
990
|
var handleTableRowAdd = function handleTableRowAdd(record) {
|
|
989
991
|
var _a, _b;
|
|
990
992
|
|
|
991
|
-
console.log(record, '-rrrrr');
|
|
992
993
|
var preKeys = (_b = (_a = deepDataSourceRef === null || deepDataSourceRef === void 0 ? void 0 : deepDataSourceRef.current) === null || _a === void 0 ? void 0 : _a[record[_rowKey]]) === null || _b === void 0 ? void 0 : _b.preKeys;
|
|
993
994
|
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
994
995
|
if (preKeys.length > 1) {
|
|
995
996
|
var deeps = function deeps(children) {
|
|
996
|
-
children.forEach(function (item, index) {
|
|
997
|
-
if (preKeys.includes(item[_rowKey])) {
|
|
997
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item, index) {
|
|
998
|
+
if (preKeys === null || preKeys === void 0 ? void 0 : preKeys.includes(item[_rowKey])) {
|
|
998
999
|
if (item[_rowKey] === record[_rowKey]) {
|
|
999
1000
|
children.splice(index + 1, 0, (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now())));
|
|
1000
1001
|
} else if (item.children) {
|
|
@@ -1025,7 +1026,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1025
1026
|
|
|
1026
1027
|
var handleCopy = function handleCopy(key, value) {
|
|
1027
1028
|
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
1028
|
-
draft.forEach(function (item) {
|
|
1029
|
+
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item) {
|
|
1029
1030
|
return item[key] = value;
|
|
1030
1031
|
});
|
|
1031
1032
|
});
|
|
@@ -1047,7 +1048,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1047
1048
|
});
|
|
1048
1049
|
|
|
1049
1050
|
if (hasOnlyOptionsDatas.length) {
|
|
1050
|
-
return hasOnlyOptionsDatas.map(function (item) {
|
|
1051
|
+
return hasOnlyOptionsDatas === null || hasOnlyOptionsDatas === void 0 ? void 0 : hasOnlyOptionsDatas.map(function (item) {
|
|
1051
1052
|
return item.dataIndex;
|
|
1052
1053
|
});
|
|
1053
1054
|
}
|
|
@@ -1064,10 +1065,10 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1064
1065
|
|
|
1065
1066
|
if (optionOnly && options) {
|
|
1066
1067
|
var dataIndex = item.dataIndex;
|
|
1067
|
-
var dataIndexData = dataSource.map(function (d) {
|
|
1068
|
+
var dataIndexData = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (d) {
|
|
1068
1069
|
return d[dataIndex];
|
|
1069
1070
|
});
|
|
1070
|
-
var newOptions = options.map(function (o) {
|
|
1071
|
+
var newOptions = options === null || options === void 0 ? void 0 : options.map(function (o) {
|
|
1071
1072
|
return Object.assign(Object.assign({}, o), {
|
|
1072
1073
|
disabled: !!dataIndexData.includes(o === null || o === void 0 ? void 0 : o.value)
|
|
1073
1074
|
});
|
|
@@ -1123,7 +1124,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1123
1124
|
var leftColumns = [];
|
|
1124
1125
|
var mainColumns = [];
|
|
1125
1126
|
var rightColumns = [];
|
|
1126
|
-
localColumns.forEach(function (item) {
|
|
1127
|
+
localColumns === null || localColumns === void 0 ? void 0 : localColumns.forEach(function (item) {
|
|
1127
1128
|
if ((item === null || item === void 0 ? void 0 : item.fixed) === 'left') {
|
|
1128
1129
|
leftColumns.push(item);
|
|
1129
1130
|
} else if ((item === null || item === void 0 ? void 0 : item.fixed) === 'right') {
|
|
@@ -1136,7 +1137,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1136
1137
|
/** 为了支持colums中的分组之后,进行递归处理 */
|
|
1137
1138
|
|
|
1138
1139
|
var mapColumns = function mapColumns(col, index) {
|
|
1139
|
-
var _a;
|
|
1140
|
+
var _a, _b;
|
|
1140
1141
|
|
|
1141
1142
|
if (!col.editable && !((_a = col.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1142
1143
|
return col;
|
|
@@ -1185,7 +1186,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1185
1186
|
});
|
|
1186
1187
|
|
|
1187
1188
|
if (col === null || col === void 0 ? void 0 : col.children) {
|
|
1188
|
-
newCol.children = col.children.map(mapColumns);
|
|
1189
|
+
newCol.children = (_b = col.children) === null || _b === void 0 ? void 0 : _b.map(mapColumns);
|
|
1189
1190
|
}
|
|
1190
1191
|
|
|
1191
1192
|
return newCol;
|
|
@@ -1210,9 +1211,11 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1210
1211
|
}, /*#__PURE__*/_react.default.createElement("tbody", Object.assign({}, props))));
|
|
1211
1212
|
}, [sortEditTable]);
|
|
1212
1213
|
var colDraggableContainer = (0, _react.useCallback)(function (_a) {
|
|
1214
|
+
var _b;
|
|
1215
|
+
|
|
1213
1216
|
var props = __rest(_a, []);
|
|
1214
1217
|
|
|
1215
|
-
return /*#__PURE__*/_react.default.createElement("tr", null, _react.default.Children.map(props.children, function (child) {
|
|
1218
|
+
return /*#__PURE__*/_react.default.createElement("tr", null, (_b = _react.default.Children) === null || _b === void 0 ? void 0 : _b.map(props.children, function (child) {
|
|
1216
1219
|
var _a, _b;
|
|
1217
1220
|
|
|
1218
1221
|
if ((_b = (_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.fixed) {
|
|
@@ -1353,7 +1356,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1353
1356
|
fixed: true,
|
|
1354
1357
|
type: 'checkbox',
|
|
1355
1358
|
columnWidth: 36,
|
|
1356
|
-
selectedRowKeys: localRowSelectList.map(function (v) {
|
|
1359
|
+
selectedRowKeys: localRowSelectList === null || localRowSelectList === void 0 ? void 0 : localRowSelectList.map(function (v) {
|
|
1357
1360
|
return v[_rowKey];
|
|
1358
1361
|
}),
|
|
1359
1362
|
onChange: function onChange(selectedRowKeys, selectedRows) {
|
package/lib/LmEditTable/util.js
CHANGED
|
@@ -24,13 +24,13 @@ function deepDataSourcePreKeys(dataSource, rowKey) {
|
|
|
24
24
|
var deepDataSource = [];
|
|
25
25
|
|
|
26
26
|
var eachChildren = function eachChildren(children, preKeys) {
|
|
27
|
-
children.forEach(function (item) {
|
|
27
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item) {
|
|
28
28
|
deepDataSource.push(Object.assign(Object.assign({}, item), {
|
|
29
|
-
preKeys: [].concat((0, _toConsumableArray2.default)(preKeys), [item[rowKey]])
|
|
29
|
+
preKeys: [].concat((0, _toConsumableArray2.default)(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]])
|
|
30
30
|
}));
|
|
31
31
|
|
|
32
|
-
if (item.children) {
|
|
33
|
-
eachChildren(item.children, [].concat((0, _toConsumableArray2.default)(preKeys), [item[rowKey]])); // deepDataSource.push({ ...item, preKeys: [...preKeys, item[rowKey]] })
|
|
32
|
+
if (item === null || item === void 0 ? void 0 : item.children) {
|
|
33
|
+
eachChildren(item === null || item === void 0 ? void 0 : item.children, [].concat((0, _toConsumableArray2.default)(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]])); // deepDataSource.push({ ...item, preKeys: [...preKeys, item[rowKey]] })
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
package/lib/LmTable/Table.js
CHANGED
|
@@ -310,7 +310,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
310
310
|
var source = [];
|
|
311
311
|
|
|
312
312
|
var deepChildren = function deepChildren(arr) {
|
|
313
|
-
arr.forEach(function (item) {
|
|
313
|
+
arr === null || arr === void 0 ? void 0 : arr.forEach(function (item) {
|
|
314
314
|
source.push((0, _lodash.omit)(item, 'children')); // 展开
|
|
315
315
|
|
|
316
316
|
if ((item === null || item === void 0 ? void 0 : item.children) && expandedRowKeys.includes(item.key)) {
|
|
@@ -327,7 +327,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
327
327
|
var source = [];
|
|
328
328
|
|
|
329
329
|
var deepChildren = function deepChildren(arr) {
|
|
330
|
-
arr.forEach(function (item) {
|
|
330
|
+
arr === null || arr === void 0 ? void 0 : arr.forEach(function (item) {
|
|
331
331
|
if (item.children && item.children.length) {
|
|
332
332
|
deepChildren(item.children);
|
|
333
333
|
} else {
|
|
@@ -758,6 +758,8 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
758
758
|
var _shellStatusRef$curre11;
|
|
759
759
|
|
|
760
760
|
if (isEmpty((_shellStatusRef$curre11 = shellStatusRef.current) === null || _shellStatusRef$curre11 === void 0 ? void 0 : _shellStatusRef$curre11.editing)) {
|
|
761
|
+
var _pasteData;
|
|
762
|
+
|
|
761
763
|
var _shellStatusRef$curre12 = shellStatusRef.current,
|
|
762
764
|
start = _shellStatusRef$curre12.start,
|
|
763
765
|
end = _shellStatusRef$curre12.end;
|
|
@@ -781,8 +783,8 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
781
783
|
|
|
782
784
|
|
|
783
785
|
var resultEnd = [];
|
|
784
|
-
pasteData.forEach(function (row, i) {
|
|
785
|
-
row.forEach(function (value, j) {
|
|
786
|
+
(_pasteData = pasteData) === null || _pasteData === void 0 ? void 0 : _pasteData.forEach(function (row, i) {
|
|
787
|
+
row === null || row === void 0 ? void 0 : row.forEach(function (value, j) {
|
|
786
788
|
resultEnd.push({
|
|
787
789
|
i: start.i + i,
|
|
788
790
|
j: start.j + j,
|
|
@@ -791,7 +793,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
791
793
|
});
|
|
792
794
|
});
|
|
793
795
|
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
794
|
-
resultEnd.forEach(function (item) {
|
|
796
|
+
resultEnd === null || resultEnd === void 0 ? void 0 : resultEnd.forEach(function (item) {
|
|
795
797
|
var _isSelected2;
|
|
796
798
|
|
|
797
799
|
if ((_isSelected2 = isSelected(item.i, item.j)) === null || _isSelected2 === void 0 ? void 0 : _isSelected2.isSelected) {
|
|
@@ -994,7 +996,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
994
996
|
var colIndex = 0;
|
|
995
997
|
|
|
996
998
|
var traverseColumns = function traverseColumns(columns) {
|
|
997
|
-
columns.forEach(function (col) {
|
|
999
|
+
columns === null || columns === void 0 ? void 0 : columns.forEach(function (col) {
|
|
998
1000
|
if (col.show === false) {
|
|
999
1001
|
return;
|
|
1000
1002
|
}
|
package/lib/LmTable/util.js
CHANGED
|
@@ -50,10 +50,12 @@ exports.range = range;
|
|
|
50
50
|
|
|
51
51
|
function dataGroup(data, key) {
|
|
52
52
|
var result = {};
|
|
53
|
-
data.forEach(function (item) {
|
|
53
|
+
data === null || data === void 0 ? void 0 : data.forEach(function (item) {
|
|
54
54
|
if (item.children) {
|
|
55
|
+
var _Object$keys;
|
|
56
|
+
|
|
55
57
|
var temp = dataGroup(item.children, key);
|
|
56
|
-
Object.keys(temp).forEach(function (k) {
|
|
58
|
+
(_Object$keys = Object.keys(temp)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (k) {
|
|
57
59
|
if (!result[k]) result[k] = [];
|
|
58
60
|
result[k] = result[k].concat(temp[k]);
|
|
59
61
|
});
|
|
@@ -100,7 +102,7 @@ function transformWithColGroup(columns, dataSource, groupColKeys) {
|
|
|
100
102
|
// 表头数据的生成,生成新的 dataIndex 值
|
|
101
103
|
// dataIndex最后的i:筛选的值相同需要加索引
|
|
102
104
|
var handledColumns = [];
|
|
103
|
-
source.forEach(function (souItem, i) {
|
|
105
|
+
source === null || source === void 0 ? void 0 : source.forEach(function (souItem, i) {
|
|
104
106
|
handledColumns = handledColumns.concat(columns.filter(function (c) {
|
|
105
107
|
// 过滤掉(表头操作) 使用列分组作为key的项
|
|
106
108
|
return groupColKeysCopy.indexOf(c.dataIndex) === -1;
|
|
@@ -143,9 +145,11 @@ function transformWithColGroup(columns, dataSource, groupColKeys) {
|
|
|
143
145
|
|
|
144
146
|
return [].concat((0, _toConsumableArray2.default)(prev), [sItem]);
|
|
145
147
|
} else {
|
|
148
|
+
var _Object$keys2;
|
|
149
|
+
|
|
146
150
|
var str = ''; // 根据筛选条件生成对应的前缀key值,比如[name, age] => 'name_xiaoming_age_18'
|
|
147
151
|
|
|
148
|
-
groupColKeysCopy.forEach(function (dataIndex, i) {
|
|
152
|
+
groupColKeysCopy === null || groupColKeysCopy === void 0 ? void 0 : groupColKeysCopy.forEach(function (dataIndex, i) {
|
|
149
153
|
if (i !== 0) {
|
|
150
154
|
str += '_';
|
|
151
155
|
}
|
|
@@ -153,7 +157,7 @@ function transformWithColGroup(columns, dataSource, groupColKeys) {
|
|
|
153
157
|
str += "".concat(dataIndex, "_").concat(sItem[dataIndex]);
|
|
154
158
|
}); // 对dataSource的key值进行更改:例如:'name' => 'name_xiaoming_age_18_address'
|
|
155
159
|
|
|
156
|
-
Object.keys(sItem).forEach(function (key) {
|
|
160
|
+
(_Object$keys2 = Object.keys(sItem)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2.forEach(function (key) {
|
|
157
161
|
if (key === '__index') {
|
|
158
162
|
return;
|
|
159
163
|
}
|
package/lib/LmUpload/LmUpload.js
CHANGED
|
@@ -77,8 +77,10 @@ var renderThumb = function renderThumb(file) {
|
|
|
77
77
|
|
|
78
78
|
var PictureItem = function PictureItem(_ref) {
|
|
79
79
|
var file = _ref.file,
|
|
80
|
+
index = _ref.index,
|
|
80
81
|
instance = _ref.instance;
|
|
81
|
-
var
|
|
82
|
+
var dispatch = instance.dispatch,
|
|
83
|
+
readOnly = instance.readOnly,
|
|
82
84
|
size = instance.size,
|
|
83
85
|
remove = instance.remove,
|
|
84
86
|
preview = instance.preview,
|
|
@@ -121,6 +123,18 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
121
123
|
fontSize: fontSize
|
|
122
124
|
};
|
|
123
125
|
}, [size]);
|
|
126
|
+
|
|
127
|
+
var handlePreview = function handlePreview() {
|
|
128
|
+
preview === null || preview === void 0 ? void 0 : preview(file);
|
|
129
|
+
dispatch({
|
|
130
|
+
type: 'changePreview',
|
|
131
|
+
preview: {
|
|
132
|
+
visible: true,
|
|
133
|
+
index: index
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
124
138
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
125
139
|
className: (0, _classnames.default)('lm_upload_item', 'lm_upload_item_card', isError && 'lm_upload_item_error'),
|
|
126
140
|
style: {
|
|
@@ -142,9 +156,7 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
142
156
|
className: "lm_upload_item_action"
|
|
143
157
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
144
158
|
className: "action_preview",
|
|
145
|
-
onClick:
|
|
146
|
-
return preview(file);
|
|
147
|
-
}
|
|
159
|
+
onClick: handlePreview
|
|
148
160
|
}, /*#__PURE__*/_react.default.createElement(_linkmoreDesign.IconFont, {
|
|
149
161
|
type: "lmweb-eye",
|
|
150
162
|
style: {
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.default = void 0;
|
|
9
11
|
|
|
10
|
-
var _react =
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _utils = require("../utils");
|
|
13
15
|
|
|
@@ -15,22 +17,26 @@ var _RenderItem = _interopRequireDefault(require("./RenderItem"));
|
|
|
15
17
|
|
|
16
18
|
var LmUploadList = function LmUploadList(_ref) {
|
|
17
19
|
var instance = _ref.instance;
|
|
18
|
-
|
|
19
|
-
var _a, _b;
|
|
20
|
-
|
|
21
20
|
var getFileHasValue = instance.getFileHasValue,
|
|
22
21
|
getFileList = instance.getFileList,
|
|
23
22
|
itemRender = instance.itemRender,
|
|
24
23
|
listType = instance.listType,
|
|
25
24
|
showUploadList = instance.showUploadList;
|
|
26
25
|
if (!showUploadList) return null;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
var fileList = (0, _react.useMemo)(function () {
|
|
27
|
+
var _a;
|
|
28
|
+
|
|
29
|
+
return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
|
|
30
|
+
return a.seq - b.seq;
|
|
31
|
+
});
|
|
32
|
+
}, [getFileList]);
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, fileList === null || fileList === void 0 ? void 0 : fileList.map(function (file, idx) {
|
|
30
34
|
return (0, _utils.render)(itemRender || _RenderItem.default, {
|
|
31
35
|
type: listType,
|
|
32
36
|
key: getFileHasValue(file) || idx,
|
|
37
|
+
index: idx,
|
|
33
38
|
file: file,
|
|
39
|
+
fileList: fileList,
|
|
34
40
|
instance: instance
|
|
35
41
|
});
|
|
36
42
|
}));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _linkmoreDesign = require("linkmore-design");
|
|
13
|
+
|
|
14
|
+
var Preview = function Preview(_ref) {
|
|
15
|
+
var instance = _ref.instance;
|
|
16
|
+
var enabledPreview = instance.enabledPreview,
|
|
17
|
+
state = instance.state,
|
|
18
|
+
dispatch = instance.dispatch,
|
|
19
|
+
getFileList = instance.getFileList;
|
|
20
|
+
if (!enabledPreview) return null; // 与展示顺序保持一致
|
|
21
|
+
|
|
22
|
+
var fileList = (0, _react.useMemo)(function () {
|
|
23
|
+
var _a;
|
|
24
|
+
|
|
25
|
+
return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
|
|
26
|
+
return a.seq - b.seq;
|
|
27
|
+
});
|
|
28
|
+
}, [getFileList]);
|
|
29
|
+
var config = (0, _react.useMemo)(function () {
|
|
30
|
+
var _state$preview = state.preview,
|
|
31
|
+
index = _state$preview.index,
|
|
32
|
+
visible = _state$preview.visible;
|
|
33
|
+
return {
|
|
34
|
+
urlList: fileList === null || fileList === void 0 ? void 0 : fileList.map(function (_ref2) {
|
|
35
|
+
var url = _ref2.url;
|
|
36
|
+
return url;
|
|
37
|
+
}),
|
|
38
|
+
initialIndex: index,
|
|
39
|
+
visible: visible,
|
|
40
|
+
close: function close() {
|
|
41
|
+
dispatch({
|
|
42
|
+
type: 'changePreview',
|
|
43
|
+
preview: {
|
|
44
|
+
visible: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, [fileList, state.preview]);
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.ImageViewer, Object.assign({}, config));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var _default = /*#__PURE__*/_react.default.memo(Preview);
|
|
54
|
+
|
|
55
|
+
exports.default = _default;
|
|
@@ -15,6 +15,8 @@ var _view = _interopRequireDefault(require("../view"));
|
|
|
15
15
|
|
|
16
16
|
var _Crop = _interopRequireDefault(require("../components/Crop"));
|
|
17
17
|
|
|
18
|
+
var _Preview = _interopRequireDefault(require("../components/Preview"));
|
|
19
|
+
|
|
18
20
|
// 包裹上传组件区域: 拓展其他结构
|
|
19
21
|
var LmUploadWrapper = function LmUploadWrapper(_ref) {
|
|
20
22
|
var instance = _ref.instance;
|
|
@@ -26,6 +28,8 @@ var LmUploadWrapper = function LmUploadWrapper(_ref) {
|
|
|
26
28
|
instance: instance
|
|
27
29
|
}), /*#__PURE__*/_react.default.createElement(_Crop.default, {
|
|
28
30
|
instance: instance
|
|
31
|
+
}), /*#__PURE__*/_react.default.createElement(_Preview.default, {
|
|
32
|
+
instance: instance
|
|
29
33
|
}));
|
|
30
34
|
};
|
|
31
35
|
|