@zhenliang/sheet 0.1.3 → 0.1.6

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,6 @@
1
1
  import type { SheetType } from "../../../type";
2
+ import { SelectProps } from 'antd';
2
3
  import 'antd/es/select/style/index.css';
3
4
  import './index.less';
4
- export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode) => SheetType.CellEditor;
5
+ export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>) => SheetType.CellEditor;
5
6
  export default getSelectEditor;
@@ -1,3 +1,9 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ 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; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
7
  /* eslint-disable eqeqeq */
2
8
 
3
9
  import { Select } from 'antd';
@@ -10,6 +16,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
10
16
  export var getSelectEditor = function getSelectEditor(options) {
11
17
  var valueKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
12
18
  var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /*#__PURE__*/_jsx(_Fragment, {});
19
+ var selectProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
13
20
  var SelectEditor = function SelectEditor(props) {
14
21
  var value = props.value,
15
22
  onConfirm = props.onConfirm;
@@ -28,7 +35,7 @@ export var getSelectEditor = function getSelectEditor(options) {
28
35
  children: [menu, extra]
29
36
  });
30
37
  };
31
- return /*#__PURE__*/_jsx(Select, {
38
+ return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
32
39
  autoFocus: true,
33
40
  className: "select-editor",
34
41
  defaultOpen: true,
@@ -43,7 +50,7 @@ export var getSelectEditor = function getSelectEditor(options) {
43
50
  options: options,
44
51
  popupClassName: 'excelTablePopupClassName',
45
52
  dropdownRender: dropdown
46
- });
53
+ }));
47
54
  };
48
55
  SelectEditor.checker = function (value) {
49
56
  if (isNil(value)) return true;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SheetType } from "../../../type";
3
2
  import './index.less';
4
3
  export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SheetType } from "../../type";
3
2
  import './draggableShell/index.less';
4
3
  export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
@@ -77,7 +77,8 @@ export var GroupEvent = function GroupEvent(props) {
77
77
  name: "group-open-title",
78
78
  handler: function handler(value) {
79
79
  onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
80
- groupOpen: Array(rowGroupConfig.groupOpen.length).fill(value)
80
+ groupOpen: Array(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen.length).fill(value),
81
+ defaultOpen: !groups.length ? value : undefined
81
82
  }));
82
83
  sheetInstance === null || sheetInstance === void 0 ? void 0 : sheetInstance.pushToHistory({
83
84
  type: 'Custom',
@@ -33,7 +33,7 @@ import { useRowSelection } from "./useRowSelection";
33
33
  import { jsx as _jsx } from "react/jsx-runtime";
34
34
  import { jsxs as _jsxs } from "react/jsx-runtime";
35
35
  var Table = function Table(_ref) {
36
- var _rowGroupConfig$group;
36
+ var _rowGroupConfig$group, _rowGroupConfig$group2;
37
37
  var sheetRef = _ref.sheetInstance,
38
38
  columns = _ref.columns,
39
39
  dataSource = _ref.dataSource,
@@ -228,10 +228,11 @@ var Table = function Table(_ref) {
228
228
  newChecked[currentRow] = !newChecked[currentRow];
229
229
  setCheckedRow(newChecked);
230
230
  }, [sheetInstance, checkedRow]);
231
- var headGroupOpen = !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.some(function (value) {
231
+ var headGroupOpen = !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.length) ? !!(rowGroupConfig !== null && rowGroupConfig !== void 0 && rowGroupConfig.defaultOpen) : !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group2 = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group2 !== void 0 && _rowGroupConfig$group2.some(function (value) {
232
232
  return !value;
233
233
  }));
234
234
  var headSelection = !!rowSelection;
235
+ console.log('shell-render', rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.defaultOpen, headGroupOpen);
235
236
  var WrappedTableShell = useMemo(function () {
236
237
  console.log('shell-render', '损耗性能大');
237
238
  if (draggable) {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import EventEmitter from 'events';
3
2
  declare const useEventBus: () => EventEmitter;
4
3
  export { useEventBus };
@@ -64,6 +64,7 @@ export declare type RowGroup = {
64
64
  groupEnd: number;
65
65
  };
66
66
  export declare type RowGroupConfig = {
67
+ defaultOpen?: boolean;
67
68
  groups: RowGroup[];
68
69
  groupOpen: boolean[];
69
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",