@kdcloudjs/kdesign 1.7.37 → 1.7.40

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 (96) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -1
  3. package/dist/kdesign-complete.less +107 -11
  4. package/dist/kdesign.css +186 -5
  5. package/dist/kdesign.css.map +1 -1
  6. package/dist/kdesign.js +1485 -240
  7. package/dist/kdesign.js.map +1 -1
  8. package/dist/kdesign.min.css +3 -3
  9. package/dist/kdesign.min.js +13 -8
  10. package/dist/kdesign.min.js.map +1 -1
  11. package/es/alert/style/index.css +4 -2
  12. package/es/alert/style/index.less +3 -1
  13. package/es/cascader/cascader.js +8 -4
  14. package/es/cascader/style/index.css +5 -2
  15. package/es/cascader/style/index.less +4 -2
  16. package/es/config-provider/compDefaultProps.d.ts +9 -0
  17. package/es/config-provider/compDefaultProps.js +10 -1
  18. package/es/date-picker/context.d.ts +4 -2
  19. package/es/date-picker/date-picker.d.ts +9 -0
  20. package/es/date-picker/date-picker.js +4 -2
  21. package/es/date-picker/panel/month/month.js +14 -9
  22. package/es/date-picker/panel/quarter/quarter.js +12 -4
  23. package/es/date-picker/panel/time/time-column.d.ts +2 -0
  24. package/es/date-picker/panel/time/time-column.js +14 -5
  25. package/es/date-picker/panel/time/time.js +8 -4
  26. package/es/date-picker/panel/week/week.js +20 -10
  27. package/es/date-picker/panel/year/year.js +12 -4
  28. package/es/date-picker/range-picker.js +11 -4
  29. package/es/index.d.ts +1 -0
  30. package/es/index.js +2 -1
  31. package/es/input-number/inputNumber.js +20 -14
  32. package/es/input-number/useSelectionRange.d.ts +2 -1
  33. package/es/input-number/useSelectionRange.js +3 -2
  34. package/es/modal/modal.d.ts +1 -0
  35. package/es/modal/modal.js +31 -5
  36. package/es/modal/style/index.css +21 -0
  37. package/es/modal/style/index.less +25 -9
  38. package/es/qr-code/index.d.ts +3 -0
  39. package/es/qr-code/index.js +3 -0
  40. package/es/qr-code/qr-code.d.ts +42 -0
  41. package/es/qr-code/qr-code.js +80 -0
  42. package/es/qr-code/style/css.js +2 -0
  43. package/es/qr-code/style/index.css +154 -0
  44. package/es/qr-code/style/index.d.ts +2 -0
  45. package/es/qr-code/style/index.js +2 -0
  46. package/es/qr-code/style/index.less +42 -0
  47. package/es/qr-code/style/mixin.less +6 -0
  48. package/es/qr-code/style/token.less +24 -0
  49. package/es/tree/tree.js +2 -2
  50. package/es/tree/treeHooks.d.ts +1 -1
  51. package/es/tree/treeHooks.js +2 -2
  52. package/es/tree-select/tree-select.js +2 -2
  53. package/lib/alert/style/index.css +4 -2
  54. package/lib/alert/style/index.less +3 -1
  55. package/lib/cascader/cascader.js +8 -4
  56. package/lib/cascader/style/index.css +5 -2
  57. package/lib/cascader/style/index.less +4 -2
  58. package/lib/config-provider/compDefaultProps.d.ts +9 -0
  59. package/lib/config-provider/compDefaultProps.js +10 -1
  60. package/lib/date-picker/context.d.ts +4 -2
  61. package/lib/date-picker/date-picker.d.ts +9 -0
  62. package/lib/date-picker/date-picker.js +4 -2
  63. package/lib/date-picker/panel/month/month.js +14 -9
  64. package/lib/date-picker/panel/quarter/quarter.js +12 -4
  65. package/lib/date-picker/panel/time/time-column.d.ts +2 -0
  66. package/lib/date-picker/panel/time/time-column.js +14 -5
  67. package/lib/date-picker/panel/time/time.js +8 -4
  68. package/lib/date-picker/panel/week/week.js +20 -10
  69. package/lib/date-picker/panel/year/year.js +12 -4
  70. package/lib/date-picker/range-picker.js +11 -4
  71. package/lib/index.d.ts +1 -0
  72. package/lib/index.js +7 -0
  73. package/lib/input-number/inputNumber.js +20 -14
  74. package/lib/input-number/useSelectionRange.d.ts +2 -1
  75. package/lib/input-number/useSelectionRange.js +3 -2
  76. package/lib/modal/modal.d.ts +1 -0
  77. package/lib/modal/modal.js +31 -5
  78. package/lib/modal/style/index.css +21 -0
  79. package/lib/modal/style/index.less +25 -9
  80. package/lib/qr-code/index.d.ts +3 -0
  81. package/lib/qr-code/index.js +27 -0
  82. package/lib/qr-code/qr-code.d.ts +42 -0
  83. package/lib/qr-code/qr-code.js +96 -0
  84. package/lib/qr-code/style/css.js +4 -0
  85. package/lib/qr-code/style/index.css +154 -0
  86. package/lib/qr-code/style/index.d.ts +2 -0
  87. package/lib/qr-code/style/index.js +4 -0
  88. package/lib/qr-code/style/index.less +42 -0
  89. package/lib/qr-code/style/mixin.less +6 -0
  90. package/lib/qr-code/style/token.less +24 -0
  91. package/lib/style/components.less +1 -0
  92. package/lib/tree/tree.js +2 -2
  93. package/lib/tree/treeHooks.d.ts +1 -1
  94. package/lib/tree/treeHooks.js +2 -2
  95. package/lib/tree-select/tree-select.js +4 -4
  96. package/package.json +4 -2
