@kdcloudjs/table 1.1.5-canary.6 → 1.1.5-canary.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.
@@ -1,14 +1,18 @@
1
1
  import { TablePipeline } from '../pipeline';
2
2
  interface ContextMenuItem {
3
+ key?: string;
3
4
  name: string;
4
- action: () => {};
5
+ action: () => void;
5
6
  disabled?: boolean;
7
+ className?: string;
6
8
  }
7
9
  export interface ContextMenuFeatureOptions {
8
10
  /** 获得自定义菜单 */
9
11
  getContextMenuItems?: (params: any) => ContextMenuItem[];
10
12
  /** 弹出框的父容器 */
11
13
  popupParent?: HTMLElement;
14
+ /** 右键菜单className */
15
+ menuClassName?: string;
12
16
  }
13
17
  export declare function contextMenu(opts?: ContextMenuFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
14
18
  export {};
@@ -16,6 +16,7 @@ export function contextMenu() {
16
16
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
17
  return function step(pipeline) {
18
18
  var popupParent = opts.popupParent || document.body;
19
+ var menuClassName = opts.menuClassName;
19
20
  var menuHelper = new MenuHelper();
20
21
 
21
22
  var addPopup = function addPopup(menu) {
@@ -124,7 +125,8 @@ export function contextMenu() {
124
125
  options: options,
125
126
  hideContextMenu: hideContextMenu,
126
127
  position: position,
127
- getPopupParent: getPopupParent
128
+ getPopupParent: getPopupParent,
129
+ className: menuClassName
128
130
  });
129
131
 
130
132
  var _hidePopup = addPopup(menu);
@@ -157,7 +159,8 @@ function getMenuItemKey(_ref) {
157
159
  }
158
160
 
159
161
  function Menu(props) {
160
- var _props$options = props.options,
162
+ var className = props.className,
163
+ _props$options = props.options,
161
164
  options = _props$options === void 0 ? [] : _props$options,
162
165
  hideContextMenu = props.hideContextMenu,
163
166
  position = props.position,
@@ -178,7 +181,7 @@ function Menu(props) {
178
181
  }
179
182
  }, [position]);
180
183
  return /*#__PURE__*/React.createElement(ContextMenuStyleWrap, {
181
- className: MenuClasses.menu,
184
+ className: cx(MenuClasses.menu, className),
182
185
  ref: menuRef,
183
186
  style: {
184
187
  left: position.x,
@@ -194,6 +197,7 @@ function Menu(props) {
194
197
  }),
195
198
  name: item.name,
196
199
  action: item.action,
200
+ className: item.className,
197
201
  disabled: item.disabled,
198
202
  hideContextMenu: hideContextMenu
199
203
  });
@@ -203,6 +207,7 @@ function Menu(props) {
203
207
  function MenuItem(props) {
204
208
  var name = props.name,
205
209
  action = props.action,
210
+ className = props.className,
206
211
  disabled = props.disabled,
207
212
  hideContextMenu = props.hideContextMenu;
208
213
  var itemRef = useRef();
@@ -243,7 +248,7 @@ function MenuItem(props) {
243
248
  };
244
249
 
245
250
  return /*#__PURE__*/React.createElement("div", {
246
- className: cx(MenuClasses.menuOption, _defineProperty({}, MenuClasses.menuOptionDisable, disabled)),
251
+ className: cx(MenuClasses.menuOption, className, _defineProperty({}, MenuClasses.menuOptionDisable, disabled)),
247
252
  ref: itemRef,
248
253
  onClick: handleClick,
249
254
  onMouseEnter: handleMouseEnter,
@@ -17,6 +17,7 @@ export function rangeSelection(opts) {
17
17
  var SCROLL_SIZE = 30;
18
18
  var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
19
19
  var tableFooter = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableFooter;
20
+ var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
20
21
 
21
22
  if (!tableBody) {
22
23
  return pipeline;
@@ -48,6 +49,13 @@ export function rangeSelection(opts) {
48
49
  startColumn: startDragCell.column,
49
50
  footerRowRange: footerRowRange
50
51
  };
52
+
53
+ if (isCellRangeSingleCell(rangeSelection)) {
54
+ artTable.classList.remove(cx(Classes.rangeSelection));
55
+ } else {
56
+ artTable.classList.add(cx(Classes.rangeSelection));
57
+ }
58
+
51
59
  rangeSelectedChange(rangeSelection);
52
60
  };
53
61
 
@@ -77,6 +85,7 @@ export function rangeSelection(opts) {
77
85
  // shift + 点击选中
78
86
 
79
87
  shiftKeySelect(mouseDownEvent);
88
+ if (mouseDownEvent.shiftKey) return;
80
89
  var target = mouseDownEvent.target;
81
90
  var startDragCell = getTargetCell(target, columns);
82
91
  var mousemove$ = fromEvent(window, 'mousemove');
@@ -137,6 +146,7 @@ export function rangeSelection(opts) {
137
146
 
138
147
  if (columns.length && rowLen && !getElementEditable(e.target)) {
139
148
  opts.preventkDefaultOfKeyDownEvent !== false && e.preventDefault();
149
+ artTable.classList.add(cx(Classes.rangeSelection));
140
150
  rangeSelectedChange({
141
151
  startRow: 0,
142
152
  endRow: rowLen - 1,
@@ -1,14 +1,18 @@
1
1
  import { TablePipeline } from '../pipeline';
2
2
  interface ContextMenuItem {
3
+ key?: string;
3
4
  name: string;
4
- action: () => {};
5
+ action: () => void;
5
6
  disabled?: boolean;
7
+ className?: string;
6
8
  }
7
9
  export interface ContextMenuFeatureOptions {
8
10
  /** 获得自定义菜单 */
9
11
  getContextMenuItems?: (params: any) => ContextMenuItem[];
10
12
  /** 弹出框的父容器 */
11
13
  popupParent?: HTMLElement;
14
+ /** 右键菜单className */
15
+ menuClassName?: string;
12
16
  }
13
17
  export declare function contextMenu(opts?: ContextMenuFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
14
18
  export {};
@@ -49,6 +49,7 @@ function contextMenu() {
49
49
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
50
  return function step(pipeline) {
51
51
  var popupParent = opts.popupParent || document.body;
52
+ var menuClassName = opts.menuClassName;
52
53
  var menuHelper = new MenuHelper();
53
54
 
54
55
  var addPopup = function addPopup(menu) {
@@ -162,7 +163,8 @@ function contextMenu() {
162
163
  options: options,
163
164
  hideContextMenu: hideContextMenu,
164
165
  position: position,
165
- getPopupParent: getPopupParent
166
+ getPopupParent: getPopupParent,
167
+ className: menuClassName
166
168
  });
167
169
 
168
170
  var _hidePopup = addPopup(menu);
@@ -195,7 +197,8 @@ function getMenuItemKey(_ref) {
195
197
  }
196
198
 
197
199
  function Menu(props) {
198
- var _props$options = props.options,
200
+ var className = props.className,
201
+ _props$options = props.options,
199
202
  options = _props$options === void 0 ? [] : _props$options,
200
203
  hideContextMenu = props.hideContextMenu,
201
204
  position = props.position,
@@ -216,7 +219,7 @@ function Menu(props) {
216
219
  }
217
220
  }, [position]);
218
221
  return /*#__PURE__*/_react.default.createElement(_commonViews.ContextMenuStyleWrap, {
219
- className: _styles.MenuClasses.menu,
222
+ className: (0, _classnames.default)(_styles.MenuClasses.menu, className),
220
223
  ref: menuRef,
221
224
  style: {
222
225
  left: position.x,
@@ -232,6 +235,7 @@ function Menu(props) {
232
235
  }),
233
236
  name: item.name,
234
237
  action: item.action,
238
+ className: item.className,
235
239
  disabled: item.disabled,
236
240
  hideContextMenu: hideContextMenu
237
241
  });
@@ -241,6 +245,7 @@ function Menu(props) {
241
245
  function MenuItem(props) {
242
246
  var name = props.name,
243
247
  action = props.action,
248
+ className = props.className,
244
249
  disabled = props.disabled,
245
250
  hideContextMenu = props.hideContextMenu;
246
251
  var itemRef = (0, _react.useRef)();
@@ -281,7 +286,7 @@ function MenuItem(props) {
281
286
  };
282
287
 
283
288
  return /*#__PURE__*/_react.default.createElement("div", {
284
- className: (0, _classnames.default)(_styles.MenuClasses.menuOption, (0, _defineProperty2.default)({}, _styles.MenuClasses.menuOptionDisable, disabled)),
289
+ className: (0, _classnames.default)(_styles.MenuClasses.menuOption, className, (0, _defineProperty2.default)({}, _styles.MenuClasses.menuOptionDisable, disabled)),
285
290
  ref: itemRef,
286
291
  onClick: handleClick,
287
292
  onMouseEnter: handleMouseEnter,
@@ -45,6 +45,7 @@ function rangeSelection(opts) {
45
45
  var SCROLL_SIZE = 30;
46
46
  var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
47
47
  var tableFooter = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableFooter;
48
+ var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
48
49
 
49
50
  if (!tableBody) {
50
51
  return pipeline;
@@ -76,6 +77,13 @@ function rangeSelection(opts) {
76
77
  startColumn: startDragCell.column,
77
78
  footerRowRange: footerRowRange
78
79
  };
80
+
81
+ if (isCellRangeSingleCell(rangeSelection)) {
82
+ artTable.classList.remove((0, _classnames.default)(_styles.Classes.rangeSelection));
83
+ } else {
84
+ artTable.classList.add((0, _classnames.default)(_styles.Classes.rangeSelection));
85
+ }
86
+
79
87
  rangeSelectedChange(rangeSelection);
80
88
  };
81
89
 
@@ -105,6 +113,7 @@ function rangeSelection(opts) {
105
113
  // shift + 点击选中
106
114
 
107
115
  shiftKeySelect(mouseDownEvent);
116
+ if (mouseDownEvent.shiftKey) return;
108
117
  var target = mouseDownEvent.target;
109
118
  var startDragCell = getTargetCell(target, columns);
110
119
  var mousemove$ = (0, _rxjs.fromEvent)(window, 'mousemove');
@@ -165,6 +174,7 @@ function rangeSelection(opts) {
165
174
 
166
175
  if (columns.length && rowLen && !getElementEditable(e.target)) {
167
176
  opts.preventkDefaultOfKeyDownEvent !== false && e.preventDefault();
177
+ artTable.classList.add((0, _classnames.default)(_styles.Classes.rangeSelection));
168
178
  rangeSelectedChange({
169
179
  startRow: 0,
170
180
  endRow: rowLen - 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.1.5-canary.6",
3
+ "version": "1.1.5-canary.7",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [