@arim-aisdc/public-components 0.0.50 → 0.0.51

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.
@@ -23,7 +23,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
23
23
  labelWidth?: string;
24
24
  color?: string;
25
25
  disabledColor?: string;
26
- formatFun?: (field: string, data: any) => void;
26
+ formatFun?: (field: string | number, data: any) => void;
27
27
  detail?: object;
28
28
  isShowInterval?: boolean;
29
29
  isActiveTrigger?: boolean;
@@ -50,7 +50,7 @@ var BaseInfo = function BaseInfo(_ref) {
50
50
  width: el.labelWidth ? el.labelWidth : ''
51
51
  },
52
52
  children: typeof el.text === 'string' ? /*#__PURE__*/_jsxs(_Fragment, {
53
- children: [el.text, ":"]
53
+ children: [el.text, "\uFF1A"]
54
54
  }) : /*#__PURE__*/_jsxs(React.Fragment, {
55
55
  children: [el.text, "\uFF1A"]
56
56
  })
@@ -9,7 +9,7 @@ export interface BaseInfoFieldType {
9
9
  labelWidth?: string;
10
10
  color?: string;
11
11
  disabledColor?: string;
12
- formatFun?: (field: string, data: any) => void;
12
+ formatFun?: (field: string | number, data: any) => void;
13
13
  detail?: object;
14
14
  isShowInterval?: boolean;
15
15
  isActiveTrigger?: boolean;
@@ -7,6 +7,6 @@ declare const ModalTip: {
7
7
  error: (info: ModalTipType) => void;
8
8
  info: (info: ModalTipType) => void;
9
9
  attention: (info: ModalTipType) => void;
10
- delete: (theme: any, info: ModalDeleteType) => void;
10
+ delete: (info: ModalDeleteType, theme?: 'light' | 'dark') => void;
11
11
  };
12
12
  export default ModalTip;
@@ -93,7 +93,7 @@ var updateModal = function updateModal(_ref3) {
93
93
  afterClose === null || afterClose === void 0 || afterClose();
94
94
  }, duration);
95
95
  };
96
- var confirmModal = function confirmModal(theme, _ref4) {
96
+ var confirmModal = function confirmModal(_ref4, theme) {
97
97
  var handlerConfirm = _ref4.handlerConfirm,
98
98
  title = _ref4.title,
99
99
  content = _ref4.content,
@@ -105,16 +105,16 @@ var confirmModal = function confirmModal(theme, _ref4) {
105
105
  content: content ? content : '删除后可能无法恢复,请谨慎操作!',
106
106
  okText: okText ? okText : '确认',
107
107
  cancelText: cancelText ? cancelText : '取消',
108
- bodyStyle: themeStyle(theme, 'bodyStyle'),
108
+ bodyStyle: themeStyle('bodyStyle', theme),
109
109
  // 背景颜色
110
- maskStyle: themeStyle(theme, 'maskStyle'),
110
+ maskStyle: themeStyle('maskStyle', theme),
111
111
  // 网罩颜色
112
112
  okButtonProps: {
113
- style: themeStyle(theme, 'okButtonProps')
113
+ style: themeStyle('okButtonProps', theme)
114
114
  },
115
115
  // 确认按钮样式
116
116
  cancelButtonProps: {
117
- style: themeStyle(theme, 'cancelButtonProps')
117
+ style: themeStyle('cancelButtonProps', theme)
118
118
  },
119
119
  // 取消按钮样式
120
120
  centered: centered ? centered : true,
@@ -179,8 +179,8 @@ var ModalTip = {
179
179
  tipCode: 'attention'
180
180
  }));
181
181
  },
182
- delete: function _delete(theme, info) {
183
- return confirmModal(theme, info);
182
+ delete: function _delete(info, theme) {
183
+ return confirmModal(info, theme);
184
184
  }
185
185
  };
186
186
  export default ModalTip;
@@ -2,4 +2,4 @@ export declare const themeType: {
2
2
  light: string;
3
3
  dark: string;
4
4
  };
5
- export declare const themeStyle: (theme: string, type: string) => React.CSSProperties;
5
+ export declare const themeStyle: (type: string, theme?: string) => React.CSSProperties;
@@ -4,7 +4,8 @@ export var themeType = {
4
4
  dark: 'dark'
5
5
  };
6
6
  // 返回主题样式
