@kdcloudjs/kdesign 1.6.13 → 1.6.15

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/kdesign-complete.less +326 -249
  3. package/dist/kdesign.css +88 -17
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +732 -399
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +4 -4
  8. package/dist/kdesign.min.js +5 -5
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/usePopper.d.ts +1 -0
  11. package/es/_utils/usePopper.js +3 -1
  12. package/es/button/button.js +1 -1
  13. package/es/button/style/index.css +3 -0
  14. package/es/button/style/index.less +4 -0
  15. package/es/button/style/token.less +1 -0
  16. package/es/carousel/carousel.d.ts +1 -0
  17. package/es/carousel/carousel.js +66 -3
  18. package/es/carousel/style/index.css +39 -0
  19. package/es/carousel/style/index.less +40 -0
  20. package/es/carousel/style/token.less +2 -0
  21. package/es/config-provider/compDefaultProps.d.ts +2 -0
  22. package/es/config-provider/compDefaultProps.js +4 -2
  23. package/es/date-picker/range-picker.js +6 -17
  24. package/es/date-picker/style/index.css +9 -9
  25. package/es/date-picker/style/index.less +1 -1
  26. package/es/date-picker/style/token.less +1 -1
  27. package/es/form/Field.js +67 -33
  28. package/es/form/FieldContext.js +1 -1
  29. package/es/form/hooks/useForm.js +29 -42
  30. package/es/form/interface.d.ts +7 -3
  31. package/es/icon/icon.js +23 -4
  32. package/es/image/preview.d.ts +1 -0
  33. package/es/image/preview.js +31 -6
  34. package/es/input/style/index.css +4 -3
  35. package/es/input/style/index.less +230 -227
  36. package/es/input/style/token.less +11 -12
  37. package/es/modal/modal.js +4 -8
  38. package/es/modal/style/index.css +7 -0
  39. package/es/modal/style/index.less +8 -0
  40. package/es/select/select.js +11 -8
  41. package/es/select/style/index.css +6 -3
  42. package/es/select/style/index.less +9 -3
  43. package/es/select/style/token.less +10 -5
  44. package/es/style/core/motion/other.less +9 -0
  45. package/es/style/icon/kdicon.css +3 -1
  46. package/es/style/icon/kdicon.woff +0 -0
  47. package/es/style/index.css +16 -0
  48. package/es/table/interface.d.ts +1 -0
  49. package/es/tooltip/tooltip.d.ts +1 -1
  50. package/es/tooltip/tooltip.js +9 -2
  51. package/es/tree/tree.d.ts +8 -0
  52. package/es/tree/tree.js +32 -17
  53. package/es/tree/treeHooks.d.ts +3 -3
  54. package/es/tree/treeHooks.js +7 -7
  55. package/es/tree/utils/treeUtils.d.ts +19 -6
  56. package/es/tree/utils/treeUtils.js +183 -33
  57. package/lib/_utils/usePopper.d.ts +1 -0
  58. package/lib/_utils/usePopper.js +3 -1
  59. package/lib/button/button.js +1 -1
  60. package/lib/button/style/index.css +3 -0
  61. package/lib/button/style/index.less +4 -0
  62. package/lib/button/style/token.less +1 -0
  63. package/lib/carousel/carousel.d.ts +1 -0
  64. package/lib/carousel/carousel.js +69 -2
  65. package/lib/carousel/style/index.css +39 -0
  66. package/lib/carousel/style/index.less +40 -0
  67. package/lib/carousel/style/token.less +2 -0
  68. package/lib/config-provider/compDefaultProps.d.ts +2 -0
  69. package/lib/config-provider/compDefaultProps.js +4 -2
  70. package/lib/date-picker/range-picker.js +6 -17
  71. package/lib/date-picker/style/index.css +9 -9
  72. package/lib/date-picker/style/index.less +1 -1
  73. package/lib/date-picker/style/token.less +1 -1
  74. package/lib/form/Field.js +68 -33
  75. package/lib/form/FieldContext.js +1 -1
  76. package/lib/form/hooks/useForm.js +28 -42
  77. package/lib/form/interface.d.ts +7 -3
  78. package/lib/icon/icon.js +22 -4
  79. package/lib/image/preview.d.ts +1 -0
  80. package/lib/image/preview.js +31 -6
  81. package/lib/input/style/index.css +4 -3
  82. package/lib/input/style/index.less +230 -227
  83. package/lib/input/style/token.less +11 -12
  84. package/lib/modal/modal.js +4 -8
  85. package/lib/modal/style/index.css +7 -0
  86. package/lib/modal/style/index.less +8 -0
  87. package/lib/select/select.js +11 -11
  88. package/lib/select/style/index.css +6 -3
  89. package/lib/select/style/index.less +9 -3
  90. package/lib/select/style/token.less +10 -5
  91. package/lib/style/core/motion/other.less +9 -0
  92. package/lib/style/icon/kdicon.css +3 -1
  93. package/lib/style/icon/kdicon.woff +0 -0
  94. package/lib/style/index.css +16 -0
  95. package/lib/table/interface.d.ts +1 -0
  96. package/lib/tooltip/tooltip.d.ts +1 -1
  97. package/lib/tooltip/tooltip.js +15 -5
  98. package/lib/tree/tree.d.ts +8 -0
  99. package/lib/tree/tree.js +30 -16
  100. package/lib/tree/treeHooks.d.ts +3 -3
  101. package/lib/tree/treeHooks.js +6 -6
  102. package/lib/tree/utils/treeUtils.d.ts +19 -6
  103. package/lib/tree/utils/treeUtils.js +193 -33
  104. package/package.json +1 -1
