@kdcloudjs/kdesign 1.6.14 → 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 (88) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/kdesign-complete.less +305 -239
  3. package/dist/kdesign.css +73 -5
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +536 -227
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +4 -4
  8. package/dist/kdesign.min.js +8 -8
  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 +1 -0
  22. package/es/config-provider/compDefaultProps.js +2 -1
  23. package/es/form/Field.js +7 -1
  24. package/es/form/FieldContext.js +1 -0
  25. package/es/form/hooks/useForm.js +14 -20
  26. package/es/form/interface.d.ts +1 -0
  27. package/es/image/preview.d.ts +1 -0
  28. package/es/image/preview.js +31 -6
  29. package/es/input/style/index.css +4 -3
  30. package/es/input/style/index.less +230 -227
  31. package/es/input/style/token.less +11 -12
  32. package/es/modal/modal.js +4 -8
  33. package/es/modal/style/index.css +7 -0
  34. package/es/modal/style/index.less +8 -0
  35. package/es/select/select.js +11 -8
  36. package/es/style/core/motion/other.less +9 -0
  37. package/es/style/icon/kdicon.css +3 -1
  38. package/es/style/icon/kdicon.woff +0 -0
  39. package/es/style/index.css +16 -0
  40. package/es/table/interface.d.ts +1 -0
  41. package/es/tooltip/tooltip.d.ts +1 -1
  42. package/es/tooltip/tooltip.js +10 -2
  43. package/es/tree/tree.d.ts +8 -0
  44. package/es/tree/tree.js +32 -17
  45. package/es/tree/treeHooks.d.ts +3 -3
  46. package/es/tree/treeHooks.js +7 -7
  47. package/es/tree/utils/treeUtils.d.ts +19 -6
  48. package/es/tree/utils/treeUtils.js +183 -33
  49. package/lib/_utils/usePopper.d.ts +1 -0
  50. package/lib/_utils/usePopper.js +3 -1
  51. package/lib/button/button.js +1 -1
  52. package/lib/button/style/index.css +3 -0
  53. package/lib/button/style/index.less +4 -0
  54. package/lib/button/style/token.less +1 -0
  55. package/lib/carousel/carousel.d.ts +1 -0
  56. package/lib/carousel/carousel.js +69 -2
  57. package/lib/carousel/style/index.css +39 -0
  58. package/lib/carousel/style/index.less +40 -0
  59. package/lib/carousel/style/token.less +2 -0
  60. package/lib/config-provider/compDefaultProps.d.ts +1 -0
  61. package/lib/config-provider/compDefaultProps.js +2 -1
  62. package/lib/form/Field.js +7 -1
  63. package/lib/form/FieldContext.js +1 -0
  64. package/lib/form/hooks/useForm.js +13 -20
  65. package/lib/form/interface.d.ts +1 -0
  66. package/lib/image/preview.d.ts +1 -0
  67. package/lib/image/preview.js +31 -6
  68. package/lib/input/style/index.css +4 -3
  69. package/lib/input/style/index.less +230 -227
  70. package/lib/input/style/token.less +11 -12
  71. package/lib/modal/modal.js +4 -8
  72. package/lib/modal/style/index.css +7 -0
  73. package/lib/modal/style/index.less +8 -0
  74. package/lib/select/select.js +11 -11
  75. package/lib/style/core/motion/other.less +9 -0
  76. package/lib/style/icon/kdicon.css +3 -1
  77. package/lib/style/icon/kdicon.woff +0 -0
  78. package/lib/style/index.css +16 -0
  79. package/lib/table/interface.d.ts +1 -0
  80. package/lib/tooltip/tooltip.d.ts +1 -1
  81. package/lib/tooltip/tooltip.js +16 -5
  82. package/lib/tree/tree.d.ts +8 -0
  83. package/lib/tree/tree.js +30 -16
  84. package/lib/tree/treeHooks.d.ts +3 -3
  85. package/lib/tree/treeHooks.js +6 -6
  86. package/lib/tree/utils/treeUtils.d.ts +19 -6
  87. package/lib/tree/utils/treeUtils.js +193 -33
  88. package/package.json +1 -1
@@ -141,6 +141,7 @@ declare const compDefaultProps: {
141
141
  };
142
142
  Image: {
143
143
  preview: boolean;
144
+ scales: number[];
144
145
  };