7
- export var themeStyle = function themeStyle(theme, type) {
7
+ export var themeStyle = function themeStyle(type) {
8
+ var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : themeType.dark;
8
9
  var isDark = theme === themeType.dark;
9
10
  switch (type) {
10
11
  case 'bodyStyle':
@@ -2,7 +2,7 @@ import { OnSelectChangeType } from "../type";
2
2
  import { Table } from '@tanstack/react-table';
3
3
  import { Dispatch, ReactNode, SetStateAction } from 'react';
4
4
  import './index.less';
5
- declare const Row: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, handleEditRowWhenDClick, canEditRowWhenDClick, theme, dragBeforeStart, shadowColumnInfo, }: {
5
+ type IRowProps = {
6
6
  table: Table<any>;
7
7
  tableId: string;
8
8
  row: any;
@@ -43,5 +43,12 @@ declare const Row: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSe
43
43
  leftLastColumnId: string;
44
44
  rightFirstColumnId: string;
45
45
  };
46
- }) => import("react/jsx-runtime").JSX.Element;
46
+ onCellContextMenu: (e: React.MouseEvent, cell: any) => void;
47
+ /**获取行hover时的tip信息 */
48
+ getRowHoverTipConfig?: (row: any) => {
49
+ title: string;
50
+ color: string;
51
+ };
52
+ };
53
+ declare const Row: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, handleEditRowWhenDClick, canEditRowWhenDClick, theme, dragBeforeStart, shadowColumnInfo, onCellContextMenu, getRowHoverTipConfig, }: IRowProps) => import("react/jsx-runtime").JSX.Element;
47
54
  export default Row;
@@ -1,4 +1,6 @@
1
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
+ import "antd/es/tooltip/style";
3
+ import _Tooltip from "antd/es/tooltip";
2
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; }
3
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; }
4
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; }
@@ -11,7 +13,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
13
  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; } }
12
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
15
  import { flexRender } from '@tanstack/react-table';
14
- import { useEffect, useRef } from 'react';
16
+ import { useEffect, useRef, useState } from 'react';
15
17
  import { useDrag, useDrop } from 'react-dnd';
16
18
  import { getEmptyImage } from 'react-dnd-html5-backend';
17
19
  import { EditableCell } from "../components/ColumnEdit";
@@ -22,7 +24,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
22
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
25
  var initselectedIndex;