@@ -11,8 +11,7 @@ import Schema from 'async-validator';
11
11
  import cloneDeep from 'lodash/cloneDeep';
12
12
  import get from 'lodash/get';
13
13
  import merge from 'lodash/merge';
14
- import set from 'lodash/set'; // import useForceUpdate from './useForceUpdate'
15
-
14
+ import set from 'lodash/set';
16
15
  import devwarning from '../../_utils/devwarning';
17
16
  export var INTERNAL_HOOK_KEY = '__KD_INTERNAL_FORM_HOOK__';
18
17
 
@@ -21,16 +20,12 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
21
20
 
22
21
  _classCallCheck(this, FormStore);
23
22
 
24
- this.isMounted = false; // private forceRootUpdate:() => void
25
-
23
+ this.isMounted = false;
26
24
  this.defaultValues = {};
27
25
  this.store = {};
28
26
  this.fields = {};
29
- this.rules = {};
30
27
  this.errorMessages = {};
31
- this.callbacks = {}; // constructor (forceRootUpdate: () => void) {
32
- // this.forceRootUpdate = forceRootUpdate
33
- // }
28
+ this.callbacks = {};
34
29
 
35
30
  this.getForm = function () {
36
31
  return {
@@ -42,7 +37,6 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
42
37
  resetFields: _this.resetFields,
43
38
  setFieldValue: _this.setFieldValue,
44
39
  setFieldsValue: _this.setFieldsValue,
45
- setRules: _this.setRules,
46
40
  validateFields: _this.validateFields,
47
41
  submit: _this.submit,
48
42
  getInternalHooks: _this.getInternalHooks
@@ -60,7 +54,8 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
60
54
  dispatch: _this.dispatch,
61
55
  setDefaultValues: _this.setDefaultValues,
62
56
  setCallbacks: _this.setCallbacks,
63
- registerField: _this.registerField
57
+ registerField: _this.registerField,
58
+ deleteField: _this.deleteField
64
59
  };
65
60
  };
66
61
 
