@lemon-fe/components 1.4.0-alpha.1 → 1.4.1

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.
@@ -5,10 +5,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { DatePicker } from 'antd';
8
- import React, { useEffect, useRef } from 'react';
8
+ import React, { useEffect, useMemo, useRef } from 'react';
9
9
  import { forwardRef, useImperativeHandle, useState } from 'react';
10
10
  import { editorPrefixClass, navigateCell } from "./utils";
11
11
  import EditorWrapper from "./wrapper";
12
+ import { uniq } from 'lodash';
12
13
  import moment from 'moment';
13
14
  export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
14
15
  var _props$format = props.format,
@@ -27,6 +28,9 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
27
28
  var elm = useRef(null);
28
29
  var isEdited = useRef(false);
29
30
  var dirty = useRef(false);
31
+ var inputFormat = useMemo(function () {
32
+ return uniq([format, 'YYYY-MM-DD', 'YYYYMMDD']);
33
+ }, []);
30
34
  useEffect(function () {
31
35
  var _elm$current;
32
36
  (_elm$current = elm.current) === null || _elm$current === void 0 || _elm$current.focus();
@@ -65,6 +69,7 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
65
69
  className: editorPrefixClass('date'),
66
70
  value: value,
67
71
  placeholder: format,
72
+ format: inputFormat,
68
73
  onOpenChange: function onOpenChange(val) {
69
74
  if (!val) {
70
75
  isEdited.current = true;
@@ -17,7 +17,7 @@ declare const Editors: {
17
17
  Text: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
18
18
  Date: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
19
19
  Number: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
20
- Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "virtual" | "listHeight"> & {
20
+ Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "showSearch" | "optionFilterProp" | "options" | "virtual" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -39,6 +39,7 @@ declare class InternalDataGrid<TData extends Record<string, any>> extends Compon
39
39
  private validator;
40
40
  private requestId;
41
41
  private isReady;
42
+ private mounted;
42
43
  private readyQueue;
43
44
  private emptyRowData;
44
45
  private sideBarDef;
@@ -1,7 +1,7 @@
1
1
  var _excluded = ["validator"],
2
2
  _excluded2 = ["title", "dataIndex", "render", "ellipsis", "sorter", "editable", "className"],
3
3
  _excluded3 = ["title", "children"],
4
- _excluded4 = ["rowKey", "fetch", "dataSource", "rowActions", "columns", "autoLoad", "loading", "summary", "detailCell", "pagination", "rowSelection", "columnTypes", "defaultColDef", "components", "sideBar", "detailCellRendererParams", "context", "showSearch", "cellDisplayFlex", "locale"];
4
+ _excluded4 = ["rowKey", "fetch", "dataSource", "rowActions", "columns", "autoLoad", "loading", "summary", "detailCell", "pagination", "rowSelection", "columnTypes", "defaultColDef", "components", "sideBar", "detailCellRendererParams", "context", "showSearch", "cellDisplayFlex", "locale", "extraFooterLeft"];
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -35,7 +35,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
35
35
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
36
36
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
37
  import { Spin, Pagination } from 'antd';
38
- import React, { Component, createRef, forwardRef } from 'react';
38
+ import React, { Component, createRef, forwardRef, Fragment } from 'react';
39
39
  import { useComponentDefaultProps } from "../component-configure";
40
40
  import { useLocaleReceiver } from "../locale-receiver";
41
41
  import { parseLocalTemplate } from "../locale/locale";
@@ -163,6 +163,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
163
163
  _defineProperty(_assertThisInitialized(_this), "validator", null);
164
164
  _defineProperty(_assertThisInitialized(_this), "requestId", 0);
165
165
  _defineProperty(_assertThisInitialized(_this), "isReady", false);
166
+ _defineProperty(_assertThisInitialized(_this), "mounted", false);
166
167
  _defineProperty(_assertThisInitialized(_this), "readyQueue", []);
167
168
  _defineProperty(_assertThisInitialized(_this), "emptyRowData", []);
168
169
  _defineProperty(_assertThisInitialized(_this), "sideBarDef", {
@@ -248,6 +249,12 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
248
249
  return _this.customColumnData;
249
250
  case 7:
250
251
  customColumnData = _context.sent;
252
+ if (_this.mounted) {
253
+ _context.next = 10;
254
+ break;
255
+ }
256
+ return _context.abrupt("return");
257
+ case 10:
251
258
  if (customColumnData) {
252
259
  try {
253
260
  data = customColumnData;
@@ -311,7 +318,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
311
318
  }
312
319
  });
313
320
  _this.clearReadyQueue();
314
- case 18:
321
+ case 20:
315
322
  case "end":
316
323
  return _context.stop();
317
324
  }
@@ -536,11 +543,15 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
536
543
  if (!suppressRowClickSelection && evt.node.selectable && evt.eventPath) {
537
544
  var enableSelectionWithoutKeys = rowMultiSelectWithClick !== null && rowMultiSelectWithClick !== void 0 ? rowMultiSelectWithClick : rowSelection !== undefined && rowSelection.type !== 'radio';
538
545
  for (var i = 0; i < evt.eventPath.length; i++) {
546
+ if (evt.eventPath[i] === document.documentElement) {
547
+ break;
548
+ }
539
549
  var elm = evt.eventPath[i];
540
- if (elm.nodeName === 'A' || elm.nodeName === 'BUTTON' || elm.nodeName === 'INPUT' || elm.role === 'button' || elm.role === 'input') {
550
+ var role = elm.role || elm.getAttribute('role');
551
+ if (elm.nodeName === 'A' || elm.nodeName === 'BUTTON' || elm.nodeName === 'INPUT' || role === 'button' || role === 'input') {
541
552
  break;
542
553
  }
543
- if (elm.role === 'gridcell') {
554
+ if (role === 'gridcell') {
544
555
  if (elm.classList.contains(prefix('editor-cell'))) {
545
556
  break;
546
557
  }
@@ -716,6 +727,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
716
727
  }, {
717
728
  key: "componentWillUnmount",
718
729
  value: function componentWillUnmount() {
730
+ this.mounted = false;
719
731
  this.isReady = false;
720
732
  window.removeEventListener('blur', this.handleFocus);
721
733
  }
@@ -726,15 +738,16 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
726
738
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
727
739
  while (1) switch (_context3.prev = _context3.next) {
728
740
  case 0:
741
+ this.mounted = true;
729
742
  window.addEventListener('blur', this.handleFocus);
730
743
  this.loadingChange(true, true);
731
744
 
732
745
  // 放在componentDidMount 执行时间比onGridReady早
733
- _context3.next = 4;
746
+ _context3.next = 5;
734
747
  return this.customColumnData;
735
- case 4:
736
- this.loadingChange(false, true);
737
748
  case 5:
749
+ this.loadingChange(false, true);
750
+ case 6:
738
751
  case "end":
739
752
  return _context3.stop();
740
753
  }
@@ -1651,6 +1664,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1651
1664
  showSearch = _this$props10.showSearch,
1652
1665
  cellDisplayFlex = _this$props10.cellDisplayFlex,
1653
1666
  locale = _this$props10.locale,
1667
+ extraFooterLeft = _this$props10.extraFooterLeft,
1654
1668
  restProps = _objectWithoutProperties(_this$props10, _excluded4);
1655
1669
  var _this$state3 = this.state,
1656
1670
  enablePagination = _this$state3.pagination,
@@ -1660,6 +1674,11 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1660
1674
  loading = _this$state3.loading;
1661
1675
  var mPage = _typeof(pagination) === 'object' ? pagination : {};
1662
1676
  var footer = [];
1677
+ if (extraFooterLeft) {
1678
+ footer.push( /*#__PURE__*/React.createElement(Fragment, {
1679
+ key: "data-grid-extra-footer-left"
1680
+ }, extraFooterLeft));
1681
+ }
1663
1682
  var gridRowSelection;
1664
1683
  if (rowSelection !== undefined) {
1665
1684
  if (rowSelection.type === 'radio') {
@@ -599,7 +599,7 @@
599
599
  }
600
600
 
601
601
  .ag-cell-label-container {
602
- font-weight: 500;
602
+ font-weight: 700;
603
603
  }
604
604
 
605
605
  .ag-header-cell-menu-button {
@@ -236,4 +236,8 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
236
236
  * @descriptioin 列定制启用汇总
237
237
  */
238
238
  enableCustomColumnSummary?: boolean;
239
+ /**
240
+ * @description 表格底部左侧额外的元素
241
+ */
242
+ extraFooterLeft?: ReactElement;
239
243
  }
@@ -34,7 +34,7 @@
34
34
 
35
35
  &-title {
36
36
  flex: 1;
37
- font-weight: 500;
37
+ font-weight: 700;
38
38
  font-size: 14px;
39
39
  line-height: 22px;
40
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.0-alpha.1",
3
+ "version": "1.4.1",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@dnd-kit/core": ">=6.0.0",
24
- "@lemon-fe/hooks": "^1.4.0-alpha.0",
24
+ "@lemon-fe/hooks": "^1.4.0",
25
25
  "@lemon-fe/utils": "^1.3.0",
26
26
  "ag-grid-community": "29.2.0",
27
27
  "ag-grid-enterprise": "29.2.0",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://registry.npmjs.org"
60
60
  },
61
- "gitHead": "ee975709e5aefc046fa159cbc14235bad5557189"
61
+ "gitHead": "4a0de8d6cf3909a13c3f7f1b8ff1e9354697275a"
62
62
  }