@lemon-fe/components 0.1.97 → 0.1.101

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,7 +1,9 @@
1
1
  /// <reference path="../../typings.d.ts" />
2
- import type { BaseTableProps as Props } from './typings';
3
- declare function BaseTable<T extends Record<string, any>>(props: Props<T>): JSX.Element;
4
- declare namespace BaseTable {
5
- var Summary: typeof import("rc-table/lib/Footer/Summary").default;
2
+ import { Table as AntdTable } from 'antd';
3
+ import type { BaseTableProps } from './typings';
4
+ interface BaseTableType {
5
+ <T>(props: BaseTableProps<T>): JSX.Element;
6
+ Summary: typeof AntdTable.Summary;
6
7
  }
7
- export default BaseTable;
8
+ declare const ForwardTable: BaseTableType;
9
+ export default ForwardTable;
@@ -34,7 +34,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
34
34
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
35
 
36
36
  /// <reference path="../../typings.d.ts" />
37
- import React, { useMemo, useState, useEffect, useRef } from 'react';
37
+ import React, { useMemo, useState, useEffect, useRef, forwardRef } from 'react';
38
38
  import { Table as AntdTable } from 'antd';
39
39
  import classNames from 'classnames';
40
40
  import { get } from 'lodash';
@@ -101,7 +101,7 @@ function Th(props) {
101
101
  }), content));
102
102
  }
103
103
 
104
- function BaseTable(props) {
104
+ function BaseTable(props, _ref) {
105
105
  var id = props.id,
106
106
  columns = props.columns,
107
107
  defaultColumnProps = props.defaultColumnProps,
@@ -415,7 +415,15 @@ function BaseTable(props) {
415
415
  }, [scrollY, rowHeight]);
416
416
  var tableNode = /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
417
417
  size: "small",
418
- ref: fullTableRef,
418
+ ref: function ref(elm) {
419
+ fullTableRef.current = elm;
420
+
421
+ if (typeof _ref === 'function') {
422
+ _ref(elm);
423
+ } else if (_ref !== null) {
424
+ _ref.current = elm;
425
+ }
426
+ },
419
427
  className: classNames("".concat(PREFIX_CLS, "-table"), className),
420
428
  columns: formatedColumns,
421
429
  dataSource: dataSource,
@@ -463,5 +471,6 @@ function BaseTable(props) {
463
471
  }, tableNode);
464
472
  }
465
473
 
466
- BaseTable.Summary = AntdTable.Summary;
467
- export default BaseTable;
474
+ var ForwardTable = /*#__PURE__*/forwardRef(BaseTable);
475
+ ForwardTable.Summary = AntdTable.Summary;
476
+ export default ForwardTable;
@@ -1,5 +1,5 @@
1
- import type { ReactElement, ReactText } from 'react';
2
- import { TableProps, TableColumnType, TableColumnGroupType, TableColumnsType } from 'antd';
1
+ import type { ReactElement, ReactText, RefObject } from 'react';
2
+ import type { TableProps, TableColumnType, TableColumnGroupType, TableColumnsType } from 'antd';
3
3
 
4
4
  export type ColumnType<T> = TableColumnType<T>;
5
5
 
@@ -44,4 +44,5 @@ export interface BaseTableProps<T> extends Omit<TableProps<T>, 'columns' | 'scro
44
44
  * @description 行操作按钮组
45
45
  */
46
46
  rowActions?: (RowAction<T> | null)[] | ((record: T, index: number) => (RowAction<T> | null)[]);
47
+ ref?: RefObject<HTMLDivElement>;
47
48
  }
@@ -1,7 +1,6 @@
1
- import { MutableRefObject } from 'react';
1
+ import React, { ForwardedRef } from 'react';
2
2
  import type { EditableTableProps, EditableTableRef } from './typings';
3
- declare type RefType = ((instance: EditableTableRef | null) => void) | MutableRefObject<EditableTableRef | null> | null;
4
3
  declare const _default: <T>(props: EditableTableProps<T> & {
5
- ref?: RefType | undefined;
4
+ ref?: React.ForwardedRef<EditableTableRef> | undefined;
6
5
  }) => JSX.Element;
7
6
  export default _default;
@@ -22,12 +22,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
22
22
 
23
23
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
24
 
25
- import React, { cloneElement, createContext, useContext, useEffect, useMemo, useState, memo, isValidElement, forwardRef, useImperativeHandle } from 'react';
25
+ import React, { cloneElement, createContext, useContext, useEffect, useMemo, useState, memo, isValidElement, forwardRef, useImperativeHandle, useRef } from 'react';
26
26
  import { get, isEqual } from 'lodash';
27
27
  import BaseTable from '../BaseTable';
28
28
  import { FormStore } from './util';
29
29
  import { PREFIX_CLS } from '../constants';
30
- import { randomStr } from '../BaseTable/utils';
31
30
  import EditableCell from './EditableCell';
32
31
  var Context = /*#__PURE__*/createContext(null);
33
32
 
@@ -221,11 +220,9 @@ function EditableTable(props, ref) {
221
220
  return mCols;
222
221
  }, [columns, editable]); // 键盘事件