145
146
  InputNumber: {
146
147
  type: string;
@@ -164,7 +164,8 @@ var compDefaultProps = {
164
164
  optionFilterProp: 'label'
165
165
  },
166
166
  Image: {
167
- preview: true
167
+ preview: true,
168
+ scales: [25, 50, 75, 100, 125, 150, 200]
168
169
  },
169
170
  InputNumber: {
170
171
  type: 'text',
package/lib/form/Field.js CHANGED
@@ -145,7 +145,8 @@ var Field = function Field(props) {
145
145
  var _getInternalHooks = getInternalHooks(_useForm.INTERNAL_HOOK_KEY),
146
146
  registerField = _getInternalHooks.registerField,
147
147
  dispatch = _getInternalHooks.dispatch,
148
- setDefaultValues = _getInternalHooks.setDefaultValues;
148
+ setDefaultValues = _getInternalHooks.setDefaultValues,
149
+ deleteField = _getInternalHooks.deleteField;
149
150
 
150
151
  var name = props.name,
151
152
  customizeHtmlFor = props.htmlFor,
@@ -261,6 +262,11 @@ var Field = function Field(props) {
261
262
  setDefaultValues((0, _defineProperty2.default)({}, name, defaultValue));
262
263
  }
263
264
  }, [name, registerField]);
265
+ (0, _react.useEffect)(function () {
266
+ return function () {
267
+ deleteField(name);
268
+ };
269
+ }, []);
264
270
  var formPrefixCls = getPrefixCls === null || getPrefixCls === void 0 ? void 0 : getPrefixCls(prefixCls, 'form', customizePrefixcls);
265
271
  var formItemClassName = (0, _classnames2.default)((_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(formPrefixCls), true), (0, _defineProperty2.default)(_classnames, "".concat(formPrefixCls, "-field"), true), (0, _defineProperty2.default)(_classnames, "".concat(formPrefixCls, "-field-hidden"), hidden), (0, _defineProperty2.default)(_classnames, "".concat(formPrefixCls, "-field-vertical"), vertical), _classnames), className);
266
272
  var value = getFieldValue(name);
@@ -32,6 +32,7 @@ var context = /*#__PURE__*/_react.default.createContext({
32
32
  dispatch: warningFunc,
33
33
  setDefaultValues: warningFunc,
34
34
  registerField: warningFunc,
35
+ deleteField: warningFunc,
35
36
  setCallbacks: warningFunc
36
37
  };
37
38
  }
@@ -37,22 +37,18 @@ var _set = _interopRequireDefault(require("lodash/set"));
37
37
 
38
38
  var _devwarning = _interopRequireDefault(require("../../_utils/devwarning"));
39
39
 
40
- // import useForceUpdate from './useForceUpdate'
41
40
  var INTERNAL_HOOK_KEY = '__KD_INTERNAL_FORM_HOOK__';
42
41
  exports.INTERNAL_HOOK_KEY = INTERNAL_HOOK_KEY;
43
42
  var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
44
43
  var _this = this;
45
44
 
46
45
  (0, _classCallCheck2.default)(this, FormStore);
47
- this.isMounted = false; // private forceRootUpdate:() => void
48
-
46
+ this.isMounted = false;
49
47
  this.defaultValues = {};
50
48
  this.store = {};
51
49
  this.fields = {};
52
50
  this.errorMessages = {};
53
- this.callbacks = {}; // constructor (forceRootUpdate: () => void) {
54
- // this.forceRootUpdate = forceRootUpdate
55
- // }
51
+ this.callbacks = {};
56
52
 
57
53
  this.getForm = function () {
58
54
  return {
@@ -81,7 +77,8 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
81
77
  dispatch: _this.dispatch,
82
78
  setDefaultValues: _this.setDefaultValues,
83
79
  setCallbacks: _this.setCallbacks,
84
- registerField: _this.registerField
80
+ registerField: _this.registerField,
81
+ deleteField: _this.deleteField
85
82
  };
86
83
  };
87
84
 
@@ -252,13 +249,6 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
252
249
  onValuesChange((0, _defineProperty2.default)({}, name, value), (0, _cloneDeep.default)(_this.store));
253
250
  }
254
251
  };
255
- /**
256
- * 注册 Field
257
- * Field 如果带有验证规则的话,则注册时进行校验
258
- * @param name Field 名称
259
- * @param field Field 实例
260
- */
261
-
262
252
 
263
253
  this.registerField = function (name, field) {
264
254
  _this.warningUnhooked();
@@ -266,6 +256,14 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
266
256
  _this.fields[name] = field;
267
257
  };
268
258
 
