tntd 3.0.47 → 3.0.49
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/query-form/Field/Composition/index.less +4 -4
- package/es/table/resizableTable/index.js +34 -5
- package/es/table/resizableTable/index.js.map +1 -1
- package/es/table/resizableTable/index.less +9 -1
- package/lib/query-form/Field/Composition/index.less +4 -4
- package/lib/segmented/index.d.ts +1 -1
- package/lib/table/resizableTable/index.d.ts +3 -0
- package/lib/table/resizableTable/index.d.ts.map +1 -1
- package/lib/table/resizableTable/index.js +34 -5
- package/lib/table/resizableTable/index.js.map +1 -1
- package/lib/table/resizableTable/index.less +9 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
outline: none;
|
|
18
18
|
transition: all 0.3s @ease-in-out;
|
|
19
19
|
user-select: none;
|
|
20
|
-
margin-bottom: @margin-
|
|
20
|
+
margin-bottom: @margin-sm;
|
|
21
21
|
|
|
22
22
|
&-prefix {
|
|
23
23
|
position: absolute;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
top: 50%;
|
|
26
26
|
transform: translateY(-50%);
|
|
27
27
|
i.anticon {
|
|
28
|
-
color: #
|
|
28
|
+
color: #8B919E;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
transition: border-color 0.3s @ease-in-out;
|
|
110
110
|
cursor: pointer;
|
|
111
111
|
&:hover {
|
|
112
|
-
background-color: #
|
|
112
|
+
background-color: #E6F4FF;
|
|
113
113
|
i.anticon {
|
|
114
114
|
color: @primary-color;
|
|
115
115
|
}
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
&:focus,
|
|
120
120
|
&:active {
|
|
121
121
|
border-color: @primary-color;
|
|
122
|
-
box-shadow: 0px 0px 4px 0px rgba(18, 107, 251, 0.
|
|
122
|
+
box-shadow: 0px 0px 4px 0px rgba(18, 107, 251, 0.10), 0px 0px 5px 0px rgba(18, 107, 251, 0.30);
|
|
123
123
|
outline: 0;
|
|
124
124
|
.tnt-queryform-composition-input-prefix {
|
|
125
125
|
i.anticon {
|
|
@@ -34,9 +34,12 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
34
34
|
var ResizableTitle = function ResizableTitle(props) {
|
|
35
35
|
var onResize = props.onResize,
|
|
36
36
|
width = props.width,
|
|
37
|
-
|
|
37
|
+
titleTip = props.titleTip,
|
|
38
|
+
restProps = __rest(props, ["onResize", "width", "titleTip"]);
|
|
38
39
|
if (!width) {
|
|
39
|
-
return _react["default"].createElement("th", Object.assign({
|
|
40
|
+
return _react["default"].createElement("th", Object.assign({
|
|
41
|
+
title: titleTip
|
|
42
|
+
}, restProps));
|
|
40
43
|
}
|
|
41
44
|
return _react["default"].createElement(_reactResizable.Resizable, {
|
|
42
45
|
width: width,
|
|
@@ -51,7 +54,9 @@ var ResizableTitle = function ResizableTitle(props) {
|
|
|
51
54
|
draggableOpts: {
|
|
52
55
|
enableUserSelectHack: false
|
|
53
56
|
}
|
|
54
|
-
}, _react["default"].createElement("th", Object.assign({
|
|
57
|
+
}, _react["default"].createElement("th", Object.assign({
|
|
58
|
+
title: titleTip
|
|
59
|
+
}, restProps)));
|
|
55
60
|
};
|
|
56
61
|
var MyComponent = function MyComponent(props, ref) {
|
|
57
62
|
var _useState = (0, _react.useState)([]),
|
|
@@ -59,13 +64,20 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
59
64
|
columns = _useState2[0],
|
|
60
65
|
setColumns = _useState2[1];
|
|
61
66
|
var dataRef = (0, _react.useRef)([]);
|
|
67
|
+
var _useState3 = (0, _react.useState)(0),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
renderKey = _useState4[0],
|
|
70
|
+
setRenderKey = _useState4[1];
|
|
71
|
+
var renderKeyRef = (0, _react.useRef)(renderKey);
|
|
62
72
|
var handleResize = function handleResize(index, minWidth) {
|
|
63
73
|
return (0, _throttle2["default"])(function (e, _ref) {
|
|
64
74
|
var size = _ref.size;
|
|
65
75
|
var updatedColumns = dataRef.current || [];
|
|
76
|
+
var width = Math.max(size.width, minWidth || 52);
|
|
66
77
|
setColumns(updatedColumns.map(function (column, idx) {
|
|
67
78
|
return idx === index ? Object.assign(Object.assign({}, column), {
|
|
68
|
-
width:
|
|
79
|
+
width: width,
|
|
80
|
+
resizeKey: width
|
|
69
81
|
}) : column;
|
|
70
82
|
}));
|
|
71
83
|
}, 25);
|
|
@@ -76,7 +88,19 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
76
88
|
if (typeof (column === null || column === void 0 ? void 0 : column.width) === 'string' && ((_a = column === null || column === void 0 ? void 0 : column.width) === null || _a === void 0 ? void 0 : _a.includes('%'))) {
|
|
77
89
|
return column;
|
|
78
90
|
}
|
|
91
|
+
var titleTip;
|
|
92
|
+
if (column && typeof column.title === 'string') {
|
|
93
|
+
titleTip = column.title;
|
|
94
|
+
}
|
|
79
95
|
return Object.assign(Object.assign({}, column), {
|
|
96
|
+
render: typeof (column === null || column === void 0 ? void 0 : column.render) === 'function' ? function () {
|
|
97
|
+
var _a2;
|
|
98
|
+
var _a;
|
|
99
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
100
|
+
args[_key] = arguments[_key];
|
|
101
|
+
}
|
|
102
|
+
return (_a = column === null || column === void 0 ? void 0 : column.render) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [column].concat(args, [renderKeyRef.current]));
|
|
103
|
+
} : column === null || column === void 0 ? void 0 : column.render,
|
|
80
104
|
onHeaderCell: function onHeaderCell(column) {
|
|
81
105
|
var width = column.width;
|
|
82
106
|
var minWidth = column.minWidth;
|
|
@@ -88,7 +112,12 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
88
112
|
}
|
|
89
113
|
return {
|
|
90
114
|
width: width,
|
|
91
|
-
|
|
115
|
+
titleTip: titleTip,
|
|
116
|
+
onResize: handleResize(index, minWidth),
|
|
117
|
+
onMouseUp: function onMouseUp() {
|
|
118
|
+
renderKeyRef.current += 1;
|
|
119
|
+
setRenderKey(renderKeyRef.current);
|
|
120
|
+
}
|
|
92
121
|
};
|
|
93
122
|
}
|
|
94
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,cAAc,CAAA;AAErB,MAAM,cAAc,GAAG,CACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,cAAc,CAAA;AAErB,MAAM,cAAc,GAAG,CACrB,KAIC,EACD,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAnD,iCAA2C,CAAQ,CAAA;IAEzD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,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AAC,SAAU,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,EAC7E,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,IAChD,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,UAAU,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import React, { useState, forwardRef, useRef, useEffect } from 'react'\nimport cn from 'classnames'\nimport { throttle } from 'lodash'\nimport { Resizable } from 'react-resizable'\nimport { Table } from '../table'\nimport './index.less'\n\nconst ResizableTitle = (\n props: React.HTMLAttributes<any> & {\n onResize: (e: React.SyntheticEvent<Element>, data: any) => void\n width: number\n titleTip: string\n }\n) => {\n const { onResize, width, titleTip, ...restProps } = props\n\n if (!width) {\n return <th title={titleTip} {...restProps} />\n }\n\n return (\n <Resizable\n width={width}\n height={0}\n handle={\n <span\n className=\"react-resizable-handle\"\n onClick={(e) => {\n e.stopPropagation()\n }}\n />\n }\n onResize={onResize}\n draggableOpts={{ enableUserSelectHack: false }}\n >\n <th title={titleTip} {...restProps} />\n </Resizable>\n )\n}\n\ninterface ColumnType {\n width?: any\n minWidth?: any\n render?: any\n title?: any\n titleTip?: any\n}\n\ninterface MyComponentProps {\n columns?: ColumnType[]\n className?: string\n}\n\nconst MyComponent: React.ForwardRefRenderFunction<any, MyComponentProps> = (props, ref) => {\n const [columns, setColumns] = useState<ColumnType[]>([])\n const dataRef = useRef<ColumnType[]>([])\n const [renderKey, setRenderKey] = useState(0)\n const renderKeyRef = useRef(renderKey)\n\n const handleResize = (index: number, minWidth: number) =>\n throttle((e, { size }) => {\n const updatedColumns = dataRef.current || []\n const width = Math.max(size.width, minWidth || 52)\n setColumns(\n updatedColumns.map((column, idx) =>\n idx === index\n ? {\n ...column,\n width: width,\n resizeKey: width,\n }\n : column\n )\n )\n }, 25)\n\n const buildColumns = (columns: ColumnType[]) =>\n columns?.map((column, index) => {\n if (typeof column?.width === 'string' && column?.width?.includes('%')) {\n return column\n }\n\n let titleTip: string\n if (column && typeof column.title === 'string') {\n titleTip = column.title\n }\n\n return {\n ...column,\n render:\n typeof column?.render === 'function'\n ? (...args: any[]) => {\n return column?.render?.(...args, renderKeyRef.current)\n }\n : column?.render,\n onHeaderCell: (column: ColumnType) => {\n let width = column.width\n let minWidth = column.minWidth\n if (typeof width === 'string' && !width.includes('%')) {\n width = Number(width.replace(/[^\\d]/g, ''))\n }\n\n if (minWidth && typeof minWidth === 'string' && !minWidth.includes('%')) {\n minWidth = Number(minWidth.replace(/[^\\d]/g, ''))\n }\n\n return {\n width,\n titleTip,\n onResize: handleResize(index, minWidth),\n onMouseUp: () => {\n renderKeyRef.current += 1\n setRenderKey(renderKeyRef.current)\n },\n }\n },\n }\n })\n\n useEffect(() => {\n if (Array.isArray(props?.columns)) {\n const curColumns = buildColumns(props.columns)\n setColumns(curColumns || [])\n }\n }, [props?.columns])\n\n useEffect(() => {\n dataRef.current = columns\n }, [columns])\n\n return (\n <Table\n {...props}\n {...(Array.isArray(props?.columns) ? { columns } : {})}\n className={cn('tnt-resizable-table', { [props.className!]: props.className })}\n components={{ header: { cell: ResizableTitle } }}\n />\n )\n}\n\nexport default forwardRef(MyComponent)\n"]}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
@table-prefix-cls: ~'@{ant-prefix}-table';
|
|
1
2
|
.tnt-resizable-table {
|
|
2
3
|
.react-resizable {
|
|
3
4
|
position: relative;
|
|
4
5
|
background-clip: padding-box;
|
|
6
|
+
|
|
7
|
+
.@{table-prefix-cls}-column-title{
|
|
8
|
+
min-width: 22px !important;
|
|
9
|
+
>.tntd-ellipsis{
|
|
10
|
+
min-width: 22px !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
}
|
|
6
15
|
.ant-table-thead{
|
|
7
16
|
tr:hover{
|
|
@@ -29,7 +38,6 @@
|
|
|
29
38
|
bottom: 0;
|
|
30
39
|
right: -5px;
|
|
31
40
|
cursor: col-resize;
|
|
32
|
-
z-index: 1;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
&-handle {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
outline: none;
|
|
18
18
|
transition: all 0.3s @ease-in-out;
|
|
19
19
|
user-select: none;
|
|
20
|
-
margin-bottom: @margin-
|
|
20
|
+
margin-bottom: @margin-sm;
|
|
21
21
|
|
|
22
22
|
&-prefix {
|
|
23
23
|
position: absolute;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
top: 50%;
|
|
26
26
|
transform: translateY(-50%);
|
|
27
27
|
i.anticon {
|
|
28
|
-
color: #
|
|
28
|
+
color: #8B919E;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
transition: border-color 0.3s @ease-in-out;
|
|
110
110
|
cursor: pointer;
|
|
111
111
|
&:hover {
|
|
112
|
-
background-color: #
|
|
112
|
+
background-color: #E6F4FF;
|
|
113
113
|
i.anticon {
|
|
114
114
|
color: @primary-color;
|
|
115
115
|
}
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
&:focus,
|
|
120
120
|
&:active {
|
|
121
121
|
border-color: @primary-color;
|
|
122
|
-
box-shadow: 0px 0px 4px 0px rgba(18, 107, 251, 0.
|
|
122
|
+
box-shadow: 0px 0px 4px 0px rgba(18, 107, 251, 0.10), 0px 0px 5px 0px rgba(18, 107, 251, 0.30);
|
|
123
123
|
outline: 0;
|
|
124
124
|
.tnt-queryform-composition-input-prefix {
|
|
125
125
|
i.anticon {
|
package/lib/segmented/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export interface SegmentedProps extends Omit<RCSegmentedProps, 'size' | 'options
|
|
|
18
18
|
block?: boolean;
|
|
19
19
|
size?: SizeType;
|
|
20
20
|
}
|
|
21
|
-
declare const Segmented: React.ForwardRefExoticComponent<Pick<SegmentedProps, "action" | "type" | "style" | "prefixCls" | "className" | "children" | "default" | "cite" | "data" | "form" | "label" | "slot" | "span" | "summary" | "title" | "pattern" | "target" | "lang" | "about" | "as" | "onClick" | "download" | "href" | "hrefLang" | "media" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "list" | "step" | "size" | "shape" | "block" | "key" | "width" | "height" | "src" | "max" | "method" | "min" | "crossOrigin" | "direction" | "checked" | "options" | "open" | "multiple" | "wrap" | "start" | "acceptCharset" | "autoComplete" | "encType" | "noValidate" | "motionName" | "htmlFor" | "required" | "accept" | "alt" | "capture" | "maxLength" | "minLength" | "readOnly" | "cols" | "rows" | "
|
|
21
|
+
declare const Segmented: React.ForwardRefExoticComponent<Pick<SegmentedProps, "action" | "type" | "style" | "prefixCls" | "className" | "children" | "default" | "cite" | "data" | "form" | "label" | "slot" | "span" | "summary" | "title" | "pattern" | "target" | "lang" | "about" | "as" | "onClick" | "download" | "href" | "hrefLang" | "media" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "list" | "step" | "size" | "shape" | "block" | "key" | "width" | "height" | "src" | "max" | "method" | "min" | "crossOrigin" | "direction" | "checked" | "options" | "open" | "multiple" | "wrap" | "start" | "acceptCharset" | "autoComplete" | "encType" | "noValidate" | "motionName" | "htmlFor" | "required" | "accept" | "alt" | "capture" | "maxLength" | "minLength" | "readOnly" | "cols" | "rows" | "headers" | "allowFullScreen" | "allowTransparency" | "async" | "autoPlay" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "classID" | "colSpan" | "controls" | "coords" | "dateTime" | "defer" | "frameBorder" | "high" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "mediaGroup" | "muted" | "optimum" | "playsInline" | "poster" | "preload" | "reversed" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "useMap" | "wmode" | "rootClassName"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
22
|
export default Segmented;
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAKtE,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAKtE,OAAO,cAAc,CAAA;AAmCrB,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,GAAG,CAAA;CACf;AAED,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;;AAyFD,wBAAsC"}
|
|
@@ -130,9 +130,12 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
130
130
|
var ResizableTitle = function ResizableTitle(props) {
|
|
131
131
|
var onResize = props.onResize,
|
|
132
132
|
width = props.width,
|
|
133
|
-
|
|
133
|
+
titleTip = props.titleTip,
|
|
134
|
+
restProps = __rest(props, ["onResize", "width", "titleTip"]);
|
|
134
135
|
if (!width) {
|
|
135
|
-
return _react["default"].createElement("th", Object.assign({
|
|
136
|
+
return _react["default"].createElement("th", Object.assign({
|
|
137
|
+
title: titleTip
|
|
138
|
+
}, restProps));
|
|
136
139
|
}
|
|
137
140
|
return _react["default"].createElement(_reactResizable.Resizable, {
|
|
138
141
|
width: width,
|
|
@@ -147,7 +150,9 @@ var ResizableTitle = function ResizableTitle(props) {
|
|
|
147
150
|
draggableOpts: {
|
|
148
151
|
enableUserSelectHack: false
|
|
149
152
|
}
|
|
150
|
-
}, _react["default"].createElement("th", Object.assign({
|
|
153
|
+
}, _react["default"].createElement("th", Object.assign({
|
|
154
|
+
title: titleTip
|
|
155
|
+
}, restProps)));
|
|
151
156
|
};
|
|
152
157
|
var MyComponent = function MyComponent(props, ref) {
|
|
153
158
|
var _useState = (0, _react.useState)([]),
|
|
@@ -155,13 +160,20 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
155
160
|
columns = _useState2[0],
|
|
156
161
|
setColumns = _useState2[1];
|
|
157
162
|
var dataRef = (0, _react.useRef)([]);
|
|
163
|
+
var _useState3 = (0, _react.useState)(0),
|
|
164
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
165
|
+
renderKey = _useState4[0],
|
|
166
|
+
setRenderKey = _useState4[1];
|
|
167
|
+
var renderKeyRef = (0, _react.useRef)(renderKey);
|
|
158
168
|
var handleResize = function handleResize(index, minWidth) {
|
|
159
169
|
return (0, _throttle2["default"])(function (e, _ref) {
|
|
160
170
|
var size = _ref.size;
|
|
161
171
|
var updatedColumns = dataRef.current || [];
|
|
172
|
+
var width = Math.max(size.width, minWidth || 52);
|
|
162
173
|
setColumns(updatedColumns.map(function (column, idx) {
|
|
163
174
|
return idx === index ? Object.assign(Object.assign({}, column), {
|
|
164
|
-
width:
|
|
175
|
+
width: width,
|
|
176
|
+
resizeKey: width
|
|
165
177
|
}) : column;
|
|
166
178
|
}));
|
|
167
179
|
}, 25);
|
|
@@ -172,7 +184,19 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
172
184
|
if (typeof (column === null || column === void 0 ? void 0 : column.width) === 'string' && ((_a = column === null || column === void 0 ? void 0 : column.width) === null || _a === void 0 ? void 0 : _a.includes('%'))) {
|
|
173
185
|
return column;
|
|
174
186
|
}
|
|
187
|
+
var titleTip;
|
|
188
|
+
if (column && typeof column.title === 'string') {
|
|
189
|
+
titleTip = column.title;
|
|
190
|
+
}
|
|
175
191
|
return Object.assign(Object.assign({}, column), {
|
|
192
|
+
render: typeof (column === null || column === void 0 ? void 0 : column.render) === 'function' ? function () {
|
|
193
|
+
var _a2;
|
|
194
|
+
var _a;
|
|
195
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
196
|
+
args[_key] = arguments[_key];
|
|
197
|
+
}
|
|
198
|
+
return (_a = column === null || column === void 0 ? void 0 : column.render) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [column].concat(args, [renderKeyRef.current]));
|
|
199
|
+
} : column === null || column === void 0 ? void 0 : column.render,
|
|
176
200
|
onHeaderCell: function onHeaderCell(column) {
|
|
177
201
|
var width = column.width;
|
|
178
202
|
var minWidth = column.minWidth;
|
|
@@ -184,7 +208,12 @@ var MyComponent = function MyComponent(props, ref) {
|
|
|
184
208
|
}
|
|
185
209
|
return {
|
|
186
210
|
width: width,
|
|
187
|
-
|
|
211
|
+
titleTip: titleTip,
|
|
212
|
+
onResize: handleResize(index, minWidth),
|
|
213
|
+
onMouseUp: function onMouseUp() {
|
|
214
|
+
renderKeyRef.current += 1;
|
|
215
|
+
setRenderKey(renderKeyRef.current);
|
|
216
|
+
}
|
|
188
217
|
};
|
|
189
218
|
}
|
|
190
219
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,4DAA2B;AAC3B,mCAAiC;AACjC,qDAA2C;AAC3C,oCAAgC;AAChC,wBAAqB;AAErB,MAAM,cAAc,GAAG,CACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/resizableTable/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,4DAA2B;AAC3B,mCAAiC;AACjC,qDAA2C;AAC3C,oCAAgC;AAChC,wBAAqB;AAErB,MAAM,cAAc,GAAG,CACrB,KAIC,EACD,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAnD,iCAA2C,CAAQ,CAAA;IAEzD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,oDAAI,KAAK,EAAE,QAAQ,IAAM,SAAS,EAAI,CAAA;KAC9C;IAED,OAAO,CACL,8BAAC,2BAAS,IACR,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,CAAC,EACT,MAAM,EACJ,wCACE,SAAS,EAAC,wBAAwB,EAClC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACb,CAAC,CAAC,eAAe,EAAE,C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W,CAAC,CAAA","sourcesContent":["import React, { useState, forwardRef, useRef, useEffect } from 'react'\nimport cn from 'classnames'\nimport { throttle } from 'lodash'\nimport { Resizable } from 'react-resizable'\nimport { Table } from '../table'\nimport './index.less'\n\nconst ResizableTitle = (\n props: React.HTMLAttributes<any> & {\n onResize: (e: React.SyntheticEvent<Element>, data: any) => void\n width: number\n titleTip: string\n }\n) => {\n const { onResize, width, titleTip, ...restProps } = props\n\n if (!width) {\n return <th title={titleTip} {...restProps} />\n }\n\n return (\n <Resizable\n width={width}\n height={0}\n handle={\n <span\n className=\"react-resizable-handle\"\n onClick={(e) => {\n e.stopPropagation()\n }}\n />\n }\n onResize={onResize}\n draggableOpts={{ enableUserSelectHack: false }}\n >\n <th title={titleTip} {...restProps} />\n </Resizable>\n )\n}\n\ninterface ColumnType {\n width?: any\n minWidth?: any\n render?: any\n title?: any\n titleTip?: any\n}\n\ninterface MyComponentProps {\n columns?: ColumnType[]\n className?: string\n}\n\nconst MyComponent: React.ForwardRefRenderFunction<any, MyComponentProps> = (props, ref) => {\n const [columns, setColumns] = useState<ColumnType[]>([])\n const dataRef = useRef<ColumnType[]>([])\n const [renderKey, setRenderKey] = useState(0)\n const renderKeyRef = useRef(renderKey)\n\n const handleResize = (index: number, minWidth: number) =>\n throttle((e, { size }) => {\n const updatedColumns = dataRef.current || []\n const width = Math.max(size.width, minWidth || 52)\n setColumns(\n updatedColumns.map((column, idx) =>\n idx === index\n ? {\n ...column,\n width: width,\n resizeKey: width,\n }\n : column\n )\n )\n }, 25)\n\n const buildColumns = (columns: ColumnType[]) =>\n columns?.map((column, index) => {\n if (typeof column?.width === 'string' && column?.width?.includes('%')) {\n return column\n }\n\n let titleTip: string\n if (column && typeof column.title === 'string') {\n titleTip = column.title\n }\n\n return {\n ...column,\n render:\n typeof column?.render === 'function'\n ? (...args: any[]) => {\n return column?.render?.(...args, renderKeyRef.current)\n }\n : column?.render,\n onHeaderCell: (column: ColumnType) => {\n let width = column.width\n let minWidth = column.minWidth\n if (typeof width === 'string' && !width.includes('%')) {\n width = Number(width.replace(/[^\\d]/g, ''))\n }\n\n if (minWidth && typeof minWidth === 'string' && !minWidth.includes('%')) {\n minWidth = Number(minWidth.replace(/[^\\d]/g, ''))\n }\n\n return {\n width,\n titleTip,\n onResize: handleResize(index, minWidth),\n onMouseUp: () => {\n renderKeyRef.current += 1\n setRenderKey(renderKeyRef.current)\n },\n }\n },\n }\n })\n\n useEffect(() => {\n if (Array.isArray(props?.columns)) {\n const curColumns = buildColumns(props.columns)\n setColumns(curColumns || [])\n }\n }, [props?.columns])\n\n useEffect(() => {\n dataRef.current = columns\n }, [columns])\n\n return (\n <Table\n {...props}\n {...(Array.isArray(props?.columns) ? { columns } : {})}\n className={cn('tnt-resizable-table', { [props.className!]: props.className })}\n components={{ header: { cell: ResizableTitle } }}\n />\n )\n}\n\nexport default forwardRef(MyComponent)\n"]}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
@table-prefix-cls: ~'@{ant-prefix}-table';
|
|
1
2
|
.tnt-resizable-table {
|
|
2
3
|
.react-resizable {
|
|
3
4
|
position: relative;
|
|
4
5
|
background-clip: padding-box;
|
|
6
|
+
|
|
7
|
+
.@{table-prefix-cls}-column-title{
|
|
8
|
+
min-width: 22px !important;
|
|
9
|
+
>.tntd-ellipsis{
|
|
10
|
+
min-width: 22px !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
}
|
|
6
15
|
.ant-table-thead{
|
|
7
16
|
tr:hover{
|
|
@@ -29,7 +38,6 @@
|
|
|
29
38
|
bottom: 0;
|
|
30
39
|
right: -5px;
|
|
31
40
|
cursor: col-resize;
|
|
32
|
-
z-index: 1;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
&-handle {
|