@zhenliang/sheet 0.1.9 → 0.1.10

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,5 +1,5 @@
1
1
  import type { SheetType } from "../../../type";
2
2
  import 'antd/es/cascader/style/index.css';
3
3
  import './index.less';
4
- declare const getCascaderEditor: (options: SheetType.OptionsType[]) => SheetType.CellEditor;
4
+ declare const getCascaderEditor: (options: SheetType.OptionsType[], getCustomOptions?: ((props: SheetType.CellEditorProps) => SheetType.OptionsType[]) | undefined) => SheetType.CellEditor;
5
5
  export default getCascaderEditor;
@@ -4,7 +4,7 @@ import { useMemo } from 'react';
4
4
  import { optionsToValuesFromLabelOrValue, valuesTransferToLabel } from "../../util";
5
5
  import "./index.less";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- var getCascaderEditor = function getCascaderEditor(options) {
7
+ var getCascaderEditor = function getCascaderEditor(options, getCustomOptions) {
8
8
  var CascaderEditor = function CascaderEditor(props) {
9
9
  var value = props.value,
10
10
  onConfirm = props.onConfirm;
@@ -15,6 +15,7 @@ var getCascaderEditor = function getCascaderEditor(options) {
15
15
  var handleChange = function handleChange(opt) {
16
16
  onConfirm(opt ? opt[opt.length - 1] : null);
17
17
  };
18
+ var customOptions = getCustomOptions ? getCustomOptions(props) : options;
18
19
  return /*#__PURE__*/_jsx(Cascader, {
19
20
  autoFocus: true,
20
21
  open: true,
@@ -22,7 +23,8 @@ var getCascaderEditor = function getCascaderEditor(options) {
22
23
  onMouseDown: function onMouseDown(event) {
23
24
  event.stopPropagation();
24
25
  },
25
- value: val
26
+ value: val,
27
+ allowClear: true
26
28
  // allowClear={false}
27
29
  ,
28
30
  displayRender: function displayRender(label) {
@@ -32,7 +34,7 @@ var getCascaderEditor = function getCascaderEditor(options) {
32
34
  // onBlur={handleBlur}
33
35
  // onKeyDown={handleKeyDown}
34
36
  ,
35
- options: options
37
+ options: customOptions
36
38
  });
37
39
  };
38
40
  CascaderEditor.formatter = function (value) {
@@ -3,6 +3,7 @@
3
3
  background: transparent !important;
4
4
  width:100%;
5
5
  height: 38px;
6
+ height: 100%;
6
7
  font-size: 12px;
7
8
  box-shadow: none !important;
8
9
  text-align: inherit !important;
@@ -2,5 +2,5 @@ import type { SheetType } from "../../../type";
2
2
  import { SelectProps } from 'antd';
3
3
  import 'antd/es/select/style/index.css';
4
4
  import './index.less';
5
- export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>) => SheetType.CellEditor;
5
+ export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>, getCustomOptions?: ((props: SheetType.CellEditorProps) => SheetType.Options[]) | undefined) => SheetType.CellEditor;
6
6
  export default getSelectEditor;
@@ -24,6 +24,7 @@ export var getSelectEditor = function getSelectEditor(options) {
24
24
  var valueKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
25
25
  var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /*#__PURE__*/_jsx(_Fragment, {});
26
26
  var selectProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
27
+ var getCustomOptions = arguments.length > 4 ? arguments[4] : undefined;
27
28
  var SelectEditor = function SelectEditor(props) {
28
29
  var _useState = useState(true),
29
30
  _useState2 = _slicedToArray(_useState, 2),
@@ -49,6 +50,7 @@ export var getSelectEditor = function getSelectEditor(options) {
49
50
  children: [menu, extra]
50
51
  });
51
52
  };
53
+ var customOptions = getCustomOptions ? getCustomOptions(props) : options;
52
54
  return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
53
55
  autoFocus: true,
54
56
  className: "select-editor",
@@ -60,7 +62,7 @@ export var getSelectEditor = function getSelectEditor(options) {
60
62
  value: SelectEditor.formatter ? SelectEditor.formatter(value) : value,
61
63
  onChange: handleChange,
62
64
  onKeyDown: handleKeyDown,
63
- options: options,
65
+ options: customOptions,
64
66
  popupClassName: 'excelTablePopupClassName',
65
67
  dropdownRender: dropdown
66
68
  }));
@@ -213,12 +213,10 @@ export var sideEffectReducer = {
213
213
  case 9:
214
214
  changes = changeInfo.changes, extChanges = changeInfo.extChanges;
215
215
  legalChanges = changes.filter(function (_ref5) {
216
- var _editor$checker;
217
216
  var row = _ref5.row,
218
217
  col = _ref5.col,
219
218
  value = _ref5.value;
220
219
  var editor = data[row][col].dataEditor;
221
- console.log('number-checker', editor === null || editor === void 0 ? void 0 : editor.checker, editor === null || editor === void 0 ? void 0 : (_editor$checker = editor.checker) === null || _editor$checker === void 0 ? void 0 : _editor$checker.call(editor, value));
222
220
  if (editor && editor.checker) {
223
221
  return editor.checker(value, data[row][col].record);
224
222
  }
@@ -236,7 +234,6 @@ export var sideEffectReducer = {
236
234
  value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 ? void 0 : (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value) : value
237
235
  };
238
236
  });
239
- console.log('number', changes, legalChanges);
240
237
  lastRow = extChanges === null || extChanges === void 0 ? void 0 : (_extChanges$ = extChanges[0]) === null || _extChanges$ === void 0 ? void 0 : _extChanges$.row;
241
238
  lastIndex = 1;
242
239
  legalExtChanges = extChanges === null || extChanges === void 0 ? void 0 : extChanges.filter(function (_ref7) {
@@ -286,7 +283,7 @@ export var sideEffectReducer = {
286
283
  }
287
284
  });
288
285
  cellChangeHandler && cellChangeHandler(legalChanges, freePaste ? legalExtChanges : []);
289
- case 19:
286
+ case 18:
290
287
  case "end":
291
288
  return _context.stop();
292
289
  }
@@ -115,7 +115,7 @@ var Cell = function Cell(props) {
115
115
  if (valueRef.current === value) {
116
116
  return;
117
117
  }
118
- if (cell !== null && cell !== void 0 && (_cell$dataEditor5 = cell.dataEditor) !== null && _cell$dataEditor5 !== void 0 && _cell$dataEditor5.checker && !((_cell$dataEditor6 = cell.dataEditor) !== null && _cell$dataEditor6 !== void 0 && (_cell$dataEditor6$che = _cell$dataEditor6.checker) !== null && _cell$dataEditor6$che !== void 0 && _cell$dataEditor6$che.call(_cell$dataEditor6, value, cell.record))) {
118
+ if (value !== null && cell !== null && cell !== void 0 && (_cell$dataEditor5 = cell.dataEditor) !== null && _cell$dataEditor5 !== void 0 && _cell$dataEditor5.checker && !((_cell$dataEditor6 = cell.dataEditor) !== null && _cell$dataEditor6 !== void 0 && (_cell$dataEditor6$che = _cell$dataEditor6.checker) !== null && _cell$dataEditor6$che !== void 0 && _cell$dataEditor6$che.call(_cell$dataEditor6, value, cell.record))) {
119
119
  setValue(valueRef.current);
120
120
  return;
121
121
  }
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useEffect, useMemo, useRef } from 'react';
14
- import ReduxLogger from 'redux-logger';
14
+ // import ReduxLogger from 'redux-logger';
15
15
  import ReduxThunk from 'redux-thunk';
16
16
  import DefaultRow from "./DefaultRow";
17
17
  import DefaultShell from "./DefaultShell";
@@ -43,6 +43,7 @@ var Sheet = function Sheet(props) {
43
43
  ContextMenu = props.menuRenderer,
44
44
  _props$virtualized = props.virtualized,
45
45
  virtualized = _props$virtualized === void 0 ? false : _props$virtualized,
46
+ sticky = props.sticky,
46
47
  className = props.className,
47
48
  data = props.data,
48
49
  _props$freePaste = props.freePaste,
@@ -66,7 +67,9 @@ var Sheet = function Sheet(props) {
66
67
  lastFocus: [],
67
68
  groupConfig: groupConfig,
68
69
  eventBus: eventBus
69
- }, [ReduxThunk, ReduxLogger]),
70
+ },
71
+ // [ReduxThunk, ReduxLogger],
72
+ [ReduxThunk]),
70
73
  _useMiddlewareReducer2 = _slicedToArray(_useMiddlewareReducer, 2),
71
74
  state = _useMiddlewareReducer2[0],
72
75
  dispatch = _useMiddlewareReducer2[1];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { SheetType } from "../../../type";
2
3
  import './index.less';
3
4
  export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { SheetType } from "../../type";
2
3
  import './draggableShell/index.less';
3
4
  export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
@@ -31,7 +31,7 @@ export declare const defaultValueRenderer: (cell: SheetType.Cell) => string | nu
31
31
  export declare function renderValue(cell: SheetType.Cell): string | number;
32
32
  export declare const optionsToValuesFromLabelOrValue: (options: SheetType.OptionsType[], val: string) => string[];
33
33
  export declare const optionsTransferToValue: (options: SheetType.OptionsType[], val: string, key?: string) => string[];
34
- export declare const optionsTransferToValue2: (options?: SheetType.OptionsType[], value?: string, path?: string[]) => string[];
34
+ export declare const optionsTransferToValue2: (options?: SheetType.OptionsType[], value?: string, path?: string[]) => (string | number)[];
35
35
  export declare const valuesTransferToLabel: (options?: SheetType.OptionsType[], value?: string) => string | null;
36
36
  export declare const groupConfigToGroupMap: (rowGroupConfig?: SheetType.RowGroupConfig) => Map<number, SheetType.RowGroup & {
37
37
  isStart: boolean;
@@ -20,6 +20,9 @@ export var GroupViewer = function GroupViewer(props) {
20
20
  }, [eventBus, row, record === null || record === void 0 ? void 0 : record.open]);
21
21
  if (value) {
22
22
  return /*#__PURE__*/_jsx("span", {
23
+ style: {
24
+ cursor: 'pointer'
25
+ },
23
26
  onMouseDown: function onMouseDown(e) {
24
27
  return e.stopPropagation();
25
28
  },
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import EventEmitter from 'events';
2
3
  declare const useEventBus: () => EventEmitter;
3
4
  export { useEventBus };
@@ -96,6 +96,7 @@ export declare type SheetProps = {
96
96
  virtualized?: boolean;
97
97
  showBackEdit?: boolean;
98
98
  backEditStyle?: Partial<CSSStyleDeclaration>;
99
+ sticky?: boolean;
99
100
  groupConfig?: RowGroupConfig;
100
101
  onCellsChanged?: CellChangeHandler;
101
102
  menuRenderer?: React.FC<MenuRenderProps>;
@@ -185,7 +186,7 @@ export declare type UpdateStateType = {
185
186
  };
186
187
  export declare type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
187
188
  export declare type Options<T = any> = {
188
- value: string;
189
+ value: string | number;
189
190
  label: string;
190
191
  } & T;
191
192
  export declare type OptionsType = Options<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",