24
26
  var Row = function Row(_ref) {
25
- var _row, _row2, _tableBodyRef$current, _tableBodyRef$current2;
27
+ var _row2, _tableBodyRef$current, _tableBodyRef$current2;
26
28
  var tableBodyRef = _ref.tableBodyRef,
27
29
  table = _ref.table,
28
30
  tableId = _ref.tableId,
@@ -55,7 +57,9 @@ var Row = function Row(_ref) {
55
57
  canEditRowWhenDClick = _ref.canEditRowWhenDClick,
56
58
  theme = _ref.theme,
57
59
  dragBeforeStart = _ref.dragBeforeStart,
58
- shadowColumnInfo = _ref.shadowColumnInfo;
60
+ shadowColumnInfo = _ref.shadowColumnInfo,
61
+ onCellContextMenu = _ref.onCellContextMenu,
62
+ getRowHoverTipConfig = _ref.getRowHoverTipConfig;
59
63
  var timerRef = useRef();
60
64
  var _useDrop = useDrop({
61
65
  accept: 'TABLE_ROW',
@@ -125,44 +129,69 @@ var Row = function Row(_ref) {
125
129
  if (!selectRowWhenClick || !row.getCanSelect()) {
126
130
  return;
127
131
  }
128
- // 能勾选且展示勾选框
129
- if (canSelection && !selectionWithoutChecked) {
130
- var selectionConfig = _objectSpread(_objectSpread({}, table.getState().rowSelection), {}, _defineProperty({}, row.id, !row.getIsSelected()));
131
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
132
- row.getCanSelect() && (table === null || table === void 0 ? void 0 : table.setRowSelection(selectionConfig));
133
- onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, row.getCanSelect() ? !row.getIsSelected() : false, evt);
134
- }
135
- // selectionWithoutChecked能多选不展示勾选框
136
- else if (canSelection && selectionWithoutChecked) {
137
- if (evt.ctrlKey) {
138
- var _selectionConfig = _objectSpread({}, table.getState().rowSelection);
139
- if (!row.getIsSelected()) {
140
- _selectionConfig[row.id] = true;
132
+ // 多选
133
+ if (canSelection) {
134
+ // 不展示多选框
135
+ if (selectionWithoutChecked) {
136
+ if (evt.ctrlKey) {
137
+ var selectionConfig = _objectSpread({}, table.getState().rowSelection);
138
+ if (!row.getIsSelected()) {
139
+ selectionConfig[row.id] = true;
140
+ } else {
141
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
142
+ selectionConfig[row.id] && Object.keys(selectionConfig).length > 1 && delete selectionConfig[row.id];
143
+ }
144
+ table === null || table === void 0 || table.setRowSelection(_objectSpread({}, selectionConfig));
145
+ } else if (evt.shiftKey) {
146
+ var _table$getRowModel$ro;
147
+ var _selectionConfig = {};
148
+ var min = Math.min(initselectedIndex || 0, row.index);
149
+ var max = Math.max(initselectedIndex || 0, row.index);
150
+ // console.log(selectionConfig, table.getRowModel(), 'selectionConfig');
151
+ var newSelectedRowIds = ((_table$getRowModel$ro = table.getRowModel().rows.filter(function (row) {
152
+ return row.index >= min && row.index <= max;
153
+ })) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.map(function (row) {
154
+ return row.id;
155
+ })) || [];
156
+ for (var i = 0; i <= newSelectedRowIds.length; i++) {
157
+ _selectionConfig[newSelectedRowIds[i]] = true;
158
+ }
159
+ table === null || table === void 0 || table.setRowSelection(_selectionConfig);
141
160
  } else {
142
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
143
- _selectionConfig[row.id] && Object.keys(_selectionConfig).length > 1 && delete _selectionConfig[row.id];
161
+ initselectedIndex = row.index;
162
+ table === null || table === void 0 || table.setRowSelection(_defineProperty({}, row === null || row === void 0 ? void 0 : row.id, true));
144
163
  }
145
- table === null || table === void 0 || table.setRowSelection(_objectSpread({}, _selectionConfig));
146
- } else if (evt.shiftKey) {
147
- var _table$getRowModel$ro;
148
- var _selectionConfig2 = {};
149
- var min = Math.min(initselectedIndex || 0, row.index);
150
- var max = Math.max(initselectedIndex || 0, row.index);
151
- console.log(_selectionConfig2, table.getRowModel(), 'selectionConfig');
152
- var newSelectedRowIds = ((_table$getRowModel$ro = table.getRowModel().rows.filter(function (row) {
153
- return row.index >= min && row.index <= max;
154
- })) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.map(function (row) {
155
- return row.id;
156
- })) || [];
157
- for (var i = 0; i <= newSelectedRowIds.length; i++) {
158
- _selectionConfig2[newSelectedRowIds[i]] = true;
164
+ }
165
+ // 展示多选框
166
+ else {
167
+ if (evt.shiftKey) {
168
+ var _table$getRowModel$ro2;
169
+ console.log('table.getState().rowSelection :>> ', table.getState().rowSelection);
170
+ var _selectionConfig2 = _objectSpread({}, table.getState().rowSelection);
171
+ var _min = Math.min(initselectedIndex || 0, row.index);
172
+ var _max = Math.max(initselectedIndex || 0, row.index);
173
+ // console.log(selectionConfig, table.getRowModel(), 'selectionConfig');
174
+ var _newSelectedRowIds = ((_table$getRowModel$ro2 = table.getRowModel().rows.filter(function (row) {
175
+ return row.index >= _min && row.index <= _max;
176
+ })) === null || _table$getRowModel$ro2 === void 0 ? void 0 : _table$getRowModel$ro2.map(function (row) {
177
+ return row.id;
178
+ })) || [];
179
+ for (var _i = 0; _i <= _newSelectedRowIds.length; _i++) {
180
+ _selectionConfig2[_newSelectedRowIds[_i]] = true;
181
+ }
182
+ table === null || table === void 0 || table.setRowSelection(_selectionConfig2);
183
+ } else {
184
+ if (!row.getIsSelected()) {
185
+ initselectedIndex = row.index;
186
+ }
187
+ var _selectionConfig3 = _objectSpread(_objectSpread({}, table.getState().rowSelection), {}, _defineProperty({}, row.id, !row.getIsSelected()));
188
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
189
+ row.getCanSelect() && (table === null || table === void 0 ? void 0 : table.setRowSelection(_selectionConfig3));
159
190
  }
160
- table === null || table === void 0 || table.setRowSelection(_selectionConfig2);
161
- } else {
162
- initselectedIndex = row.index;
163
- table === null || table === void 0 || table.setRowSelection(_defineProperty({}, row === null || row === void 0 ? void 0 : row.id, true));
164
191
  }
165
- } else {
192
+ }
193
+ // 单选
194
+ else {
166
195
  setRowSelectedId === null || setRowSelectedId === void 0 || setRowSelectedId(row === null || row === void 0 ? void 0 : row.id);
167
196
  selectedRowChange === null || selectedRowChange === void 0 || selectedRowChange(row);
168
197
  onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, true, evt);
@@ -231,10 +260,26 @@ var Row = function Row(_ref) {
231
260
  var rowMouseLeave = function rowMouseLeave() {
232
261
  onRowMouseLeave === null || onRowMouseLeave === void 0 || onRowMouseLeave(row);
233
262
  };
263
+ var handleCellRightClick = function handleCellRightClick(e, cell) {
264
+ onCellContextMenu(e, cell);
265
+ };
234
266
  var leftLastColumnId = shadowColumnInfo.leftLastColumnId,
235
267
  rightFirstColumnId = shadowColumnInfo.rightFirstColumnId;
236
- return /*#__PURE__*/_jsxs(_Fragment, {
237
- children: [/*#__PURE__*/_jsx("tr", {
268
+ var _useState = useState({
269
+ title: ' ',
270
+ color: ''
271
+ }),
272
+ _useState2 = _slicedToArray(_useState, 2),
273
+ tooltipConfig = _useState2[0],
274
+ setTooltipConfig = _useState2[1];
275
+ var onOpenChange = function onOpenChange(open) {
276
+ if (open) {
277
+ setTooltipConfig(getRowHoverTipConfig(row.original));
278
+ }
279
+ };
280
+ var rowCom = function rowCom() {
281
+ var _row;
282
+ return /*#__PURE__*/_jsx("tr", {
238
283
  // ref={canRowDrag && !editting ? dropRef : null}
239
284
  id: rowEditing ? "".concat(tableId, "-tbody-tr-editing") : undefined,
240
285
  ref: function ref(node) {
@@ -266,7 +311,10 @@ var Row = function Row(_ref) {
266
311
  })) || '', " tbody-tr-td"),
267
312
  style: _objectSpread({
268
313
  height: rowHeight - 1
269
- }, getPinningStyle(cell, table, false))
314
+ }, getPinningStyle(cell, table, false)),
315
+ onContextMenu: function onContextMenu(e) {
316
+ return handleCellRightClick(e, cell);
317
+ }
270
318
  }, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell.getContext())), {}, {
271
319
  children: EditableCell(_objectSpread(_objectSpread({}, cell.column.columnDef), {}, {
272
320
  editing: columnEditing,
@@ -276,7 +324,21 @@ var Row = function Row(_ref) {
276
324
  }))
277
325
  }), cell.id);
278
326
  })
279
- }), row.getIsExpanded() && /*#__PURE__*/_jsx("tr", {
327
+ });
328
+ };
329
+ return /*#__PURE__*/_jsxs(_Fragment, {
330
+ children: [!!getRowHoverTipConfig ? /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, tooltipConfig), {}, {
331
+ autoAdjustOverflow: false,
332
+ onOpenChange: onOpenChange,
333
+ destroyTooltipOnHide: {
334
+ keepParent: false
335
+ },
336
+ overlayClassName: "table-max-row-tooltip-wrapper",
337
+ getPopupContainer: function getPopupContainer() {
338
+ return tableBodyRef.current || document.body;
339
+ },
340
+ children: rowCom()
341
+ })) : rowCom(), row.getIsExpanded() && /*#__PURE__*/_jsx("tr", {
280
342
  className: "tbody-tr-subrow",
281
343
  children: /*#__PURE__*/_jsx("td", {
282
344
  colSpan: (_row2 = row["getVisibleCells"]) === null || _row2 === void 0 ? void 0 : _row2.call(row).length,
@@ -0,0 +1,15 @@
1
+ import { IMenuOptionsType } from '../../type';
2
+ import './index.less';
3
+ type IContextMenuType = {
4
+ visible: boolean;
5
+ clientX: number;
6
+ clientY: number;
7
+ row: any;
8
+ column: any;
9
+ options: IMenuOptionsType;
10
+ /**点击菜单选项 */
11
+ onClickContextMenu?: (menuItem: any) => void;
12
+ closeContextMenu: () => void;
13
+ };
14
+ declare const ContextMenu: ({ visible, clientX, clientY, row, column, options, onClickContextMenu, closeContextMenu, }: IContextMenuType) => import("react/jsx-runtime").JSX.Element;
15
+ export default ContextMenu;
@@ -0,0 +1,71 @@
1
+ import { useEffect, useLayoutEffect, useRef } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import "./index.less";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ var ContextMenu = function ContextMenu(_ref) {
7
+ var visible = _ref.visible,
8
+ clientX = _ref.clientX,
9
+ clientY = _ref.clientY,
10
+ row = _ref.row,
11
+ column = _ref.column,
12
+ options = _ref.options,
13
+ onClickContextMenu = _ref.onClickContextMenu,
14
+ closeContextMenu = _ref.closeContextMenu;
15
+ var wrapperRef = useRef(null);
16
+ var handleClickMenu = function handleClickMenu(value) {
17
+ onClickContextMenu({
18
+ row: row,
19
+ column: column,
20
+ value: value
21
+ });
22
+ };
23
+ useEffect(function () {
24
+ if (visible) {
25
+ window.addEventListener('click', closeContextMenu);
26
+ }
27
+ return function () {
28
+ window.removeEventListener('click', closeContextMenu);
29
+ };
30
+ }, [visible]);
31
+ useLayoutEffect(function () {
32
+ if (visible && wrapperRef.current) {
33
+ // console.log('useLayoutEffect', wrapperRef.current.getBoundingClientRect(), window.innerHeight);
34
+ var _wrapperRef$current$g = wrapperRef.current.getBoundingClientRect(),
35
+ bottom = _wrapperRef$current$g.bottom,
36
+ height = _wrapperRef$current$g.height,
37
+ top = _wrapperRef$current$g.top,
38
+ width = _wrapperRef$current$g.width,
39
+ left = _wrapperRef$current$g.left,
40
+ right = _wrapperRef$current$g.right;
41
+ if (bottom > window.innerHeight && top >= height) {
42
+ // 如果弹层下方被遮挡,不能完整展示 & 上方可完整展示弹层 就把弹层展示到上方
43
+ wrapperRef.current.style.top = "".concat(top - height, "px");
44
+ }
45
+ if (right > window.innerWidth && left >= width) {
46
+ // 如果弹层右侧被遮挡,不能完整展示 & 左侧可完整展示弹层 就把弹层展示到左侧
47
+ wrapperRef.current.style.left = "".concat(left - width, "px");
48
+ }
49
+ }
50
+ }, [clientX, clientY, visible]);
51
+ return /*#__PURE__*/_jsx(_Fragment, {
52
+ children: visible && /*#__PURE__*/createPortal( /*#__PURE__*/_jsx("div", {
53
+ className: "cell-context-menu-wrapper",
54
+ ref: wrapperRef,
55
+ style: {
56
+ left: clientX,
57
+ top: clientY
58
+ },
59
+ children: options.map(function (option) {
60
+ return /*#__PURE__*/_jsx("div", {
61
+ className: "cell-context-menu-item",
62
+ onClick: function onClick() {
63
+ return handleClickMenu(option.value);
64
+ },
65
+ children: option.label
66
+ }, option.value);
67
+ })
68
+ }), document.body)
69
+ });
70
+ };
71
+ export default ContextMenu;
@@ -0,0 +1,20 @@
1
+ .cell-context-menu-wrapper {
2
+ position: fixed;
3
+ top: 10px;
4
+ left: 10px;
5
+ background: @globalColor7;
6
+ cursor: pointer;
7
+ padding: 6px;
8
+ color: @globalColor1;
9
+ box-shadow: 3px 3px 7px rgba(0, 0, 0, 10%);
10
+
11
+ .cell-context-menu-item {
12
+ padding: 5px;
13
+ min-width: 150px;
14
+ font-size: 14px;
15
+
16
+ &:hover {
17
+ background-color: @rowHoverBackgroundColor;
18
+ }
19
+ }
20
+ }
@@ -1,5 +1,5 @@
1
1
  import { Table } from '@tanstack/react-table';
2
- import { OnSelectChangeType } from "../type";
2
+ import { IMenuOptionsType, OnSelectChangeType } from "../type";
3
3
  import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
4
4
  import './index.less';
5
5
  type TableBodyPropsType = {
@@ -51,6 +51,22 @@ type TableBodyPropsType = {
51
51
  leftLastColumnId: string;
52
52
  rightFirstColumnId: string;
53
53
  };
54
+ /**右键菜单,配置后,开启右键菜单功能:点击右键时,获取菜单可选项 */
55
+ getContextMenu?: (params: {
56
+ row: any;
57
+ column: any;
58
+ }) => IMenuOptionsType;
59
+ /**点击菜单选项 */
60
+ onClickContextMenu?: (params: {
61
+ row: any;
62
+ column: any;
63
+ clickedMenuValue: any;
64
+ }) => void;
65
+ /**获取行hover时的tip信息 */
66
+ getRowHoverTipConfig?: (row: any) => {
67
+ title: string;
68
+ color: string;
69
+ };
54
70
  };
55
- declare const TableBody: ({ tableContentRef, tableBodyRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, selectedRowDragging, setSelectedRowDragging, canRowDrag, rowKey, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, datas, emptyDataHeight, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, dragBeforeStart, shadowColumnInfo, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
71
+ declare const TableBody: ({ tableContentRef, tableBodyRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, selectedRowDragging, setSelectedRowDragging, canRowDrag, rowKey, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, datas, emptyDataHeight, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, dragBeforeStart, shadowColumnInfo, getContextMenu, onClickContextMenu, getRowHoverTipConfig, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
56
72
  export default TableBody;
@@ -1,5 +1,11 @@
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); }
1
2
  import "antd/es/spin/style";
2
3
  import _Spin from "antd/es/spin";
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
+ 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
+ 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; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ 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); }
3
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
10
  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."); }
5
11
  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); }
@@ -12,6 +18,7 @@ import { useDrop } from 'react-dnd';
12
18
  import { CustomDragLayer } from "../components/CustomDragerLayer";
13
19
  // import RowContent from "../components/RowContent";
14
20
 
21
+ import { useCallback, useState } from 'react';
15
22
  import { createPortal } from 'react-dom';
16
23
  // @ts-ignore
17
24
  import DataEmptyDarkPng from "../../../assets/images/data-empty-dark.png";
@@ -19,6 +26,7 @@ import DataEmptyDarkPng from "../../../assets/images/data-empty-dark.png";
19
26
  import DataEmptyLightPng from "../../../assets/images/data-empty-light.png";
20
27
  import { ColumnType } from "../TableMax";
21
28
  import Row from "./Row";
29
+ import ContextMenu from "./contextMenu/ContextMenu";
22
30
  import "./index.less";
23
31
  import { jsx as _jsx } from "react/jsx-runtime";
24
32
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -61,8 +69,48 @@ var TableBody = function TableBody(_ref) {
61
69
  editingRowId = _ref.editingRowId,
62
70
  handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
63
71
  dragBeforeStart = _ref.dragBeforeStart,
64
- shadowColumnInfo = _ref.shadowColumnInfo;
72
+ shadowColumnInfo = _ref.shadowColumnInfo,
73
+ getContextMenu = _ref.getContextMenu,
74
+ onClickContextMenu = _ref.onClickContextMenu,
75
+ getRowHoverTipConfig = _ref.getRowHoverTipConfig;
65
76
  var headerGroups = table.getHeaderGroups();
77
+ var _useState = useState({
78
+ visible: false,
79
+ clientX: 0,
80
+ clientY: 0,
81
+ row: {},
82
+ column: {},
83
+ options: []
84
+ }),
85
+ _useState2 = _slicedToArray(_useState, 2),
86
+ contextMenuData = _useState2[0],
87
+ setContextMenuData = _useState2[1];
88
+
89
+ // cell右键菜单
90
+ var handleCellContextMenu = function handleCellContextMenu(e, cell) {
91
+ // console.log('cell :>> ', cell);
92
+ if (getContextMenu) {
93
+ setContextMenuData({
94
+ visible: true,
95
+ clientX: e.clientX,
96
+ clientY: e.clientY,
97
+ row: cell.row.original,
98
+ column: cell.column.columnDef,
99
+ options: getContextMenu({
100
+ row: cell.row.original,
101
+ column: cell.column.columnDef
102
+ })
103
+ });
104
+ e.preventDefault();
105
+ }
106
+ };
107
+
108
+ // 关闭菜单
109
+ var closeContextMenu = useCallback(function () {
110
+ setContextMenuData(_objectSpread(_objectSpread({}, contextMenuData), {}, {
111
+ visible: false
112
+ }));
113
+ }, []);
66
114
 
67
115
  // useEffect(() => {
68
116
  // if (tbodyRef.current) {
@@ -230,7 +278,9 @@ var TableBody = function TableBody(_ref) {
230
278
  hasVerticalScrollBar: hasVerticalScrollBar,
231
279
  handleEditRowWhenDClick: handleEditRowWhenDClick,
232
280
  canEditRowWhenDClick: canEditRowWhenDClick,
233
- shadowColumnInfo: shadowColumnInfo
281
+ shadowColumnInfo: shadowColumnInfo,
282
+ onCellContextMenu: handleCellContextMenu,
283
+ getRowHoverTipConfig: getRowHoverTipConfig
234
284
  }, row.id);
235
285
  });
236
286
  };
@@ -269,7 +319,10 @@ var TableBody = function TableBody(_ref) {
269
319
  id: "table-max-tableBody-tbody-".concat(tableId),
270
320
  children: tbodyRender()
271
321
  })]
272
- })]
322
+ }), /*#__PURE__*/_jsx(ContextMenu, _objectSpread(_objectSpread({}, contextMenuData), {}, {
323
+ onClickContextMenu: onClickContextMenu,
324
+ closeContextMenu: closeContextMenu
325
+ }))]
273
326
  })
274
327
  );
275
328
  };
@@ -1,4 +1,3 @@
1
-
2
1
  table {
3
2
  table-layout: fixed;
4
3
 
@@ -141,3 +140,8 @@ table {
141
140
  content: '';
142
141
  pointer-events: none;
143
142
  }
143
+
144
+ .table-max-row-tooltip-wrapper {
145
+ left: 50% !important;
146
+ transform: translateX(-50%) !important;
147
+ }
@@ -133,26 +133,26 @@ table {
133
133
 
134
134
  .custom-light-select:not(.custom-light-select-customize-input) .custom-light-select-selector {
135
135
  border-radius: 2px;
136
- background-color: #f5f6f7ff;
136
+ background-color: @global-curd-input-background-color;
137
137
  padding: 0 2px;
138
138
  }
139
139
 
140
140
  .custom-dark-select:not(.custom-dark-select-customize-input) .custom-dark-select-selector {
141
141
  border-radius: 2px;
142
- background-color: #494c5dff;
142
+ background-color: @global-curd-input-background-color;
143
143
  padding: 0 2px;
144
144
  }
145
145
 
146
146
  .custom-light-input-number {
147
147
  width: 100% !important;
148
148
  border-radius: 2px;
149
- background-color: #f5f6f7ff;
149
+ background-color: @global-curd-input-background-color;
150
150
  }
151
151
 
152
152
  .custom-dark-input-number {
153
153
  width: 100% !important;
154
154
  border-radius: 2px;
155
- background-color: #494c5dff;
155
+ background-color: @global-curd-input-background-color;
156
156
  }
157
157
 
158
158
  .custom-dark-select-single .custom-dark-select-selector .custom-dark-select-selection-search {
@@ -171,23 +171,23 @@ table {
171
171
 
172
172
  .custom-dark-picker {
173
173
  padding: 4px;
174
- background: #494c5dff;
174
+ background: @global-curd-input-background-color;
175
175
  }
176
176
 
177
177
  .custom-dark-input-affix-wrapper,
178
178
  .custom-dark-picker-input .custom-dark-picker-clear {
179
- background: #494c5dff;
179
+ background: @global-curd-input-background-color;
180
180
  }
181
181
 
182
182
  .custom-light-picker {
183
183
  padding: 4px;
184
- background: #f5f6f7ff;
184
+ background: @global-curd-input-background-color;
185
185
  }
186
186
 
187
187
  .custom-light-input-affix-wrapper,
188
188
  .custom-light-input,
189
189
  .custom-light-picker-input .custom-light-picker-clear {
190
- background: #f5f6f7ff;
190
+ background: @global-curd-input-background-color;
191
191
  }
192
192
  }
193
193
  }
@@ -167,7 +167,10 @@ var TableMax = function TableMax(_ref) {
167
167
  dragBeforeEnd = _ref$dragBeforeEnd === void 0 ? function () {
168
168
  return true;
169
169
  } : _ref$dragBeforeEnd,
170
- dragBeforeStart = _ref.dragBeforeStart;
170
+ dragBeforeStart = _ref.dragBeforeStart,
171
+ getContextMenu = _ref.getContextMenu,
172
+ onClickContextMenu = _ref.onClickContextMenu,
173
+ getRowHoverTipConfig = _ref.getRowHoverTipConfig;
171
174
  var columns = useMemo(function () {
172
175
  // 给columns配置默认的过滤函数、排序函数
173
176
  return setDefaultSortFn(setDefaultFilterFn(cloneDeep(originColumns)));
@@ -1005,7 +1008,10 @@ var TableMax = function TableMax(_ref) {
1005
1008
  theme: theme,
1006
1009
  dragBeforeStart: dragBeforeStart,
1007
1010
  hasVerticalScrollBar: hasVerticalScrollBar,
1008
- shadowColumnInfo: shadowColumnInfo
1011
+ shadowColumnInfo: shadowColumnInfo,
1012
+ getContextMenu: getContextMenu,
1013
+ onClickContextMenu: onClickContextMenu,
1014
+ getRowHoverTipConfig: getRowHoverTipConfig
1009
1015
  };
1010
1016
  return /*#__PURE__*/_jsx(_Form, {
1011
1017
  form: form,
@@ -23,15 +23,33 @@
23
23
  .custom-dark-input,
24
24
  .custom-dark-input-affix-wrapper,
25
25
  .custom-dark-switch {
26
- background-color: #494c5dff;
26
+ background-color: @global-curd-input-background-color;
27
27
  }
28
28
 
29
29
  .custom-dark-switch-checked {
30
- background-color: #fa541c;
30
+ background-color: @global-primary-color;
31
31
  }
32
32
 
33
33
  .custom-dark-picker-clear,
34
34
  .custom-dark-select-clear {
35
- background-color: #494c5dff;
35
+ background-color: @global-curd-input-background-color;
36
+ }
37
+
38
+ .custom-light-select,
39
+ .custom-light-picker,
40
+ .custom-light-input-number,
41
+ .custom-light-input,
42
+ .custom-light-input-affix-wrapper,
43
+ .custom-light-switch {
44
+ background-color: @global-curd-input-background-color;
45
+ }
46
+
47
+ .custom-light-switch-checked {
48
+ background-color: @global-primary-color;
49
+ }
50
+
51
+ .custom-light-picker-clear,
52
+ .custom-light-select-clear {
53
+ background-color: @global-curd-input-background-color;
36
54
  }
37
55
  }
@@ -43,7 +43,7 @@
43
43
  margin-bottom: 10px;
44
44
 
45
45
  .reset {
46
- color: #fa541cff;
46
+ color: @global-primary-color;
47
47
  }
48
48
  }
49
49
 
@@ -109,6 +109,6 @@
109
109
  color: @globalColor1;
110
110
 
111
111
  &:hover {
112
- color: #fa541c;
112
+ color: @global-primary-color;
113
113
  }
114
114
  }
@@ -34,7 +34,7 @@
34
34
  // margin-bottom: 6px;
35
35
 
36
36
  &:hover {
37
- color: #fa541c;
37
+ color: @global-primary-color;
38
38
  }
39
39
  }
40
40
 
@@ -12,6 +12,10 @@ export type ColumnPinningConfigType = {
12
12
  right: string[];
13
13
  };
14
14
  export type OnSelectChangeType = (row: any, original: any, selected: boolean, event: any) => void;
15
+ export type IMenuOptionsType = {
16
+ label: string;
17
+ value: any;
18
+ }[];
15
19
  export type TableMaxProps = {
16
20
  /**
17
21
  * @description ddd
@@ -194,6 +198,22 @@ export type TableMaxProps = {
194
198
  columnResizeMode?: ColumnResizeMode;
195
199
  /**行拖动开始前 */
196
200
  dragBeforeStart?: () => boolean;
201
+ /**右键菜单,配置后,开启右键菜单功能:点击右键时,获取菜单可选项 */
202
+ getContextMenu?: (params: {
203
+ row: any;
204
+ column: any;
205
+ }) => IMenuOptionsType;
206
+ /**点击菜单选项 */
207
+ onClickContextMenu?: (params: {
208
+ row: any;
209
+ column: any;
210
+ clickedMenuValue: any;
211
+ }) => void;
212
+ /**获取行hover时的tip信息 */
213
+ getRowHoverTipConfig?: (row: any) => {
214
+ title: string;
215
+ color: string;
216
+ };
197
217
  };
198
218
  export type TableContextType = {
199
219
  table: any;
@@ -1,5 +1,9 @@
1
1
 
2
2
  // @primary-color: #fa541c; // 全局主色
3
+ @global-primary-color: var(--global-primary-color, #fa541c); // 全局主色
4
+
5
+ // 输入框背景色
6
+ @global-curd-input-background-color: var(--global-curd-input-background-color, #494c5dff);
3
7
 
4
8
  @scrollThumb: var(--scrollThumb, rgba(255, 255, 255, 0.2));
5
9
  @scrollThumbHover: var(--scrollThumbHover, rgba(255, 255, 255, 0.3));
@@ -1,2 +1,2 @@
1
- import { VariablesConfigType } from "../components/ThemeProvider";
1
+ import { VariablesConfigType } from '../components/ThemeProvider';
2
2
  export declare const PublicThemeVariablesConfig: VariablesConfigType;
@@ -1,5 +1,7 @@
1
1
  export var PublicThemeVariablesConfig = {
2
- "light": {
2
+ light: {
3
+ '--global-curd-input-background-color': '#f5f6f7ff',
4
+ '--global-primary-color': '#fa541c',
3
5
  '--scrollThumb': 'rgba(0, 0, 0, 0.2)',
4
6
  '--scrollThumbHover': 'rgba(0, 0, 0, 0.3)',
5
7
  '--sliderRightBorder': '#221919',
@@ -53,7 +55,9 @@ export var PublicThemeVariablesConfig = {
53
55
  // 表格列设置区列显隐图标颜色
54
56
  '--tableColor7': '#F5F6F7' // 表格列设置区列表元素边框颜色
55
57
  },
56
- "dark": {
58
+ dark: {
59
+ '--global-curd-input-background-color': '#494c5dff',
60
+ '--global-primary-color': '#fa541c',
57
61
  '--primaryColor': 'blue',
58
62
  '--split-line': '#5E6175',
59
63
  '--scrollThumb': 'rgba(255, 255, 255, 0.2)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -18,6 +18,7 @@
18
18
  "lint": "npm run lint:es && npm run lint:css",
19
19
  "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
20
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
+ "local": "dumi dev",
21
22
  "prepare": "husky install && dumi setup",
22
23
  "prepublishOnly": "father doctor && npm run build",
23
24
  "start": "npm run dev"