fis-component 0.1.19 → 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.
package/dist/cjs/index.js CHANGED
@@ -69867,10 +69867,10 @@ const FISCollapse = ({ className, collapseSize = "sm", expandIconPosition = "sta
69867
69867
  });
69868
69868
  }
69869
69869
  };
69870
- const renderHeader = (item, isActive) => {
69870
+ const renderHeader = (item, isActive, hasContent) => {
69871
69871
  const { title, description, badge, leftIcon, customHeader } = item;
69872
69872
  const handleClick = (e) => {
69873
- if (collapsible === "disabled")
69873
+ if (!hasContent || collapsible === "disabled")
69874
69874
  return;
69875
69875
  e.stopPropagation();
69876
69876
  handleToggle(item.key);
@@ -69878,9 +69878,13 @@ const FISCollapse = ({ className, collapseSize = "sm", expandIconPosition = "sta
69878
69878
  const iconComponent = (jsxRuntime.jsx(DivIconWrapperSC, { "$collapseSize": collapseSize, className: isActive ? "open" : "", onClick: collapsible === "icon" ? handleClick : undefined, style: {
69879
69879
  cursor: collapsible === "disabled" ? "not-allowed" : "pointer",
69880
69880
  }, children: jsxRuntime.jsx(CaretIcon, {}) }));
69881
- return (jsxRuntime.jsx("div", { onClick: collapsible === "header" ? handleClick : undefined, style: {
69882
- cursor: collapsible === "disabled" ? "not-allowed" : "pointer",
69883
- }, children: customHeader ? (jsxRuntime.jsxs(DivCustomHeaderSC, { "$collapseSize": collapseSize, children: [expandIconPosition === "start" && iconComponent, jsxRuntime.jsx(DivCustomSC, { children: customHeader }), expandIconPosition === "end" && iconComponent] })) : (jsxRuntime.jsxs(DivHeaderSC, { "$collapseSize": collapseSize, children: [jsxRuntime.jsxs(DivLeftSC, { "$collapseSize": collapseSize, children: [expandIconPosition === "start" && iconComponent, jsxRuntime.jsx(DivLeftIconSC, { "$collapseSize": collapseSize, children: leftIcon ?? jsxRuntime.jsx(CategoryIcon, {}) }), jsxRuntime.jsxs(DivContentSC, { children: [jsxRuntime.jsx(PTitleSC, { "$collapseSize": collapseSize, children: title }), description && (jsxRuntime.jsx(SpanDescriptionSC, { children: description }))] })] }), badge && (jsxRuntime.jsx(FISBadge, { size: badgeSize, label: badge, color: "neutral-light", disabled: collapsible === "disabled" })), expandIconPosition === "end" && iconComponent] })) }));
69881
+ return (jsxRuntime.jsx("div", { onClick: hasContent && collapsible === "header" ? handleClick : undefined, style: {
69882
+ cursor: hasContent
69883
+ ? collapsible === "disabled"
69884
+ ? "not-allowed"
69885
+ : "pointer"
69886
+ : "default",
69887
+ }, children: customHeader ? (jsxRuntime.jsxs(DivCustomHeaderSC, { "$collapseSize": collapseSize, children: [hasContent && expandIconPosition === "start" && iconComponent, jsxRuntime.jsx(DivCustomSC, { children: customHeader }), hasContent && expandIconPosition === "end" && iconComponent] })) : (jsxRuntime.jsxs(DivHeaderSC, { "$collapseSize": collapseSize, children: [jsxRuntime.jsxs(DivLeftSC, { "$collapseSize": collapseSize, children: [hasContent && expandIconPosition === "start" && iconComponent, leftIcon && (jsxRuntime.jsx(DivLeftIconSC, { "$collapseSize": collapseSize, children: leftIcon })), jsxRuntime.jsxs(DivContentSC, { children: [jsxRuntime.jsx(PTitleSC, { "$collapseSize": collapseSize, children: title }), description && (jsxRuntime.jsx(SpanDescriptionSC, { children: description }))] })] }), badge && (jsxRuntime.jsx(FISBadge, { size: badgeSize, label: badge, color: "neutral-light", disabled: collapsible === "disabled" })), hasContent && expandIconPosition === "end" && iconComponent] })) }));
69884
69888
  };
69885
69889
  return (jsxRuntime.jsx(DivContainerSC$3, { className: className, children: jsxRuntime.jsx(StyledCollapse, { ...rest, "$collapseSize": collapseSize, ghost: true, bordered: false, activeKey: activeKeys, expandIcon: () => null, expandIconPosition: expandIconPosition, collapsible: collapsible, onChange: (keys) => {
69886
69890
  if (collapsible === "disabled")
@@ -69893,8 +69897,9 @@ const FISCollapse = ({ className, collapseSize = "sm", expandIconPosition = "sta
69893
69897
  setActiveKeys(Array.isArray(keys) ? keys : [keys]);
69894
69898
  }
69895
69899
  }, children: items.map((item) => {
69896
- const isActive = isActiveKey(item.key);
69897
- return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(Collapse$1.Panel, { header: renderHeader(item, isActive), showArrow: false, children: jsxRuntime.jsx(DivBodySC, { "$collapseSize": collapseSize, children: item.children }) }, item.key), jsxRuntime.jsx(FISDivider, {})] }, item.key));
69900
+ const hasContent = React.Children.count(item.children) > 0;
69901
+ const isActive = hasContent && isActiveKey(item.key);
69902
+ return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(Collapse$1.Panel, { header: renderHeader(item, isActive, hasContent), showArrow: false, collapsible: hasContent ? collapsible : "icon", children: jsxRuntime.jsx(DivBodySC, { "$collapseSize": collapseSize, children: item.children }) }, item.key), jsxRuntime.jsx(FISDivider, {})] }, item.key));
69898
69903
  }) }) }));
