@lemon-fe/components 1.3.8 → 1.4.0-alpha.0

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,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { ActionsProps } from '../actions';
3
3
  import type { DataGridProps } from '../data-grid/typings';
4
+ import type { DurationPickerProps } from '../duration-picker';
4
5
  import type { FilterProps } from '../filter/typings';
5
6
  import type { SelectViewProps } from '../select-view';
6
7
  declare type PropsGetter<T> = ((props: T) => T) | Partial<T>;
@@ -9,6 +10,7 @@ export interface ComponentConfigureContextProps {
9
10
  Filter?: PropsGetter<FilterProps<unknown>>;
10
11
  Actions?: PropsGetter<ActionsProps>;
11
12
  SelectView?: PropsGetter<SelectViewProps<unknown, unknown>>;
13
+ DurationPicker?: PropsGetter<DurationPickerProps>;
12
14
  }
13
15
  export declare const ComponentConfigureContext: import("react").Context<ComponentConfigureContextProps>;
14
16
  export declare const ComponentConfigureProvider: import("react").Provider<ComponentConfigureContextProps>;
@@ -4,5 +4,7 @@ import { editorPrefixClass } from "./utils";
4
4
  export default function EditorWrapper(props) {
5
5
  return /*#__PURE__*/React.createElement("div", _extends({
6
6
  className: editorPrefixClass()
7
- }, props));
7
+ }, props, {
8
+ role: "input"
9
+ }));
8
10
  }
@@ -113,6 +113,7 @@ declare class InternalDataGrid<TData extends Record<string, any>> extends Compon
113
113
  * @returns
114
114
  */
115
115
  focusPreviousCell(): void;
116
+ private handleRowClicked;
116
117
  render(): JSX.Element;
117
118
  }
118
119
  export declare type DataGridRef<T extends Record<string, any>> = InternalDataGrid<T>;
@@ -522,6 +522,42 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
522
522
  column: typeof column === 'string' ? column : column.getColId()
523
523
  };
524
524
  });
525
+ // 自行实现行点击选择
526
+ _defineProperty(_assertThisInitialized(_this), "handleRowClicked", function (evt) {
527
+ var _this$props4 = _this.props,
528
+ rowSelection = _this$props4.rowSelection,
529
+ onRowClicked = _this$props4.onRowClicked,
530
+ rowMultiSelectWithClick = _this$props4.rowMultiSelectWithClick,
531
+ _this$props4$suppress = _this$props4.suppressRowClickSelection,
532
+ suppressRowClickSelection = _this$props4$suppress === void 0 ? false : _this$props4$suppress,
533
+ _this$props4$suppress2 = _this$props4.suppressRowDeselection,
534
+ suppressRowDeselection = _this$props4$suppress2 === void 0 ? false : _this$props4$suppress2;
535
+ onRowClicked === null || onRowClicked === void 0 || onRowClicked(evt);
536
+ if (!suppressRowClickSelection && evt.node.selectable && evt.eventPath) {
537
+ var enableSelectionWithoutKeys = rowMultiSelectWithClick !== null && rowMultiSelectWithClick !== void 0 ? rowMultiSelectWithClick : rowSelection !== undefined && rowSelection.type !== 'radio';
538
+ for (var i = 0; i < evt.eventPath.length; i++) {
539
+ var elm = evt.eventPath[i];
540
+ if (elm.nodeName === 'A' || elm.nodeName === 'BUTTON' || elm.nodeName === 'INPUT' || elm.role === 'button' || elm.role === 'input') {
541
+ break;
542
+ }
543
+ if (elm.role === 'gridcell') {
544
+ if (elm.classList.contains(prefix('editor-cell'))) {
545
+ break;
546
+ }
547
+ var selected = evt.node.isSelected();
548
+ if (selected) {
549
+ var event = evt.event;
550
+ if (enableSelectionWithoutKeys || !suppressRowDeselection && (event.ctrlKey || event.metaKey)) {
551
+ evt.node.setSelected(false);
552
+ }
553
+ } else {
554
+ evt.node.setSelected(true, !enableSelectionWithoutKeys, false, 'rowClicked');
555
+ }
556
+ break;
557
+ }
558
+ }
559
+ }
560
+ });
525
561
  _this.state = _objectSpread({
526
562
  loading: false
527
563
  }, _this.getPagination());