223
222
 
224
- var tableID = useMemo(function () {
225
- return randomStr();
226
- }, []);
223
+ var tableRef = useRef(null);
227
224
  useEffect(function () {
228
- var table = document.getElementById(tableID);
225
+ var table = tableRef.current;
229
226
 
230
227
  if (table === null) {
231
228
  return;
@@ -340,7 +337,7 @@ function EditableTable(props, ref) {
340
337
  return function () {
341
338
  table.removeEventListener('keyup', handleKeyUp);
342
339
  };
343
- }, [tableID]);
340
+ }, []);
344
341
  useImperativeHandle(ref, function () {
345
342
  return {
346
343
  validate: function validate() {
@@ -356,7 +353,7 @@ function EditableTable(props, ref) {
356
353
  dataSource: rows,
357
354
  rowKey: "key"
358
355
  }, restProps), {}, {
359
- id: tableID
356
+ ref: tableRef
360
357
  })));
361
358
  }
362
359
 
@@ -1,5 +1,3 @@
1
- @import '../theme.less';
2
-
3
1
  .@{prefixCls}-form-item {
4
2
  display: flex;
5
3
  align-items: center;
@@ -16,4 +14,10 @@
16
14
  padding: 6px 6px 6px 0;
17
15
  cursor: pointer;
18
16
  }
17
+
18
+ .ant-table-cell-row-hover &:not(.ant-input) {
19
+ background-color: #fff;
20
+ border: 1px solid #c0c0c0;
21
+ border-radius: 4px;
22
+ }
19
23
  }
@@ -1,6 +1,6 @@
1
1
  import type { Key, ReactElement } from 'react';
2
2
  import type { BaseTableProps, ColumnType } from '../BaseTable/typings';
3
- import { RuleItem } from 'async-validator/dist-types/interface';
3
+ import type { RuleItem } from 'async-validator/dist-types/interface';
4
4
 
5
5
  type RowType = {
6
6
  key: Key;
@@ -70,7 +70,10 @@ export type EditableTableRowError = {
70
70
  };
71
71
 
72
72
  export interface EditableTableProps<T>
73
- extends Pick<BaseTableProps<T>, 'rowKey' | 'virtual' | 'scroll' | 'pagination'> {
73
+ extends Pick<
74
+ BaseTableProps<T>,
75
+ 'rowKey' | 'virtual' | 'scroll' | 'pagination' | 'loading' | 'summaryRecord' | 'summaryTitle'
76
+ > {
74
77
  editable?: boolean;
75
78
  value?: T[];
76
79
  error?: string | EditableTableRowError[];
@@ -1,5 +1,5 @@
1
1
  import type { Key } from 'react';
2
- import { EditableTableObserverHandler, EditableTableRule } from './typings';
2
+ import type { EditableTableObserverHandler, EditableTableRule } from './typings';
3
3
  export declare class FormStore<T = Record<Key, any>> {
4
4
  private data;
5
5
  private keys;
@@ -592,30 +592,30 @@ function Filter(props) {
592
592
  transform: 'rotate(180deg)'
593
593
  } : undefined
594
594
  }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
595
- id: "a",
595
+ id: "filter-down",
596
596
  d: "M0 0h10v10H0z"
597
597
  })), /*#__PURE__*/React.createElement("g", {
598
598
  transform: "matrix(1 0 0 -1 0 10)",
599
599
  fill: "none",
600
600
  fillRule: "evenodd"
601
601
  }, /*#__PURE__*/React.createElement("mask", {
602
- id: "b",
602
+ id: "filter-down-mask",
603
603
  fill: "#fff"
604
604
  }, /*#__PURE__*/React.createElement("use", {
605
- xlinkHref: "#a",
605
+ xlinkHref: "#filter-down",
606
606
  transform: "rotate(-90 5 5)"
607
607
  })), /*#__PURE__*/React.createElement("use", {
608
608
  fillOpacity: "0",
609
609
  fill: "#C4C4C4",
610
610
  transform: "rotate(-90 5 5)",
611
- xlinkHref: "#a"
611
+ xlinkHref: "#filter-down"
612
612
  }), /*#__PURE__*/React.createElement("path", {
613
613
  d: "M2.172 1.757 5 4.586l2.828-2.829M2.172 5.757 5 8.586l2.828-2.829",
614
614
  stroke: "currentColor",
615
615
  strokeLinecap: "round",
616
616
  strokeLinejoin: "round",
617
617
  strokeDasharray: "0,0",
618
- mask: "url(#b)"
618
+ mask: "url(#filter-down-mask)"
619
619
  }))))))))));
620
620
  }
621
621
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.97",
3
+ "version": "0.1.101",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -39,5 +39,5 @@
39
39
  "react": "^17.0.2",
40
40
  "react-dom": "^17.0.2"
41
41
  },
42
- "gitHead": "7823b5e252d052d697f8f4c584d39ee3c2014d92"
42
+ "gitHead": "8c04f1424c67790d3d4f7218663fc221c8645e77"
43
43
  }