69899
69904
  };
69900
69905
 
@@ -75944,7 +75949,13 @@ const SpanTotalSC = styled.span `
75944
75949
  `;
75945
75950
 
75946
75951
  const LIMIT_DEFAULT = 10;
75947
- const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minimize, recordCounted, onIconPageRecordClick, showTotal, ...rest }) => {
75952
+ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minimize, recordCounted, scrollToFirstRowOnChange = true, tableRef, onIconPageRecordClick, showTotal, onChange, onShowSizeChange, ...rest }) => {
75953
+ const scrollToFirstRow = () => {
75954
+ if (scrollToFirstRowOnChange) {
75955
+ tableRef?.current?.scrollTo({ top: 0 });
75956
+ tableRef?.current?.nativeElement.scrollIntoView({ block: "start" });
75957
+ }
75958
+ };
75948
75959
  const rangeRecords = React.useMemo(() => {
75949
75960
  return [
75950
75961
  (current - 1) * pageSize + 1,
@@ -75976,7 +75987,10 @@ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minim
75976
75987
  }
75977
75988
  return originalElement;
75978
75989
  };
75979
- return (jsxRuntime.jsxs(DivPaginationContainer, { children: [jsxRuntime.jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxRuntime.jsxs(DivPaginationContent, { children: [jsxRuntime.jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender }), jsxRuntime.jsx(FISSelect, { style: { width: "100px" }, size: "xs", options: [
75990
+ return (jsxRuntime.jsxs(DivPaginationContainer, { children: [jsxRuntime.jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxRuntime.jsxs(DivPaginationContent, { children: [jsxRuntime.jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender, onChange: (page, size) => {
75991
+ onChange?.(page, size);
75992
+ scrollToFirstRow();
75993
+ } }), jsxRuntime.jsx(FISSelect, { style: { width: "100px" }, size: "xs", options: [
75980
75994
  {
75981
75995
  groupLabel: "",
75982
75996
  items: (rest.pageSizeOptions || [10, 20, 50, 100]).map((size) => ({
@@ -75985,9 +75999,11 @@ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minim
75985
75999
  })),
75986
76000
  },
75987
76001
  ], value: String(pageSize), multi: false, onChange: (value) => {
75988
- if (rest.onShowSizeChange) {
75989
- rest.onShowSizeChange(Number(value), pageSize);
75990
- }
76002
+ const nextPageSize = Number(value);
76003
+ const nextCurrent = Math.min(current, Math.max(1, Math.ceil(total / nextPageSize)));
76004
+ onShowSizeChange?.(nextCurrent, nextPageSize);
76005
+ onChange?.(nextCurrent, nextPageSize);
76006
+ scrollToFirstRow();
75991
76007
  } })] })] }));
75992
76008
  };
75993
76009