@kdcloudjs/kdesign 1.6.31 → 1.6.33
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/CHANGELOG.md +28 -0
- package/LICENSE +3 -0
- package/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +2071 -219
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +8 -8
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/getStringLength.d.ts +1 -0
- package/es/_utils/getStringLength.js +14 -0
- package/es/_utils/hooks.d.ts +3 -0
- package/es/_utils/hooks.js +50 -1
- package/es/_utils/raf.d.ts +3 -0
- package/es/_utils/raf.js +35 -0
- package/es/_utils/resizeObserver.d.ts +15 -0
- package/es/_utils/resizeObserver.js +79 -0
- package/es/_utils/usePopper.js +1 -1
- package/es/date-picker/date-picker.js +2 -5
- package/es/select/interface.d.ts +2 -0
- package/es/select/select.js +22 -2
- package/es/stepper/stepper.js +2 -1
- package/es/table/feature/colGroupExtendable.d.ts +4 -0
- package/es/table/feature/colGroupExtendable.js +9 -0
- package/es/table/interface.d.ts +2 -1
- package/es/table/table.js +5 -1
- package/es/virtual-list/Filler.d.ts +9 -0
- package/es/virtual-list/Filler.js +38 -0
- package/es/virtual-list/index.d.ts +3 -0
- package/es/virtual-list/index.js +3 -0
- package/es/virtual-list/utils/algorithmUtil.d.ts +19 -0
- package/es/virtual-list/utils/algorithmUtil.js +79 -0
- package/es/virtual-list/utils/itemUtil.d.ts +75 -0
- package/es/virtual-list/utils/itemUtil.js +176 -0
- package/es/virtual-list/virtual-list.d.ts +34 -0
- package/es/virtual-list/virtual-list.js +589 -0
- package/lib/_utils/getStringLength.d.ts +1 -0
- package/lib/_utils/getStringLength.js +21 -0
- package/lib/_utils/hooks.d.ts +3 -0
- package/lib/_utils/hooks.js +56 -0
- package/lib/_utils/raf.d.ts +3 -0
- package/lib/_utils/raf.js +43 -0
- package/lib/_utils/resizeObserver.d.ts +15 -0
- package/lib/_utils/resizeObserver.js +95 -0
- package/lib/_utils/usePopper.js +1 -1
- package/lib/date-picker/date-picker.js +2 -6
- package/lib/select/interface.d.ts +2 -0
- package/lib/select/select.js +23 -2
- package/lib/stepper/stepper.js +3 -1
- package/lib/table/feature/colGroupExtendable.d.ts +4 -0
- package/lib/table/feature/colGroupExtendable.js +17 -0
- package/lib/table/interface.d.ts +2 -1
- package/lib/table/table.js +6 -1
- package/lib/virtual-list/Filler.d.ts +9 -0
- package/lib/virtual-list/Filler.js +59 -0
- package/lib/virtual-list/index.d.ts +3 -0
- package/lib/virtual-list/index.js +36 -0
- package/lib/virtual-list/utils/algorithmUtil.d.ts +19 -0
- package/lib/virtual-list/utils/algorithmUtil.js +88 -0
- package/lib/virtual-list/utils/itemUtil.d.ts +75 -0
- package/lib/virtual-list/utils/itemUtil.js +206 -0
- package/lib/virtual-list/virtual-list.d.ts +34 -0
- package/lib/virtual-list/virtual-list.js +626 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (str: string): number;
|
package/es/_utils/hooks.d.ts
CHANGED
|
@@ -50,4 +50,7 @@ interface ContentRectType {
|
|
|
50
50
|
y: number;
|
|
51
51
|
}
|
|
52
52
|
export declare function useResizeObserver(element: (() => HTMLElement | null) | HTMLElement | null, handler?: (react: ContentRectType) => void): void;
|
|
53
|
+
export declare function useIsFirstRender(): boolean;
|
|
54
|
+
export declare function useForceUpdate(): import("react").DispatchWithoutAction;
|
|
55
|
+
export declare function useStateWithPromise<T>(defaultVal: T): [T, (updater: any) => Promise<T>];
|
|
53
56
|
export {};
|
package/es/_utils/hooks.js
CHANGED
|
@@ -6,6 +6,7 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
|
6
6
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
7
7
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
8
8
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
9
10
|
|
|
10
11
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
12
|
|
|
@@ -13,7 +14,7 @@ function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return;
|
|
|
13
14
|
|
|
14
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
16
|
|
|
16
|
-
import { useEffect, useState, useRef } from 'react';
|
|
17
|
+
import { useEffect, useState, useRef, useReducer } from 'react';
|
|
17
18
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
18
19
|
import devWarning from './devwarning';
|
|
19
20
|
/**
|
|
@@ -236,4 +237,52 @@ export function useResizeObserver(element, handler) {
|
|
|
236
237
|
resizeObserver && resizeObserver.disconnect();
|
|
237
238
|
};
|
|
238
239
|
}, [element, handler]);
|
|
240
|
+
}
|
|
241
|
+
export function useIsFirstRender() {
|
|
242
|
+
var isFirst = useRef(true);
|
|
243
|
+
useEffect(function () {
|
|
244
|
+
isFirst.current = false;
|
|
245
|
+
}, []);
|
|
246
|
+
return isFirst.current;
|
|
247
|
+
}
|
|
248
|
+
export function useForceUpdate() {
|
|
249
|
+
var _useReducer = useReducer(function (v) {
|
|
250
|
+
return v + 1;
|
|
251
|
+
}, 0),
|
|
252
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
253
|
+
dispatch = _useReducer2[1];
|
|
254
|
+
|
|
255
|
+
return dispatch;
|
|
256
|
+
}
|
|
257
|
+
export function useStateWithPromise(defaultVal) {
|
|
258
|
+
var _useState3 = useState({
|
|
259
|
+
value: defaultVal,
|
|
260
|
+
resolve: function resolve(e) {
|
|
261
|
+
// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
|
|
262
|
+
e;
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
265
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
266
|
+
state = _useState4[0],
|
|
267
|
+
setState = _useState4[1];
|
|
268
|
+
|
|
269
|
+
useEffect(function () {
|
|
270
|
+
state.resolve(state.value);
|
|
271
|
+
}, [state]);
|
|
272
|
+
return [state.value, function (updater) {
|
|
273
|
+
return new _Promise(function (resolve) {
|
|
274
|
+
setState(function (prevState) {
|
|
275
|
+
var nextVal = updater;
|
|
276
|
+
|
|
277
|
+
if (typeof updater === 'function') {
|
|
278
|
+
nextVal = updater(prevState.value);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
value: nextVal,
|
|
283
|
+
resolve: resolve
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}];
|
|
239
288
|
}
|
package/es/_utils/raf.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var target = typeof window === 'undefined' ? global : window;
|
|
2
|
+
var vendors = ['webkit', 'ms', 'moz', 'o'];
|
|
3
|
+
var raf = target.requestAnimationFrame; // eslint-disable-line
|
|
4
|
+
|
|
5
|
+
var caf = target.cancelAnimationFrame; // eslint-disable-line
|
|
6
|
+
|
|
7
|
+
if (!raf || !caf) {
|
|
8
|
+
vendors.some(function (prefix) {
|
|
9
|
+
raf = target["".concat(prefix, "RequestAnimationFrame")];
|
|
10
|
+
caf = target["".concat(prefix, "CancelAnimationFrame")] || target["".concat(prefix, "CancelRequestAnimationFrame")];
|
|
11
|
+
return raf && caf;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!raf || !caf) {
|
|
15
|
+
var lastTime = 0;
|
|
16
|
+
|
|
17
|
+
raf = function raf(cb) {
|
|
18
|
+
var currentTime = Date.now();
|
|
19
|
+
var diff = Math.max(0, 16 - (currentTime - lastTime));
|
|
20
|
+
var timer = setTimeout(function () {
|
|
21
|
+
cb();
|
|
22
|
+
lastTime = currentTime + diff;
|
|
23
|
+
}, diff);
|
|
24
|
+
return timer;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
caf = function caf(timer) {
|
|
28
|
+
clearTimeout(timer);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
raf = raf.bind(target);
|
|
34
|
+
caf = caf.bind(target);
|
|
35
|
+
export { raf, caf };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ResizeProps {
|
|
3
|
+
onResize?: (entry: ResizeObserverEntry[]) => void;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare class ResizeObserverComponent extends React.Component<ResizeProps> {
|
|
7
|
+
resizeObserver: any;
|
|
8
|
+
componentDidMount(): void;
|
|
9
|
+
componentDidUpdate(): void;
|
|
10
|
+
componentWillUnmount: () => void;
|
|
11
|
+
createResizeObserver: () => void;
|
|
12
|
+
destroyResizeObserver: () => void;
|
|
13
|
+
render(): React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export default ResizeObserverComponent;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct";
|
|
2
|
+
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime-corejs3/helpers/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
6
|
+
import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
8
|
+
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
|
15
|
+
import { findDOMNode } from 'react-dom';
|
|
16
|
+
|
|
17
|
+
var ResizeObserverComponent = /*#__PURE__*/function (_React$Component) {
|
|
18
|
+
_inherits(ResizeObserverComponent, _React$Component);
|
|
19
|
+
|
|
20
|
+
var _super = _createSuper(ResizeObserverComponent);
|
|
21
|
+
|
|
22
|
+
function ResizeObserverComponent() {
|
|
23
|
+
var _this;
|
|
24
|
+
|
|
25
|
+
_classCallCheck(this, ResizeObserverComponent);
|
|
26
|
+
|
|
27
|
+
_this = _super.apply(this, arguments);
|
|
28
|
+
|
|
29
|
+
_this.componentWillUnmount = function () {
|
|
30
|
+
if (_this.resizeObserver) {
|
|
31
|
+
_this.destroyResizeObserver();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
_this.createResizeObserver = function () {
|
|
36
|
+
_this.resizeObserver = new ResizeObserver(function (entry) {
|
|
37
|
+
var onResize = _this.props.onResize;
|
|
38
|
+
onResize && onResize(entry);
|
|
39
|
+
}); // eslint-disable-next-line react/no-find-dom-node
|
|
40
|
+
|
|
41
|
+
_this.resizeObserver.observe(findDOMNode(_assertThisInitialized(_this)));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
_this.destroyResizeObserver = function () {
|
|
45
|
+
_this.resizeObserver && _this.resizeObserver.disconnect();
|
|
46
|
+
_this.resizeObserver = null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return _this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_createClass(ResizeObserverComponent, [{
|
|
53
|
+
key: "componentDidMount",
|
|
54
|
+
value: function componentDidMount() {
|
|
55
|
+
if (! /*#__PURE__*/React.isValidElement(this.props.children)) {
|
|
56
|
+
console.warn('The children of ResizeObserver is invalid.');
|
|
57
|
+
} else {
|
|
58
|
+
this.createResizeObserver();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "componentDidUpdate",
|
|
63
|
+
value: function componentDidUpdate() {
|
|
64
|
+
// eslint-disable-next-line react/no-find-dom-node
|
|
65
|
+
if (!this.resizeObserver && findDOMNode(this)) {
|
|
66
|
+
this.createResizeObserver();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "render",
|
|
71
|
+
value: function render() {
|
|
72
|
+
return this.props.children;
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
|
|
76
|
+
return ResizeObserverComponent;
|
|
77
|
+
}(React.Component);
|
|
78
|
+
|
|
79
|
+
export default ResizeObserverComponent;
|
package/es/_utils/usePopper.js
CHANGED
|
@@ -545,7 +545,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
545
545
|
} else {
|
|
546
546
|
if (matchTrigger('hover')) {
|
|
547
547
|
mouseleaveTimer && clearTimeout(mouseleaveTimer);
|
|
548
|
-
mouseleaveTimer = window.setTimeout(hidePopper, mouseLeaveDelay *
|
|
548
|
+
mouseleaveTimer = window.setTimeout(hidePopper, mouseLeaveDelay * 1000);
|
|
549
549
|
} else {
|
|
550
550
|
hidePopper();
|
|
551
551
|
}
|
|
@@ -85,7 +85,6 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
85
85
|
onClick = datePickerProps.onClick,
|
|
86
86
|
_onOk = datePickerProps.onOk; // ref
|
|
87
87
|
|
|
88
|
-
var panelDivRef = React.useRef(null);
|
|
89
88
|
var inputDivRefDefault = React.useRef(null);
|
|
90
89
|
var inputDivRef = ref || inputDivRefDefault;
|
|
91
90
|
var popperRefDefault = React.useRef(null);
|
|
@@ -244,9 +243,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
244
243
|
if (!openValue) {
|
|
245
244
|
setSelectedValue(dateValue);
|
|
246
245
|
|
|
247
|
-
if (valueText
|
|
248
|
-
triggerTextChange('');
|
|
249
|
-
} else if (valueText !== text) {
|
|
246
|
+
if (valueText !== text) {
|
|
250
247
|
resetText();
|
|
251
248
|
}
|
|
252
249
|
} else {
|
|
@@ -399,7 +396,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
399
396
|
|
|
400
397
|
var inputProps = {
|
|
401
398
|
inputRef: inputRef,
|
|
402
|
-
panelDivRef:
|
|
399
|
+
panelDivRef: popperRef,
|
|
403
400
|
id: id,
|
|
404
401
|
autoFocus: autoFocus,
|
|
405
402
|
allowClear: allowClear,
|
package/es/select/interface.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PopperProps } from '../_utils/usePopper';
|
|
3
|
+
import { AvailableVirtualListProps } from '../virtual-list';
|
|
3
4
|
export declare const SelectSizes: ["large", "middle", "small"];
|
|
4
5
|
export declare type SelectSize = typeof SelectSizes[number];
|
|
5
6
|
export declare const BorderTypes: ["none", "underline", "bordered"];
|
|
@@ -37,6 +38,7 @@ export interface AbstractSelectProps extends PopperProps {
|
|
|
37
38
|
filterOption?: boolean | ((inputValue: string, option?: OptionsType) => boolean);
|
|
38
39
|
optionFilterProp?: string;
|
|
39
40
|
optionLabelProp?: string;
|
|
41
|
+
virtualListProps?: AvailableVirtualListProps | boolean;
|
|
40
42
|
}
|
|
41
43
|
export interface LabeledValue {
|
|
42
44
|
key?: string;
|
package/es/select/select.js
CHANGED
|
@@ -17,6 +17,7 @@ import { toArray } from '../_utils/react-children';
|
|
|
17
17
|
import { Icon, Checkbox, Tag } from '../index';
|
|
18
18
|
import Option from './option';
|
|
19
19
|
import usePopper from '../_utils/usePopper';
|
|
20
|
+
import VirtualList from '../virtual-list';
|
|
20
21
|
var INPUT_MIN_WIDTH = 4; // 输入框最小宽度
|
|
21
22
|
|
|
22
23
|
var InternalSelect = function InternalSelect(props, ref) {
|
|
@@ -61,7 +62,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
61
62
|
optionLabelProp = selectProps.optionLabelProp,
|
|
62
63
|
_selectProps$popperSt = selectProps.popperStyle,
|
|
63
64
|
popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
|
|
64
|
-
tagRender = selectProps.tagRender
|
|
65
|
+
tagRender = selectProps.tagRender,
|
|
66
|
+
virtualListProps = selectProps.virtualListProps;
|
|
65
67
|
var isMultiple = mode === 'multiple'; // 是否多选
|
|
66
68
|
|
|
67
69
|
var _useMergedState = useMergedState(undefined, {
|
|
@@ -570,6 +572,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
570
572
|
listHeight = selectProps.listHeight;
|
|
571
573
|
var selectedVal = multipleRef.current.selectedVal;
|
|
572
574
|
var childrenToRender = filledOptions;
|
|
575
|
+
var eleOptionList = filledOptions;
|
|
573
576
|
|
|
574
577
|
if (Array.isArray(childrenToRender) && childrenToRender.length > 0) {
|
|
575
578
|
childrenToRender = _mapInstanceProperty(childrenToRender).call(childrenToRender, function (item, index) {
|
|
@@ -577,6 +580,23 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
577
580
|
var temp = renderOption(item, index);
|
|
578
581
|
return temp;
|
|
579
582
|
});
|
|
583
|
+
eleOptionList = /*#__PURE__*/React.createElement(VirtualList, _extends({
|
|
584
|
+
role: "listbox",
|
|
585
|
+
data: childrenToRender,
|
|
586
|
+
itemKey: function itemKey(child) {
|
|
587
|
+
var _a;
|
|
588
|
+
|
|
589
|
+
return (_a = child.props) === null || _a === void 0 ? void 0 : _a.value;
|
|
590
|
+
},
|
|
591
|
+
onMouseDown: function onMouseDown(e) {
|
|
592
|
+
return e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
593
|
+
},
|
|
594
|
+
isStaticItemHeight: true,
|
|
595
|
+
height: listHeight || 300,
|
|
596
|
+
measureLongestItem: false
|
|
597
|
+
}, virtualListProps), function (child) {
|
|
598
|
+
return child;
|
|
599
|
+
});
|
|
580
600
|
}
|
|
581
601
|
|
|
582
602
|
var heightStyle = {
|
|
@@ -597,7 +617,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
597
617
|
className: dropDownCls,
|
|
598
618
|
style: dropDownStyle,
|
|
599
619
|
ref: dropDownRef
|
|
600
|
-
}, !dropdownRender && childrenToRender.length > 0 && dropRender(
|
|
620
|
+
}, !dropdownRender && childrenToRender.length > 0 && dropRender(eleOptionList, heightStyle), renderNotContent(), /*#__PURE__*/React.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && /*#__PURE__*/React.createElement("div", {
|
|
601
621
|
className: multipleFooterCls
|
|
602
622
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
603
623
|
style: checkboxStyle,
|
package/es/stepper/stepper.js
CHANGED
|
@@ -13,6 +13,7 @@ import devWarning from '../_utils/devwarning';
|
|
|
13
13
|
import { tuple } from '../_utils/type';
|
|
14
14
|
import { omit } from '../_utils/omit';
|
|
15
15
|
import { useMergedState } from '../_utils/hooks';
|
|
16
|
+
import { isExp } from '../_utils/numberUtil';
|
|
16
17
|
export var StepTypes = tuple('embed', 'base');
|
|
17
18
|
|
|
18
19
|
var InternalStepper = function InternalStepper(props, ref) {
|
|
@@ -105,7 +106,7 @@ var InternalStepper = function InternalStepper(props, ref) {
|
|
|
105
106
|
return false;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
var startingNumber =
|
|
109
|
+
var startingNumber = isExp(stepperrref.current.value) ? Big(stepperrref.current.value).valueOf() : stepperrref.current.value || parseFloat(inputNumberProps.min) || 0;
|
|
109
110
|
var calculationResults = new Big(startingNumber)[type](stepNum).valueOf();
|
|
110
111
|
var legalNumber = stepperrref.current.verifiValue(calculationResults);
|
|
111
112
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
2
|
+
import { TablePipeline } from '../interface';
|
|
3
|
+
declare function colGroupExtendable(pipeline: TablePipeline, columnGroupExtend: colGroupExtendOption): void;
|
|
4
|
+
export default colGroupExtendable;
|
package/es/table/interface.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableProps as BaseTableProps, TablePipeline as TP, ArtColumnStaticPart } from '@kdcloudjs/table';
|
|
3
|
-
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
3
|
+
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions, colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
4
4
|
declare type TablePropsOfComponents = Pick<BaseTableProps, 'components'> & {
|
|
5
5
|
components?: {
|
|
6
6
|
/** 复选框 */
|
|
@@ -31,6 +31,7 @@ export interface TableProps extends TablePropsOfExtend, TablePropsOfComponents {
|
|
|
31
31
|
columnResize?: boolean | ColumnResizeOptions;
|
|
32
32
|
contextMenu?: IContextMenu;
|
|
33
33
|
rangeSelection?: TableRangeSelection;
|
|
34
|
+
columnGroupExtend?: colGroupExtendOption;
|
|
34
35
|
}
|
|
35
36
|
export declare type RowSelectionType = 'checkbox' | 'radio';
|
|
36
37
|
export declare type RowSelectionFixed = 'start' | 'end';
|
package/es/table/table.js
CHANGED
|
@@ -21,6 +21,7 @@ import useRangeSelection from './feature/useRangeSelection';
|
|
|
21
21
|
import useMergeCellHover from './feature/mergeCellHover';
|
|
22
22
|
import devWarning from '../_utils/devwarning';
|
|
23
23
|
import useFooterDataSource from './feature/useFooterDataSource';
|
|
24
|
+
import usecolGroupExtendable from './feature/colGroupExtendable';
|
|
24
25
|
var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
25
26
|
var columns = props.columns,
|
|
26
27
|
dataSource = props.dataSource,
|
|
@@ -52,7 +53,9 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
52
53
|
cssVariables = props.cssVariables,
|
|
53
54
|
stickyScrollHeight = props.stickyScrollHeight,
|
|
54
55
|
scrollbarWidth = props.scrollbarWidth,
|
|
55
|
-
scrollLoad = props.scrollLoad
|
|
56
|
+
scrollLoad = props.scrollLoad,
|
|
57
|
+
_props$columnGroupExt = props.columnGroupExtend,
|
|
58
|
+
columnGroupExtend = _props$columnGroupExt === void 0 ? {} : _props$columnGroupExt;
|
|
56
59
|
|
|
57
60
|
var _useContext = useContext(ConfigContext),
|
|
58
61
|
getPrefixCls = _useContext.getPrefixCls,
|
|
@@ -106,6 +109,7 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
106
109
|
useRangeSelection(pipeline, rangeSelection);
|
|
107
110
|
useMergeCellHover(pipeline);
|
|
108
111
|
useFooterDataSource(pipeline, footerDataSource);
|
|
112
|
+
usecolGroupExtendable(pipeline, columnGroupExtend);
|
|
109
113
|
/* -------------------------------------------------------------------------- */
|
|
110
114
|
|
|
111
115
|
/* after useTablePipeline, merge pipeline.getProps result */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
var Filler = function Filler(_ref) {
|
|
5
|
+
var height = _ref.height,
|
|
6
|
+
offset = _ref.offset,
|
|
7
|
+
children = _ref.children,
|
|
8
|
+
propsOuterStyle = _ref.outerStyle;
|
|
9
|
+
var outerStyle = {};
|
|
10
|
+
var innerStyle = {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (offset !== undefined) {
|
|
16
|
+
outerStyle = _extends({
|
|
17
|
+
height: height,
|
|
18
|
+
position: 'relative',
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
zIndex: 0
|
|
21
|
+
}, propsOuterStyle);
|
|
22
|
+
innerStyle = _extends(_extends({}, innerStyle), {
|
|
23
|
+
transform: "translateY(".concat(offset, "px)"),
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
left: 0,
|
|
26
|
+
right: 0,
|
|
27
|
+
top: 0
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
style: outerStyle
|
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
style: innerStyle
|
|
35
|
+
}, children));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default Filler;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Key } from './itemUtil';
|
|
2
|
+
/**
|
|
3
|
+
* Get index with specific start index one by one. e.g.
|
|
4
|
+
* min: 3, max: 9, start: 6
|
|
5
|
+
*
|
|
6
|
+
* Return index is:
|
|
7
|
+
* [0]: 6
|
|
8
|
+
* [1]: 7
|
|
9
|
+
* [2]: 5
|
|
10
|
+
* [3]: 8
|
|
11
|
+
* [4]: 4
|
|
12
|
+
* [5]: 9
|
|
13
|
+
* [6]: 3
|
|
14
|
+
*/
|
|
15
|
+
export declare function getIndexByStartLoc(min: number, max: number, start: number, index: number): number;
|
|
16
|
+
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T, index: number) => Key): {
|
|
17
|
+
index: number;
|
|
18
|
+
multiple: boolean;
|
|
19
|
+
} | null;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get index with specific start index one by one. e.g.
|
|
3
|
+
* min: 3, max: 9, start: 6
|
|
4
|
+
*
|
|
5
|
+
* Return index is:
|
|
6
|
+
* [0]: 6
|
|
7
|
+
* [1]: 7
|
|
8
|
+
* [2]: 5
|
|
9
|
+
* [3]: 8
|
|
10
|
+
* [4]: 4
|
|
11
|
+
* [5]: 9
|
|
12
|
+
* [6]: 3
|
|
13
|
+
*/
|
|
14
|
+
export function getIndexByStartLoc(min, max, start, index) {
|
|
15
|
+
var beforeCount = start - min;
|
|
16
|
+
var afterCount = max - start;
|
|
17
|
+
var balanceCount = Math.min(beforeCount, afterCount) * 2;
|
|
18
|
+
|
|
19
|
+
if (index <= balanceCount) {
|
|
20
|
+
var stepIndex = Math.floor(index / 2);
|
|
21
|
+
|
|
22
|
+
if (index % 2) {
|
|
23
|
+
return start + stepIndex + 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return start - stepIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (beforeCount > afterCount) {
|
|
30
|
+
return start - (index - afterCount);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return start + (index - beforeCount);
|
|
34
|
+
}
|
|
35
|
+
export function findListDiffIndex(originList, targetList, getKey) {
|
|
36
|
+
var originLen = originList.length;
|
|
37
|
+
var targetLen = targetList.length;
|
|
38
|
+
var shortList;
|
|
39
|
+
var longList;
|
|
40
|
+
|
|
41
|
+
if (originLen === 0 && targetLen === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (originLen < targetLen) {
|
|
46
|
+
shortList = originList;
|
|
47
|
+
longList = targetList;
|
|
48
|
+
} else {
|
|
49
|
+
shortList = targetList;
|
|
50
|
+
longList = originList;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var notExistKey = {
|
|
54
|
+
__EMPTY_ITEM__: true
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function getItemKey(item, index) {
|
|
58
|
+
return item !== undefined ? getKey(item, index) : notExistKey;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var diffIndex = null;
|
|
62
|
+
var multiple = Math.abs(originLen - targetLen) !== 1;
|
|
63
|
+
|
|
64
|
+
for (var i = 0; i < longList.length; i += 1) {
|
|
65
|
+
var shortKey = getItemKey(shortList[i], i);
|
|
66
|
+
var longKey = getItemKey(longList[i], i);
|
|
67
|
+
|
|
68
|
+
if (shortKey !== longKey) {
|
|
69
|
+
diffIndex = i;
|
|
70
|
+
multiple = multiple || shortKey !== getItemKey(longList[i + 1], i + 1);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return diffIndex === null ? null : {
|
|
76
|
+
index: diffIndex,
|
|
77
|
+
multiple: multiple
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 为了计算方便,定位元素的下标可能返回数组长度,代表最后一个元素
|
|
3
|
+
*/
|
|
4
|
+
export declare const GHOST_ITEM_KEY = "__rc_ghost_item__";
|
|
5
|
+
export declare type Key = string | number;
|
|
6
|
+
interface LocationItemResult {
|
|
7
|
+
/** 用于定位的元素的下标 */
|
|
8
|
+
index: number;
|
|
9
|
+
/** 定位元素自身需要补充的偏移量 */
|
|
10
|
+
offsetPtg: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 根据滚动条当前的滚动百分比,计算出基准元素
|
|
14
|
+
* 在基准元素的上方和下方渲染可见区域的其他元素
|
|
15
|
+
*/
|
|
16
|
+
export declare function getLocationItem(scrollPtg: number, total: number): LocationItemResult;
|
|
17
|
+
/**
|
|
18
|
+
* 获取HTML元素高度
|
|
19
|
+
*/
|
|
20
|
+
export declare function getNodeHeight(node: HTMLElement, needMargin?: boolean): number;
|
|
21
|
+
/**
|
|
22
|
+
* 获取有效的scrollTop值
|
|
23
|
+
* Safari的缓动效果会获得负值的scrollTop
|
|
24
|
+
*/
|
|
25
|
+
export declare function getValidScrollTop(scrollTop: number, scrollRange: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* 视口已滚动距离 / 总可滚动距离
|
|
28
|
+
*/
|
|
29
|
+
export declare function getScrollPercentage({ scrollTop, scrollHeight, clientHeight, }: {
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
scrollHeight: number;
|
|
32
|
+
clientHeight: number;
|
|
33
|
+
}): number;
|
|
34
|
+
/**
|
|
35
|
+
* 计算需要渲染的元素的开始下标、结束下标和用于定位的元素下标
|
|
36
|
+
*/
|
|
37
|
+
export declare function getRangeIndex(scrollPtg: number, itemCount: number, visibleCount: number): {
|
|
38
|
+
itemIndex: number;
|
|
39
|
+
itemOffsetPtg: number;
|
|
40
|
+
startIndex: number;
|
|
41
|
+
endIndex: number;
|
|
42
|
+
};
|
|
43
|
+
interface ItemTopConfig {
|
|
44
|
+
itemHeight: number;
|
|
45
|
+
itemOffsetPtg: number;
|
|
46
|
+
scrollTop: number;
|
|
47
|
+
scrollPtg: number;
|
|
48
|
+
clientHeight: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 计算元素相对于视口顶部的偏移量
|
|
52
|
+
*/
|
|
53
|
+
export declare function getItemRelativeTop({ itemHeight, itemOffsetPtg, scrollPtg, clientHeight, }: Omit<ItemTopConfig, 'scrollTop'>): number;
|
|
54
|
+
/**
|
|
55
|
+
* 计算元素相对于整个滚动区域顶部的偏移量
|
|
56
|
+
*/
|
|
57
|
+
export declare function getItemAbsoluteTop({ scrollTop, ...rest }: ItemTopConfig): number;
|
|
58
|
+
interface CompareItemConfig {
|
|
59
|
+
locatedItemRelativeTop: number;
|
|
60
|
+
locatedItemIndex: number;
|
|
61
|
+
compareItemIndex: number;
|
|
62
|
+
getItemKey: (index: number) => Key;
|
|
63
|
+
startIndex: number;
|
|
64
|
+
endIndex: number;
|
|
65
|
+
itemElementHeights: {
|
|
66
|
+
[key: string]: number;
|
|
67
|
+
};
|
|
68
|
+
itemHeight: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 计算某一指定下标的元素相对于视口顶部的偏移量
|
|
72
|
+
*/
|
|
73
|
+
export declare function getCompareItemRelativeTop({ locatedItemRelativeTop, locatedItemIndex, compareItemIndex, startIndex, endIndex, getItemKey, itemElementHeights, itemHeight, }: CompareItemConfig): number;
|
|
74
|
+
export declare function getLongestItemIndex(data: Array<any>): number;
|
|
75
|
+
export {};
|