259
+ this.deleteField = function (name) {
260
+ _this.warningUnhooked();
261
+
262
+ Object.hasOwnProperty.call(_this.fields, name) && delete _this.fields[name];
263
+ Object.hasOwnProperty.call(_this.errorMessages, name) && delete _this.errorMessages[name];
264
+ Object.hasOwnProperty.call(_this.store, name) && delete _this.store[name];
265
+ };
266
+
269
267
  this.validateFields = function (namePathList) {
270
268
  _this.warningUnhooked();
271
269
 
@@ -362,17 +360,12 @@ var FormStore = /*#__PURE__*/(0, _createClass2.default)(function FormStore() {
362
360
  });
363
361
 
364
362
  function useForm(form) {
365
- var formRef = _react.default.useRef(); // const forceUpdate = useForceUpdate()
366
-
363
+ var formRef = _react.default.useRef();
367
364
 
368
365
  if (!formRef.current) {
369
366
  if (form) {
370
367
  formRef.current = form;
371
368
  } else {
372
- // Create a new FormStore if not provided
373
- // const forceReRender = () => {
374
- // forceUpdate()
375
- // }
376
369
  var formStore = new FormStore();
377
370
  formRef.current = formStore.getForm();
378
371
  }
@@ -75,6 +75,7 @@ export interface InternalHooks {
75
75
  registerField: (name: NamePath, field: {
76
76
  current: FieldInstance;
77
77
  }) => void;
78
+ deleteField: (name: NamePath) => void;
78
79
  }
79
80
  export declare type NotifySource = 'externalUpdateValue' | 'updateValue' | 'reset' | 'validateField' | 'validateFinish';
80
81
  export interface ValidateErrorEntity<Values = any> {
@@ -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;
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "__esModule", {
13
13
  });
14
14
  exports.default = void 0;
15
15
 
16
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
17
+
16
18
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
17
19
 
18
20
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
@@ -53,6 +55,7 @@ var Preview = function Preview(props) {
53
55
  alt = allProps.alt,
54
56
  name = allProps.name,
55
57
  size = allProps.size,
58
+ scales = allProps.scales,
56
59
  visible = allProps.visible,
57
60
  onClose = allProps.onClose,
58
61
  current = allProps.current,
@@ -82,14 +85,28 @@ var Preview = function Preview(props) {
82
85
  scale = _React$useState6[0],
83
86
  setScale = _React$useState6[1];
84
87
 
88
+ var maxScale = scales[scales.length - 1] / 100;
89
+ var minScale = scales[0] / 100;
85
90
  React.useEffect(function () {
86
91
  if (show) {
87
92
  document.body.style.overflow = 'hidden';
88
93
  var throMouseWheel = (0, _throttle.default)(function (e) {
89
94
  if (e.wheelDelta > 0) {
90
- setScale(scale + 0.1);
95
+ if (scale > maxScale) return;
96
+
97
+ if (scale + 0.1 > maxScale) {
98
+ setScale(maxScale);
99
+ } else {
100
+ setScale(scale + 0.1);
101
+ }
91
102
  } else if (e.wheelDelta < 0) {
92
- if (scale > 1) setScale(scale - 0.1);
103
+ if (scale < minScale) return;
104
+
105
+ if (scale - 0.1 < minScale) {
106
+ setScale(minScale);
107
+ } else {
108
+ setScale(scale - 0.1);
109
+ }
93
110
  }
94
111
  }, 200);
95
112
  document.addEventListener('mousewheel', throMouseWheel);
@@ -103,12 +120,17 @@ var Preview = function Preview(props) {
103
120
  }, [show, scale]);
104
121
 
105
122
  var handleZoomOut = function handleZoomOut() {
106
- var newScale = scale - 1;
107
- setScale(Math.max(newScale, 1));
123
+ var nextScale = scales.findLast(function (s) {
124
+ return s / 100 < scale;
125
+ });
126
+ if (nextScale !== undefined) setScale(nextScale / 100);
108
127
  };
109
128
 
110
129
  var handleZoomIn = function handleZoomIn() {
111
- setScale(scale + 1);
130
+ var nextScale = (0, _find.default)(scales).call(scales, function (s) {
131
+ return s / 100 > scale;
132
+ });
133
+ if (nextScale !== undefined) setScale(nextScale / 100);
112
134
  };
113
135
 
114
136
  var previewImgProps = {
@@ -150,11 +172,14 @@ var Preview = function Preview(props) {
150
172
  }), /*#__PURE__*/React.createElement(_icon.default, {
151
173
  type: "shrink",
152
174
  className: (0, _classnames.default)({
153
- disabled: scale <= 1
175
+ disabled: scale <= minScale
154
176
  }),
155
177
  onClick: handleZoomOut
156
178
  }), /*#__PURE__*/React.createElement(_icon.default, {
157
179
  type: "zoom",
180
+ className: (0, _classnames.default)({
181
+ disabled: scale >= maxScale
182
+ }),
158
183
  onClick: handleZoomIn
159
184
  }), props.type !== 'upload' && operations, props.type !== 'upload' && length && /*#__PURE__*/React.createElement(_icon.default, {
160
185
  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;