@jiaozhiye/qm-design-react 1.0.0-beta.21 → 1.0.0-beta.22
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/lib/form/src/form.d.ts +1 -0
- package/lib/form/src/utils.d.ts +1 -0
- package/lib/index.esm.js +138 -81
- package/lib/index.full.js +1 -1
- package/lib/index.js +137 -80
- package/package.json +1 -1
package/lib/form/src/form.d.ts
CHANGED
|
@@ -111,6 +111,7 @@ declare class QmForm extends Component<IProps, IState> {
|
|
|
111
111
|
type: any;
|
|
112
112
|
fieldName: any;
|
|
113
113
|
}): boolean;
|
|
114
|
+
formatFormValue: (values: IFormData) => IFormData;
|
|
114
115
|
getFormAuth(): Promise<void>;
|
|
115
116
|
INPUT(option: IFormItem): JSXElement;
|
|
116
117
|
RANGE_INPUT(option: IFormItem): JSXElement;
|
package/lib/form/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
export declare const getDate: (dateString: string | undefined, format: string) => dayjs.Dayjs | null;
|
|
3
3
|
export declare const formatDate: (date: Dayjs | null, format: string) => string;
|
|
4
|
+
export declare const isEmptyValue: (value: unknown) => boolean;
|
|
4
5
|
export declare const deepMapList: (list: any[], valueKey: string, textKey: string) => any[];
|
|
5
6
|
export declare const deepFind: (arr: any[], mark: string) => any;
|
|
6
7
|
export declare const deepFindValues: <T>(arr: T[], str: string, depth?: number) => T[];
|
package/lib/index.esm.js
CHANGED
|
@@ -19,7 +19,7 @@ import 'dayjs/locale/zh-cn';
|
|
|
19
19
|
import zhCN_antd from 'antd/lib/locale/zh_CN';
|
|
20
20
|
import enGB_antd from 'antd/lib/locale/en_GB';
|
|
21
21
|
import omit from 'omit.js';
|
|
22
|
-
import {
|
|
22
|
+
import { isArray, isPlainObject, isNumber, isFunction as isFunction$1, isUndefined, isString, throttle, xor, isEqual, get, merge, debounce, transform, set, intersection, cloneDeep, map, groupBy, flatten, spread, mergeWith, sumBy, maxBy, minBy, pickBy } from 'lodash-es';
|
|
23
23
|
import classNames from 'classnames';
|
|
24
24
|
import { UpOutlined, DownOutlined, DownloadOutlined, FullscreenExitOutlined, FullscreenOutlined, HolderOutlined, UnorderedListOutlined, SearchOutlined, CheckOutlined, CloseOutlined, ExclamationCircleOutlined, ReloadOutlined, UploadOutlined, ZoomInOutlined, ZoomOutOutlined, RotateRightOutlined, RotateLeftOutlined, PlusOutlined, InfoCircleFilled, PrinterOutlined, SettingOutlined, CheckSquareOutlined, CloseCircleOutlined, PieChartOutlined, FunnelPlotOutlined, StepBackwardOutlined, StepForwardOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
|
25
25
|
import CountUp from 'react-countup';
|
|
@@ -3046,6 +3046,66 @@ var removeResizeListener = function removeResizeListener(element, fn) {
|
|
|
3046
3046
|
}
|
|
3047
3047
|
};
|
|
3048
3048
|
|
|
3049
|
+
dayjs.extend(advancedFormat);
|
|
3050
|
+
dayjs.extend(customParseFormat);
|
|
3051
|
+
var getDate$1 = function getDate(dateString, format) {
|
|
3052
|
+
return dateString ? dayjs(dateString, format) : null;
|
|
3053
|
+
};
|
|
3054
|
+
var formatDate$1 = function formatDate(date, format) {
|
|
3055
|
+
return date ? dayjs(date).format(format) : '';
|
|
3056
|
+
};
|
|
3057
|
+
var isEmptyValue = function isEmptyValue(value) {
|
|
3058
|
+
return value === undefined || value === null;
|
|
3059
|
+
};
|
|
3060
|
+
var deepMapList = function deepMapList(list, valueKey, textKey) {
|
|
3061
|
+
return list.map(function (x) {
|
|
3062
|
+
var item = {
|
|
3063
|
+
value: x[valueKey],
|
|
3064
|
+
text: x[textKey]
|
|
3065
|
+
};
|
|
3066
|
+
x.disabled && (item.disabled = true);
|
|
3067
|
+
|
|
3068
|
+
if (Array.isArray(x.children)) {
|
|
3069
|
+
item.children = deepMapList(x.children, valueKey, textKey);
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
return item;
|
|
3073
|
+
});
|
|
3074
|
+
};
|
|
3075
|
+
var deepFind = function deepFind(arr, mark) {
|
|
3076
|
+
var res = null;
|
|
3077
|
+
|
|
3078
|
+
for (var i = 0; i < arr.length; i++) {
|
|
3079
|
+
if (Array.isArray(arr[i].children)) {
|
|
3080
|
+
res = deepFind(arr[i].children, mark);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
if (res) {
|
|
3084
|
+
return res;
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
if (arr[i].value === mark) {
|
|
3088
|
+
return arr[i];
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
return res;
|
|
3093
|
+
};
|
|
3094
|
+
var deepFindValues = function deepFindValues(arr, str) {
|
|
3095
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
3096
|
+
var result = [];
|
|
3097
|
+
arr.forEach(function (x) {
|
|
3098
|
+
if (x.value == str.split(',')[depth]) {
|
|
3099
|
+
result.push(x);
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
if (Array.isArray(x.children)) {
|
|
3103
|
+
result.push.apply(result, _toConsumableArray(deepFindValues(x.children, str, depth + 1)));
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3106
|
+
return result;
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3049
3109
|
/*
|
|
3050
3110
|
* @Author: 焦质晔
|
|
3051
3111
|
* @Date: 2021-08-07 21:32:01
|
|
@@ -3994,23 +4054,27 @@ var RangeInputNumber = /*#__PURE__*/function (_Component) {
|
|
|
3994
4054
|
|
|
3995
4055
|
_this = _super.apply(this, arguments);
|
|
3996
4056
|
|
|
4057
|
+
_this.validateValues = function (values) {
|
|
4058
|
+
// 结束值 不能大于 开始值
|
|
4059
|
+
if (values.every(function (x) {
|
|
4060
|
+
return x !== null;
|
|
4061
|
+
}) && values[0] > values[1]) {
|
|
4062
|
+
values[1] = values[0];
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
_this.triggerChange(values);
|
|
4066
|
+
};
|
|
4067
|
+
|
|
3997
4068
|
_this.triggerChange = function (changedValue) {
|
|
3998
4069
|
var _this$props = _this.props,
|
|
3999
4070
|
_this$props$onChange = _this$props.onChange,
|
|
4000
4071
|
onChange = _this$props$onChange === void 0 ? noop$1 : _this$props$onChange,
|
|
4001
4072
|
onValuesChange = _this$props.onValuesChange;
|
|
4002
|
-
|
|
4073
|
+
var values = changedValue.every(function (x) {
|
|
4003
4074
|
return x === null;
|
|
4004
|
-
}) ? [] : changedValue;
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
return x !== null;
|
|
4008
|
-
}) && changedValue[0] > changedValue[1]) {
|
|
4009
|
-
changedValue[1] = changedValue[0];
|
|
4010
|
-
}
|
|
4011
|
-
|
|
4012
|
-
onChange(changedValue);
|
|
4013
|
-
onValuesChange(changedValue);
|
|
4075
|
+
}) ? [] : _toConsumableArray(changedValue);
|
|
4076
|
+
onChange(values);
|
|
4077
|
+
onValuesChange(values);
|
|
4014
4078
|
};
|
|
4015
4079
|
|
|
4016
4080
|
return _this;
|
|
@@ -4063,6 +4127,9 @@ var RangeInputNumber = /*#__PURE__*/function (_Component) {
|
|
|
4063
4127
|
disabled: disabled,
|
|
4064
4128
|
onChange: function onChange(val) {
|
|
4065
4129
|
_this2.triggerChange([val, value[1]]);
|
|
4130
|
+
},
|
|
4131
|
+
onBlur: function onBlur() {
|
|
4132
|
+
_this2.validateValues(value);
|
|
4066
4133
|
}
|
|
4067
4134
|
}), /*#__PURE__*/React__default.createElement(Input, {
|
|
4068
4135
|
className: "site-input-split",
|
|
@@ -4098,6 +4165,9 @@ var RangeInputNumber = /*#__PURE__*/function (_Component) {
|
|
|
4098
4165
|
disabled: disabled,
|
|
4099
4166
|
onChange: function onChange(val) {
|
|
4100
4167
|
_this2.triggerChange([value[0], val]);
|
|
4168
|
+
},
|
|
4169
|
+
onBlur: function onBlur() {
|
|
4170
|
+
_this2.validateValues(value);
|
|
4101
4171
|
}
|
|
4102
4172
|
}));
|
|
4103
4173
|
}
|
|
@@ -4158,8 +4228,7 @@ var FormRangeInputNumber = /*#__PURE__*/function (_Component2) {
|
|
|
4158
4228
|
}
|
|
4159
4229
|
}, /*#__PURE__*/React__default.createElement(RangeInputNumber, {
|
|
4160
4230
|
option: this.props.option,
|
|
4161
|
-
onValuesChange: function onValuesChange() {
|
|
4162
|
-
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
4231
|
+
onValuesChange: function onValuesChange(values) {
|
|
4163
4232
|
onChange(values);
|
|
4164
4233
|
$$form.setViewValue(fieldName, values.join('-'));
|
|
4165
4234
|
}
|
|
@@ -5618,63 +5687,6 @@ var FormTextArea = /*#__PURE__*/function (_Component) {
|
|
|
5618
5687
|
|
|
5619
5688
|
FormTextArea.contextType = FormContext;
|
|
5620
5689
|
|
|
5621
|
-
dayjs.extend(advancedFormat);
|
|
5622
|
-
dayjs.extend(customParseFormat);
|
|
5623
|
-
var getDate$1 = function getDate(dateString, format) {
|
|
5624
|
-
return dateString ? dayjs(dateString, format) : null;
|
|
5625
|
-
};
|
|
5626
|
-
var formatDate$1 = function formatDate(date, format) {
|
|
5627
|
-
return date ? dayjs(date).format(format) : '';
|
|
5628
|
-
};
|
|
5629
|
-
var deepMapList = function deepMapList(list, valueKey, textKey) {
|
|
5630
|
-
return list.map(function (x) {
|
|
5631
|
-
var item = {
|
|
5632
|
-
value: x[valueKey],
|
|
5633
|
-
text: x[textKey]
|
|
5634
|
-
};
|
|
5635
|
-
x.disabled && (item.disabled = true);
|
|
5636
|
-
|
|
5637
|
-
if (Array.isArray(x.children)) {
|
|
5638
|
-
item.children = deepMapList(x.children, valueKey, textKey);
|
|
5639
|
-
}
|
|
5640
|
-
|
|
5641
|
-
return item;
|
|
5642
|
-
});
|
|
5643
|
-
};
|
|
5644
|
-
var deepFind = function deepFind(arr, mark) {
|
|
5645
|
-
var res = null;
|
|
5646
|
-
|
|
5647
|
-
for (var i = 0; i < arr.length; i++) {
|
|
5648
|
-
if (Array.isArray(arr[i].children)) {
|
|
5649
|
-
res = deepFind(arr[i].children, mark);
|
|
5650
|
-
}
|
|
5651
|
-
|
|
5652
|
-
if (res) {
|
|
5653
|
-
return res;
|
|
5654
|
-
}
|
|
5655
|
-
|
|
5656
|
-
if (arr[i].value === mark) {
|
|
5657
|
-
return arr[i];
|
|
5658
|
-
}
|
|
5659
|
-
}
|
|
5660
|
-
|
|
5661
|
-
return res;
|
|
5662
|
-
};
|
|
5663
|
-
var deepFindValues = function deepFindValues(arr, str) {
|
|
5664
|
-
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
5665
|
-
var result = [];
|
|
5666
|
-
arr.forEach(function (x) {
|
|
5667
|
-
if (x.value == str.split(',')[depth]) {
|
|
5668
|
-
result.push(x);
|
|
5669
|
-
}
|
|
5670
|
-
|
|
5671
|
-
if (Array.isArray(x.children)) {
|
|
5672
|
-
result.push.apply(result, _toConsumableArray(deepFindValues(x.children, str, depth + 1)));
|
|
5673
|
-
}
|
|
5674
|
-
});
|
|
5675
|
-
return result;
|
|
5676
|
-
};
|
|
5677
|
-
|
|
5678
5690
|
var _disabledDate$1 = function disabledDate(current, _ref) {
|
|
5679
5691
|
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
5680
5692
|
minDateTime = _ref2[0],
|
|
@@ -13831,7 +13843,53 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
13831
13843
|
result.push(x);
|
|
13832
13844
|
});
|
|
13833
13845
|
return result;
|
|
13834
|
-
}); //
|
|
13846
|
+
}); // 格式化表单数据
|
|
13847
|
+
|
|
13848
|
+
_this.formatFormValue = function (values) {
|
|
13849
|
+
var _a, _b;
|
|
13850
|
+
|
|
13851
|
+
var _loop = function _loop(key) {
|
|
13852
|
+
var val = values[key];
|
|
13853
|
+
|
|
13854
|
+
if (isEmptyValue(val)) {
|
|
13855
|
+
values[key] = '';
|
|
13856
|
+
}
|
|
13857
|
+
|
|
13858
|
+
if (Array.isArray(val)) {
|
|
13859
|
+
val.forEach(function (x, i) {
|
|
13860
|
+
if (isEmptyValue(x)) {
|
|
13861
|
+
values[key][i] = '';
|
|
13862
|
+
}
|
|
13863
|
+
});
|
|
13864
|
+
}
|
|
13865
|
+
|
|
13866
|
+
if (key.includes('|') && Array.isArray(val)) {
|
|
13867
|
+
var _key$split = key.split('|'),
|
|
13868
|
+
_key$split2 = _slicedToArray$1(_key$split, 2),
|
|
13869
|
+
start = _key$split2[0],
|
|
13870
|
+
end = _key$split2[1];
|
|
13871
|
+
|
|
13872
|
+
values[start] = (_a = val[0]) !== null && _a !== void 0 ? _a : '';
|
|
13873
|
+
values[end] = (_b = val[1]) !== null && _b !== void 0 ? _b : '';
|
|
13874
|
+
}
|
|
13875
|
+
};
|
|
13876
|
+
|
|
13877
|
+
for (var key in values) {
|
|
13878
|
+
_loop(key);
|
|
13879
|
+
} // 筛选器 - 空值设置成 undefined
|
|
13880
|
+
|
|
13881
|
+
|
|
13882
|
+
if (_this.isFilterType) {
|
|
13883
|
+
for (var _key in values) {
|
|
13884
|
+
if (isEmpty(values[_key])) {
|
|
13885
|
+
values[_key] = undefined;
|
|
13886
|
+
}
|
|
13887
|
+
}
|
|
13888
|
+
}
|
|
13889
|
+
|
|
13890
|
+
return values;
|
|
13891
|
+
}; // 列定义
|
|
13892
|
+
|
|
13835
13893
|
|
|
13836
13894
|
_this.createFieldsDefine = function () {
|
|
13837
13895
|
var _this$props = _this.props,
|
|
@@ -13874,7 +13932,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
13874
13932
|
_this.finishHandle = function (values) {
|
|
13875
13933
|
var _a, _b;
|
|
13876
13934
|
|
|
13877
|
-
(_b = (_a = _this.props).onFinish) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign({}, _this.get_fields_other(), values));
|
|
13935
|
+
(_b = (_a = _this.props).onFinish) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign({}, _this.get_fields_other(), _this.formatFormValue(values)));
|
|
13878
13936
|
}; // 提交表单且数据验证失败后回调事件
|
|
13879
13937
|
|
|
13880
13938
|
|
|
@@ -13882,8 +13940,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
13882
13940
|
_ref.values;
|
|
13883
13941
|
var errorFields = _ref.errorFields;
|
|
13884
13942
|
|
|
13885
|
-
var _a, _b;
|
|
13886
|
-
|
|
13943
|
+
var _a, _b;
|
|
13887
13944
|
|
|
13888
13945
|
(_b = (_a = _this.props).onFinishFailed) === null || _b === void 0 ? void 0 : _b.call(_a, errorFields);
|
|
13889
13946
|
}; // 获取表单的值,异步方法,错误前置的原则
|
|
@@ -13902,7 +13959,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
13902
13959
|
|
|
13903
13960
|
case 3:
|
|
13904
13961
|
res = _context.sent;
|
|
13905
|
-
return _context.abrupt("return", [null, Object.assign({}, this.get_fields_other(), res)]);
|
|
13962
|
+
return _context.abrupt("return", [null, Object.assign({}, this.get_fields_other(), this.formatFormValue(res))]);
|
|
13906
13963
|
|
|
13907
13964
|
case 7:
|
|
13908
13965
|
_context.prev = 7;
|
|
@@ -14217,7 +14274,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
14217
14274
|
|
|
14218
14275
|
var result = [];
|
|
14219
14276
|
|
|
14220
|
-
var
|
|
14277
|
+
var _loop2 = function _loop2(i, len) {
|
|
14221
14278
|
var index = _this3.formItems.findIndex(function (x) {
|
|
14222
14279
|
return x === _this3.dividers[i];
|
|
14223
14280
|
});
|
|
@@ -14236,7 +14293,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
14236
14293
|
};
|
|
14237
14294
|
|
|
14238
14295
|
for (var i = 0, len = this.dividers.length; i < len; i++) {
|
|
14239
|
-
|
|
14296
|
+
_loop2(i);
|
|
14240
14297
|
}
|
|
14241
14298
|
|
|
14242
14299
|
return result;
|
|
@@ -14258,7 +14315,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
14258
14315
|
|
|
14259
14316
|
var blockItems = this.getBlockDerivedItems();
|
|
14260
14317
|
|
|
14261
|
-
var
|
|
14318
|
+
var _loop3 = function _loop3(i, len) {
|
|
14262
14319
|
var arr = blockItems[i];
|
|
14263
14320
|
|
|
14264
14321
|
var divider = _this4.dividers.find(function (x) {
|
|
@@ -14279,7 +14336,7 @@ var QmForm = /*#__PURE__*/function (_Component) {
|
|
|
14279
14336
|
};
|
|
14280
14337
|
|
|
14281
14338
|
for (var i = 0, len = blockItems.length; i < len; i++) {
|
|
14282
|
-
var _ret =
|
|
14339
|
+
var _ret = _loop3(i);
|
|
14283
14340
|
|
|
14284
14341
|
if (_typeof$2(_ret) === "object") return _ret.v;
|
|
14285
14342
|
}
|
|
@@ -29976,7 +30033,7 @@ QmPrint.defaultProps = {
|
|
|
29976
30033
|
QmPrint.contextType = ConfigContext;
|
|
29977
30034
|
|
|
29978
30035
|
var name = "@jiaozhiye/qm-design-react";
|
|
29979
|
-
var version = "1.0.0-beta.
|
|
30036
|
+
var version = "1.0.0-beta.22";
|
|
29980
30037
|
var description = "A Component Library for React";
|
|
29981
30038
|
var keywords = [
|
|
29982
30039
|
"React",
|