@@ -58,6 +58,10 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
58
58
  _useState2 = _slicedToArray(_useState, 2),
59
59
  inputValue = _useState2[0],
60
60
  setInputValue = _useState2[1];
61
+ var _useState3 = useState(1),
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ forceUpdate = _useState4[0],
64
+ setForceUpdate = _useState4[1];
61
65
  var inputStatus = useRef({
62
66
  isHandleChange: false,
63
67
  inputFocused: false
@@ -109,10 +113,11 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
109
113
  var handleChange = function handleChange(event) {
110
114
  inputStatus.current.isHandleChange = true;
111
115
  var legalNumber = verifiValue(event.target.value);
116
+ updateSelectionRangePosition(event);
112
117
  if (legalNumber === false) {
118
+ setForceUpdate(forceUpdate + 1);
113
119
  return false;
114
120
  }
115
- updateSelectionRangePosition(event);
116
121
  value === undefined && setInputValue(legalNumber);
117
122
  onChange && onChange(handleEventAttachValue(event, numberMode ? Number(legalNumber) : legalNumber));
118
123
  };
@@ -151,23 +156,23 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
151
156
  if (decimalValueLength <= decimalLength && integerValueLength <= digitLength - decimalLength) {
152
157
  resultNumerical = numerical;
153
158
  } else if (integerValueLength > digitLength - decimalLength) {
154
- var _context;
155
- resultNumerical = _concatInstanceProperty(_context = "".concat(sign)).call(_context, integerValue.substr(0, digitLength - decimalLength));
159
+ var _context, _context2;
160
+ resultNumerical = mustInPrecisionScope ? inputValue : _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(sign)).call(_context2, integerValue.substr(0, digitLength - decimalLength))).call(_context, decimalValue ? '.' + decimalValue : '');
156
161
  } else if (decimalValueLength > decimalLength) {
157
- var _context2, _context3;
158
- resultNumerical = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(sign)).call(_context3, integerValue, ".")).call(_context2, decimalValue.substr(0, decimalLength));
162
+ var _context3, _context4;
163
+ resultNumerical = mustInPrecisionScope ? inputValue : _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(sign)).call(_context4, integerValue, ".")).call(_context3, decimalValue.substr(0, decimalLength));
159
164
  }
160
165
  } else if (typeof decimalLength !== 'number' && typeof digitLength === 'number') {
161
166
  if (integerValueLength >= digitLength) {
162
- var _context4;
163
- resultNumerical = _concatInstanceProperty(_context4 = "".concat(sign)).call(_context4, integerValue.substr(0, digitLength));
167
+ var _context5;
168
+ resultNumerical = _concatInstanceProperty(_context5 = "".concat(sign)).call(_context5, integerValue.substr(0, digitLength));
164
169
  } else {
165
- var _context5, _context6, _context7;
166
- resultNumerical = decimalValueLength ? _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = "".concat(sign)).call(_context6, integerValue, ".")).call(_context5, decimalValue.substr(0, digitLength - integerValueLength)) : _concatInstanceProperty(_context7 = "".concat(sign)).call(_context7, integerValue);
170
+ var _context6, _context7, _context8;
171
+ resultNumerical = decimalValueLength ? _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "".concat(sign)).call(_context7, integerValue, ".")).call(_context6, decimalValue.substr(0, digitLength - integerValueLength)) : _concatInstanceProperty(_context8 = "".concat(sign)).call(_context8, integerValue);
167
172
  }
168
173
  } else if (typeof decimalLength === 'number' && typeof digitLength !== 'number') {
169
- var _context8, _context9, _context10;
170
- resultNumerical = decimalValueLength ? _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = "".concat(sign)).call(_context9, integerValue, ".")).call(_context8, decimalValue.substr(0, decimalLength)) : _concatInstanceProperty(_context10 = "".concat(sign)).call(_context10, integerValue);
174
+ var _context9, _context10, _context11;
175
+ resultNumerical = decimalValueLength ? _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "".concat(sign)).call(_context10, integerValue, ".")).call(_context9, decimalValue.substr(0, decimalLength)) : _concatInstanceProperty(_context11 = "".concat(sign)).call(_context11, integerValue);
171
176
  } else {
172
177
  resultNumerical = numerical;
173
178
  }
