@donglegeyu/company-ui 1.2.33 → 1.2.34

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.
@@ -260,6 +260,7 @@ function SmartListTemplate({
260
260
  width: field.width || 120,
261
261
  fixed: field.fixed,
262
262
  ellipsis: enableEllipsis,
263
+ sorter: field.sortable === true ? true : void 0,
263
264
  render: (_, record) => {
264
265
  const customContent = bodyCell ? bodyCell({ ...field, key: field.key }, record) : null;
265
266
  if (customContent !== null) {
@@ -566,8 +567,14 @@ function SmartListTemplate({
566
567
  [onChange]
567
568
  );
568
569
  const handleTableChange = (0, import_react.useCallback)(
569
- (_pagination) => {
570
- onChange == null ? void 0 : onChange(_pagination);
570
+ (_pagination, _filters, sorter) => {
571
+ const sortInfo = Array.isArray(sorter) ? sorter[0] : sorter;
572
+ const sortField = sortInfo == null ? void 0 : sortInfo.field;
573
+ const sortOrder = sortInfo == null ? void 0 : sortInfo.order;
574
+ onChange == null ? void 0 : onChange({
575
+ sortField,
576
+ sortOrder
577
+ });
571
578
  },
572
579
  [onChange]
573
580
  );
@@ -31,7 +31,7 @@ export interface FilterItem {
31
31
  export interface DisplayItem {
32
32
  key: string;
33
33
  label?: string;
34
- type: 'item' | 'button';
34
+ type: "item" | "button";
35
35
  inputType?: string;
36
36
  placeholder?: string | string[];
37
37
  options?: {
@@ -42,16 +42,18 @@ export interface DisplayItem {
42
42
  export interface FieldDefinition {
43
43
  key: string;
44
44
  label: string;
45
- type?: 'input' | 'select' | 'date' | 'daterange' | 'item';
45
+ type?: "input" | "select" | "date" | "daterange" | "item";
46
46
  placeholder?: string;
47
47
  options?: {
48
48
  label: string;
49
49
  value: string | number;
50
50
  }[];
51
51
  width?: number;
52
- fixed?: 'left' | 'right';
52
+ fixed?: "left" | "right";
53
53
  ellipsis?: boolean;
54
54
  hideInFilter?: boolean;
55
+ /** 是否支持列排序(表头显示排序按钮)。默认 false */
56
+ sortable?: boolean;
55
57
  }
56
58
  export interface PaginationConfig {
57
59
  current: number;
@@ -335,6 +335,7 @@ export default function SmartListTemplate(_ref) {
335
335
  width: field.width || 120,
336
336
  fixed: field.fixed,
337
337
  ellipsis: enableEllipsis,
338
+ sorter: field.sortable === true ? true : undefined,
338
339
  render: function render(_, record) {
339
340
  var customContent = bodyCell ? bodyCell(_objectSpread(_objectSpread({}, field), {}, {
340
341
  key: field.key
@@ -797,8 +798,14 @@ export default function SmartListTemplate(_ref) {
797
798
  var handleFilterChange = useCallback(function (data) {
798
799
  onChange === null || onChange === void 0 || onChange(data);
799
800
  }, [onChange]);
800
- var handleTableChange = useCallback(function (_pagination) {
801
- onChange === null || onChange === void 0 || onChange(_pagination);
801
+ var handleTableChange = useCallback(function (_pagination, _filters, sorter) {
802
+ var sortInfo = Array.isArray(sorter) ? sorter[0] : sorter;
803
+ var sortField = sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.field;
804
+ var sortOrder = sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.order;
805
+ onChange === null || onChange === void 0 || onChange({
806
+ sortField: sortField,
807
+ sortOrder: sortOrder
808
+ });
802
809
  }, [onChange]);
803
810
  var handlePageChange = useCallback(function (page, pageSize) {
804
811
  setPaginationConfig({
@@ -31,7 +31,7 @@ export interface FilterItem {
31
31
  export interface DisplayItem {
32
32
  key: string;
33
33
  label?: string;
34
- type: 'item' | 'button';
34
+ type: "item" | "button";
35
35
  inputType?: string;
36
36
  placeholder?: string | string[];
37
37
  options?: {
@@ -42,16 +42,18 @@ export interface DisplayItem {
42
42
  export interface FieldDefinition {
43
43
  key: string;
44
44
  label: string;
45
- type?: 'input' | 'select' | 'date' | 'daterange' | 'item';
45
+ type?: "input" | "select" | "date" | "daterange" | "item";
46
46
  placeholder?: string;
47
47
  options?: {
48
48
  label: string;
49
49
  value: string | number;
50
50
  }[];
51
51
  width?: number;
52
- fixed?: 'left' | 'right';
52
+ fixed?: "left" | "right";
53
53
  ellipsis?: boolean;
54
54
  hideInFilter?: boolean;
55
+ /** 是否支持列排序(表头显示排序按钮)。默认 false */
56
+ sortable?: boolean;
55
57
  }
56
58
  export interface PaginationConfig {
57
59
  current: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donglegeyu/company-ui",
3
- "version": "1.2.33",
3
+ "version": "1.2.34",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",