ronds-metadata 1.0.64 → 1.0.65

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.
@@ -2,14 +2,16 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import "antd/es/message/style";
3
3
  import _message from "antd/es/message";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["isAddColumn", "editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
5
+ var _excluded = ["title", "isAddColumn", "editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
6
6
  import React from 'react';
7
7
  import { EditableContext } from '../interface';
8
8
  import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
9
9
  import "./index.css";
10
+ import Texty from './Texty';
10
11
 
11
12
  var EditableCell = function EditableCell(props) {
12
- var isAddColumn = props.isAddColumn,
13
+ var title = props.title,
14
+ isAddColumn = props.isAddColumn,
13
15
  editable = props.editable,
14
16
  record = props.record,
15
17
  editableType = props.editableType,
@@ -64,7 +66,12 @@ var EditableCell = function EditableCell(props) {
64
66
  if (editableType === 'single') {
65
67
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
66
68
  className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
67
- }), editable && editConfig.curRow === rowIndex ? getDataCell(props) : children);
69
+ }), editable && editConfig.curRow === rowIndex ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
70
+ tooltipStyle: {
71
+ wordWrap: 'break-word'
72
+ },
73
+ tooltipMaxWidth: 800
74
+ }, children));
68
75
  }
69
76
 
70
77
  if (editableType === 'freedom') {
@@ -73,12 +80,22 @@ var EditableCell = function EditableCell(props) {
73
80
  onClick: onCellClick
74
81
  }, restProps, {
75
82
  className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
76
- }), editable && (isFreeEditRow(editConfig.curRow, rowIndex) || isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) ? getDataCell(props) : children);
83
+ }), editable && (isFreeEditRow(editConfig.curRow, rowIndex) || isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
84
+ tooltipStyle: {
85
+ wordWrap: 'break-word'
86
+ },
87
+ tooltipMaxWidth: 800
88
+ }, children));
77
89
  }
78
90
 
79
91
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
80
92
  className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
81
- }), editable ? getDataCell(props) : children);
93
+ }), editable ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
94
+ tooltipStyle: {
95
+ wordWrap: 'break-word'
96
+ },
97
+ tooltipMaxWidth: 800
98
+ }, children));
82
99
  };
83
100
 
84
101
  export default EditableCell;
