@farmzone/fz-react-ui 1.0.15 → 1.0.17
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/index.cjs +20 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -331,7 +331,7 @@ interface PaginationProps {
|
|
|
331
331
|
onPageChange?: (page: number) => void;
|
|
332
332
|
showTotalCount?: boolean;
|
|
333
333
|
}
|
|
334
|
-
declare function Pagination(props: PaginationProps): react.JSX.Element
|
|
334
|
+
declare function Pagination(props: PaginationProps): react.JSX.Element;
|
|
335
335
|
|
|
336
336
|
type BreadCrumbItem = {
|
|
337
337
|
label: string;
|
|
@@ -652,6 +652,7 @@ interface Column<T> {
|
|
|
652
652
|
sortable?: boolean;
|
|
653
653
|
sort?: "asc" | "desc" | null;
|
|
654
654
|
fixed?: TableFixed;
|
|
655
|
+
tooltipText?: (value: unknown, record: T, index: number) => ReactNode;
|
|
655
656
|
}
|
|
656
657
|
|
|
657
658
|
interface CheckboxInfo {
|
|
@@ -970,6 +971,7 @@ type SelectOption<P> = BaseOption<P> & {
|
|
|
970
971
|
placeholder?: string;
|
|
971
972
|
containerClassName?: string;
|
|
972
973
|
canReset?: boolean;
|
|
974
|
+
autoSubmit?: boolean;
|
|
973
975
|
};
|
|
974
976
|
type RadioOption<P> = BaseOption<P> & {
|
|
975
977
|
type: "radio";
|
package/dist/index.d.ts
CHANGED
|
@@ -331,7 +331,7 @@ interface PaginationProps {
|
|
|
331
331
|
onPageChange?: (page: number) => void;
|
|
332
332
|
showTotalCount?: boolean;
|
|
333
333
|
}
|
|
334
|
-
declare function Pagination(props: PaginationProps): react.JSX.Element
|
|
334
|
+
declare function Pagination(props: PaginationProps): react.JSX.Element;
|
|
335
335
|
|
|
336
336
|
type BreadCrumbItem = {
|
|
337
337
|
label: string;
|
|
@@ -652,6 +652,7 @@ interface Column<T> {
|
|
|
652
652
|
sortable?: boolean;
|
|
653
653
|
sort?: "asc" | "desc" | null;
|
|
654
654
|
fixed?: TableFixed;
|
|
655
|
+
tooltipText?: (value: unknown, record: T, index: number) => ReactNode;
|
|
655
656
|
}
|
|
656
657
|
|
|
657
658
|
interface CheckboxInfo {
|
|
@@ -970,6 +971,7 @@ type SelectOption<P> = BaseOption<P> & {
|
|
|
970
971
|
placeholder?: string;
|
|
971
972
|
containerClassName?: string;
|
|
972
973
|
canReset?: boolean;
|
|
974
|
+
autoSubmit?: boolean;
|
|
973
975
|
};
|
|
974
976
|
type RadioOption<P> = BaseOption<P> & {
|
|
975
977
|
type: "radio";
|
package/dist/index.js
CHANGED
|
@@ -1397,7 +1397,8 @@ function getVisiblePageRange(currentPage, totalPages) {
|
|
|
1397
1397
|
return { start, end };
|
|
1398
1398
|
}
|
|
1399
1399
|
function Pagination(props) {
|
|
1400
|
-
const { page = 0, totalPages =
|
|
1400
|
+
const { page = 0, totalPages: rawTotalPages = 0, onPageChange } = props;
|
|
1401
|
+
const totalPages = Math.max(1, rawTotalPages);
|
|
1401
1402
|
const [displayPage, setDisplayPage] = useState(page);
|
|
1402
1403
|
useEffect(() => {
|
|
1403
1404
|
setDisplayPage(page);
|
|
@@ -1409,6 +1410,7 @@ function Pagination(props) {
|
|
|
1409
1410
|
},
|
|
1410
1411
|
[onPageChange]
|
|
1411
1412
|
);
|
|
1413
|
+
const isEmpty = rawTotalPages === 0;
|
|
1412
1414
|
const pageButtons = useMemo(() => {
|
|
1413
1415
|
const { start, end } = getVisiblePageRange(displayPage, totalPages);
|
|
1414
1416
|
const buttons = [];
|
|
@@ -1420,9 +1422,10 @@ function Pagination(props) {
|
|
|
1420
1422
|
"button",
|
|
1421
1423
|
{
|
|
1422
1424
|
type: "button",
|
|
1425
|
+
disabled: isEmpty,
|
|
1423
1426
|
className: cn(
|
|
1424
|
-
"min-w-7 min-h-7 rounded-[4px] text-[14px] px-[5px] font-medium
|
|
1425
|
-
isActive ? "bg-[#2675e2] text-white font-bold" : "bg-white text-[#000000] font-normal hover:bg-gray-50"
|
|
1427
|
+
"min-w-7 min-h-7 rounded-[4px] text-[14px] px-[5px] font-medium",
|
|
1428
|
+
isEmpty ? "bg-[#2675e2] text-white font-bold cursor-default" : isActive ? "bg-[#2675e2] text-white font-bold cursor-pointer" : "bg-white text-[#000000] font-normal hover:bg-gray-50 cursor-pointer"
|
|
1426
1429
|
),
|
|
1427
1430
|
onClick: () => handlePageChange(pageIndex),
|
|
1428
1431
|
children: displayPageNumber
|
|
@@ -1432,7 +1435,7 @@ function Pagination(props) {
|
|
|
1432
1435
|
);
|
|
1433
1436
|
}
|
|
1434
1437
|
return buttons;
|
|
1435
|
-
}, [displayPage, totalPages, handlePageChange]);
|
|
1438
|
+
}, [displayPage, totalPages, handlePageChange, isEmpty]);
|
|
1436
1439
|
const isFirstDisabled = displayPage <= 0;
|
|
1437
1440
|
const isPreviousDisabled = displayPage <= 0;
|
|
1438
1441
|
const isNextDisabled = displayPage >= totalPages - 1;
|
|
@@ -1452,9 +1455,6 @@ function Pagination(props) {
|
|
|
1452
1455
|
children
|
|
1453
1456
|
}
|
|
1454
1457
|
);
|
|
1455
|
-
if (!totalPages || totalPages === 0) {
|
|
1456
|
-
return null;
|
|
1457
|
-
}
|
|
1458
1458
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1.5", children: [
|
|
1459
1459
|
renderNavButton(
|
|
1460
1460
|
() => handlePageChange(0),
|
|
@@ -2794,7 +2794,7 @@ function DatePickerSingle(props) {
|
|
|
2794
2794
|
"div",
|
|
2795
2795
|
{
|
|
2796
2796
|
role: "button",
|
|
2797
|
-
tabIndex:
|
|
2797
|
+
tabIndex: -1,
|
|
2798
2798
|
"aria-hidden": disabled,
|
|
2799
2799
|
onClick: () => {
|
|
2800
2800
|
if (!disabled) toggleCalendar(inputValue);
|
|
@@ -4706,7 +4706,13 @@ function Table(props) {
|
|
|
4706
4706
|
showHorizontalDivider = true,
|
|
4707
4707
|
showVerticalDivider = true
|
|
4708
4708
|
} = props;
|
|
4709
|
-
const {
|
|
4709
|
+
const {
|
|
4710
|
+
fixed = false,
|
|
4711
|
+
onSelectionChange,
|
|
4712
|
+
selectedKeys = [],
|
|
4713
|
+
disabledKeys = [],
|
|
4714
|
+
disabledTooltip
|
|
4715
|
+
} = checkboxInfo ?? {};
|
|
4710
4716
|
const scrollRef = useRef(null);
|
|
4711
4717
|
const footerRef = useRef(null);
|
|
4712
4718
|
const [tableHeight, setTableHeight] = useState(500);
|
|
@@ -5095,7 +5101,7 @@ function Table(props) {
|
|
|
5095
5101
|
TableCellContent,
|
|
5096
5102
|
{
|
|
5097
5103
|
cellContent,
|
|
5098
|
-
tooltipText: String(record[col.key] ?? ""),
|
|
5104
|
+
tooltipText: col.tooltipText ? col.tooltipText(record[col.key], record, rowIdx) : String(record[col.key] ?? ""),
|
|
5099
5105
|
align: align ?? "",
|
|
5100
5106
|
tooltipConfig: col.key === "__checkbox__" ? false : tooltipConfig,
|
|
5101
5107
|
onCellClick: col.key !== "__checkbox__" && onRowClickRef.current ? () => onRowClickRef.current?.(record, rowIdx) : void 0
|
|
@@ -5228,7 +5234,7 @@ function Table(props) {
|
|
|
5228
5234
|
] })
|
|
5229
5235
|
}
|
|
5230
5236
|
),
|
|
5231
|
-
!
|
|
5237
|
+
!showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsx(
|
|
5232
5238
|
TableFooter,
|
|
5233
5239
|
{
|
|
5234
5240
|
paginationInfo,
|
|
@@ -7747,8 +7753,9 @@ function PageFilter(props) {
|
|
|
7747
7753
|
const handleInputChange = (key) => (e) => {
|
|
7748
7754
|
onChange({ [key]: e.target.value });
|
|
7749
7755
|
};
|
|
7750
|
-
const handleSelectChange = (key) => (value) => {
|
|
7756
|
+
const handleSelectChange = (key, autoSubmit) => (value) => {
|
|
7751
7757
|
onChange({ [key]: value });
|
|
7758
|
+
if (autoSubmit) onSubmit();
|
|
7752
7759
|
};
|
|
7753
7760
|
const handleRadioChange = (key) => (value) => {
|
|
7754
7761
|
onChange({ [key]: value });
|
|
@@ -7791,7 +7798,7 @@ function PageFilter(props) {
|
|
|
7791
7798
|
Select2,
|
|
7792
7799
|
{
|
|
7793
7800
|
value: currentValue,
|
|
7794
|
-
onChange: handleSelectChange(optionKey),
|
|
7801
|
+
onChange: handleSelectChange(optionKey, option.autoSubmit),
|
|
7795
7802
|
options: option.options,
|
|
7796
7803
|
placeholder: option.placeholder || "\uC120\uD0DD",
|
|
7797
7804
|
canReset: option.canReset ?? true,
|