@@ -614,9 +650,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
614
650
  }, {
615
651
  key: "getPagination",
616
652
  value: function getPagination() {
617
- var _this$props4 = this.props,
618
- pagination = _this$props4.pagination,
619
- fetch = _this$props4.fetch;
653
+ var _this$props5 = this.props,
654
+ pagination = _this$props5.pagination,
655
+ fetch = _this$props5.fetch;
620
656
  var page = 1;
621
657
  var pageSize = 50;
622
658
  var total = 0;
@@ -646,11 +682,11 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
646
682
  key: "componentDidUpdate",
647
683
  value: function componentDidUpdate(prevProps) {
648
684
  var _prevProps$rowSelecti;
649
- var _this$props5 = this.props,
650
- columns = _this$props5.columns,
651
- rowSelection = _this$props5.rowSelection,
652
- dataSource = _this$props5.dataSource,
653
- context = _this$props5.context;
685
+ var _this$props6 = this.props,
686
+ columns = _this$props6.columns,
687
+ rowSelection = _this$props6.rowSelection,
688
+ dataSource = _this$props6.dataSource,
689
+ context = _this$props6.context;
654
690
  if (!shallowEqual(context, prevProps.context)) {
655
691
  this.store.setState({
656
692
  context: context
@@ -840,9 +876,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
840
876
  if (col.type === undefined) {
841
877
  return _objectSpread({}, col);
842
878
  }
843
- var _this$props6 = this.props,
844
- mColumnTypes = _this$props6.columnTypes,
845
- mDefaultColDef = _this$props6.defaultColDef;
879
+ var _this$props7 = this.props,
880
+ mColumnTypes = _this$props7.columnTypes,
881
+ mDefaultColDef = _this$props7.defaultColDef;
846
882
  var colTypes = this.getMemoizedColumnTypes(mColumnTypes);
847
883
  var result = {};
848
884
  var types;
@@ -865,12 +901,12 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
865
901
  value: function getColumnDefs() {
866
902
  var _this3 = this,
867
903
  _this$props$customCol;
868
- var _this$props7 = this.props,
869
- _this$props7$columns = _this$props7.columns,
870
- columns = _this$props7$columns === void 0 ? [] : _this$props7$columns,
871
- rowActions = _this$props7.rowActions,
872
- rowSelection = _this$props7.rowSelection,
873
- locale = _this$props7.locale;
904
+ var _this$props8 = this.props,
905
+ _this$props8$columns = _this$props8.columns,
906
+ columns = _this$props8$columns === void 0 ? [] : _this$props8$columns,
907
+ rowActions = _this$props8.rowActions,
908
+ rowSelection = _this$props8.rowSelection,
909
+ locale = _this$props8.locale;
874
910
  var leafColIds = [];
875
911
  var map = function map(cols) {
876
912
  return cols.map(function (item) {
@@ -1333,9 +1369,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1333
1369
  value: function getDataFromServer() {
1334
1370
  var _this6 = this;
1335
1371
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1336
- var _this$props8 = this.props,
1337
- fetch = _this$props8.fetch,
1338
- onLoad = _this$props8.onLoad;
1372
+ var _this$props9 = this.props,
1373
+ fetch = _this$props9.fetch,
1374
+ onLoad = _this$props9.onLoad;
1339
1375
  if (typeof fetch === 'function') {
1340
1376
  if (this.requestId < Number.MAX_SAFE_INTEGER) {
1341
1377
  this.requestId += 1;
@@ -1594,28 +1630,28 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1594
1630
  key: "render",
1595
1631
  value: function render() {
1596
1632
  var _this11 = this;
1597
- var _this$props9 = this.props,
1598
- rowKey = _this$props9.rowKey,
1599
- fetch = _this$props9.fetch,
1600
- dataSource = _this$props9.dataSource,
1601
- rowActions = _this$props9.rowActions,
1602
- columns = _this$props9.columns,
1603
- autoLoad = _this$props9.autoLoad,
1604
- loadingProp = _this$props9.loading,
1605
- summary = _this$props9.summary,
1606
- detailCell = _this$props9.detailCell,
1607
- pagination = _this$props9.pagination,
1608
- rowSelection = _this$props9.rowSelection,
1609
- columnTypesProp = _this$props9.columnTypes,
1610
- defaultColDefProp = _this$props9.defaultColDef,
1611
- componentsProp = _this$props9.components,
1612
- sideBarProp = _this$props9.sideBar,
1613
- detailCellRendererParams = _this$props9.detailCellRendererParams,
1614
- context = _this$props9.context,
1615
- showSearch = _this$props9.showSearch,
1616
- cellDisplayFlex = _this$props9.cellDisplayFlex,
1617
- locale = _this$props9.locale,
1618
- restProps = _objectWithoutProperties(_this$props9, _excluded4);
1633
+ var _this$props10 = this.props,
1634
+ rowKey = _this$props10.rowKey,
1635
+ fetch = _this$props10.fetch,
1636
+ dataSource = _this$props10.dataSource,
1637
+ rowActions = _this$props10.rowActions,
1638
+ columns = _this$props10.columns,
1639
+ autoLoad = _this$props10.autoLoad,
1640
+ loadingProp = _this$props10.loading,
1641
+ summary = _this$props10.summary,
1642
+ detailCell = _this$props10.detailCell,
1643
+ pagination = _this$props10.pagination,
1644
+ rowSelection = _this$props10.rowSelection,
1645
+ columnTypesProp = _this$props10.columnTypes,
1646
+ defaultColDefProp = _this$props10.defaultColDef,
1647
+ componentsProp = _this$props10.components,
1648
+ sideBarProp = _this$props10.sideBar,
1649
+ detailCellRendererParams = _this$props10.detailCellRendererParams,
1650
+ context = _this$props10.context,
1651
+ showSearch = _this$props10.showSearch,
1652
+ cellDisplayFlex = _this$props10.cellDisplayFlex,
1653
+ locale = _this$props10.locale,
1654
+ restProps = _objectWithoutProperties(_this$props10, _excluded4);
1619
1655
  var _this$state3 = this.state,
1620
1656
  enablePagination = _this$state3.pagination,
1621
1657
  page = _this$state3.page,
@@ -1699,7 +1735,6 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1699
1735
  maintainColumnOrder: true,
1700
1736
  suppressCsvExport: true,
1701
1737
  suppressExcelExport: true,
1702
- rowMultiSelectWithClick: gridRowSelection === 'multiple',
1703
1738
  noRowsOverlayComponent: this.NoRowsOverlay,
1704
1739
  getMainMenuItems: this.getMainMenuItems,
1705
1740
  rowBuffer: 20,
@@ -1711,6 +1746,8 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1711
1746
  getRowStyle: this.getRowStyle,
1712
1747
  stopEditingWhenCellsLoseFocus: false,
1713
1748
  onRowDataUpdated: this.rowDataUpdated,
1749
+ suppressRowClickSelection: true,
1750
+ onRowClicked: this.handleRowClicked,
1714
1751
  onCellValueChanged: this.cellValueChanged,
1715
1752
  onCellEditingStopped: this.cellEditingStop,
1716
1753
  onCellFocused: this.cellFocused,
@@ -24,6 +24,7 @@ function ActionItem(props) {
24
24
  var children = item.children || [];
25
25
  var node = /*#__PURE__*/React.createElement("div", {
26
26
  className: classNames(prefix('item'), _defineProperty({}, prefix("item-disabled"), item.disabled)),
27
+ role: "button",
27
28
  onClick: item.disabled ? undefined : item.onClick
28
29
  }, item.label, children.length > 0 && /*#__PURE__*/React.createElement(Icons.Down, null));
29
30
  if (children.length > 0) {
@@ -14,6 +14,7 @@ export default function CellDeleteRender(props) {
14
14
  }
15
15
  return /*#__PURE__*/React.createElement(Icons.Delete, {
16
16
  key: "delete",
17
+ role: "button",
17
18
  onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18
19
  return _regeneratorRuntime().wrap(function _callee$(_context) {
19
20
  while (1) switch (_context.prev = _context.next) {
@@ -15,10 +15,10 @@ declare type Option = {
15
15
  value: () => Moment[];
16
16
  id?: string;
17
17
  };
18
- interface Props extends Omit<RangePickerProps, 'value' | 'onChange' | 'disabled'> {
18
+ export interface DurationPickerProps extends Omit<RangePickerProps, 'value' | 'onChange' | 'disabled'> {
19
19
  prefixCls?: string;
20
20
  types: DateType[];
21
- options?: Option[];
21
+ options?: Option[] | 'year';
22
22
  dateFormat?: string;
23
23
  value?: DurationPickerValue;
24
24
  hideType?: boolean;
@@ -26,5 +26,5 @@ interface Props extends Omit<RangePickerProps, 'value' | 'onChange' | 'disabled'
26
26
  disabled?: boolean;
27
27
  showTime?: boolean;
28
28
  }
29
- declare function DurationPicker(props: Props): JSX.Element;
29
+ declare function DurationPicker(originalProps: DurationPickerProps): JSX.Element;
30
30
  export default DurationPicker;
@@ -15,6 +15,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  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; }
16
16
  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; }
17
17
  import React, { useMemo, useState, useEffect } from 'react';
18
+ import { useComponentDefaultProps } from "../component-configure";
18
19
  import { PREFIX_CLS } from "../constants";
19
20
  import DatePicker from "../date-picker";
20
21
  import InputCompact from "../input-compact";
@@ -22,8 +23,9 @@ import { useLocaleReceiver } from "../locale-receiver";
22
23
  import Select from "../select";
23
24
  import moment from 'moment';
24
25
  var emptyValue = [];
25
- function DurationPicker(props) {
26
+ function DurationPicker(originalProps) {
26
27
  var _result$type, _result$option;
28
+ var props = useComponentDefaultProps('DurationPicker', originalProps);
27
29
  var _props$prefixCls = props.prefixCls,
28
30
  prefixCls = _props$prefixCls === void 0 ? PREFIX_CLS : _props$prefixCls,
29
31
  types = props.types,
@@ -47,16 +49,19 @@ function DurationPicker(props) {
47
49
  lastWeekText = DurationPickerLocale.lastWeekText,
48
50
  thisMonthText = DurationPickerLocale.thisMonthText,
49
51
  lastMonthText = DurationPickerLocale.lastMonthText,
50
- lastThirtyDaysText = DurationPickerLocale.lastThirtyDaysText;
52
+ lastThirtyDaysText = DurationPickerLocale.lastThirtyDaysText,
53
+ lastQuarterText = DurationPickerLocale.lastQuarterText,
54
+ thisQuarterText = DurationPickerLocale.thisQuarterText,
55
+ thisYearText = DurationPickerLocale.thisYearText;
51
56
  var options = useMemo(function () {
52
- if (optionsProp) {
57
+ if (optionsProp && Array.isArray(optionsProp)) {
53
58
  return optionsProp.map(function (item) {
54
59
  return _objectSpread(_objectSpread({}, item), {}, {
55
60
  id: item.id || item.label
56
61
  });
57
62
  });
58
63
  }
59
- return [{
64
+ var result = [{
60
65
  label: customDateText,
61
66
  id: '自定义时段',
62
67
  value: function value() {
@@ -105,6 +110,28 @@ function DurationPicker(props) {
105
110
  return [moment().add(-29, 'days').startOf('day'), moment().endOf('day')];
106
111
  }
107
112
  }];
113
+ if (optionsProp === 'year') {
114
+ result.push({
115
+ label: thisQuarterText,
116
+ id: '本季',
117
+ value: function value() {
118
+ return [moment().startOf('quarter'), moment().endOf('quarter')];
119
+ }
120
+ }, {
121
+ label: lastQuarterText,
122
+ id: '上季',
123
+ value: function value() {
124
+ return [moment().add(-1, 'quarters').startOf('quarter'), moment().add(-1, 'quarters').endOf('quarter')];
125
+ }
126
+ }, {
127
+ label: thisYearText,
128
+ id: '今年',
129
+ value: function value() {
130
+ return [moment().startOf('year'), moment().endOf('year')];
131
+ }
132
+ });
133
+ }
134
+ return result;
108
135
  }, [optionsProp]);
109
136
  var defaultDurationPickerValue = useMemo(function () {
110
137
  if (valueProp === undefined) {
@@ -220,6 +247,7 @@ function DurationPicker(props) {
220
247
  item: item
221
248
  };
222
249
  }),
250
+ listHeight: options.length * 32,
223
251
  onSelect: function onSelect(_, opt) {
224
252
  handleChangeOption(opt.item);
225
253
  },
@@ -6,6 +6,9 @@ var locale = {
6
6
  lastWeekText: 'Last Week',
7
7
  thisMonthText: 'This Month',
8
8
  lastMonthText: 'Last Month',
9
- lastThirtyDaysText: 'Last 30 Days'
9
+ lastThirtyDaysText: 'Last 30 Days',
10
+ lastQuarterText: 'Last Quarter',
11
+ thisQuarterText: 'This Quarter',
12
+ thisYearText: 'This Year'
10
13
  };
11
14
  export default locale;
@@ -7,4 +7,7 @@ export interface DurationPickerLocale {
7
7
  thisMonthText: string;
8
8
  lastMonthText: string;
9
9
  lastThirtyDaysText: string;
10
+ thisQuarterText: string;
11
+ lastQuarterText: string;
12
+ thisYearText: string;
10
13
  }
@@ -6,6 +6,9 @@ var locale = {
6
6
  lastWeekText: '上周',
7
7
  thisMonthText: '本月',
8
8
  lastMonthText: '上月',
9
- lastThirtyDaysText: '最近30日'
9
+ lastThirtyDaysText: '最近30日',
10
+ lastQuarterText: '上季',
11
+ thisQuarterText: '本季',
12
+ thisYearText: '今年'
10
13
  };
11
14
  export default locale;
@@ -81,6 +81,7 @@ var getStorageData = function getData(storageKey) {
81
81
  return null;
82
82
  };
83
83
  var setStorageData = function setData(storageKey, data, action) {
84
+ console.log(action);
84
85
  localStorage.setItem("filter-storage-".concat(storageKey), JSON.stringify(data));
85
86
  };
86
87
  var DEFAULT_TAB_ALIAS = '$$default';
@@ -290,7 +291,10 @@ function Filter(originalProps) {
290
291
  break;
291
292
  case 13:
292
293
  if (storageKey) {
293
- setStorageData(storageKey, searches, action);
294
+ setStorageData(storageKey, searches, {
295
+ type: action,
296
+ target: target
297
+ });
294
298
  }
295
299
  case 14:
296
300
  case "end":
package/es/icons/add.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import type { CSSProperties } from 'react';
2
- export default function Add(props: {
3
- className?: string;
4
- style?: CSSProperties;
5
- onClick?: () => void;
6
- }): JSX.Element;
1
+ import type { ComponentProps } from 'react';
2
+ import Icon from '@ant-design/icons';
3
+ export default function Add(props: ComponentProps<typeof Icon>): JSX.Element;
package/es/popup/index.js CHANGED
@@ -256,7 +256,8 @@ function Popup(props) {
256
256
  }
257
257
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
258
258
  className: prefix('wrapper'),
259
- onClick: handleOpen
259
+ onClick: handleOpen,
260
+ role: "button"
260
261
  }, trigger), modalElm);
261
262
  }
262
263
  export default Popup;
@@ -50,6 +50,8 @@ function SelectView(originalProps, _ref4) {
50
50
  readOnly = props.readOnly,
51
51
  _props$header = props.header,
52
52
  headerProp = _props$header === void 0 ? null : _props$header,
53
+ customSelectedGridProps = props.customSelectedGridProps,
54
+ customDataGridProps = props.customDataGridProps,
53
55
  defaultColDef = props.defaultColDef,
54
56
  rowHeight = props.rowHeight,
55
57
  cellDisplayFlex = props.cellDisplayFlex,
@@ -59,10 +61,7 @@ function SelectView(originalProps, _ref4) {
59
61
  customColumnPanelStorage = props.customColumnPanelStorage,
60
62
  _props$suppressRowCli = props.suppressRowClickSelection,
61
63
  suppressRowClickSelection = _props$suppressRowCli === void 0 ? false : _props$suppressRowCli,
62
- _props$rowMultiSelect = props.rowMultiSelectWithClick,
63
- rowMultiSelectWithClick = _props$rowMultiSelect === void 0 ? true : _props$rowMultiSelect,
64
- customSelectedGridProps = props.customSelectedGridProps,
65
- customDataGridProps = props.customDataGridProps;
64
+ rowMultiSelectWithClick = props.rowMultiSelectWithClick;
66
65
  var prefix = prefixClassName("select-view");
67
66
  var _useState = useState(value || emptyValue),
68
67
  _useState2 = _slicedToArray(_useState, 2),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.3.8",
3
+ "version": "1.4.0-alpha.0",
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.3.0",
24
+ "@lemon-fe/hooks": "^1.4.0-alpha.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": "4309f16775ec972984987ea6ff400e520ec98d21"
61
+ "gitHead": "4f4e5c8b423373121fdb38f1ab3e18dc340915d0"
62
62
  }