@@ -169,25 +164,25 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
169
164
  this.getRules = function (namePathList) {
170
165
  _this.warningUnhooked();
171
166
 
172
- if (!namePathList) {
173
- return _this.rules;
167
+ var list = cloneDeep(namePathList);
168
+
169
+ if (!list) {
170
+ list = _Object$keys(_this.fields);
174
171
  }
175
172
 
176
173
  var rules = {};
177
- namePathList.forEach(function (name) {
178
- if (_this.rules[name]) {
179
- rules[name] = cloneDeep(_this.rules[name]);
174
+ list.forEach(function (name) {
175
+ var _a, _b;
176
+
177
+ var current = _this.fields[name].current;
178
+
179
+ if ((_a = current === null || current === void 0 ? void 0 : current.meta) === null || _a === void 0 ? void 0 : _a.rules) {
180
+ rules[name] = cloneDeep((_b = current === null || current === void 0 ? void 0 : current.meta) === null || _b === void 0 ? void 0 : _b.rules);
180
181
  }
181
182
  });
182
183
  return _Object$keys(rules).length === 0 ? null : rules;
183
184
  };
184
185
 
185
- this.setRules = function (name, rules) {
186
- _this.warningUnhooked();
187
-
188
- set(_this.rules, name, rules);
189
- };
190
-
191
186
  this.setCallbacks = function (callbacks) {
192
187
  _this.warningUnhooked();
193
188
 
@@ -231,27 +226,19 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
231
226
  onValuesChange(_defineProperty({}, name, value), cloneDeep(_this.store));
232
227
  }
233
228
  };
234
- /**
235
- * 注册 Field
236
- * Field 如果带有验证规则的话,则注册时进行校验
237
- * @param name Field 名称
238
- * @param field Field 实例
239
- */
240
-
241
229
 
242
230
  this.registerField = function (name, field) {
243
231
  _this.warningUnhooked();
244
232
 
245
233
  _this.fields[name] = field;
246
- var meta = field.meta;
234
+ };
247
235
 
248
- if (meta.rules !== undefined) {
249
- _this.setRules(name, meta.rules); // TODO: 初始化的时候是否需要校验??
250
- // this.validateFields([name]).catch(({ errorInfos }) => {
251
- // this.validateFieldFaild(errorInfos, 'internal')
252
- // })
236
+ this.deleteField = function (name) {
237
+ _this.warningUnhooked();
253
238
 
254
- }
239
+ Object.hasOwnProperty.call(_this.fields, name) && delete _this.fields[name];
240
+ Object.hasOwnProperty.call(_this.errorMessages, name) && delete _this.errorMessages[name];
241
+ Object.hasOwnProperty.call(_this.store, name) && delete _this.store[name];
255
242
  };
256
243
 
257
244
  this.validateFields = function (namePathList) {
@@ -296,7 +283,11 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
296
283
  _this.notifyObservers(_this.store, namePathList || [], 'validateFinish');
297
284
  }).catch(function (_ref2) {
298
285
  var errorInfos = _ref2.errorInfos;
299
- _this.errorMessages = {};
286
+
287
+ if (!namePathList) {
288
+ _this.errorMessages = {};
289
+ }
290
+
300
291
  var _errorInfos$fields = errorInfos.fields,
301
292
  fields = _errorInfos$fields === void 0 ? {} : _errorInfos$fields;
302
293
 
@@ -336,7 +327,7 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
336
327
  _this.warningUnhooked();
337
328
 
338
329
  _Object$values(_this.fields).forEach(function (_ref4) {
339
- var onStoreChange = _ref4.onStoreChange;
330
+ var onStoreChange = _ref4.current.onStoreChange;
340
331
  var stores = {
341
332
  prev: prevStore,
342
333
  curr: _this.store
@@ -347,16 +338,12 @@ var FormStore = /*#__PURE__*/_createClass(function FormStore() {
347
338
  });
348
339
 
349
340
  function useForm(form) {
350
- var formRef = React.useRef(); // const forceUpdate = useForceUpdate()
341
+ var formRef = React.useRef();
351
342
 
352
343
  if (!formRef.current) {
353
344
  if (form) {
354
345
  formRef.current = form;
355
346
  } else {
356
- // Create a new FormStore if not provided
357
- // const forceReRender = () => {
358
- // forceUpdate()
359
- // }
360
347
  var formStore = new FormStore();
361
348
  formRef.current = formStore.getForm();
362
349
  }
@@ -10,7 +10,9 @@ export interface FieldError {
10
10
  [name: string]: string;
11
11
  }
12
12
  export interface Fields {
13
- [name: string]: FieldInstance;
13
+ [name: string]: {
14
+ current: FieldInstance;
15
+ };
14
16
  }
15
17
  export interface FormInstance<Values = any> {
16
18
  getFieldError: (name: NamePath) => string | undefined;
@@ -21,7 +23,6 @@ export interface FormInstance<Values = any> {
21
23
  resetFields: (fields?: NamePath[]) => void;
22
24
  setFieldsValue: (value: Values) => void;
23
25
  setFieldValue: (name: NamePath, value: Values) => void;
24
- setRules: (name: NamePath, rules: any) => void;
25
26
  validateFields: (namePathList?: NamePath[]) => Promise<Values>;
26
27
  submit: () => void;
27
28
  getInternalHooks: (secret: string) => InternalHooks | null;
@@ -71,7 +72,10 @@ export interface InternalHooks {
71
72
  dispatch: (action: ReducerAction) => void;
72
73
  setDefaultValues: (values: Store) => void;
73
74
  setCallbacks: (callbacks: Callbacks) => void;
74
- registerField: (name: NamePath, field: FieldInstance) => void;
75
+ registerField: (name: NamePath, field: {
76
+ current: FieldInstance;
77
+ }) => void;
78
+ deleteField: (name: NamePath) => void;
75
79
  }
76
80
  export declare type NotifySource = 'externalUpdateValue' | 'updateValue' | 'reset' | 'validateField' | 'validateFinish';
77
81
  export interface ValidateErrorEntity<Values = any> {
package/es/icon/icon.js CHANGED
@@ -1,6 +1,21 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
4
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
5
+
6
+ var __rest = this && this.__rest || function (s, e) {
7
+ var t = {};
8
+
9
+ for (var p in s) {
10
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
11
+ }
12
+
13
+ if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
14
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
15
+ }
16
+ return t;
17
+ };
18
+
4
19
  import React, { useContext } from 'react';
5
20
  import classNames from 'classnames';
6
21
  import ConfigContext from '../config-provider/ConfigContext';
@@ -13,6 +28,7 @@ var InternalIcon = function InternalIcon(props, ref) {
13
28
  userDefaultProps = _useContext.compDefaultProps;
14
29
 
15
30
  var iconProps = getCompProps('Icon', userDefaultProps, props);
31
+
16
32
  var type = iconProps.type,
17
33
  spin = iconProps.spin,
18
34
  style = iconProps.style,
@@ -21,7 +37,9 @@ var InternalIcon = function InternalIcon(props, ref) {
21
37
  rotate = iconProps.rotate,
22
38
  onClick = iconProps.onClick,
23
39
  onMouseEnter = iconProps.onMouseEnter,
24
- onMouseLeave = iconProps.onMouseLeave;
40
+ onMouseLeave = iconProps.onMouseLeave,
41
+ others = __rest(iconProps, ["type", "spin", "style", "prefix", "className", "rotate", "onClick", "onMouseEnter", "onMouseLeave"]);
42
+
25
43
  var innerRef = React.useRef();
26
44
  var iconRef = ref || innerRef;
27
45
  var iconPrefix = prefix || iconProps.iconPrefix;
@@ -45,14 +63,15 @@ var InternalIcon = function InternalIcon(props, ref) {
45
63
  iconStyle.transform = "rotate(".concat(rotate, "deg)");
46
64
  }
47
65
 
48
- return /*#__PURE__*/React.createElement("i", {
66
+ return /*#__PURE__*/React.createElement("i", _extends({
49
67
  className: iconClass,
50
68
  onClick: handleClick,
51
69
  onMouseEnter: handleMouseEnter,
52
70
  onMouseLeave: handleMouseLeave,
53
- style: iconStyle,
71
+ style: iconStyle
72
+ }, others, {
54
73
  ref: iconRef
55
- });
74
+ }));
56
75
  };
57
76
 
58
77
  var Icon = /*#__PURE__*/React.forwardRef(InternalIcon);
@@ -5,6 +5,7 @@ export interface PreviewProps {
5
5
  alt?: string;
6
6
  name?: string;
7
7
  size?: string;
8
+ scales?: Array<number>;
8
9
  visible: boolean;
9
10
  type?: PreviewType;
10
11
  className?: string;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
+ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
3
4
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
5
  import * as React from 'react';
5
6
  import ReactDOM from 'react-dom';
@@ -24,6 +25,7 @@ var Preview = function Preview(props) {
24
25
  alt = allProps.alt,
25
26
  name = allProps.name,
26
27
  size = allProps.size,
28
+ scales = allProps.scales,
27
29
  visible = allProps.visible,
28
30
  onClose = allProps.onClose,
29
31
  current = allProps.current,
@@ -53,14 +55,28 @@ var Preview = function Preview(props) {
53
55
  scale = _React$useState6[0],
54
56
  setScale = _React$useState6[1];
55
57
 
58
+ var maxScale = scales[scales.length - 1] / 100;
59
+ var minScale = scales[0] / 100;
56
60
  React.useEffect(function () {
57
61
  if (show) {
58
62
  document.body.style.overflow = 'hidden';
59
63
  var throMouseWheel = throttle(function (e) {
60
64
  if (e.wheelDelta > 0) {
61
- setScale(scale + 0.1);
65
+ if (scale > maxScale) return;
66
+
67
+ if (scale + 0.1 > maxScale) {
68
+ setScale(maxScale);
69
+ } else {
70
+ setScale(scale + 0.1);
71
+ }
62
72
  } else if (e.wheelDelta < 0) {
63
- if (scale > 1) setScale(scale - 0.1);
73
+ if (scale < minScale) return;
74
+
75
+ if (scale - 0.1 < minScale) {
76
+ setScale(minScale);
77
+ } else {
78
+ setScale(scale - 0.1);
79
+ }
64
80
  }
65
81
  }, 200);
66
82
  document.addEventListener('mousewheel', throMouseWheel);
@@ -74,12 +90,18 @@ var Preview = function Preview(props) {
74
90
  }, [show, scale]);
75
91
 
76
92
  var handleZoomOut = function handleZoomOut() {
77
- var newScale = scale - 1;
78
- setScale(Math.max(newScale, 1));
93
+ var nextScale = scales.findLast(function (s) {
94
+ return s / 100 < scale;
95
+ });
96
+ if (nextScale !== undefined) setScale(nextScale / 100);
79
97
  };
80
98
 
81
99
  var handleZoomIn = function handleZoomIn() {
82
- setScale(scale + 1);
100
+ var nextScale = _findInstanceProperty(scales).call(scales, function (s) {
101
+ return s / 100 > scale;
102
+ });
103
+
104
+ if (nextScale !== undefined) setScale(nextScale / 100);
83
105
  };
84
106
 
85
107
  var previewImgProps = {
@@ -121,11 +143,14 @@ var Preview = function Preview(props) {
121
143
  }), /*#__PURE__*/React.createElement(Icon, {
122
144
  type: "shrink",
123
145
  className: classNames({
124
- disabled: scale <= 1
146
+ disabled: scale <= minScale
125
147
  }),
126
148
  onClick: handleZoomOut
127
149
  }), /*#__PURE__*/React.createElement(Icon, {
128
150
  type: "zoom",
151
+ className: classNames({
152
+ disabled: scale >= maxScale
153
+ }),
129
154
  onClick: handleZoomIn
130
155
  }), props.type !== 'upload' && operations, props.type !== 'upload' && length && /*#__PURE__*/React.createElement(Icon, {
131
156
  type: "arrow-right",
@@ -259,6 +259,7 @@ textarea {
259
259
  padding: var(--kd-c-input-spacing-padding-vertical-small, 3px) var(--kd-c-input-spacing-padding-horizontal-small, 9px);
260
260
  }
261
261
  .kd-input-wrapper {
262
+ padding-left: var(--kd-c-input-wrapper-padding-left, 0px) !important;
262
263
  width: 100%;
263
264
  min-width: 0;
264
265
  border: var(--kd-c-input-sizing-border, 1px) solid var(--kd-c-input-color-border-disabled, var(--kd-g-color-border-strong, #d9d9d9));
@@ -306,7 +307,7 @@ textarea {
306
307
  }
307
308
  .kd-input-wrapper .kd-input {
308
309
  border: none;
309
- padding-left: 0;
310
+ padding-left: var(--kd-c-input-padding-left, 9px);
310
311
  padding-right: 0;
311
312
  height: 100%;
312
313
  }
@@ -453,8 +454,8 @@ textarea {
453
454
  font-size: 14px;
454
455
  font-variant: tabular-nums;
455
456
  list-style: none;
456
- -webkit-font-feature-settings: "tnum";
457
- font-feature-settings: "tnum";
457
+ -webkit-font-feature-settings: 'tnum';
458
+ font-feature-settings: 'tnum';
458
459
  position: relative;
459
460
  display: -webkit-box;
460
461
  display: -ms-flexbox;