@@ -197,13 +202,13 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
197
202
  });
198
203
  };
199
204
  var handleKeyDown = function handleKeyDown(event) {
200
- var _context11;
205
+ var _context12;
201
206
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
202
207
  if (!stepOption || props.disabled || props.readOnly) {
203
208
  return;
204
209
  }
205
210
  var keyCode = event.keyCode;
206
- if (_includesInstanceProperty(_context11 = [38, 40]).call(_context11, keyCode)) {
211
+ if (_includesInstanceProperty(_context12 = [38, 40]).call(_context12, keyCode)) {
207
212
  event.preventDefault();
208
213
  handleStepChang(keyCode === 38 ? 'plus' : 'minus');
209
214
  }
@@ -310,7 +315,8 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
310
315
  }, [inputValue, formatter]);
311
316
  var updateSelectionRangePosition = useSelectionRange({
312
317
  inputElement: (_a = inputNumberRef.current) === null || _a === void 0 ? void 0 : _a.input,
313
- inputValue: displayedInputValue
318
+ inputValue: displayedInputValue,
319
+ forceUpdate: forceUpdate
314
320
  });
315
321
  return /*#__PURE__*/React.createElement(Input, _extends({}, others, {
316
322
  ref: inputNumberRef,
@@ -1,4 +1,5 @@
1
- export default function useSelectionRange({ inputElement, inputValue, }: {
1
+ export default function useSelectionRange({ inputElement, inputValue, forceUpdate, }: {
2
2
  inputElement: HTMLInputElement;
3
3
  inputValue: string;
4
+ forceUpdate: number;
4
5
  }): (event: any) => void;
@@ -2,7 +2,8 @@ import { useRef, useLayoutEffect } from 'react';
2
2
  import isNumber from 'lodash/isNumber';
3
3
  export default function useSelectionRange(_ref) {
4
4
  var inputElement = _ref.inputElement,
5
- inputValue = _ref.inputValue;
5
+ inputValue = _ref.inputValue,
6
+ forceUpdate = _ref.forceUpdate;
6
7
  var refSelectionPosition = useRef();
7
8
  useLayoutEffect(function () {
8
9
  var position = refSelectionPosition.current;
@@ -10,7 +11,7 @@ export default function useSelectionRange(_ref) {
10
11
  var start = Math.max(0, inputValue.length - position);
11
12
  inputElement.setSelectionRange(start, start);
12
13
  }
13
- }, [inputValue]);
14
+ }, [inputValue, forceUpdate]);
14
15
  return function (event) {
15
16
  var _event$target = event.target,
16
17
  end = _event$target.selectionEnd,
@@ -43,6 +43,7 @@ export interface IModalProps {
43
43
  width?: number;
44
44
  showline?: boolean;
45
45
  bounds?: DraggableBounds | string | false;
46
+ overroll?: boolean;
46
47
  onDragStart?: DraggableEventHandler;
47
48
  onDrag?: DraggableEventHandler;
48
49
  onDragStop?: DraggableEventHandler;
package/es/modal/modal.js CHANGED
@@ -27,7 +27,7 @@ import { useHideDocumentScrollBar } from '../_utils/hooks';
27
27
  export var ConfirmModalTypes = ['confirm', 'normal'];
28
28
  export var ModalTypes = tuple('confirm', 'warning', 'error', 'normal');
29
29
  var InternalModal = function InternalModal(props, ref) {
30
- var _classNames3, _classNames4, _context2, _context3;
30
+ var _classNames3, _classNames4, _context2, _context3, _context4;
31
31
  var _useContext = useContext(ConfigContext),
32
32
  getPrefixCls = _useContext.getPrefixCls,
33
33
  prefixCls = _useContext.prefixCls,
@@ -70,7 +70,8 @@ var InternalModal = function InternalModal(props, ref) {
70
70
  onDrag = modalProps.onDrag,
71
71
  onDragStop = modalProps.onDragStop,
72
72
  bounds = modalProps.bounds,
73
- others = __rest(modalProps, ["body", "bodyClassName", "bodyStyle", "cancelButtonProps", "cancelText", "className", "closable", "closeIcon", "destroyOnClose", "draggable", "focusTriggerAfterClose", "footer", "footerClassName", "footerStyle", "footerBtnOrder", "getContainer", "height", "keyboard", "mask", "maskClosable", "maskStyle", "maskClassName", "okButtonProps", "okText", "onCancel", "onOk", "prefixCls", "title", "titleIcon", "type", "visible", "width", "showline", "onDragStart", "onDrag", "onDragStop", "bounds"]);
73
+ overroll = modalProps.overroll,
74
+ others = __rest(modalProps, ["body", "bodyClassName", "bodyStyle", "cancelButtonProps", "cancelText", "className", "closable", "closeIcon", "destroyOnClose", "draggable", "focusTriggerAfterClose", "footer", "footerClassName", "footerStyle", "footerBtnOrder", "getContainer", "height", "keyboard", "mask", "maskClosable", "maskStyle", "maskClassName", "okButtonProps", "okText", "onCancel", "onOk", "prefixCls", "title", "titleIcon", "type", "visible", "width", "showline", "onDragStart", "onDrag", "onDragStop", "bounds", "overroll"]);
74
75
  var isForceController = visible !== undefined;
75
76
  var _useState = useState(isForceController ? visible : true),
76
77
  _useState2 = _slicedToArray(_useState, 2),
@@ -78,6 +79,7 @@ var InternalModal = function InternalModal(props, ref) {
78
79
  setInnerVisible = _useState2[1]; // 需要根据visible来判断,不能一开始为true再去设置false
79
80
  var previousActiveElement = useRef(null);
80
81
  var innerRef = useRef(null);
82
+ var wrapperRef = useRef(null);
81
83
  var containerRef = ref || innerRef;
82
84
  var modalPrefixCls = getPrefixCls(prefixCls, 'modal', customPrefixcls);
83
85
  devWarning(ModalTypes.indexOf(type) === -1, 'modal', "cannot found modal type '".concat(type, "'"));
@@ -185,11 +187,16 @@ var InternalModal = function InternalModal(props, ref) {
185
187
  proxyCloseModal(onCancel);
186
188
  }
187
189
  }, [proxyCloseModal, onCancel, maskClosable]);
190
+ var handleWrapperClick = function handleWrapperClick(e) {
191
+ if (wrapperRef.current === e.target) {
192
+ handleMaskClick();
193
+ }
194
+ };
188
195
  var isHidden = !destroyOnClose && !(isForceController ? visible : innerVisible);
189
196
  var modalClasses = classNames(modalPrefixCls, className, (_classNames3 = {}, _defineProperty(_classNames3, "".concat(modalPrefixCls, "-container"), true), _defineProperty(_classNames3, "".concat(modalPrefixCls, "-container-hidden"), isHidden), _defineProperty(_classNames3, "".concat(modalPrefixCls, "-container-show"), !isHidden), _classNames3));
190
197
  var headerClass = "".concat(modalPrefixCls, "-header");
191
198
  var container = /*#__PURE__*/React.createElement("div", {
192
- className: classNames((_classNames4 = {}, _defineProperty(_classNames4, "".concat(modalPrefixCls, "-container-box"), true), _defineProperty(_classNames4, "".concat(modalPrefixCls, "-has-container-box"), modalContainer), _defineProperty(_classNames4, "".concat(modalPrefixCls, "-showline"), showline), _classNames4)),
199
+ className: classNames((_classNames4 = {}, _defineProperty(_classNames4, "".concat(modalPrefixCls, "-container-box"), true), _defineProperty(_classNames4, "".concat(modalPrefixCls, "-has-container-box"), modalContainer && !overroll), _defineProperty(_classNames4, "".concat(modalPrefixCls, "-showline"), showline), _classNames4)),
193
200
  style: {
194
201
  width: width,
195
202
  height: height
@@ -239,8 +246,18 @@ var InternalModal = function InternalModal(props, ref) {
239
246
  onClick: handleMaskClick,
240
247
  className: classNames(maskClassName, _defineProperty({}, "".concat(modalPrefixCls, "-mask"), true)),
241
248
  style: maskStyle
242
- }), /*#__PURE__*/React.createElement(Draggable, {
243
- defaultPosition: defaultPosition,
249
+ }), overroll ? /*#__PURE__*/React.createElement("div", {
250
+ tabIndex: -1,
251
+ className: classNames(_defineProperty({}, "".concat(modalPrefixCls, "-wrapper"), modalContainer && ((isForceController ? visible : innerVisible) || !destroyOnClose))),
252
+ ref: wrapperRef,
253
+ onClick: handleWrapperClick
254
+ }, /*#__PURE__*/React.createElement("div", {
255
+ className: "".concat(modalPrefixCls, "-dialog")
256
+ }, /*#__PURE__*/React.createElement(Draggable, {
257
+ defaultPosition: {
258
+ x: 0,
259
+ y: 0
260
+ },
244
261
  handle: ".".concat(headerClass),
245
262
  disabled: !draggable,
246
263
  onStart: handleDragStart,
@@ -248,6 +265,15 @@ var InternalModal = function InternalModal(props, ref) {
248
265
  onStop: onDragStop,
249
266
  bounds: bounds,
250
267
  cancel: _concatInstanceProperty(_context3 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context3, modalPrefixCls, "-close-icon")
268
+ }, container))) : /*#__PURE__*/React.createElement(Draggable, {
269
+ defaultPosition: defaultPosition,
270
+ handle: ".".concat(headerClass),
271
+ disabled: !draggable,
272
+ onStart: handleDragStart,
273
+ onDrag: onDrag,
274
+ onStop: onDragStop,
275
+ bounds: bounds,
276
+ cancel: _concatInstanceProperty(_context4 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context4, modalPrefixCls, "-close-icon")
251
277
  }, container));
252
278
  var renderComp = ((isForceController ? visible : innerVisible) || !destroyOnClose) && comp;
253
279
  if (modalContainer && renderComp) return /*#__PURE__*/ReactDOM.createPortal(renderComp, modalContainer);
@@ -252,6 +252,27 @@
252
252
  .kd-modal-margin-btn {
253
253
  margin-right: var(--kd-c-modal-footer-button-spacing, 12px);
254
254
  }
255
+ .kd-modal-wrapper {
256
+ position: fixed;
257
+ top: 0;
258
+ right: 0;
259
+ bottom: 0;
260
+ left: 0;
261
+ overflow: auto;
262
+ text-align: center;
263
+ }
264
+ .kd-modal-wrapper::before {
265
+ display: inline-block;
266
+ width: 0;
267
+ height: 100%;
268
+ vertical-align: middle;
269
+ content: '';
270
+ }
271
+ .kd-modal-dialog {
272
+ display: inline-block;
273
+ vertical-align: middle;
274
+ max-width: calc(100vw);
275
+ }
255
276
  .kd-modal-showline .kd-modal-header {
256
277
  border-bottom: var(--kd-c-modal-sizing-border, 1px) solid var(--kd-c-modal-color-border, var(--kd-g-color-border-strong-2, #d9d9d9));
257
278
  }
@@ -29,15 +29,13 @@
29
29
  }
30
30
 
31
31
  &-hidden {
32
- display: none
32
+ display: none;
33
33
  }
34
34
  }
35
35
  &-mask {
36
36
  .overlay(@modal-mask-color-background, 0);
37
37
  }
38
- // &-mask + &-container-box {
39
38
 
40
- // }
41
39
  &-has-container-box {
42
40
  position: fixed;
43
41
  left: 50%;
@@ -116,16 +114,34 @@
116
114
  color: @modal-footer-font-color;
117
115
  flex-shrink: 0;
118
116
  }
119
- // each(@modal-footer-type-set, {
120
- // .@{modal-prefix-cls}-@{key}-footer {
121
- // justify-content: @value;
122
- // }
123
- // });
124
117
  }
125
118
 
126
119
  &-margin-btn {
127
120
  margin-right: @modal-footer-button-spacing;
128
121
  }
122
+
123
+ &-wrapper {
124
+ position: fixed;
125
+ top: 0;
126
+ right: 0;
127
+ bottom: 0;
128
+ left: 0;
129
+ overflow: auto;
130
+ text-align: center;
131
+
132
+ &::before {
133
+ display: inline-block;
134
+ width: 0;
135
+ height: 100%;
136
+ vertical-align: middle;
137
+ content: '';
138
+ }
139
+ }
140
+ &-dialog {
141
+ display: inline-block;
142
+ vertical-align: middle;
143
+ max-width: calc(100vw);
144
+ }
129
145
  }
130
146
 
131
147
  .@{modal-prefix-cls}-showline {
@@ -135,4 +151,4 @@
135
151
  .@{modal-prefix-cls}-footer {
136
152
  border-top: @modal-border-width solid @modal-border-color;
137
153
  }
138
- }
154
+ }
@@ -0,0 +1,3 @@
1
+ import QRCode from './qr-code';
2
+ export * from './qr-code';
3
+ export default QRCode;
@@ -0,0 +1,3 @@
1
+ import QRCode from './qr-code';
2
+ export * from './qr-code';
3
+ export default QRCode;
@@ -0,0 +1,42 @@
1
+ import React, { CSSProperties, FunctionComponentElement } from 'react';
2
+ export declare type QRPropsCanvas = QRProps & React.CanvasHTMLAttributes<HTMLCanvasElement>;
3
+ export declare type QRPropsSvg = QRProps & React.SVGAttributes<SVGSVGElement>;
4
+ export declare const QRCodeTypes: ["canvas", "svg"];
5
+ export declare type QRCodeType = typeof QRCodeTypes[number];
6
+ export declare const QRCodeStatus: ["active", "expired", "loading"];
7
+ export declare type QRCodeStatus = typeof QRCodeStatus[number];
8
+ export declare const QRCodeErrorLevels: ["L", "M", "Q", "H"];
9
+ export declare type QRCodeErrorLevel = typeof QRCodeErrorLevels[number];
10
+ interface ImageSettings {
11
+ src: string;
12
+ height: number;
13
+ width: number;
14
+ excavate: boolean;
15
+ x?: number;
16
+ y?: number;
17
+ }
18
+ export interface QRProps {
19
+ value: string;
20
+ type?: QRCodeType;
21
+ size?: number;
22
+ style?: CSSProperties;
23
+ color?: string;
24
+ bgColor?: string;
25
+ bordered?: boolean;
26
+ imageSettings?: ImageSettings;
27
+ }
28
+ export interface QRCodeProps extends QRProps {
29
+ className?: string;
30
+ prefixCls?: string;
31
+ icon?: string;
32
+ iconSize?: number;
33
+ status?: QRCodeStatus;
34
+ errorLevel?: QRCodeErrorLevel;
35
+ children?: React.ReactNode;
36
+ onRefresh?: () => void;
37
+ }
38
+ declare const QRCode: {
39
+ (props: QRCodeProps): FunctionComponentElement<QRCodeProps>;
40
+ displayName: string;
41
+ };
42
+ export default QRCode;
@@ -0,0 +1,80 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
+ import React, { useContext } from 'react';
4
+ import classNames from 'classnames';
5
+ import ConfigContext from '../config-provider/ConfigContext';
6
+ import { getCompProps } from '../_utils';
7
+ import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react';
8
+ import Spin from '../spin';
9
+ import Button from '../button';
10
+ import Icon from '../icon';
11
+ import devWarning from '../_utils/devwarning';
12
+ import { tuple } from '../_utils/type';
13
+ export var QRCodeTypes = tuple('canvas', 'svg');
14
+ export var QRCodeStatus = tuple('active', 'expired', 'loading');
15
+ export var QRCodeErrorLevels = tuple('L', 'M', 'Q', 'H');
16
+ var QRCode = function QRCode(props) {
17
+ var _useContext = useContext(ConfigContext),
18
+ getPrefixCls = _useContext.getPrefixCls,
19
+ prefixCls = _useContext.prefixCls,
20
+ userDefaultProps = _useContext.compDefaultProps;
21
+ var qrCodeProps = getCompProps('QRCode', userDefaultProps, props);
22
+ var value = qrCodeProps.value,
23
+ size = qrCodeProps.size,
24
+ status = qrCodeProps.status,
25
+ style = qrCodeProps.style,
26
+ type = qrCodeProps.type,
27
+ errorLevel = qrCodeProps.errorLevel,
28
+ color = qrCodeProps.color,
29
+ onRefresh = qrCodeProps.onRefresh,
30
+ icon = qrCodeProps.icon,
31
+ _qrCodeProps$iconSize = qrCodeProps.iconSize,
32
+ iconSize = _qrCodeProps$iconSize === void 0 ? 24 : _qrCodeProps$iconSize,
33
+ bgColor = qrCodeProps.bgColor,
34
+ _qrCodeProps$bordered = qrCodeProps.bordered,
35
+ bordered = _qrCodeProps$bordered === void 0 ? true : _qrCodeProps$bordered;
36
+ var className = qrCodeProps.className,
37
+ customPrefixcls = qrCodeProps.prefixCls;
38
+ var qrCodePrefixCls = getPrefixCls(prefixCls, 'qrcode', customPrefixcls);
39
+ var qrCodeClass = classNames(qrCodePrefixCls, className, _defineProperty({}, "".concat(qrCodePrefixCls, "-borderless"), !bordered));
40
+ var gap = 8;
41
+ var containerSize = size + gap * 2 + 2;
42
+ devWarning(!value === false, 'QRCode', 'need to receive `value` props');
43
+ devWarning(icon && errorLevel === 'L', 'QRCode', 'ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.');
44
+ var imageSettings = {
45
+ src: icon,
46
+ x: undefined,
47
+ y: undefined,
48
+ height: iconSize,
49
+ width: iconSize,
50
+ excavate: true
51
+ };
52
+ var codeProps = {
53
+ value: value,
54
+ size: size,
55
+ level: errorLevel,
56
+ fgColor: color,
57
+ imageSettings: icon ? imageSettings : undefined
58
+ };
59
+ return /*#__PURE__*/React.createElement("div", {
60
+ className: qrCodeClass,
61
+ style: _extends(_extends({}, style), {
62
+ width: "".concat(containerSize, "px"),
63
+ height: "".concat(containerSize, "px"),
64
+ backgroundColor: bgColor
65
+ })
66
+ }, status !== 'active' && /*#__PURE__*/React.createElement("div", {
67
+ className: "".concat(qrCodePrefixCls, "-mask")
68
+ }, status === 'loading' && /*#__PURE__*/React.createElement(Spin, null), status === 'expired' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
69
+ className: "".concat(qrCodePrefixCls, "-expired")
70
+ }, "\u4E8C\u7EF4\u7801\u8FC7\u671F"), onRefresh && /*#__PURE__*/React.createElement(Button, {
71
+ icon: /*#__PURE__*/React.createElement(Icon, {
72
+ type: "refresh"
73
+ }),
74
+ type: "text",
75
+ onClick: onRefresh,
76
+ size: "middle"
77
+ }, "\u70B9\u51FB\u5237\u65B0"))), type === 'canvas' ? /*#__PURE__*/React.createElement(QRCodeCanvas, _extends({}, codeProps)) : /*#__PURE__*/React.createElement(QRCodeSVG, _extends({}, codeProps)));
78
+ };
79
+ QRCode.displayName = 'QRCode';
80
+ export default QRCode;
@@ -0,0 +1,2 @@
1
+ import '../../style/index.css';
2
+ import './index.css';
@@ -0,0 +1,154 @@
1
+ /* ----------- color ——————---- start */
2
+ /* ----------- color ——————---- end */
3
+ /* ----------- motion ——————---- start */
4
+ /* ----------- motion ——————---- end */
5
+ /* ----------- transition ——————---- start */
6
+ /* ----------- transition ——————---- end */
7
+ /* ----------- font ——————---- start */
8
+ /* ----------- font ——————---- end */
9
+ /* ----------- zIndex ——————---- start */
10
+ /*
11
+ 普通组件内部自身层级应设置在0-100间
12
+ */
13
+ /* ----------- zIndex ——————---- end */
14
+ /* ----------- Button ——————---- start */
15
+ /* ----------- Button ——————---- end */
16
+ /* ----------- Collapse ——————---- start */
17
+ /* ----------- Collapse ——————---- end */
18
+ /* ----------- Card ——————---- start */
19
+ /* ----------- Card ——————---- end */
20
+ /* ----------- Carousel ——————---- start */
21
+ /* ----------- Carousel ——————---- end */
22
+ /* ----------- Cascader ——————---- start */
23
+ /* ----------- Cascader ——————---- end */
24
+ /* ----------- Switch ——————---- start */
25
+ /* ----------- Switch ——————---- end */
26
+ /* ----------- Input ——————---- start */
27
+ /* ----------- Input ——————---- end */
28
+ /* ----------- InputNumber ——————---- start */
29
+ /* ----------- InputNumber ——————---- end */
30
+ /* ----------- checkbox ——————---- start */
31
+ /* ----------- checkbox ——————---- start */
32
+ /* ----------- checkbox ——————---- end */
33
+ /* ----------- Radio ——————---- start */
34
+ /* ----------- Radio ——————---- end */
35
+ /* ----------- icon ——————---- start */
36
+ /* ----------- icon ——————---- end */
37
+ /* ----------- Popconfirm ——————---- start */
38
+ /* ----------- Popconfirm ——————---- end */
39
+ /* ----------- Progress ——————---- start */
40
+ /* ----------- Progress ——————---- end */
41
+ /* ----------- Pagination ——————---- start */
42
+ /* ----------- Pagination ——————---- end */
43
+ /* ----------- Timeline ——————---- start */
44
+ /* ----------- Timeline ——————---- end */
45
+ /* ----------- Tabs ——————---- start */
46
+ /* ----------- Tabs ——————---- end */
47
+ /* ----------- Select ——————---- start */
48
+ /* ----------- Select ——————---- end */
49
+ /* ----------- Rate ——————---- start */
50
+ /* ----------- Rate ——————---- end */
51
+ /* ----------- Dropdown ——————---- start */
52
+ /* ----------- Dropdown ——————---- end */
53
+ /* ----------- Tooltip ——————---- start */
54
+ /* ----------- Tooltip ——————---- end */
55
+ /* ----------- Transfer ——————---- start */
56
+ /* ----------- Transfer ——————---- end */
57
+ /* ----------- DatePicker ——————---- start */
58
+ /* ----------- DatePicker ——————---- end */
59
+ /* ----------- ColorPicker ——————---- start */
60
+ /* ----------- ColorPicker ——————---- end */
61
+ /* ----------- Tree ——————---- start */
62
+ /* ----------- Tree ——————---- end */
63
+ /* ----------- Alert ——————---- start */
64
+ /* ----------- Alert ——————---- end */
65
+ /* ----------- Split-Panel ——————---- start */
66
+ /* ----------- Split-Panel ——————---- end */
67
+ /* ----------- Modal ——————---- start */
68
+ /* ----------- Modal ——————---- end */
69
+ /* ----------- Steps ——————---- start */
70
+ /* ----------- Steps ——————---- end */
71
+ /* ----------- Form ——————---- start */
72
+ /* ----------- Form ——————---- end */
73
+ /* ----------- Tag ——————---- start */
74
+ /* ----------- Tag ——————---- end */
75
+ /* ----------- Menu ——————---- start */
76
+ /* ----------- Menu ——————---- end */
77
+ /* ----------- notice ——————---- start */
78
+ /* ----------- message ——————---- end */
79
+ /* ----------- Spin ——————---- start */
80
+ /* ----------- Spin ——————---- end */
81
+ /* ----------- Spin ——————---- start */
82
+ /* ----------- Spin ——————---- end */
83
+ /* ----------- Layout ——————---- start */
84
+ /* ----------- Layout ——————---- end */
85
+ /* ----------- Typography ——————---- start */
86
+ /* ----------- Typography ——————---- start */
87
+ /* ----------- Search ——————---- start */
88
+ /* ----------- Search ——————---- start */
89
+ /* ----------- Badge ——————---- start */
90
+ /* ----------- Badge ——————---- end */
91
+ /* ----------- Anchor ——————---- start */
92
+ /* ----------- Anchor ——————---- end */
93
+ /* ----------- Avatar ——————---- start */
94
+ /* ----------- Avatar ——————---- end */
95
+ /* ----------- AdvancedSelector ——————---- start */
96
+ /* ----------- AdvancedSelector ——————---- end */
97
+ /* ----------- motion ——————---- start */
98
+ /* ----------- motion ——————---- end */
99
+ /* ----------- transition ——————---- start */
100
+ /* ----------- transition ——————---- end */
101
+ /* ----------- zIndex ——————---- start */
102
+ /*
103
+ 普通组件内部自身层级应设置在0-100间
104
+ */
105
+ /* ----------- zIndex ——————---- end */
106
+ .kd-qrcode {
107
+ position: relative;
108
+ -webkit-box-sizing: border-box;
109
+ box-sizing: border-box;
110
+ display: -webkit-box;
111
+ display: -ms-flexbox;
112
+ display: flex;
113
+ -webkit-box-pack: center;
114
+ -ms-flex-pack: center;
115
+ justify-content: center;
116
+ -webkit-box-align: center;
117
+ -ms-flex-align: center;
118
+ align-items: center;
119
+ margin: 0;
120
+ border-radius: var(--kd-c-qrcode-border-radius, 2px);
121
+ border: var(--kd-c-qrcode-size-border, 1px) solid var(--kd-c-qrcode-color-border, rgba(5, 5, 5, 0.06));
122
+ padding: var(--kd-c-qrcode-spacing-padding-horizontal, 8px);
123
+ font-size: var(--kd-c-qrcode-font-size, 12px);
124
+ list-style: none;
125
+ overflow: hidden;
126
+ }
127
+ .kd-qrcode-expired {
128
+ margin-bottom: var(--kd-c-qrcode-spacing-margin-vertical, 4px);
129
+ }
130
+ .kd-qrcode-mask {
131
+ position: absolute;
132
+ z-index: 10;
133
+ display: -webkit-box;
134
+ display: -ms-flexbox;
135
+ display: flex;
136
+ -webkit-box-orient: vertical;
137
+ -webkit-box-direction: normal;
138
+ -ms-flex-direction: column;
139
+ flex-direction: column;
140
+ -webkit-box-pack: center;
141
+ -ms-flex-pack: center;
142
+ justify-content: center;
143
+ -webkit-box-align: center;
144
+ -ms-flex-align: center;
145
+ align-items: center;
146
+ width: 100%;
147
+ height: 100%;
148
+ color: var(--kd-c-qrcode-color-text, #111111);
149
+ background: var(--kd-c-qrcode-color-background, rgba(255, 255, 255, 0.96));
150
+ text-align: center;
151
+ }
152
+ .kd-qrcode-borderless {
153
+ border: none;
154
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,42 @@
1
+ @import '../../style/themes/index';
2
+ @import './mixin.less';
3
+ @qrcode-prefix-cls: ~'@{kd-prefix}-qrcode';
4
+ @qrcode-prefix-icon-cls: ~'@{kd-prefix}-icon';
5
+ @--kd-c-spin-page-dot-spin-sizing-square: 30px;
6
+
7
+ .@{qrcode-prefix-cls} {
8
+ .qrcode;
9
+ position: relative;
10
+ box-sizing: border-box;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ margin: 0;
15
+ border-radius: @qrcode-border-radius;
16
+ border: @qrcode-size-boder solid @qrcode-color-border;
17
+ padding: @qrcode-spacing-padding-horizontal;
18
+ font-size: @qrcode-font-size;
19
+ list-style: none;
20
+ overflow: hidden;
21
+
22
+ &-expired{
23
+ margin-bottom: @qrcode-spacing-margin-vertical;
24
+ }
25
+
26
+ &-mask{
27
+ position: absolute;
28
+ z-index: 10;
29
+ display: flex;
30
+ flex-direction: column;
31
+ justify-content: center;
32
+ align-items: center;
33
+ width: 100%;
34
+ height: 100%;
35
+ color: @qrcode-color-text;
36
+ background: @qrcode-color-background;
37
+ text-align: center;
38
+ }
39
+ &-borderless{
40
+ border: none;
41
+ }
42
+ }
@@ -0,0 +1,6 @@
1
+ @import './token.less';
2
+
3
+ .qrcode() {
4
+ // color: @qrcode-color-text;
5
+ // font-size: @qrcode-font-size;
6
+ }