fis-component 0.1.20 → 0.1.21

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.
@@ -40,6 +40,17 @@ declare const meta: {
40
40
  defaultValue: boolean;
41
41
  description: string;
42
42
  };
43
+ scrollToFirstRowOnChange: {
44
+ control: {
45
+ type: "boolean";
46
+ };
47
+ defaultValue: boolean;
48
+ description: string;
49
+ };
50
+ tableRef: {
51
+ control: false;
52
+ description: string;
53
+ };
43
54
  onIconPageRecordClick: {
44
55
  action: string;
45
56
  description: string;
@@ -1,8 +1,11 @@
1
1
  import React from "react";
2
2
  import { PaginationProps as AntdPaginationProps } from "antd";
3
+ import type { FISTableRef } from "../Table/Table";
3
4
  export interface PaginationProps extends AntdPaginationProps {
4
5
  minimize?: boolean;
5
6
  recordCounted?: boolean;
7
+ scrollToFirstRowOnChange?: boolean;
8
+ tableRef?: React.RefObject<FISTableRef>;
6
9
  onIconPageRecordClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
7
10
  }
8
11
  declare const FISPagination: React.FC<PaginationProps>;
@@ -1,7 +1,7 @@
1
1
  import type { StoryObj } from "@storybook/react";
2
2
  declare const meta: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<import(".").TableProps & import("react").RefAttributes<HTMLLabelElement>>;
4
+ component: import("react").ForwardRefExoticComponent<import(".").TableProps & import("react").RefAttributes<import("rc-table").Reference>>;
5
5
  tags: string[];
6
6
  args: {
7
7
  className: string;
@@ -38,3 +38,4 @@ type Story = StoryObj<typeof meta>;
38
38
  export declare const Default: Story;
39
39
  export declare const RowSelection: () => import("react/jsx-runtime").JSX.Element;
40
40
  export declare const CompactOperations: () => import("react/jsx-runtime").JSX.Element;
41
+ export declare const WithPagination: () => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,10 @@
1
- import { TableProps as AntdTableProps } from "antd";
1
+ import { Table, TableProps as AntdTableProps } from "antd";
2
2
  export interface TableProps extends Omit<AntdTableProps<any>, "columns" | "dataSource"> {
3
3
  className?: string;
4
4
  dataSource: AntdTableProps<any>["dataSource"];
5
5
  columns: AntdTableProps<any>["columns"];
6
6
  verticalHeader?: "top" | "bottom" | "center";
7
7
  }
8
- declare const FISTable: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<HTMLLabelElement>>;
8
+ export type FISTableRef = React.ElementRef<typeof Table>;
9
+ declare const FISTable: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<import("rc-table").Reference>>;
9
10
  export default FISTable;
@@ -33,6 +33,7 @@ export { default as FISChipButton } from "./components/ChipButton";
33
33
  export { default as FISInputTime } from "./components/Input/InputTime";
34
34
  export { default as FISInputDate } from "./components/Input/InputDate";
35
35
  export { default as FISTable } from "./components/Table/Table";
36
+ export type { FISTableRef, TableProps as FISTableProps, } from "./components/Table/Table";
36
37
  export { default as FISTableHeaderCell } from "./components/Table/HeaderCell";
37
38
  export { default as FISTableCell } from "./components/Table/ColumnCell";
38
39
  export { default as FISSorter } from "./components/Table/Sorter/FISSorter";
@@ -46,4 +47,5 @@ export { default as FISSelectItem } from "./components/SelectItem";
46
47
  export { default as useNotification } from "./components/Notification/useNotification";
47
48
  export { default as useToast } from "./components/Toast/useToast";
48
49
  export { default as FISPagination } from "./components/Pagination";
50
+ export type { PaginationProps as FISPaginationProps, } from "./components/Pagination";
49
51
  export { default as FISText } from "./components/Text";
package/dist/esm/index.js CHANGED
@@ -75929,7 +75929,13 @@ const SpanTotalSC = styled.span `
75929
75929
  `;
75930
75930
 
75931
75931
  const LIMIT_DEFAULT = 10;
75932
- const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minimize, recordCounted, onIconPageRecordClick, showTotal, ...rest }) => {
75932
+ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minimize, recordCounted, scrollToFirstRowOnChange = true, tableRef, onIconPageRecordClick, showTotal, onChange, onShowSizeChange, ...rest }) => {
75933
+ const scrollToFirstRow = () => {
75934
+ if (scrollToFirstRowOnChange) {
75935
+ tableRef?.current?.scrollTo({ top: 0 });
75936
+ tableRef?.current?.nativeElement.scrollIntoView({ block: "start" });
75937
+ }
75938
+ };
75933
75939
  const rangeRecords = useMemo$1(() => {
75934
75940
  return [
75935
75941
  (current - 1) * pageSize + 1,
@@ -75961,7 +75967,10 @@ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minim
75961
75967
  }
75962
75968
  return originalElement;
75963
75969
  };
75964
- return (jsxs(DivPaginationContainer, { children: [jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxs(DivPaginationContent, { children: [jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender }), jsx(FISSelect, { style: { width: "100px" }, size: "xs", options: [
75970
+ return (jsxs(DivPaginationContainer, { children: [jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxs(DivPaginationContent, { children: [jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender, onChange: (page, size) => {
75971
+ onChange?.(page, size);
75972
+ scrollToFirstRow();
75973
+ } }), jsx(FISSelect, { style: { width: "100px" }, size: "xs", options: [
75965
75974
  {
75966
75975
  groupLabel: "",
75967
75976
  items: (rest.pageSizeOptions || [10, 20, 50, 100]).map((size) => ({
@@ -75970,9 +75979,11 @@ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minim
75970
75979
  })),
75971
75980
  },
75972
75981
  ], value: String(pageSize), multi: false, onChange: (value) => {
75973
- if (rest.onShowSizeChange) {
75974
- rest.onShowSizeChange(Number(value), pageSize);
75975
- }
75982
+ const nextPageSize = Number(value);
75983
+ const nextCurrent = Math.min(current, Math.max(1, Math.ceil(total / nextPageSize)));
75984
+ onShowSizeChange?.(nextCurrent, nextPageSize);
75985
+ onChange?.(nextCurrent, nextPageSize);
75986
+ scrollToFirstRow();
75976
75987
  } })] })] }));
75977
75988
  };
75978
75989