@pisell/materials 2.2.11 → 2.2.13

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,5 +1,5 @@
1
- import React from "react";
2
- import { SortListProps } from "./types";
3
- import "./index.less";
1
+ import React from 'react';
2
+ import { SortListProps } from './types';
3
+ import './index.less';
4
4
  declare const Sort: React.FC<SortListProps>;
5
5
  export default Sort;
@@ -2,16 +2,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2
2
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
3
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
4
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
- import React, { useMemo } from "react";
6
- import { Button, Dropdown, Popover } from "antd";
7
- import classNames from "classnames";
8
- import { CheckOutlined } from "@ant-design/icons";
9
- import SwitchVertical01 from "@pisell/icon/es/SwitchVertical01";
5
+ import React, { useMemo } from 'react';
6
+ import { Button, Dropdown, Popover } from 'antd';
7
+ import classNames from 'classnames';
8
+ import { CheckOutlined } from '@ant-design/icons';
9
+ import SwitchVertical01 from '@pisell/icon/es/SwitchVertical01';
10
10
  import { isMobile } from "../../utils/platform";
11
11
  import { getText } from "../../locales";
12
12
  import InlineMenu from "./components/InlineMenu";
13
13
  import "./index.less";
14
- var prefix = "pisell-lowcode-";
14
+ var prefix = 'pisell-lowcode-';
15
15
  var Label = function Label(_ref) {
16
16
  var content = _ref.content;
17
17
  return /*#__PURE__*/React.createElement("div", {
@@ -21,53 +21,53 @@ var Label = function Label(_ref) {
21
21
  var sortChildrenMap = {
22
22
  date: function date(key, isLocal) {
23
23
  return [{
24
- key: "".concat(key, ":desc").concat(isLocal ? ":date" : ""),
24
+ key: "".concat(key, ":asc").concat(isLocal ? ':date' : ''),
25
25
  label: /*#__PURE__*/React.createElement(Label, {
26
- content: getText("sort-oldest-to-newest")
26
+ content: getText('sort-oldest-to-newest')
27
27
  })
28
28
  }, {
29
- key: "".concat(key, ":asc").concat(isLocal ? ":date" : ""),
29
+ key: "".concat(key, ":desc").concat(isLocal ? ':date' : ''),
30
30
  label: /*#__PURE__*/React.createElement(Label, {
31
- content: getText("sort-newest-to-oldest")
31
+ content: getText('sort-newest-to-oldest')
32
32
  })
33
33
  }];
34
34
  },
35
35
  time: function time(key, isLocal) {
36
36
  return [{
37
- key: "".concat(key, ":desc").concat(isLocal ? ":time" : ""),
37
+ key: "".concat(key, ":desc").concat(isLocal ? ':time' : ''),
38
38
  label: /*#__PURE__*/React.createElement(Label, {
39
- content: getText("sort-from-morning-to-night")
39
+ content: getText('sort-from-morning-to-night')
40
40
  })
41
41
  }, {
42
- key: "".concat(key, ":asc").concat(isLocal ? ":time" : ""),
42
+ key: "".concat(key, ":asc").concat(isLocal ? ':time' : ''),
43
43
  label: /*#__PURE__*/React.createElement(Label, {
44
- content: getText("sort-from-evening-to-morning")
44
+ content: getText('sort-from-evening-to-morning')
45
45
  })
46
46
  }];
47
47
  },
48
48
  string: function string(key, isLocal) {
49
49
  return [{
50
- key: "".concat(key, ":asc").concat(isLocal ? ":string" : ""),
50
+ key: "".concat(key, ":asc").concat(isLocal ? ':string' : ''),
51
51
  label: /*#__PURE__*/React.createElement(Label, {
52
- content: getText("sort-a-z")
52
+ content: getText('sort-a-z')
53
53
  })
54
54
  }, {
55
- key: "".concat(key, ":desc").concat(isLocal ? ":string" : ""),
55
+ key: "".concat(key, ":desc").concat(isLocal ? ':string' : ''),
56
56
  label: /*#__PURE__*/React.createElement(Label, {
57
- content: getText("sort-z-a")
57
+ content: getText('sort-z-a')
58
58
  })
59
59
  }];
60
60
  },
61
61
  number: function number(key, isLocal) {
62
62
  return [{
63
- key: "".concat(key, ":asc").concat(isLocal ? ":number" : ""),
63
+ key: "".concat(key, ":asc").concat(isLocal ? ':number' : ''),
64
64
  label: /*#__PURE__*/React.createElement(Label, {
65
- content: getText("sort-0-9")
65
+ content: getText('sort-0-9')
66
66
  })
67
67
  }, {
68
- key: "".concat(key, ":desc").concat(isLocal ? ":number" : ""),
68
+ key: "".concat(key, ":desc").concat(isLocal ? ':number' : ''),
69
69
  label: /*#__PURE__*/React.createElement(Label, {
70
- content: getText("sort-9-0")
70
+ content: getText('sort-9-0')
71
71
  })
72
72
  }];
73
73
  }
@@ -89,14 +89,14 @@ var Sort = function Sort(_ref2) {
89
89
  children: sortChildrenMap[d.type](d.name, !!(d !== null && d !== void 0 && d.localFilter)),
90
90
  popupClassName: "".concat(prefix, "sort-sub-menu-popup-wrap"),
91
91
  // 增加显示隐藏配置
92
- className: "".concat(d.isHidden ? "".concat(prefix, "sort-menu-wrap-hide") : "")
92
+ className: "".concat(d.isHidden ? "".concat(prefix, "sort-menu-wrap-hide") : '')
93
93
  };
94
94
  });
95
95
  }, [list, localPagination]);
96
96
  var onClick = function onClick(detail) {
97
97
  var _detail$keyPath, _detail$keyPath2;
98
98
  if (((_detail$keyPath = detail.keyPath) === null || _detail$keyPath === void 0 ? void 0 : _detail$keyPath[0]) === value) {
99
- onChange === null || onChange === void 0 ? void 0 : onChange("", detail);
99
+ onChange === null || onChange === void 0 ? void 0 : onChange('', detail);
100
100
  return;
101
101
  }
102
102
  onChange === null || onChange === void 0 ? void 0 : onChange(detail === null || detail === void 0 ? void 0 : (_detail$keyPath2 = detail.keyPath) === null || _detail$keyPath2 === void 0 ? void 0 : _detail$keyPath2[0], detail);
@@ -108,12 +108,12 @@ var Sort = function Sort(_ref2) {
108
108
  style: style,
109
109
  className: classNames(_defineProperty({}, "".concat(prefix, "sort-button-active"), !!value)),
110
110
  size: "large"
111
- }, isMobileBool ? null : getText("sort-button-text"));
111
+ }, isMobileBool ? null : getText('sort-button-text'));
112
112
  }, [button, style, value, isMobileBool]);
