@zhenliang/sheet 0.1.0 → 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.
- package/dist/core/editor/numberEditor/index.d.ts +1 -1
- package/dist/core/shell/draggableShell/index.d.ts +1 -0
- package/dist/core/shell/tableShell.d.ts +1 -0
- package/dist/core/table/useGroupConfig.js +8 -7
- package/dist/core/viewer/cascaderViewer/index.d.ts +1 -1
- package/dist/core/viewer/cascaderViewer/index.js +1 -1
- package/dist/core/viewer/index.d.ts +1 -0
- package/dist/core/viewer/index.js +1 -0
- package/dist/example/antComponent.js +2 -2
- package/dist/hooks/useEventBus.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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'
|
|
6
|
+
export declare const getNumberEditor: (extraProps?: Partial<Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>>) => SheetType.CellEditor;
|
|
@@ -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<{
|
|
@@ -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
|
-
}).
|
|
22
|
-
|
|
23
|
-
|
|
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 (
|
|
32
|
+
groupConfigRef.current.groups.forEach(function (_ref, index) {
|
|
33
33
|
var _groupConfigRef$curre;
|
|
34
|
-
var 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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SheetType } from "../../../type";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getCascaderViewer: (options: SheetType.OptionsType[]) => SheetType.CellViewer;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// == string 和 number 类型忽略
|
|
3
3
|
|
|
4
4
|
import { valuesTransferToLabel } from "../../util";
|
|
5
|
-
export var
|
|
5
|
+
export var getCascaderViewer = function getCascaderViewer(options) {
|
|
6
6
|
var TypeViewer = function TypeViewer(props) {
|
|
7
7
|
var value = props.value;
|
|
8
8
|
return valuesTransferToLabel(options, value) || value;
|
|
@@ -20,7 +20,7 @@ import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
|
20
20
|
import { getCascaderEditor, getDateEditor, getNumberEditor, getSelectEditor } from "../core/editor";
|
|
21
21
|
import Table from "../core/table";
|
|
22
22
|
import { BtnViewer } from "../core/viewer/btnViewer";
|
|
23
|
-
import {
|
|
23
|
+
import { getCascaderViewer } from "../core/viewer/cascaderViewer";
|
|
24
24
|
import { EditViewer } from "../core/viewer/editViewer";
|
|
25
25
|
import { SwitchViewer } from "../core/viewer/switchViewer";
|
|
26
26
|
import { SheetType } from "../type";
|
|
@@ -78,7 +78,7 @@ var cascaderOptions = [{
|
|
|
78
78
|
}]
|
|
79
79
|
}]
|
|
80
80
|
}];
|
|
81
|
-
var CascaderViewer =
|
|
81
|
+
var CascaderViewer = getCascaderViewer(cascaderOptions);
|
|
82
82
|
var CascaderSelector = getCascaderEditor(cascaderOptions);
|
|
83
83
|
var columns = [{
|
|
84
84
|
title: 'Full Name',
|