@@ -0,0 +1,40 @@
1
+ [data-texty] {
2
+ width: 100%;
3
+ display: block;
4
+ overflow: hidden;
5
+ text-overflow: ellipsis;
6
+ white-space: nowrap;
7
+ }
8
+ [data-texty-tooltip] {
9
+ margin: 6px 0;
10
+ padding: 4px 10px;
11
+ border-radius: 4px;
12
+ background-color: #222;
13
+ color: #fff;
14
+ z-index: 99999;
15
+ }
16
+ [data-texty-arrow] {
17
+ position: absolute;
18
+ bottom: -6px;
19
+ width: 0;
20
+ height: 0;
21
+ border-style: solid;
22
+ border-width: 6px 6px 0;
23
+ border-color: #222 transparent transparent;
24
+ }
25
+ [data-texty-arrow*='bottom'] {
26
+ top: -6px;
27
+ bottom: inherit;
28
+ transform: rotate(180deg);
29
+ }
30
+ /* disable the builtin tooltip for truncated text on Safari */
31
+ @media screen and (-webkit-min-device-pixel-ratio: 0) {
32
+ @supports (not (-ms-ime-align: auto)) {
33
+ .EllipsisText::before {
34
+ content: '';
35
+ display: block;
36
+ width: 0;
37
+ height: 0;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import './Texty.less';
3
+ export interface ITextyProps {
4
+ /** 样式名 */
5
+ className?: string;
6
+ /**
7
+ * 获取组件的ref 默认undefined
8
+ */
9
+ innerRef?: Function;
10
+ /**
11
+ * tooltip的渲染元素 默认div
12
+ */
13
+ tagName?: string;
14
+ /**
15
+ * 提示框内容 默认为children
16
+ */
17
+ tooltip?: React.ReactElement;
18
+ /**
19
+ * tooltip的className
20
+ */
21
+ tooltipClassName?: string;
22
+ /**
23
+ * tooltip的Style
24
+ */
25
+ tooltipStyle?: React.CSSProperties;
26
+ /**
27
+ * tooltip的最大宽度
28
+ */
29
+ tooltipMaxWidth?: number;
30
+ /**
31
+ * 鼠标移入后 多久显示
32
+ */
33
+ showDelay?: number;
34
+ /**
35
+ * 鼠标移出后 多久隐藏
36
+ */
37
+ hideDelay?: number;
38
+ /**
39
+ * 箭头的className
40
+ */
41
+ arrowClassName?: string;
42
+ /**
43
+ * 隐藏箭头
44
+ */
45
+ hideArrow?: boolean;
46
+ /**
47
+ * tooltip位置
48
+ */
49
+ placement?: 'auto' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
50
+ /**
51
+ * 附加tooltip的HTML元素**在大多数情况下,您无需手动设置**
52
+ */
53
+ container?: any;
54
+ /** 鼠标移出事件 */
55
+ onMouseLeave?: (e: any) => void;
56
+ /** 鼠标移入事件 */
57
+ onMouseEnter?: (e: any) => void;
58
+ }
59
+ /**
60
+ * 基于Popper的tooltip
61
+ */
62
+ declare class Texty extends React.PureComponent<ITextyProps, any> {
63
+ state: {
64
+ isHovered: boolean;
65
+ };
66
+ private listenTimer;
67
+ private targetNode;
68
+ private hideTimer;
69
+ private showTimer;
70
+ componentDidUpdate(): void;
71
+ componentWillUnmount(): void;
72
+ render(): JSX.Element;
73
+ renderTooltip: ({ ref, style, placement, arrowProps, }: any) => React.ReactPortal;
74
+ setTargetRef: (ref: any) => void;
75
+ handleMouseEvent: (e: any) => void;
76
+ handleScroll: (e: any) => void;
77
+ _clearListenTimer(): void;
78
+ _clearShowTimer(): void;
79
+ _clearHideTimer(): void;
80
+ handleMouseEnter: (e: any) => void;
81
+ handleMouseLeave: (e: any) => void;
82
+ }
83
+ export default Texty;
@@ -0,0 +1,277 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
8
+ var _excluded = ["tagName", "children", "placement", "innerRef", "showDelay", "hideDelay", "tooltip", "tooltipClassName", "tooltipStyle", "tooltipMaxWidth", "hideArrow", "container"];
9
+ import React from 'react';
10
+ import ReactDom from 'react-dom';
11
+ import { Popper } from 'react-popper';
12
+ import "./Texty.css";
13
+ var modifiers = [{
14
+ name: 'preventOverflow',
15
+ options: {
16
+ mainAxis: true,
17
+ padding: 10
18
+ }
19
+ }];
20
+ /**
21
+ * 基于Popper的tooltip
22
+ */
23
+
24
+ var Texty = /*#__PURE__*/function (_React$PureComponent) {
25
+ _inherits(Texty, _React$PureComponent);
26
+
27
+ var _super = _createSuper(Texty);
28
+
29
+ function Texty() {
30
+ var _this;
31
+
32
+ _classCallCheck(this, Texty);
33
+
34
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
+ args[_key] = arguments[_key];
36
+ }
37
+
38
+ _this = _super.call.apply(_super, [this].concat(args));
39
+ _this.state = {
40
+ isHovered: false
41
+ };
42
+ _this.listenTimer = void 0;
43
+ _this.targetNode = void 0;
44
+ _this.hideTimer = void 0;
45
+ _this.showTimer = void 0;
46
+
47
+ _this.renderTooltip = function (_ref) {
48
+ var ref = _ref.ref,
49
+ style = _ref.style,
50
+ placement = _ref.placement,
51
+ arrowProps = _ref.arrowProps;
52
+ var _this$props = _this.props,
53
+ children = _this$props.children,
54
+ container = _this$props.container,
55
+ tooltip = _this$props.tooltip,
56
+ tooltipClassName = _this$props.tooltipClassName,
57
+ tooltipStyle = _this$props.tooltipStyle,
58
+ tooltipMaxWidth = _this$props.tooltipMaxWidth,
59
+ arrowClassName = _this$props.arrowClassName,
60
+ hideArrow = _this$props.hideArrow;
61
+ var content = tooltip || children;
62
+ var extraStyle = tooltipMaxWidth ? _objectSpread(_objectSpread({}, tooltipStyle), {}, {
63
+ maxWidth: tooltipMaxWidth
64
+ }) : tooltipStyle;
65
+ return /*#__PURE__*/ReactDom.createPortal( /*#__PURE__*/React.createElement("div", {
66
+ ref: ref,
67
+ "data-texty-tooltip": placement,
68
+ className: tooltipClassName,
69
+ style: extraStyle ? _objectSpread(_objectSpread({}, style), extraStyle) : style,
70
+ onClick: _this.handleMouseEvent,
71
+ onDoubleClick: _this.handleMouseEvent,
72
+ onContextMenu: _this.handleMouseEvent,
73
+ onMouseDown: _this.handleMouseEvent,
74
+ onMouseUp: _this.handleMouseEvent
75
+ }, content, !hideArrow && /*#__PURE__*/React.createElement("div", {
76
+ ref: arrowProps.ref,
77
+ "data-texty-arrow": placement,
78
+ className: arrowClassName,
79
+ style: arrowProps.style
80
+ })), container || _this.targetNode.ownerDocument.body);
81
+ };
82
+
83
+ _this.setTargetRef = function (ref) {
84
+ _this.props.innerRef && _this.props.innerRef(ref);
85
+ _this.targetNode = ref; // console.log("setTargetRef",ref,this.targetNode)
86
+ };
87
+
88
+ _this.handleMouseEvent = function (e) {
89
+ e.stopPropagation();
90
+ };
91
+
92
+ _this.handleScroll = function (e) {
93
+ var _e$srcElement, _e$srcElement2;
94
+
95
+ if ((e === null || e === void 0 ? void 0 : (_e$srcElement = e.srcElement) === null || _e$srcElement === void 0 ? void 0 : _e$srcElement.className) === 'contract-trigger') {
96
+ return;
97
+ }
98
+
99
+ if ((e === null || e === void 0 ? void 0 : (_e$srcElement2 = e.srcElement) === null || _e$srcElement2 === void 0 ? void 0 : _e$srcElement2.className) === 'texty-scroll') {
100
+ return;
101
+ }
102
+
103
+ _this.setState({
104
+ isHovered: false
105
+ });
106
+ };
107
+
108
+ _this.handleMouseEnter = function (e) {
109
+ // console.log('handleMouseEnter');
110
+ // eslint-disable-next-line react/prop-types
111
+ var _this$props2 = _this.props,
112
+ showDelay = _this$props2.showDelay,
113
+ onMouseEnter = _this$props2.onMouseEnter;
114
+ onMouseEnter && onMouseEnter(e);
115
+
116
+ _this._clearHideTimer();
117
+
118
+ if (!showDelay) {
119
+ _this.setState({
120
+ isHovered: true
121
+ });
122
+
123
+ return;
124
+ }
125
+
126
+ _this.showTimer = setTimeout(function () {
127
+ _this.setState({
128
+ isHovered: true
129
+ });
130
+
131
+ delete _this.showTimer;
132
+ }, showDelay);
133
+ };
134
+
135
+ _this.handleMouseLeave = function (e) {
136
+ // console.log('handleMouseLeave');
137
+ // eslint-disable-next-line react/prop-types
138
+ var _this$props3 = _this.props,
139
+ hideDelay = _this$props3.hideDelay,
140
+ onMouseLeave = _this$props3.onMouseLeave;
141
+ onMouseLeave && onMouseLeave(e);
142
+
143
+ _this._clearShowTimer();
144
+
145
+ var isHovered = _this.state.isHovered;
146
+ if (!isHovered) return;
147
+
148
+ if (!hideDelay) {
149
+ _this.setState({
150
+ isHovered: false
151
+ });
152
+
153
+ return;
154
+ }
155
+
156
+ _this.hideTimer = setTimeout(function () {
157
+ _this.setState({
158
+ isHovered: false
159
+ });
160
+
161
+ delete _this.hideTimer;
162
+ }, hideDelay);
163
+ };
164
+
165
+ return _this;
166
+ }
167
+
168
+ _createClass(Texty, [{
169
+ key: "componentDidUpdate",
170
+ value: function componentDidUpdate() {
171
+ var _this2 = this;
172
+
173
+ // console.log(this.state);
174
+ if (this.state.isHovered) {
175
+ window.addEventListener('scroll', this.handleScroll, true); // react - virtualized - auto - sizer would trigger scroll events after tooltip shown in some case,we have to skip those scroll events
176
+
177
+ this.listenTimer = setTimeout(function () {
178
+ window.removeEventListener('scroll', _this2.handleScroll, true);
179
+ window.addEventListener('scroll', _this2.handleScroll, true);
180
+ delete _this2.listenTimer;
181
+ }, 50);
182
+ } else {
183
+ this._clearListenTimer();
184
+
185
+ window.removeEventListener('scroll', this.handleScroll, true);
186
+ }
187
+ }
188
+ }, {
189
+ key: "componentWillUnmount",
190
+ value: function componentWillUnmount() {
191
+ this._clearListenTimer();
192
+
193
+ window.removeEventListener('scroll', this.handleScroll, true);
194
+
195
+ this._clearShowTimer();
196
+
197
+ this._clearHideTimer();
198
+ }
199
+ }, {
200
+ key: "render",
201
+ value: function render() {
202
+ /* eslint-disable no-unused-vars */
203
+ var _this$props4 = this.props,
204
+ tagName = _this$props4.tagName,
205
+ children = _this$props4.children,
206
+ placement = _this$props4.placement,
207
+ innerRef = _this$props4.innerRef,
208
+ showDelay = _this$props4.showDelay,
209
+ hideDelay = _this$props4.hideDelay,
210
+ tooltip = _this$props4.tooltip,
211
+ tooltipClassName = _this$props4.tooltipClassName,
212
+ tooltipStyle = _this$props4.tooltipStyle,
213
+ tooltipMaxWidth = _this$props4.tooltipMaxWidth,
214
+ hideArrow = _this$props4.hideArrow,
215
+ container = _this$props4.container,
216
+ rest = _objectWithoutProperties(_this$props4, _excluded);
217
+ /* eslint-enable no-unused-vars */
218
+
219
+
220
+ var Tag = tagName;
221
+
222
+ if (!children) {
223
+ return null; // return <Tag { ...rest } ref={ this.setTargetRef } data-texty={ false } />;
224
+ }
225
+
226
+ var target = this.targetNode;
227
+ var isTruncated = !!target && target.scrollWidth > target.offsetWidth;
228
+ var showTooltip = this.state.isHovered && isTruncated; // console.log("showTooltip",showTooltip)
229
+
230
+ return /*#__PURE__*/React.createElement(Tag, _extends({}, rest, {
231
+ ref: this.setTargetRef,
232
+ "data-texty": showTooltip,
233
+ onMouseEnter: this.handleMouseEnter,
234
+ onMouseLeave: this.handleMouseLeave
235
+ }), children, showTooltip && /*#__PURE__*/React.createElement(Popper, {
236
+ referenceElement: target,
237
+ placement: placement,
238
+ modifiers: modifiers
239
+ }, this.renderTooltip));
240
+ }
241
+ }, {
242
+ key: "_clearListenTimer",
243
+ value: function _clearListenTimer() {
244
+ if (this.listenTimer) {
245
+ clearTimeout(this.listenTimer);
246
+ delete this.listenTimer;
247
+ }
248
+ }
249
+ }, {
250
+ key: "_clearShowTimer",
251
+ value: function _clearShowTimer() {
252
+ if (this.showTimer) {
253
+ clearTimeout(this.showTimer);
254
+ delete this.showTimer;
255
+ }
256
+ }
257
+ }, {
258
+ key: "_clearHideTimer",
259
+ value: function _clearHideTimer() {
260
+ if (this.hideTimer) {
261
+ clearTimeout(this.hideTimer);
262
+ delete this.hideTimer;
263
+ }
264
+ }
265
+ }]);
266
+
267
+ return Texty;
268
+ }(React.PureComponent);
269
+
270
+ Texty.defaultProps = {
271
+ tagName: 'div',
272
+ showDelay: 150,
273
+ hideDelay: 150,
274
+ hideArrow: true,
275
+ placement: 'top'
276
+ };
277
+ export default Texty;
@@ -22,6 +22,13 @@
22
22
  background-color: #ebebeb;
23
23
  border-right: 1px solid #f2f2f2;
24
24
  }
25
+ .ronds-edit-table .ant-table-fixed {
26
+ table-layout: fixed;
27
+ }
28
+ .ronds-edit-table .ant-table-tbody > tr > td {
29
+ word-wrap: break-word;
30
+ word-break: break-all;
31
+ }
25
32
  .ronds-edit-table .ant-table.ant-table-small .ant-table-title,
26
33
  .ronds-edit-table .ant-table.ant-table-small .ant-table-footer,
27
34
  .ronds-edit-table .ant-table.ant-table-small .ant-table-thead > tr > th,
@@ -292,8 +292,8 @@ var Editable = function Editable(props) {
292
292
  dataKey: '_aciton_',
293
293
  title: '操作',
294
294
  width: 40,
295
- frozen: 'right',
296
295
  ellipsis: true,
296
+ fixed: 'left',
297
297
  render: function render(val, record) {
298
298
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableAction, {
299
299
  type: type,
@@ -375,9 +375,8 @@ var Editable = function Editable(props) {
375
375
  }, /*#__PURE__*/React.createElement(_Table, _extends({
376
376
  className: "ronds-edit-table",
377
377
  bordered: true,
378
- tableLayout: "auto",
379
378
  scroll: {
380
- x: true,
379
+ x: '100%',
381
380
  y: 'calc(100% - 40px)'
382
381
  }
383
382
  }, tableProps, {
@@ -405,8 +404,8 @@ var Editable = function Editable(props) {
405
404
  block: true,
406
405
  type: "dashed",
407
406
  style: {
408
- marginBottom: 16,
409
- marginTop: 16
407
+ marginBottom: '5px',
408
+ marginTop: '5px'
410
409
  },
411
410
  onClick: onAddRow
412
411
  }, "\u6DFB\u52A0\u4E00\u884C")));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.64",
4
+ "version": "1.0.65",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -47,6 +47,7 @@
47
47
  "react": "^16.12.0",
48
48
  "react-color": "^2.19.3",
49
49
  "react-markdown-editor-lite": "^1.3.2",
50
+ "react-popper": "^2.2.5",
50
51
  "rxjs": "^7.5.4"
51
52
  },
52
53
  "peerDependencies": {