@zhenliang/sheet 0.1.7-3.beta.3 → 0.1.7-3.beta.5

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.
@@ -386,13 +386,6 @@ var Sheet = function Sheet(props) {
386
386
  showMenu: menu.showMenu,
387
387
  contextMenu: ContextMenu,
388
388
  onContextMenu: onContextMenu
389
- }), /*#__PURE__*/_jsx(Remark, {
390
- showRemark: remarkInfo.show && !menu.showMenu,
391
- position: {
392
- left: remarkInfo.position.left,
393
- top: remarkInfo.position.top
394
- },
395
- children: remarkElement
396
389
  }), EmptyElement]
397
390
  }), /*#__PURE__*/_jsxs("div", {
398
391
  className: "harvest-sheet-control",
@@ -423,6 +416,13 @@ var Sheet = function Sheet(props) {
423
416
  }
424
417
  }), children]
425
418
  })]
419
+ }), /*#__PURE__*/_jsx(Remark, {
420
+ showRemark: remarkInfo.show && !menu.showMenu,
421
+ position: {
422
+ left: remarkInfo.position.left,
423
+ top: remarkInfo.position.top
424
+ },
425
+ children: remarkElement
426
426
  }), /*#__PURE__*/_jsx(SearchInput, {
427
427
  style: props.searchStyle,
428
428
  value: state.searchText,
@@ -378,7 +378,7 @@ span.harvest-sheet-container:focus {
378
378
  color: #a4a9b2;
379
379
  }
380
380
  }
381
- .harvest-sheet-container .harvest-remark-container{
381
+ .harvest-remark-container{
382
382
  opacity: 1;
383
383
  border:1px solid #E5E5E5;
384
384
  border-radius: 2px;
@@ -209,38 +209,65 @@ var Table = function Table(_ref) {
209
209
  return null;
210
210
  }
211
211
  return remarkRender === null || remarkRender === void 0 ? void 0 : remarkRender(remarkInfo);
212
- }, [remarkRender, remarkInfo, showRemark]);
212
+ }, [remarkRender, remarkInfo, showRemark, data]);
213
+ var addRemark = useCallback(function (value) {
214
+ handleAddRemark === null || handleAddRemark === void 0 || handleAddRemark(value);
215
+ setShowRemark(true);
216
+ }, [handleAddRemark]);
213
217
  var menuRenderer = args.menuRenderer;
214
218
  var wrappMenuRenderer = useMemo(function () {
215
219
  var remarkMenu = /*#__PURE__*/_jsx("div", {
216
220
  className: "harvest-menu-item",
217
221
  onClick: function onClick() {
218
- return remarkInfo && (handleAddRemark === null || handleAddRemark === void 0 ? void 0 : handleAddRemark(remarkInfo));
222
+ return addRemark(remarkInfo);
219
223
  },
220
224
  children: "\u6DFB\u52A0\u8BC4\u8BBA"
221
- });
225
+ }, "remark");
222
226
  if (!menuRenderer) {
223
227
  if (showRemark) {
224
228
  return function (props) {
225
- return /*#__PURE__*/_jsx("div", {
226
- className: "harvest-menu",
227
- style: _objectSpread({}, props.position),
228
- children: remarkMenu
229
- });
229
+ var _data$row3;
230
+ var cell = props.cell;
231
+ var _ref5 = cell !== null && cell !== void 0 ? cell : {},
232
+ _ref5$col = _ref5.col,
233
+ col = _ref5$col === void 0 ? -1 : _ref5$col,
234
+ _ref5$row = _ref5.row,
235
+ row = _ref5$row === void 0 ? -1 : _ref5$row;
236
+ var target = data === null || data === void 0 || (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[col + 1];
237
+ if ((target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed) {
238
+ return /*#__PURE__*/_jsx("div", {
239
+ className: "harvest-menu",
240
+ style: _objectSpread({}, props.position),
241
+ children: remarkMenu
242
+ });
243
+ }
244
+ return null;
230
245
  };
231
246
  }
232
247
  return undefined;
233
248
  } else {
234
249
  return function (props) {
250
+ var _data$row4;
251
+ var cell = props.cell;
252
+ var _ref6 = cell !== null && cell !== void 0 ? cell : {},
253
+ _ref6$col = _ref6.col,
254
+ col = _ref6$col === void 0 ? -1 : _ref6$col,
255
+ _ref6$row = _ref6.row,
256
+ row = _ref6$row === void 0 ? -1 : _ref6$row;
257
+ var target = data === null || data === void 0 || (_data$row4 = data[row]) === null || _data$row4 === void 0 ? void 0 : _data$row4[col + 1];
235
258
  var MenuFC = menuRenderer;
236
- return /*#__PURE__*/_jsxs(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
237
- children: [remarkMenu, /*#__PURE__*/_jsx("div", {
238
- className: "harvest-menu-divider"
239
- })]
259
+ if (showRemark && (target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed) {
260
+ return /*#__PURE__*/_jsx(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
261
+ target: target,
262
+ children: remarkMenu
263
+ }));
264
+ }
265
+ return /*#__PURE__*/_jsx(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
266
+ target: target
240
267
  }));
241
268
  };
242
269
  }
