@kdcloudjs/kdesign 1.6.7 → 1.6.10

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.
@@ -24,6 +24,7 @@ var context = /*#__PURE__*/_react.default.createContext({
24
24
  resetFields: warningFunc,
25
25
  setFieldsValue: warningFunc,
26
26
  setFieldValue: warningFunc,
27
+ setRules: warningFunc,
27
28
  submit: warningFunc,
28
29
  validateFields: warningFunc,
29
30
  getInternalHooks: function getInternalHooks() {
@@ -65,6 +65,7 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
65
65
  resetFields: _this.resetFields,
66
66
  setFieldValue: _this.setFieldValue,
67
67
  setFieldsValue: _this.setFieldsValue,
68
+ setRules: _this.setRules,
68
69
  validateFields: _this.validateFields,
69
70
  submit: _this.submit,
70
71
  getInternalHooks: _this.getInternalHooks
@@ -318,16 +319,15 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
318
319
  _this.notifyObservers(_this.store, namePathList || [], 'validateFinish');
319
320
  }).catch(function (_ref2) {
320
321
  var errorInfos = _ref2.errorInfos;
322
+ _this.errorMessages = {};
321
323
  var _errorInfos$fields = errorInfos.fields,
322
324
  fields = _errorInfos$fields === void 0 ? {} : _errorInfos$fields;
323
325
  (0, _keys.default)(fields).forEach(function (name) {
324
- // 取第一个错误的信息
325
326
  _this.errorMessages[name] = fields[name][0].message;
326
327
  });
327
328
 
328
329
  _this.notifyObservers(_this.store, namePathList || [], 'validateFinish');
329
- }); // 返回 promise 给外部调用者
330
-
330
+ });
331
331
  return validatePromise;
332
332
  };
333
333
 
@@ -21,6 +21,7 @@ export interface FormInstance<Values = any> {
21
21
  resetFields: (fields?: NamePath[]) => void;
22
22
  setFieldsValue: (value: Values) => void;
23
23
  setFieldValue: (name: NamePath, value: Values) => void;
24
+ setRules: (name: NamePath, rules: any) => void;
24
25
  validateFields: (namePathList?: NamePath[]) => Promise<Values>;
25
26
  submit: () => void;
26
27
  getInternalHooks: (secret: string) => InternalHooks | null;
@@ -129,6 +129,12 @@
129
129
  color: var(--kd-c-menu-light-color-text, var(--kd-g-color-text-primary, #212121));
130
130
  background: #fafafa;
131
131
  }
132
+ .menu-light-base .kd-menu-submenu:not(.kd-menu-submenu-disabled):not(.kd-menu-submenu-active):hover,
133
+ .menu-light-base .kd-menu-submenu-hover {
134
+ background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
135
+ color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
136
+ border: none;
137
+ }
132
138
  .menu-light-base .kd-menu-item:not(.kd-menu-item-disabled):not(.kd-menu-item-active):hover {
133
139
  background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
134
140
  color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
@@ -477,6 +483,12 @@
477
483
  color: var(--kd-c-menu-light-color-text, var(--kd-g-color-text-primary, #212121));
478
484
  background: #fafafa;
479
485
  }
486
+ .kd-menu-light .kd-menu-submenu:not(.kd-menu-submenu-disabled):not(.kd-menu-submenu-active):hover,
487
+ .kd-menu-light .kd-menu-submenu-hover {
488
+ background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
489
+ color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
490
+ border: none;
491
+ }
480
492
  .kd-menu-light .kd-menu-item:not(.kd-menu-item-disabled):not(.kd-menu-item-active):hover {
481
493
  background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
482
494
  color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
@@ -569,6 +581,12 @@
569
581
  color: var(--kd-c-menu-light-color-text, var(--kd-g-color-text-primary, #212121));
570
582
  background: #fafafa;
571
583
  }
584
+ .kd-menu-popper.light .kd-menu-submenu:not(.kd-menu-submenu-disabled):not(.kd-menu-submenu-active):hover,
585
+ .kd-menu-popper.light .kd-menu-submenu-hover {
586
+ background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
587
+ color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
588
+ border: none;
589
+ }
572
590
  .kd-menu-popper.light .kd-menu-item:not(.kd-menu-item-disabled):not(.kd-menu-item-active):hover {
573
591
  background-color: var(--kd-c-menu-light-color-background-hover, #f5f5f5);
574
592
  color: var(--kd-c-menu-light-color-text-hover, var(--kd-g-color-text-primary, #212121));
@@ -107,6 +107,11 @@
107
107
  background: #fafafa;
108
108
  }
109
109
 
110
+ .@{submenu-prefix-cls}:not(.@{submenu-prefix-cls}-disabled):not(.@{submenu-prefix-cls}-active):hover,
111
+ .@{submenu-prefix-cls}-hover {
112
+ .menu-light-hover();
113
+ }
114
+
110
115
  .@{menuitem-prefix-cls}:not(.@{menuitem-prefix-cls}-disabled):not(.@{menuitem-prefix-cls}-active):hover {
111
116
  .menu-light-hover();
112
117
  }
@@ -108,11 +108,11 @@ var InteranalSlider = function InteranalSlider(props, ref) {
108
108
  value = _useMergedState2[0],
109
109
  setValue = _useMergedState2[1];
110
110
 
111
- var _useState = (0, _react.useState)(false),
112
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
113
- dragging = _useState2[0],
114
- setDraging = _useState2[1];
115
-
111
+ var isDragging = (0, _react.useRef)(false);
112
+ var valueRef = (0, _react.useRef)((0, _hooks.useMergedState)(0, {
113
+ defaultValue: defaultValue,
114
+ value: propsValue
115
+ }));
116
116
  var mouseOffset;
117
117
 
118
118
  var addDocumentMouseEvents = function addDocumentMouseEvents() {
@@ -183,11 +183,11 @@ var InteranalSlider = function InteranalSlider(props, ref) {
183
183
  var onEnd = function onEnd() {
184
184
  removeDocumentEvents();
185
185
 
186
- if (dragging) {
187
- onAfterChange && onAfterChange(value);
186
+ if (isDragging.current) {
187
+ onAfterChange && onAfterChange(valueRef.current);
188
188
  }
189
189
 
190
- setDraging(false);
190
+ isDragging.current = false;
191
191
  };
192
192
 
193
193
  var handleTouchStart = function handleTouchStart() {// console.log('object :>> ', 'object', addDocumentMouseEvents)
@@ -210,11 +210,12 @@ var InteranalSlider = function InteranalSlider(props, ref) {
210
210
  } // 设置状态值
211
211
 
212
212
 
213
- setDraging(true);
213
+ isDragging.current = true;
214
214
  var newV = calcValueByPos(position);
215
215
 
216
216
  if (newV !== value) {
217
217
  setValue(newV);
218
+ valueRef.current = newV;
218
219
  }
219
220
 
220
221
  onChange && onChange(newV); // 监听document的鼠标事件
@@ -241,11 +242,11 @@ var InteranalSlider = function InteranalSlider(props, ref) {
241
242
  if (!sliderRef.current) {
242
243
  removeDocumentEvents();
243
244
 
244
- if (dragging) {
245
+ if (isDragging.current) {
245
246
  onAfterChange(value);
246
247
  }
247
248
 
248
- setDraging(false);
249
+ isDragging.current = false;
249
250
  return;
250
251
  }
251
252
 
@@ -254,6 +255,7 @@ var InteranalSlider = function InteranalSlider(props, ref) {
254
255
 
255
256
  if (newV !== value) {
256
257
  setValue(newV);
258
+ valueRef.current = newV;
257
259
  }
258
260
 
259
261
  onChange && onChange(newV);
@@ -271,7 +273,7 @@ var InteranalSlider = function InteranalSlider(props, ref) {
271
273
  style: style,
272
274
  onTouchStart: disabled ? noop : handleTouchStart,
273
275
  onMouseDown: disabled ? noop : handleMouseDown,
274
- onMouseUp: disabled ? noop : handleMouseUp,
276
+ // onMouseUp={disabled ? noop : handleMouseUp}
275
277
  onKeyDown: disabled ? noop : handleKeyDown,
276
278
  onFocus: disabled ? noop : handleFocus,
277
279
  onBlur: disabled ? noop : handleBlur
@@ -141,4 +141,11 @@ export interface UploadRequestOption<T = any> {
141
141
  headers?: HttpRequestHeader;
142
142
  method: UploadRequestMethod;
143
143
  }
144
+ export interface IFileItem {
145
+ file: UploadFile;
146
+ prefixCls: string;
147
+ listType: string;
148
+ handleReUpload: (file: UploadFile, e: React.MouseEvent) => void;
149
+ handleRemove: (file: UploadFile, e: React.MouseEvent) => void;
150
+ }
144
151
  export {};
@@ -147,6 +147,7 @@ var InternalUpload = function InternalUpload(props, ref) {
147
147
  onRemove = allProps.onRemove,
148
148
  directory = allProps.directory,
149
149
  className = allProps.className,
150
+ itemRender = allProps.itemRender,
150
151
  showUploadList = allProps.showUploadList,
151
152
  customPrefixcls = allProps.prefixCls;
152
153
 
@@ -391,13 +392,6 @@ var InternalUpload = function InternalUpload(props, ref) {
391
392
  directory: directory ? 'directory' : undefined,
392
393
  webkitdirectory: directory ? 'webkitdirectory' : undefined
393
394
  };
394
- var mapStatus = {
395
- uploading: 'loadding',
396
- error: 'warning-solid',
397
- done: 'attachment',
398
- success: 'attachment',
399
- notStart: 'attachment'
400
- };
401
395
  var dragEvents = {};
402
396
 
403
397
  var _React$useState3 = React.useState(false),
@@ -493,76 +487,105 @@ var InternalUpload = function InternalUpload(props, ref) {
493
487
  }, inputFileProps, {
494
488
  ref: mergedRef
495
489
  }))))), showUploadList && (0, _map.default)(fileList).call(fileList, function (file) {
496
- var _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20;
497
-
498
- return /*#__PURE__*/React.createElement("li", {
499
- key: file.uid,
500
- className: (0, _classnames.default)((0, _concat.default)(_context8 = "".concat(prefixCls, "-")).call(_context8, listType, "-list-item"), {
501
- error: file.status === 'error'
502
- })
503
- }, listType === 'text' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
504
- className: (0, _concat.default)(_context9 = "".concat(prefixCls, "-")).call(_context9, listType, "-list-item-icon")
505
- }, /*#__PURE__*/React.createElement(_icon.default, {
506
- spin: file.status === 'uploading',
507
- type: mapStatus[file.status]
508
- })), /*#__PURE__*/React.createElement("span", {
509
- className: (0, _concat.default)(_context10 = "".concat(prefixCls, "-")).call(_context10, listType, "-list-item-name"),
510
- title: file.name
511
- }, file.name), /*#__PURE__*/React.createElement("span", {
512
- className: (0, _concat.default)(_context11 = "".concat(prefixCls, "-")).call(_context11, listType, "-list-item-size")
513
- }, "(", (0, _utils2.getFileSize)(file.size), ")"), /*#__PURE__*/React.createElement("div", {
514
- className: (0, _concat.default)(_context12 = "".concat(prefixCls, "-")).call(_context12, listType, "-list-item-action")
515
- }, file.status === 'error' && /*#__PURE__*/React.createElement("a", {
516
- href: "true",
517
- className: (0, _concat.default)(_context13 = "".concat(prefixCls, "-")).call(_context13, listType, "-list-item-reupload"),
518
- onClick: handleReUpload.bind(_this, file)
519
- }, "\u91CD\u65B0\u4E0A\u4F20"), /*#__PURE__*/React.createElement("a", {
520
- href: "true",
521
- className: (0, _concat.default)(_context14 = "".concat(prefixCls, "-")).call(_context14, listType, "-list-item-delete"),
522
- onClick: handleRemove.bind(_this, file)
523
- }, "\u5220\u9664"))) : file.status === 'uploading' ? /*#__PURE__*/React.createElement("div", {
524
- className: (0, _concat.default)(_context15 = "".concat(prefixCls, "-")).call(_context15, listType, "-list-item-loading")
525
- }, /*#__PURE__*/React.createElement(_progress.default, {
526
- percent: file.percent,
527
- textMap: ['文件上传中'],
528
- showInfo: false
529
- })) : file.status === 'error' ? /*#__PURE__*/React.createElement("div", {
530
- className: (0, _concat.default)(_context16 = "".concat(prefixCls, "-")).call(_context16, listType, "-list-item-error")
531
- }, /*#__PURE__*/React.createElement("div", {
532
- className: (0, _concat.default)(_context17 = "".concat(prefixCls, "-")).call(_context17, listType, "-list-item-error-text")
533
- }, /*#__PURE__*/React.createElement(_icon.default, {
534
- type: mapStatus[file.status],
535
- style: {
536
- verticalAlign: 'top'
537
- }
538
- }), "\u4E0A\u4F20\u5931\u8D25"), /*#__PURE__*/React.createElement("div", {
539
- className: (0, _concat.default)(_context18 = "".concat(prefixCls, "-")).call(_context18, listType, "-list-item-action")
540
- }, /*#__PURE__*/React.createElement("a", {
541
- href: "true",
542
- className: (0, _concat.default)(_context19 = "".concat(prefixCls, "-")).call(_context19, listType, "-list-item-reupload"),
543
- onClick: handleReUpload.bind(_this, file)
544
- }, "\u91CD\u65B0\u4E0A\u4F20"), /*#__PURE__*/React.createElement("a", {
545
- href: "true",
546
- className: (0, _concat.default)(_context20 = "".concat(prefixCls, "-")).call(_context20, listType, "-list-item-delete"),
547
- onClick: handleRemove.bind(_this, file)
548
- }, "\u5220\u9664"))) : /*#__PURE__*/React.createElement(_image.default, {
549
- previewType: "upload",
550
- name: file.name,
551
- size: (0, _utils2.getFileSize)(file.size),
552
- src: file.thumbUrl || file.url,
553
- style: {
554
- width: '100%',
555
- height: '100%'
556
- },
557
- operations: [/*#__PURE__*/React.createElement(_icon.default, {
558
- key: "1",
559
- type: "delete",
560
- onClick: handleRemove.bind(_this, file)
561
- })]
490
+ return itemRender ? itemRender( /*#__PURE__*/React.createElement(Item, (0, _extends2.default)({}, {
491
+ file: file,
492
+ prefixCls: prefixCls,
493
+ listType: listType,
494
+ handleReUpload: handleReUpload,
495
+ handleRemove: handleRemove
496
+ })), file, setFileList) : /*#__PURE__*/React.createElement(Item, (0, _extends2.default)({
497
+ key: file.uid
498
+ }, {
499
+ file: file,
500
+ prefixCls: prefixCls,
501
+ listType: listType,
502
+ handleReUpload: handleReUpload,
503
+ handleRemove: handleRemove
562
504
  }));
563
505
  })));
564
506
  };
565
507
 
508
+ var Item = function Item(_ref3) {
509
+ var _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20;
510
+
511
+ var file = _ref3.file,
512
+ prefixCls = _ref3.prefixCls,
513
+ listType = _ref3.listType,
514
+ handleReUpload = _ref3.handleReUpload,
515
+ handleRemove = _ref3.handleRemove;
516
+ var mapStatus = {
517
+ uploading: 'loadding',
518
+ error: 'warning-solid',
519
+ done: 'attachment',
520
+ success: 'attachment',
521
+ notStart: 'attachment'
522
+ };
523
+ return /*#__PURE__*/React.createElement("li", {
524
+ className: (0, _classnames.default)((0, _concat.default)(_context8 = "".concat(prefixCls, "-")).call(_context8, listType, "-list-item"), {
525
+ error: file.status === 'error'
526
+ })
527
+ }, listType === 'text' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
528
+ className: (0, _concat.default)(_context9 = "".concat(prefixCls, "-")).call(_context9, listType, "-list-item-icon")
529
+ }, /*#__PURE__*/React.createElement(_icon.default, {
530
+ spin: file.status === 'uploading',
531
+ type: mapStatus[file.status]
532
+ })), /*#__PURE__*/React.createElement("span", {
533
+ className: (0, _concat.default)(_context10 = "".concat(prefixCls, "-")).call(_context10, listType, "-list-item-name"),
534
+ title: file.name
535
+ }, file.name), /*#__PURE__*/React.createElement("span", {
536
+ className: (0, _concat.default)(_context11 = "".concat(prefixCls, "-")).call(_context11, listType, "-list-item-size")
537
+ }, "(", (0, _utils2.getFileSize)(file.size), ")"), /*#__PURE__*/React.createElement("div", {
538
+ className: (0, _concat.default)(_context12 = "".concat(prefixCls, "-")).call(_context12, listType, "-list-item-action")
539
+ }, file.status === 'error' && /*#__PURE__*/React.createElement("a", {
540
+ href: "true",
541
+ className: (0, _concat.default)(_context13 = "".concat(prefixCls, "-")).call(_context13, listType, "-list-item-reupload"),
542
+ onClick: handleReUpload.bind(_this, file)
543
+ }, "\u91CD\u65B0\u4E0A\u4F20"), /*#__PURE__*/React.createElement("a", {
544
+ href: "true",
545
+ className: (0, _concat.default)(_context14 = "".concat(prefixCls, "-")).call(_context14, listType, "-list-item-delete"),
546
+ onClick: handleRemove.bind(_this, file)
547
+ }, "\u5220\u9664"))) : file.status === 'uploading' ? /*#__PURE__*/React.createElement("div", {
548
+ className: (0, _concat.default)(_context15 = "".concat(prefixCls, "-")).call(_context15, listType, "-list-item-loading")
549
+ }, /*#__PURE__*/React.createElement(_progress.default, {
550
+ percent: file.percent,
551
+ textMap: ['文件上传中'],
552
+ showInfo: false
553
+ })) : file.status === 'error' ? /*#__PURE__*/React.createElement("div", {
554
+ className: (0, _concat.default)(_context16 = "".concat(prefixCls, "-")).call(_context16, listType, "-list-item-error")
555
+ }, /*#__PURE__*/React.createElement("div", {
556
+ className: (0, _concat.default)(_context17 = "".concat(prefixCls, "-")).call(_context17, listType, "-list-item-error-text")
557
+ }, /*#__PURE__*/React.createElement(_icon.default, {
558
+ type: mapStatus[file.status],
559
+ style: {
560
+ verticalAlign: 'top'
561
+ }
562
+ }), "\u4E0A\u4F20\u5931\u8D25"), /*#__PURE__*/React.createElement("div", {
563
+ className: (0, _concat.default)(_context18 = "".concat(prefixCls, "-")).call(_context18, listType, "-list-item-action")
564
+ }, /*#__PURE__*/React.createElement("a", {
565
+ href: "true",
566
+ className: (0, _concat.default)(_context19 = "".concat(prefixCls, "-")).call(_context19, listType, "-list-item-reupload"),
567
+ onClick: handleReUpload.bind(_this, file)
568
+ }, "\u91CD\u65B0\u4E0A\u4F20"), /*#__PURE__*/React.createElement("a", {
569
+ href: "true",
570
+ className: (0, _concat.default)(_context20 = "".concat(prefixCls, "-")).call(_context20, listType, "-list-item-delete"),
571
+ onClick: handleRemove.bind(_this, file)
572
+ }, "\u5220\u9664"))) : /*#__PURE__*/React.createElement(_image.default, {
573
+ previewType: "upload",
574
+ name: file.name,
575
+ size: (0, _utils2.getFileSize)(file.size),
576
+ src: file.thumbUrl || file.url,
577
+ style: {
578
+ width: '100%',
579
+ height: '100%'
580
+ },
581
+ operations: [/*#__PURE__*/React.createElement(_icon.default, {
582
+ key: "1",
583
+ type: "delete",
584
+ onClick: handleRemove.bind(_this, file)
585
+ })]
586
+ }));
587
+ };
588
+
566
589
  var Upload = /*#__PURE__*/React.forwardRef(InternalUpload);
567
590
  Upload.displayName = 'Upload';
568
591
  var _default = Upload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.6.7",
3
+ "version": "1.6.10",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [