@ccs-ui/rc-pro 2.3.6-beta-5 → 2.3.6-beta-7
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/es/dialog/button.d.ts +1 -1
- package/es/ellipsis/index.d.ts +21 -5
- package/es/ellipsis/index.js +87 -30
- package/es/ellipsis/index.less +5 -0
- package/es/ellipsis/useMeasure.d.ts +2 -0
- package/es/ellipsis/useMeasure.js +142 -0
- package/es/ellipsis/useResizeEffect.d.ts +2 -0
- package/es/ellipsis/useResizeEffect.js +23 -0
- package/es/ellipsis/withStopPropagation.d.ts +4 -0
- package/es/ellipsis/withStopPropagation.js +38 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/pro-table/table.d.ts +2 -1
- package/es/table/index.js +21 -16
- package/es/table/index.less +0 -42
- package/package.json +3 -3
package/es/dialog/button.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
16
16
|
export type DialogButtonRef = {
|
|
17
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "onClose" | "onOk" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
|
|
20
20
|
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
21
|
formInitialValues: FormProps['initialValues'];
|
|
22
22
|
buttonRef: RefObject<DialogButtonRef>;
|
package/es/ellipsis/index.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
import { PropagationEvent } from './withStopPropagation';
|
|
5
|
+
export type EllipsisProps = {
|
|
6
|
+
content: string;
|
|
7
|
+
direction?: 'start' | 'end' | 'middle';
|
|
8
|
+
rows?: number;
|
|
9
|
+
expandText?: ReactNode;
|
|
10
|
+
collapseText?: ReactNode;
|
|
11
|
+
stopPropagationForActionButtons?: PropagationEvent[];
|
|
12
|
+
onContentClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
13
|
+
defaultExpanded?: boolean;
|
|
14
|
+
showTooltip?: boolean;
|
|
4
15
|
};
|
|
5
|
-
|
|
6
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 文本缩略
|
|
18
|
+
* @param EllipsisProps
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const CcsEllipsis: FC<EllipsisProps>;
|
|
22
|
+
export default CcsEllipsis;
|
package/es/ellipsis/index.js
CHANGED
|
@@ -4,35 +4,92 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
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; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import CcsUtils from '@ccs-ui/utils';
|
|
8
|
+
import { Tooltip } from 'antd';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import "./index.less";
|
|
11
|
+
import useMeasure from "./useMeasure";
|
|
12
|
+
import { useResizeEffect } from "./useResizeEffect";
|
|
13
|
+
import { withStopPropagation } from "./withStopPropagation";
|
|
9
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
var classPrefix = "ccs-ellipsis";
|
|
16
|
+
var defaultProps = {
|
|
17
|
+
direction: 'end',
|
|
18
|
+
rows: 1,
|
|
19
|
+
expandText: '',
|
|
20
|
+
content: '',
|
|
21
|
+
collapseText: '',
|
|
22
|
+
stopPropagationForActionButtons: [],
|
|
23
|
+
onContentClick: function onContentClick() {},
|
|
24
|
+
defaultExpanded: false,
|
|
25
|
+
showTooltip: false
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 文本缩略
|
|
30
|
+
* @param EllipsisProps
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
var CcsEllipsis = function CcsEllipsis(p) {
|
|
34
|
+
var props = CcsUtils.mergeProps(defaultProps, p);
|
|
35
|
+
var direction = props.direction,
|
|
36
|
+
rows = props.rows,
|
|
37
|
+
expandText = props.expandText,
|
|
38
|
+
collapseText = props.collapseText,
|
|
39
|
+
stopPropagationForActionButtons = props.stopPropagationForActionButtons,
|
|
40
|
+
onContentClick = props.onContentClick,
|
|
41
|
+
defaultExpanded = props.defaultExpanded,
|
|
42
|
+
showTooltip = props.showTooltip;
|
|
43
|
+
var content = props.content === null ? '' : props.content.toString();
|
|
44
|
+
|
|
45
|
+
// ============================ Refs ============================
|
|
46
|
+
var rootRef = React.useRef(null);
|
|
47
|
+
|
|
48
|
+
// ========================== Expanded ==========================
|
|
49
|
+
var _React$useState = React.useState(defaultExpanded),
|
|
50
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
51
|
+
expanded = _React$useState2[0],
|
|
52
|
+
setExpanded = _React$useState2[1];
|
|
53
|
+
var expandNode = expandText ? withStopPropagation(stopPropagationForActionButtons, /*#__PURE__*/_jsx("a", {
|
|
54
|
+
onClick: function onClick() {
|
|
55
|
+
setExpanded(true);
|
|
56
|
+
},
|
|
57
|
+
children: expandText
|
|
58
|
+
})) : null;
|
|
59
|
+
var collapseNode = collapseText ? withStopPropagation(stopPropagationForActionButtons, /*#__PURE__*/_jsx("a", {
|
|
60
|
+
onClick: function onClick() {
|
|
61
|
+
setExpanded(false);
|
|
62
|
+
},
|
|
63
|
+
children: collapseText
|
|
64
|
+
})) : null;
|
|
65
|
+
|
|
66
|
+
// ========================== Ellipsis ==========================
|
|
67
|
+
var _useMeasure = useMeasure(content, rows, direction, expanded, expandNode, collapseNode),
|
|
68
|
+
_useMeasure2 = _slicedToArray(_useMeasure, 2),
|
|
69
|
+
measureNodes = _useMeasure2[0],
|
|
70
|
+
forceResize = _useMeasure2[1];
|
|
71
|
+
useResizeEffect(forceResize, rootRef);
|
|
72
|
+
|
|
73
|
+
// =========================== Render ===========================
|
|
74
|
+
var renderNode = /*#__PURE__*/_jsx("div", {
|
|
75
|
+
ref: rootRef,
|
|
76
|
+
className: classPrefix,
|
|
77
|
+
onClick: function onClick(e) {
|
|
78
|
+
if (e.target === e.currentTarget) {
|
|
79
|
+
onContentClick(e);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
children: measureNodes
|
|
37
83
|
});
|
|
38
|
-
|
|
84
|
+
return showTooltip ? /*#__PURE__*/_jsx(Tooltip, {
|
|
85
|
+
zIndex: 9999,
|
|
86
|
+
title: content,
|
|
87
|
+
placement: "bottomLeft",
|
|
88
|
+
destroyTooltipOnHide: true,
|
|
89
|
+
overlayInnerStyle: {
|
|
90
|
+
whiteSpace: 'normal'
|
|
91
|
+
},
|
|
92
|
+
children: renderNode
|
|
93
|
+
}) : renderNode;
|
|
94
|
+
};
|
|
95
|
+
export default CcsEllipsis;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default function useMeasure(content: string, rows: number, direction: 'start' | 'end' | 'middle', expanded: boolean, expandNode: React.ReactElement | null, collapseNode: React.ReactElement | null): readonly [import("react/jsx-runtime").JSX.Element, () => void];
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEvent } from 'rc-util';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { unstable_batchedUpdates } from 'react-dom';
|
|
10
|
+
import runes from 'runes2';
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
var ELLIPSIS_TEXT = '...';
|
|
15
|
+
var measureStyle = {
|
|
16
|
+
visibility: 'hidden',
|
|
17
|
+
whiteSpace: 'inherit',
|
|
18
|
+
lineHeight: 'inherit',
|
|
19
|
+
fontSize: 'inherit'
|
|
20
|
+
};
|
|
21
|
+
export default function useMeasure(content, rows, direction, expanded, expandNode, collapseNode) {
|
|
22
|
+
var contentChars = React.useMemo(function () {
|
|
23
|
+
return runes(content);
|
|
24
|
+
}, [content]);
|
|
25
|
+
var _React$useState = React.useState(0),
|
|
26
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
27
|
+
maxHeight = _React$useState2[0],
|
|
28
|
+
setMaxHeight = _React$useState2[1];
|
|
29
|
+
var _React$useState3 = React.useState([0, 0]),
|
|
30
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
31
|
+
walkingIndexes = _React$useState4[0],
|
|
32
|
+
setWalkingIndexes = _React$useState4[1];
|
|
33
|
+
var midIndex = Math.ceil((walkingIndexes[0] + walkingIndexes[1]) / 2);
|
|
34
|
+
var _React$useState5 = React.useState(100),
|
|
35
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
36
|
+
status = _React$useState6[0],
|
|
37
|
+
setStatus = _React$useState6[1];
|
|
38
|
+
|
|
39
|
+
// ============================ Refs ============================
|
|
40
|
+
var singleRowMeasureRef = React.useRef(null);
|
|
41
|
+
var fullMeasureRef = React.useRef(null);
|
|
42
|
+
var midMeasureRef = React.useRef(null);
|
|
43
|
+
var startMeasure = useEvent(function () {
|
|
44
|
+
// use batch update to avoid async update trigger 2 render
|
|
45
|
+
unstable_batchedUpdates(function () {
|
|
46
|
+
setStatus(1);
|
|
47
|
+
setWalkingIndexes([0, direction === 'middle' ? Math.ceil(contentChars.length / 2) : contentChars.length]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Initialize
|
|
52
|
+
React.useLayoutEffect(function () {
|
|
53
|
+
startMeasure();
|
|
54
|
+
}, [contentChars, rows]);
|
|
55
|
+
|
|
56
|
+
// Measure element height
|
|
57
|
+
React.useLayoutEffect(function () {
|
|
58
|
+
if (status === 1) {
|
|
59
|
+
var _fullMeasureRef$curre, _singleRowMeasureRef$;
|
|
60
|
+
var fullMeasureHeight = ((_fullMeasureRef$curre = fullMeasureRef.current) === null || _fullMeasureRef$curre === void 0 ? void 0 : _fullMeasureRef$curre.offsetHeight) || 0;
|
|
61
|
+
var singleRowMeasureHeight = ((_singleRowMeasureRef$ = singleRowMeasureRef.current) === null || _singleRowMeasureRef$ === void 0 ? void 0 : _singleRowMeasureRef$.offsetHeight) || 0;
|
|
62
|
+
var rowMeasureHeight = singleRowMeasureHeight * (rows + 0.5);
|
|
63
|
+
if (fullMeasureHeight <= rowMeasureHeight) {
|
|
64
|
+
setStatus(100);
|
|
65
|
+
} else {
|
|
66
|
+
setMaxHeight(rowMeasureHeight);
|
|
67
|
+
setStatus(2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, [status]);
|
|
71
|
+
|
|
72
|
+
// Walking measure
|
|
73
|
+
React.useLayoutEffect(function () {
|
|
74
|
+
if (status === 2) {
|
|
75
|
+
var _midMeasureRef$curren;
|
|
76
|
+
var diff = walkingIndexes[1] - walkingIndexes[0];
|
|
77
|
+
var midHeight = ((_midMeasureRef$curren = midMeasureRef.current) === null || _midMeasureRef$curren === void 0 ? void 0 : _midMeasureRef$curren.offsetHeight) || 0;
|
|
78
|
+
if (diff > 1) {
|
|
79
|
+
if (midHeight > maxHeight) {
|
|
80
|
+
setWalkingIndexes([walkingIndexes[0], midIndex]);
|
|
81
|
+
} else {
|
|
82
|
+
setWalkingIndexes([midIndex, walkingIndexes[1]]);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (midHeight > maxHeight) {
|
|
86
|
+
setWalkingIndexes([walkingIndexes[0], walkingIndexes[0]]);
|
|
87
|
+
} else {
|
|
88
|
+
setWalkingIndexes([walkingIndexes[1], walkingIndexes[1]]);
|
|
89
|
+
}
|
|
90
|
+
setStatus(99);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, [status, walkingIndexes]);
|
|
94
|
+
|
|
95
|
+
// =========================== Render ===========================
|
|
96
|
+
/** Render by cut index */
|
|
97
|
+
var renderContent = function renderContent(index) {
|
|
98
|
+
var prefixContent = contentChars.slice(0, index);
|
|
99
|
+
var suffixContent = contentChars.slice(contentChars.length - index);
|
|
100
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
101
|
+
children: [direction === 'start' && /*#__PURE__*/_jsxs(_Fragment, {
|
|
102
|
+
children: [expandNode, ELLIPSIS_TEXT]
|
|
103
|
+
}), direction !== 'start' && prefixContent.join(''), direction === 'middle' && /*#__PURE__*/_jsx(_Fragment, {
|
|
104
|
+
children: expandNode ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
105
|
+
children: [ELLIPSIS_TEXT, expandNode, ELLIPSIS_TEXT]
|
|
106
|
+
}) : ELLIPSIS_TEXT
|
|
107
|
+
}), direction !== 'end' && suffixContent.join(''), direction === 'end' && /*#__PURE__*/_jsxs(_Fragment, {
|
|
108
|
+
children: [ELLIPSIS_TEXT, expandNode]
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var finalContent = React.useMemo(function () {
|
|
113
|
+
if (expanded || status === 100) {
|
|
114
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
115
|
+
children: [content, status === 99 && collapseNode]
|
|
116
|
+
}, "display");
|
|
117
|
+
}
|
|
118
|
+
if (status === 99) {
|
|
119
|
+
return renderContent(midIndex);
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}, [expanded, status, content, collapseNode, midIndex]);
|
|
123
|
+
var allNodes = /*#__PURE__*/_jsxs(_Fragment, {
|
|
124
|
+
children: [status === 1 && /*#__PURE__*/_jsxs("div", {
|
|
125
|
+
"aria-hidden": true,
|
|
126
|
+
ref: fullMeasureRef,
|
|
127
|
+
style: measureStyle,
|
|
128
|
+
children: [content, expandNode]
|
|
129
|
+
}, "full"), status === 1 && /*#__PURE__*/_jsx("div", {
|
|
130
|
+
"aria-hidden": true,
|
|
131
|
+
ref: singleRowMeasureRef,
|
|
132
|
+
style: measureStyle,
|
|
133
|
+
children: "\xA0"
|
|
134
|
+
}, "stable"), status === 2 && /*#__PURE__*/_jsx("div", {
|
|
135
|
+
"aria-hidden": true,
|
|
136
|
+
ref: midMeasureRef,
|
|
137
|
+
style: measureStyle,
|
|
138
|
+
children: renderContent(midIndex)
|
|
139
|
+
}, "walking-mid"), finalContent]
|
|
140
|
+
});
|
|
141
|
+
return [allNodes, startMeasure];
|
|
142
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect, useMemoizedFn } from 'ahooks';
|
|
2
|
+
export function useResizeEffect(effect, targetRef) {
|
|
3
|
+
var fn = useMemoizedFn(effect);
|
|
4
|
+
useIsomorphicLayoutEffect(function () {
|
|
5
|
+
var target = targetRef.current;
|
|
6
|
+
if (!target) return;
|
|
7
|
+
if (window.ResizeObserver) {
|
|
8
|
+
var animationFrame;
|
|
9
|
+
var observer = new ResizeObserver(function () {
|
|
10
|
+
animationFrame = window.requestAnimationFrame(function () {
|
|
11
|
+
return fn(target);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
observer.observe(target);
|
|
15
|
+
return function () {
|
|
16
|
+
window.cancelAnimationFrame(animationFrame);
|
|
17
|
+
observer.disconnect();
|
|
18
|
+
};
|
|
19
|
+
} else {
|
|
20
|
+
fn(target);
|
|
21
|
+
}
|
|
22
|
+
}, [targetRef]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type PropagationEvent = 'click' | 'touchstart';
|
|
4
|
+
export declare function withStopPropagation(events: PropagationEvent[], element: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || 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; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
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; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import React from 'react';
|
|
11
|
+
var eventToPropRecord = {
|
|
12
|
+
click: 'onClick',
|
|
13
|
+
touchstart: 'onTouchStart'
|
|
14
|
+
};
|
|
15
|
+
export function withStopPropagation(events, element) {
|
|
16
|
+
var props = _objectSpread({}, element.props);
|
|
17
|
+
var _iterator = _createForOfIteratorHelper(events),
|
|
18
|
+
_step;
|
|
19
|
+
try {
|
|
20
|
+
var _loop = function _loop() {
|
|
21
|
+
var key = _step.value;
|
|
22
|
+
var prop = eventToPropRecord[key];
|
|
23
|
+
props[prop] = function (e) {
|
|
24
|
+
var _element$props$prop, _element$props;
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
(_element$props$prop = (_element$props = element.props)[prop]) === null || _element$props$prop === void 0 || _element$props$prop.call(_element$props, e);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
30
|
+
_loop();
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
_iterator.e(err);
|
|
34
|
+
} finally {
|
|
35
|
+
_iterator.f();
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/React.cloneElement(element, props);
|
|
38
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { default as CcsAppConfig } from './config';
|
|
|
7
7
|
export { default as CcsDatePicker } from './date-picker';
|
|
8
8
|
export { default as CcsDialog } from './dialog';
|
|
9
9
|
export { default as CcsEditor } from './editor';
|
|
10
|
-
export { default as
|
|
10
|
+
export { default as CcsEllipsis } from './ellipsis';
|
|
11
11
|
export { default as CcsFullScreenButton } from './full-screen';
|
|
12
12
|
export { default as useAppConfig } from './hooks/use-app';
|
|
13
13
|
export { default as useCcsOnceEvent } from './hooks/use-once-event';
|
package/es/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { default as CcsAppConfig } from "./config";
|
|
|
7
7
|
export { default as CcsDatePicker } from "./date-picker";
|
|
8
8
|
export { default as CcsDialog } from "./dialog";
|
|
9
9
|
export { default as CcsEditor } from "./editor";
|
|
10
|
-
export { default as
|
|
10
|
+
export { default as CcsEllipsis } from "./ellipsis";
|
|
11
11
|
export { default as CcsFullScreenButton } from "./full-screen";
|
|
12
12
|
export { default as useAppConfig } from "./hooks/use-app";
|
|
13
13
|
export { default as useCcsOnceEvent } from "./hooks/use-once-event";
|
package/es/pro-table/table.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import React, { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
|
5
5
|
import CCS from '..';
|
|
6
6
|
import { PropsWithCss, PropsWithNodeChildren, TableColumns } from '../ccs';
|
|
7
7
|
import { CcsFieldNamesType } from '../context';
|
|
8
|
+
import { EllipsisProps } from '../ellipsis';
|
|
8
9
|
import './index.less';
|
|
9
10
|
type ParamType = Record<string, any>;
|
|
10
11
|
export type ShowDependType = {
|
|
@@ -19,7 +20,7 @@ export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, '
|
|
|
19
20
|
/** 隐藏列 */
|
|
20
21
|
hidden?: boolean;
|
|
21
22
|
/** 省略显示行数,最大支持10行 */
|
|
22
|
-
ellipsis?: boolean | number;
|
|
23
|
+
ellipsis?: Omit<EllipsisProps, 'content'> | boolean | number;
|
|
23
24
|
};
|
|
24
25
|
type TableTitleType<T> = {
|
|
25
26
|
selectedRows: T[];
|
package/es/table/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
var _excluded = ["onResize", "width"],
|
|
3
2
|
_excluded2 = ["data", "style", "scroll", "rowKey", "columns", "tableRef", "pagination", "rowSelection", "className", "tableContentRef"];
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -9,10 +9,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
9
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
11
|
import { useDebounceFn, useUpdate } from 'ahooks';
|
|
12
|
-
import { Table,
|
|
12
|
+
import { Table, theme } from 'antd';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import { useEffect, useImperativeHandle } from 'react';
|
|
15
15
|
import { Resizable } from 'react-resizable';
|
|
16
|
+
import CcsEllipsis2 from "../ellipsis";
|
|
16
17
|
import useTabs from "../hooks/use-tabs";
|
|
17
18
|
import "./index.less";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -151,21 +152,25 @@ var CustomTable = function CustomTable(props) {
|
|
|
151
152
|
});
|
|
152
153
|
cls === null || cls === void 0 || cls.forEach(function (c) {
|
|
153
154
|
if (c.ellipsis && !c.render) {
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
var ellipsisProps = {};
|
|
156
|
+
if (typeof c.ellipsis === 'number') {
|
|
157
|
+
ellipsisProps = {
|
|
158
|
+
rows: c.ellipsis
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (typeof c.ellipsis === 'boolean') ellipsisProps = {
|
|
162
|
+
rows: 1
|
|
163
|
+
};
|
|
164
|
+
if (_typeof(c.ellipsis) === 'object') ellipsisProps = c.ellipsis;
|
|
165
|
+
|
|
166
|
+
// 禁用默认 ellipsis
|
|
167
|
+
c.ellipsis = false;
|
|
168
|
+
// 渲染内容
|
|
157
169
|
c.render = function (e) {
|
|
158
|
-
return /*#__PURE__*/_jsx(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
destroyTooltipOnHide: true,
|
|
163
|
-
className: classNames(_defineProperty({}, "ccs-table-cell-ellipsis-multi lineclamp".concat(ellipsis), isMultiRow)),
|
|
164
|
-
overlayInnerStyle: {
|
|
165
|
-
whiteSpace: 'normal'
|
|
166
|
-
},
|
|
167
|
-
children: e
|
|
168
|
-
});
|
|
170
|
+
return /*#__PURE__*/_jsx(CcsEllipsis2, _objectSpread({
|
|
171
|
+
content: e,
|
|
172
|
+
showTooltip: true
|
|
173
|
+
}, ellipsisProps));
|
|
169
174
|
};
|
|
170
175
|
}
|
|
171
176
|
// 拖拽头部改变列宽响应
|
package/es/table/index.less
CHANGED
|
@@ -117,48 +117,6 @@
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
&-cell-ellipsis {
|
|
121
|
-
overflow: hidden;
|
|
122
|
-
text-overflow: ellipsis;
|
|
123
|
-
white-space: nowrap;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
&-cell-ellipsis-multi {
|
|
127
|
-
overflow: hidden;
|
|
128
|
-
text-overflow: ellipsis;
|
|
129
|
-
display: -webkit-box;
|
|
130
|
-
-webkit-box-orient: vertical;
|
|
131
|
-
white-space: normal;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&-cell-ellipsis-multi.lineclamp2 {
|
|
135
|
-
-webkit-line-clamp: 2;
|
|
136
|
-
}
|
|
137
|
-
&-cell-ellipsis-multi.lineclamp3 {
|
|
138
|
-
-webkit-line-clamp: 3;
|
|
139
|
-
}
|
|
140
|
-
&-cell-ellipsis-multi.lineclamp4 {
|
|
141
|
-
-webkit-line-clamp: 4;
|
|
142
|
-
}
|
|
143
|
-
&-cell-ellipsis-multi.lineclamp5 {
|
|
144
|
-
-webkit-line-clamp: 5;
|
|
145
|
-
}
|
|
146
|
-
&-cell-ellipsis-multi.lineclamp6 {
|
|
147
|
-
-webkit-line-clamp: 6;
|
|
148
|
-
}
|
|
149
|
-
&-cell-ellipsis-multi.lineclamp7 {
|
|
150
|
-
-webkit-line-clamp: 7;
|
|
151
|
-
}
|
|
152
|
-
&-cell-ellipsis-multi.lineclamp8 {
|
|
153
|
-
-webkit-line-clamp: 8;
|
|
154
|
-
}
|
|
155
|
-
&-cell-ellipsis-multi.lineclamp9 {
|
|
156
|
-
-webkit-line-clamp: 9;
|
|
157
|
-
}
|
|
158
|
-
&-cell-ellipsis-multi.lineclamp10 {
|
|
159
|
-
-webkit-line-clamp: 10;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
120
|
&-nodata {
|
|
163
121
|
color: red;
|
|
164
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccs-ui/rc-pro",
|
|
3
|
-
"version": "2.3.6-beta-
|
|
3
|
+
"version": "2.3.6-beta-7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"react-custom-scrollbars": "^4.2.1",
|
|
71
71
|
"react-draggable": "^4.4.5",
|
|
72
72
|
"react-error-overlay": "^6.0.11",
|
|
73
|
-
"react-
|
|
74
|
-
"
|
|
73
|
+
"react-resizable": "^3.0.5",
|
|
74
|
+
"runes2": "^1.1.4"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@ant-design/compatible": "^5.1.2",
|