243
- }, [showRemark, showRemarkPop, menuRenderer, remarkInfo]);
270
+ }, [showRemark, showRemarkPop, menuRenderer, remarkInfo, addRemark, data]);
244
271
  return /*#__PURE__*/_jsx(ConfigProvider, {
245
272
  renderEmpty: function renderEmpty() {
246
273
  return /*#__PURE__*/_jsx(Empty, {
@@ -2,10 +2,6 @@ import { SheetEvent } from "../sheet/Event";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  export var RemarkEvent = function RemarkEvent(_ref) {
4
4
  var handler = _ref.handler;
5
- // const handleClick = useCallback((value: SheetType.CellPosition) => {
6
- // if (!value) return;
7
- // console.log(value);
8
- // }, []);
9
5
  return /*#__PURE__*/_jsx(SheetEvent, {
10
6
  name: "cell-select-single",
11
7
  handler: handler
@@ -15,14 +15,13 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
15
15
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
17
  import { getNumberEditor, getSelectEditor, Table } from "./..";
18
- import { Button, message } from 'antd';
18
+ import { Button, Input } from 'antd';
19
19
  import { isNil } from 'lodash';
20
- import { useCallback, useEffect, useRef, useState } from 'react';
20
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21
21
  import { SwitchViewer } from "../core/viewer";
22
22
  import { SheetType } from "../type";
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
- import { Fragment as _Fragment } from "react/jsx-runtime";
26
25
  var RateValueInput = getNumberEditor({
27
26
  addonAfter: '%',
28
27
  min: 0,
@@ -435,17 +434,45 @@ export default (function () {
435
434
  });
436
435
  }, 3);
437
436
  }, []);
437
+ var _useState3 = useState([]),
438
+ _useState4 = _slicedToArray(_useState3, 2),
439
+ currentRemark = _useState4[0],
440
+ setCurrentRemark = _useState4[1];
438
441
  var renderRemark = useCallback(function (value) {
439
- return /*#__PURE__*/_jsxs(_Fragment, {
442
+ return /*#__PURE__*/_jsxs("div", {
443
+ style: {
444
+ background: 'white'
445
+ },
440
446
  children: [/*#__PURE__*/_jsxs("p", {
441
447
  children: [" columns:", value.columnKey]
442
448
  }), /*#__PURE__*/_jsxs("p", {
443
449
  children: [" id:", value.id]
444
450
  }), /*#__PURE__*/_jsx("p", {
445
451
  children: " bugs --"
452
+ }), /*#__PURE__*/_jsx(Input, {
453
+ onPressEnter: function onPressEnter(e) {
454
+ setCurrentRemark([{
455
+ id: value.id,
456
+ remarks: [value.columnKey]
457
+ }]);
458
+ }
446
459
  })]
447
460
  });
448
461
  }, []);
462
+ var wrapData = useMemo(function () {
463
+ return state.map(function (d) {
464
+ var _currentRemark$find;
465
+ var remarks = currentRemark === null || currentRemark === void 0 || (_currentRemark$find = currentRemark.find(function (r) {
466
+ return r.id === d.id;
467
+ })) === null || _currentRemark$find === void 0 ? void 0 : _currentRemark$find.remarks;
468
+ if (remarks) {
469
+ return _objectSpread(_objectSpread({}, d), {}, {
470
+ remarks: remarks
471
+ });
472
+ }
473
+ return d;
474
+ });
475
+ }, [state, currentRemark]);
449
476
  return /*#__PURE__*/_jsxs("div", {
450
477
  style: {
451
478
  height: '100vh',
@@ -460,12 +487,10 @@ export default (function () {
460
487
  sheetInstance: sheetInstance,
461
488
  columns: columns,
462
489
  showRemark: true,
463
- remarkRender: renderRemark,
464
- handleAddRemark: function handleAddRemark(value) {
465
- message.info("".concat(value.id, "\uFF1A").concat(value.columnKey));
466
- console.log(value.id, value.columnKey);
467
- },
468
- dataSource: state,
490
+ remarkRender: renderRemark
491
+ // handleAddRemark={handleAddRemark}
492
+ ,
493
+ dataSource: wrapData,
469
494
  onChange: handleChange,
470
495
  onContextMenu: function onContextMenu() {},
471
496
  menuRenderer: function menuRenderer(props) {
@@ -93,6 +93,7 @@ export type MenuRenderProps = {
93
93
  cell?: CellPosition;
94
94
  onContextMenu?: (event: any) => void;
95
95
  children?: ReactNode | ReactNode[];
96
+ target?: any;
96
97
  };
97
98
  export type SheetInstance = {
98
99
  zoomTo: (row?: number) => void;
@@ -56,6 +56,11 @@ export type TableGroupConfig = {
56
56
  onChange?: (value: SheetType.RowGroupConfig) => void;
57
57
  };
58
58
  export type EventHandler = (value: any) => void;
59
+ export type RemarkProps = {
60
+ cell: SheetType.CellPosition;
61
+ columnKey: string;
62
+ id?: string | number;
63
+ };
59
64
  export type TableProps = {
60
65
  /**
61
66
  * @description 表格类名
@@ -83,16 +88,8 @@ export type TableProps = {
83
88
  freeze?: boolean;
84
89
  showBackEdit?: boolean;
85
90
  showRemark?: boolean;
86
- remarkRender?: (props: {
87
- cell: SheetType.CellPosition;
88
- columnKey: string;
89
- id?: string | number;
90
- }) => ReactNode;
91
- handleAddRemark?: (value: {
92
- cell: SheetType.CellPosition;
93
- columnKey: string;
94
- id?: string | number;
95
- }) => void;
91
+ remarkRender?: (props: RemarkProps) => ReactNode;
92
+ handleAddRemark?: (value: RemarkProps) => void;
96
93
  backEditStyle?: Partial<CSSProperties>;
97
94
  searchStyle?: Partial<CSSProperties>;
98
95
  rowSelection?: TableRowSelection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.73.beta.3",
3
+ "version": "0.1.73.beta.5",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",