@zhenliang/sheet 0.1.1 → 0.1.2

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.
@@ -3,4 +3,4 @@ import { InputNumberProps } from 'antd';
3
3
  import 'antd/es/input-number/style/index.css';
4
4
  import './index.less';
5
5
  export declare const NumberEditor: SheetType.CellEditor;
6
- export declare const getNumberEditor: (extraProps?: Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>) => SheetType.CellEditor;
6
+ export declare const getNumberEditor: (extraProps?: Partial<Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>>) => SheetType.CellEditor;
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  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; }
5
5
  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; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { flatten } from 'lodash';
7
8
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
8
9
  import { dataSourceToRowConfig } from "./util";
9
10
  export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig, hasChildren) {
@@ -15,13 +16,12 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
15
16
  var childrenLength = useMemo(function () {
16
17
  if (!(dataSource !== null && dataSource !== void 0 && dataSource.length)) return 0;
17
18
  var data = dataSource;
18
- var childrenCount = data.filter(function (item) {
19
+ var childrenCount = flatten(data.filter(function (item) {
19
20
  var _item$children;
20
21
  return !!((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length);
21
- }).reduce(function (count, _ref) {
22
- var children = _ref.children;
23
- return count + (children === null || children === void 0 ? void 0 : children.length) ? children.length : 0;
24
- }, 0);
22
+ }).map(function (item) {
23
+ return item.children;
24
+ })).length;
25
25
  return childrenCount;
26
26
  }, [dataSource]);
27
27
  useEffect(function () {
@@ -29,9 +29,9 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
29
29
  console.log('groupConfigEffect', dataSource.length);
30
30
  var rowConfig = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
31
31
  if (groupConfigRef.current) {
32
- groupConfigRef.current.groups.forEach(function (_ref2, index) {
32
+ groupConfigRef.current.groups.forEach(function (_ref, index) {
33
33
  var _groupConfigRef$curre;
34
- var groupName = _ref2.groupName;
34
+ var groupName = _ref.groupName;
35
35
  var rowIndex = rowConfig.groups.findIndex(function (item) {
36
36
  return item.groupName === groupName;
37
37
  });
@@ -42,6 +42,7 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
42
42
  console.log('groupConfigEffect', rowConfig.groups, rowConfig.groupOpen);
43
43
  groupConfigRef.current = rowConfig;
44
44
  }, [dataSource.length, childrenLength, hasChildren]);
45
+ console.log('groupConfigEffect', dataSource.length, childrenLength);
45
46
  var handleGroupChange = useCallback(function (value) {
46
47
  setGroupConfig(value);
47
48
  groupConfigRef.current = value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",