113
113
  var content = useMemo(function () {
114
114
  return /*#__PURE__*/React.createElement(InlineMenu, {
115
115
  items: sortItems,
116
- value: value || "",
116
+ value: value || '',
117
117
  onChange: onChange
118
118
  });
119
119
  }, [value, sortItems, onChange]);
@@ -123,11 +123,11 @@ var Sort = function Sort(_ref2) {
123
123
  content: content,
124
124
  arrow: false,
125
125
  overlayClassName: "".concat(prefix, "mobile-sort-overlay"),
126
- trigger: ["click"]
126
+ trigger: ['click']
127
127
  }, btnContent);
128
128
  }
129
129
  return /*#__PURE__*/React.createElement(Dropdown, {
130
- trigger: ["click"],
130
+ trigger: ['click'],
131
131
  placement: placement,
132
132
  menu: {
133
133
  items: sortItems,
@@ -1,4 +1,4 @@
1
- import { TableProps } from "antd";
2
- import React from "react";
1
+ import { TableProps } from 'antd';
2
+ import React from 'react';
3
3
  declare const BasicTable: (props: TableProps<any>) => React.JSX.Element;
4
4
  export default BasicTable;
@@ -14,13 +14,13 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
14
14
  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
- import { Table, Form } from "antd";
18
- import React, { useState, useMemo, useCallback, useEffect } from "react";
17
+ import { Table, Form } from 'antd';
18
+ import React, { useState, useMemo, useCallback, useEffect } from 'react';
19
19
  import { FormPagination } from "../../Pagination";
20
20
  import { calcFilterSort } from "../Table/utils";
21
21
  import { useSharedState } from "../../../hooks";
22
22
  import { Context } from "../model";
23
- import { isArr } from "@pisell/utils";
23
+ import { isArr } from '@pisell/utils';
24
24
  var BasicTable = function BasicTable(props) {
25
25
  var _pagination$pageSizeO;
26
26
  var dataSource = props.dataSource,
@@ -37,14 +37,14 @@ var BasicTable = function BasicTable(props) {
37
37
  sort = _useState4[0],
38
38
  setSort = _useState4[1];
39
39
  var form = Form.useFormInstance();
40
- var formPagination = Form.useWatch("pagination", {
40
+ var formPagination = Form.useWatch('pagination', {
41
41
  form: form,
42
42
  preserve: true
43
43
  }) || {
44
44
  page: 1,
45
45
  size: 10
46
46
  };
47
- var group = Form.useWatch("group_by", {
47
+ var group = Form.useWatch('group_by', {
48
48
  form: form,
49
49
  preserve: true
50
50
  });
@@ -84,6 +84,7 @@ var BasicTable = function BasicTable(props) {
84
84
  total: _total
85
85
  };
86
86
  }, [localPagination, dataSource, formPagination === null || formPagination === void 0 ? void 0 : formPagination.page, formPagination === null || formPagination === void 0 ? void 0 : formPagination.size, filter, sort, other.columns]);
87
+ console.log(pagination, 'wh8888');
87
88
 
88
89
  // 总数
89
90
  var total = useMemo(function () {
@@ -99,19 +100,19 @@ var BasicTable = function BasicTable(props) {
99
100
  var _expandedRowKeys = [];
100
101
  _dataSource === null || _dataSource === void 0 ? void 0 : (_dataSource$list = _dataSource.list) === null || _dataSource$list === void 0 ? void 0 : _dataSource$list.forEach(function (item) {
101
102
  if (item.__is_group) {
102
- _expandedRowKeys.push(item["__rowKey"]);
103
+ _expandedRowKeys.push(item['__rowKey']);
103
104
  }
104
105
  });
105
106
  return _expandedRowKeys;
106
107
  }, [_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list]);
107
108
  useEffect(function () {
108
109
  dispatch({
109
- type: "setCurrentDataSource",
110
+ type: 'setCurrentDataSource',
110
111
  payload: (_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list) || []
111
112
  });
112
113
  }, [_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list]);
113
114
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Table, _extends({
114
- key: defaultExpandedRowKeys.join("-")
115
+ key: defaultExpandedRowKeys.join('-')
115
116
  }, other, {
116
117
  // 开启分组条件后关闭行选择功能
117
118
  rowSelection: isGroup ? false : other === null || other === void 0 ? void 0 : other.rowSelection,
@@ -132,13 +133,13 @@ var BasicTable = function BasicTable(props) {
132
133
  return _objectSpread(_objectSpread({}, (other === null || other === void 0 ? void 0 : (_other$onRow = other.onRow) === null || _other$onRow === void 0 ? void 0 : _other$onRow.call(other, record, index)) || {}), {}, {
133
134
  __is_group: record.__is_group,
134
135
  __is_drag_sort: other.dragSort,
135
- className: record.__is_group ? "pisell-lowcode-table-group-row-wrap" : ""
136
+ className: record.__is_group ? 'pisell-lowcode-table-group-row-wrap' : ''
136
137
  });
137
138
  },
138
139
  expandable: {
139
140
  defaultExpandAllRows: true
140
141
  }
141
- })), total > ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || (pagination === null || pagination === void 0 ? void 0 : (_pagination$pageSizeO = pagination.pageSizeOptions) === null || _pagination$pageSizeO === void 0 ? void 0 : _pagination$pageSizeO[0]) || 10) ? /*#__PURE__*/React.createElement(Form.Item, {
142
+ })), total > ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || (pagination === null || pagination === void 0 ? void 0 : (_pagination$pageSizeO = pagination.pageSizeOptions) === null || _pagination$pageSizeO === void 0 ? void 0 : _pagination$pageSizeO[0]) || 10) || pagination !== null && pagination !== void 0 && pagination.showPagination && total > 10 ? /*#__PURE__*/React.createElement(Form.Item, {
142
143
  name: "pagination"
143
144
  }, /*#__PURE__*/React.createElement(FormPagination, _extends({}, pagination, {
144
145
  showTotal: _showTotal,
@@ -181,7 +181,7 @@ export var sortDataSource = function sortDataSource(dataSource, sortObj) {
181
181
  }
182
182
  // 对比日期排序
183
183
  if (sortType === "date") {
184
- if (sortValue === "asc") {
184
+ if (sortValue !== "asc") {
185
185
  return new Date(bValue).getTime() - new Date(aValue).getTime();
186
186
  }
187
187
  return new Date(aValue).getTime() - new Date(bValue).getTime();
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { SortListProps } from "./types";
3
- import "./index.less";
1
+ import React from 'react';
2
+ import { SortListProps } from './types';
3
+ import './index.less';
4
4
  declare const Sort: React.FC<SortListProps>;
5
5
  export default Sort;
@@ -48,11 +48,11 @@ var Label = ({ content }) => {
48
48
  var sortChildrenMap = {
49
49
  date: (key, isLocal) => [
50
50
  {
51
- key: `${key}:desc${isLocal ? ":date" : ""}`,
51
+ key: `${key}:asc${isLocal ? ":date" : ""}`,
52
52
  label: /* @__PURE__ */ import_react.default.createElement(Label, { content: (0, import_locales.getText)("sort-oldest-to-newest") })
53
53
  },
54
54
  {
55
- key: `${key}:asc${isLocal ? ":date" : ""}`,
55
+ key: `${key}:desc${isLocal ? ":date" : ""}`,
56
56
  label: /* @__PURE__ */ import_react.default.createElement(Label, { content: (0, import_locales.getText)("sort-newest-to-oldest") })
57
57
  }
58
58
  ],
@@ -1,4 +1,4 @@
1
- import { TableProps } from "antd";
2
- import React from "react";
1
+ import { TableProps } from 'antd';
2
+ import React from 'react';
3
3
  declare const BasicTable: (props: TableProps<any>) => React.JSX.Element;
4
4
  export default BasicTable;
@@ -45,7 +45,10 @@ var BasicTable = (props) => {
45
45
  const [filter, setFilter] = (0, import_react.useState)();
46
46
  const [sort, setSort] = (0, import_react.useState)();
47
47
  const form = import_antd.Form.useFormInstance();
48
- const formPagination = import_antd.Form.useWatch("pagination", { form, preserve: true }) || {
48
+ const formPagination = import_antd.Form.useWatch("pagination", {
49
+ form,
50
+ preserve: true
51
+ }) || {
49
52
  page: 1,
50
53
  size: 10
51
54
  };
@@ -90,6 +93,7 @@ var BasicTable = (props) => {
90
93
  sort,
91
94
  other.columns
92
95
  ]);
96
+ console.log(pagination, "wh8888");
93
97
  const total = (0, import_react.useMemo)(() => {
94
98
  if (localPagination) {
95
99
  return (_dataSource == null ? void 0 : _dataSource.total) || 0;
@@ -144,7 +148,7 @@ var BasicTable = (props) => {
144
148
  defaultExpandAllRows: true
145
149
  }
146
150
  }
147
- ), total > ((pagination == null ? void 0 : pagination.pageSize) || ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) || 10) ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "pagination" }, /* @__PURE__ */ import_react.default.createElement(
151
+ ), total > ((pagination == null ? void 0 : pagination.pageSize) || ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) || 10) || (pagination == null ? void 0 : pagination.showPagination) && total > 10 ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "pagination" }, /* @__PURE__ */ import_react.default.createElement(
148
152
  import_Pagination.FormPagination,
149
153
  {
150
154
  ...pagination,
@@ -193,7 +193,7 @@ var sortDataSource = (dataSource, sortObj) => {
193
193
  return bValue == null ? void 0 : bValue.localeCompare(aValue);
194
194
  }
195
195
  if (sortType2 === "date") {
196
- if (sortValue === "asc") {
196
+ if (sortValue !== "asc") {
197
197
  return new Date(bValue).getTime() - new Date(aValue).getTime();
198
198
  }
199
199
  return new Date(aValue).getTime() - new Date(bValue).getTime();
@@ -932,6 +932,20 @@ export default {
932
932
  value: 'target => !!target.getProps().getPropValue("pagination")',
933
933
  },
934
934
  },
935
+ {
936
+ name: "pagination.showPagination",
937
+ title: {
938
+ label: "始终显示分页",
939
+ tip: "pagination.showPagination | 当前数据总数大于10 则始终显示分页器",
940
+ },
941
+ propType: "bool",
942
+ setter: "BoolSetter",
943
+ defaultValue: false,
944
+ condition: {
945
+ type: "JSFunction",
946
+ value: 'target => !!target.getProps().getPropValue("pagination")',
947
+ },
948
+ },
935
949
  {
936
950
  name: "pagination.showTotal",
937
951
  title: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "2.2.11",
3
+ "version": "2.2.13",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -61,9 +61,9 @@
61
61
  "react-window": "^1.8.10",
62
62
  "react-virtualized-auto-sizer": "^1.0.20",
63
63
  "crypto-js": "^4.2.0",
64
- "@pisell/utils": "1.0.25",
65
- "@pisell/date-picker": "1.0.87",
66
- "@pisell/icon": "0.0.11"
64
+ "@pisell/utils": "1.0.27",
65
+ "@pisell/icon": "0.0.11",
66
+ "@pisell/date-picker": "1.0.92"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react": "^18.0.0",