@farmzone/fz-react-ui 1.0.6 → 1.0.8

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 CHANGED
@@ -248,7 +248,7 @@ function TooltipContent({
248
248
  var Z_INDEX = {
249
249
  TABLE_COL_STICKY: 1,
250
250
  TABLE_FIXED_CELL: 5,
251
- TABLE_FIXED_HEADER_CELL: 10,
251
+ TABLE_FIXED_HEADER_CELL: 15,
252
252
  LOCAL_OVERLAY: 10,
253
253
  LAYOUT_HEADER: 20,
254
254
  DROPDOWN_LOCAL: 20,
@@ -499,12 +499,10 @@ function Input2(props) {
499
499
  const actualType = type === "password" && showPassword ? "text" : type;
500
500
  const handlePasswordToggle = () => setShowPassword((prev) => !prev);
501
501
  const finalRightIcon = rightIcon || (shouldShowPasswordToggle ? /* @__PURE__ */ jsxRuntime.jsx(
502
- "button",
502
+ "div",
503
503
  {
504
- type: "button",
505
504
  onClick: handlePasswordToggle,
506
505
  className: "text-muted-foreground hover:text-foreground cursor-pointer transition-colors",
507
- disabled,
508
506
  children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-4 w-4" })
509
507
  }
510
508
  ) : null);
@@ -3753,7 +3751,7 @@ function confirmModal(options) {
3753
3751
  }
3754
3752
  function TableFooter(props) {
3755
3753
  const { paginationInfo, renderLeft, renderRight } = props;
3756
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between py-4 min-h-16", children: [
3754
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between py-4 min-h-16 border-t-1 border-gray-100", children: [
3757
3755
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-start flex-1 min-w-0", children: renderLeft }),
3758
3756
  paginationInfo && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5", children: /* @__PURE__ */ jsxRuntime.jsx(Pagination, { ...paginationInfo }) }),
3759
3757
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end flex-1 min-w-0", children: renderRight })
@@ -3963,8 +3961,6 @@ function ArrowIcon(props) {
3963
3961
  }
3964
3962
  );
3965
3963
  }
3966
- var DEFAULT_SORT_KEY = "";
3967
- var DEFAULT_SORT_ORDER = "asc";
3968
3964
  var DEFAULT_SORT_OPTIONS = {
3969
3965
  visibleType: "always",
3970
3966
  sortKey: "",
@@ -4013,27 +4009,18 @@ function TableHeader(props) {
4013
4009
  if (onSortChange) {
4014
4010
  const isActive = sortOption?.sortKey === columnKey;
4015
4011
  const currentOrder = sortOption?.sortOrder;
4016
- if (isActive) {
4017
- if (currentOrder === "desc") {
4018
- onSortChange(columnKey, "asc");
4019
- } else if (currentOrder === "asc") {
4020
- onSortChange(DEFAULT_SORT_KEY, DEFAULT_SORT_ORDER);
4021
- } else {
4022
- onSortChange(columnKey, "desc");
4023
- }
4012
+ if (isActive && currentOrder === "desc") {
4013
+ onSortChange(columnKey, "asc");
4024
4014
  } else {
4025
4015
  onSortChange(columnKey, "desc");
4026
4016
  }
4027
4017
  return;
4028
4018
  }
4029
4019
  setInternalSortState((prev) => {
4030
- if (prev.columnKey !== columnKey) {
4031
- return { columnKey, order: "desc" };
4032
- }
4033
- if (prev.order === "desc") {
4020
+ if (prev.columnKey === columnKey && prev.order === "desc") {
4034
4021
  return { columnKey, order: "asc" };
4035
4022
  }
4036
- return { columnKey: null, order: null };
4023
+ return { columnKey, order: "desc" };
4037
4024
  });
4038
4025
  };
4039
4026
  const renderSortIcon = (columnKey) => {
@@ -4669,9 +4656,11 @@ function Table(props) {
4669
4656
  paginationInfo,
4670
4657
  renderFooter,
4671
4658
  tooltipConfig = "overflow",
4672
- isDynamicHeight = true
4659
+ isDynamicHeight = true,
4660
+ showHorizontalDivider = true,
4661
+ showVerticalDivider = true
4673
4662
  } = props;
4674
- const { fixed = false, onSelectionChange, selectedKeys = [] } = checkboxInfo ?? {};
4663
+ const { fixed = false, onSelectionChange, selectedKeys = [], disabledKeys = [], disabledTooltip } = checkboxInfo ?? {};
4675
4664
  const scrollRef = React6.useRef(null);
4676
4665
  const footerRef = React6.useRef(null);
4677
4666
  const [tableHeight, setTableHeight] = React6.useState(500);
@@ -4713,11 +4702,14 @@ function Table(props) {
4713
4702
  const footerH = footerRef.current?.getBoundingClientRect().height ?? 0;
4714
4703
  setTableHeight(window.innerHeight - top - footerH - 24);
4715
4704
  }, [showSkeleton, showEmpty]);
4716
- const isAllSelected = data.length > 0 && selectedKeys.length === data.length;
4717
4705
  const selectedKeysRef = React6.useRef(selectedKeys);
4718
4706
  selectedKeysRef.current = selectedKeys;
4719
4707
  const onSelectionChangeRef = React6.useRef(onSelectionChange);
4720
4708
  onSelectionChangeRef.current = onSelectionChange;
4709
+ const disabledKeysRef = React6.useRef(disabledKeys);
4710
+ disabledKeysRef.current = disabledKeys;
4711
+ const disabledTooltipRef = React6.useRef(disabledTooltip);
4712
+ disabledTooltipRef.current = disabledTooltip;
4721
4713
  const dataRef = React6.useRef(data);
4722
4714
  dataRef.current = data;
4723
4715
  const onRowClickRef = React6.useRef(onRowClick);
@@ -4732,6 +4724,8 @@ function Table(props) {
4732
4724
  },
4733
4725
  [rowKey]
4734
4726
  );
4727
+ const selectableKeys = data.map((record, index) => getRowKey(record, index)).filter((key) => !disabledKeys.includes(key));
4728
+ const isAllSelected = selectableKeys.length > 0 && selectableKeys.every((key) => selectedKeys.includes(key));
4735
4729
  const allColumns = React6.useMemo(() => {
4736
4730
  const checkboxCol = {
4737
4731
  key: "__checkbox__",
@@ -4746,19 +4740,24 @@ function Table(props) {
4746
4740
  checked: isAllSelected,
4747
4741
  onChange: () => {
4748
4742
  if (!onSelectionChangeRef.current) return;
4749
- const allKeys = dataRef.current.map((record, index) => getRowKey(record, index));
4743
+ const allKeys = dataRef.current.map((record, index) => getRowKey(record, index)).filter((key) => !disabledKeysRef.current.includes(key));
4750
4744
  onSelectionChangeRef.current(isAllSelected ? [] : allKeys);
4751
4745
  }
4752
4746
  }
4753
4747
  ),
4754
4748
  render: (_value, record, rowIdx) => {
4755
4749
  const key = getRowKey(record, rowIdx);
4750
+ const isDisabled = disabledKeysRef.current.includes(key);
4751
+ const tooltip = disabledTooltipRef.current;
4752
+ const tooltipContent = isDisabled && tooltip ? typeof tooltip === "function" ? tooltip(key) : tooltip : void 0;
4756
4753
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
4757
4754
  Checkbox,
4758
4755
  {
4759
4756
  checked: selectedKeysRef.current.includes(key),
4757
+ disabled: isDisabled,
4758
+ tooltipConfig: tooltipContent ? { content: tooltipContent, position: "bottom" } : void 0,
4760
4759
  onChange: () => {
4761
- if (!onSelectionChangeRef.current) return;
4760
+ if (!onSelectionChangeRef.current || isDisabled) return;
4762
4761
  const cur = selectedKeysRef.current;
4763
4762
  const next = cur.includes(key) ? cur.filter((k) => k !== key) : [...cur, key];
4764
4763
  onSelectionChangeRef.current(next);
@@ -5019,7 +5018,7 @@ function Table(props) {
5019
5018
  id: `${col.key}-body`,
5020
5019
  "data-row-cell": "true",
5021
5020
  "data-col-key": col.key,
5022
- className: `${isCheckbox ? "p-0" : "px-2 py-3"} whitespace-nowrap text-sm text-gray-900 border-r border-b border-gray-200 last:border-r-0 bg-inherit group-hover:bg-gray-100 transition-all`,
5021
+ className: `${isCheckbox ? "p-0" : "p-3"} whitespace-nowrap text-sm text-gray-900 border-gray-300/70 last:border-r-0 bg-inherit group-hover:bg-gray-100 transition-all ${showVerticalDivider ? "border-r" : ""} ${showHorizontalDivider ? "border-b" : ""}`,
5023
5022
  style: {
5024
5023
  width,
5025
5024
  minWidth: minWidth || width,
@@ -5111,7 +5110,7 @@ function Table(props) {
5111
5110
  const rest = baseRows.filter((row) => !effectiveRowOrder.includes(String(getRowKey(row.original, row.index))));
5112
5111
  return [...ordered, ...rest];
5113
5112
  }, [baseRows, effectiveRowOrder, getRowKey]);
5114
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded shadow-panel", children: [
5113
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded shadow-table border border-gray-200 overflow-hidden", children: [
5115
5114
  /* @__PURE__ */ jsxRuntime.jsx(
5116
5115
  "div",
5117
5116
  {
@@ -5119,7 +5118,7 @@ function Table(props) {
5119
5118
  ref: scrollRef,
5120
5119
  className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5121
5120
  style: { height: `${tableHeight}px` },
5122
- children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed", children: [
5121
+ children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed border-spacing-0", children: [
5123
5122
  /* @__PURE__ */ jsxRuntime.jsx(
5124
5123
  TableHeader,
5125
5124
  {
@@ -7658,7 +7657,7 @@ var SubmitForm = Object.assign(SubmitFormRoot, {
7658
7657
  });
7659
7658
  function LabeledFilterOption(props) {
7660
7659
  const { label, children, gap } = props;
7661
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginLeft: gap }, className: "flex flex-row items-center gap-5", children: [
7660
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginLeft: gap }, className: "flex flex-row items-center gap-4", children: [
7662
7661
  label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium text-gray-60 shrink-0", children: label }),
7663
7662
  children
7664
7663
  ] });
@@ -7670,7 +7669,7 @@ function PageFilter(props) {
7670
7669
  onSubmit,
7671
7670
  onReset,
7672
7671
  containerClassName,
7673
- rowGap = 32,
7672
+ rowGap = 28,
7674
7673
  colGap = 0,
7675
7674
  submitButtonText = "\uAC80\uC0C9",
7676
7675
  resetButtonText = "\uCD08\uAE30\uD654",
@@ -7784,9 +7783,9 @@ function PageFilter(props) {
7784
7783
  style: primaryColor ? { borderTopColor: primaryColor } : void 0,
7785
7784
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex flex-col", style: { gap: `${colGap}px` }, children: rows.map((row, ix) => {
7786
7785
  const isLastRow = rows.length - 1 === ix;
7787
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row min-h-12", children: [
7786
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row min-h-11", children: [
7788
7787
  row.options.map((option, index) => renderFilterOption(option, rowGap, index)),
7789
- isLastRow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-4 flex flex-row items-center gap-2", children: [
7788
+ isLastRow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-2 flex flex-row items-center gap-2", children: [
7790
7789
  /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "search", onClick: handleSubmit, children: submitButtonText }),
7791
7790
  onReset && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "reset", onClick: handleReset, children: resetButtonText })
7792
7791
  ] })
@@ -9532,7 +9531,8 @@ function DetailModalFrame(props) {
9532
9531
  contentClassName,
9533
9532
  renderExtraContent,
9534
9533
  renderFooterExtra,
9535
- onDirtyChange
9534
+ onDirtyChange,
9535
+ headerType
9536
9536
  } = props;
9537
9537
  const controller = useDetailController({ mode, onModeChange });
9538
9538
  React6.useEffect(() => {
@@ -9571,7 +9571,14 @@ function DetailModalFrame(props) {
9571
9571
  const isEditMode = controller.mode === "edit";
9572
9572
  const canEdit = Boolean(editSchema && (editFields || renderEditBody));
9573
9573
  return /* @__PURE__ */ jsxRuntime.jsxs(Modal, { isOpen: open, onClose: handleClose, contentClassName: cn("max-w-2xl", contentClassName), children: [
9574
- /* @__PURE__ */ jsxRuntime.jsx(ModalHeader, { className: "flex flex-row items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-semibold text-gray-900", children: title }) }),
9574
+ headerType ? /* @__PURE__ */ jsxRuntime.jsx(
9575
+ ModalIconHeader,
9576
+ {
9577
+ type: isEditMode ? "edit" : headerType,
9578
+ title,
9579
+ onClose: handleClose
9580
+ }
9581
+ ) : /* @__PURE__ */ jsxRuntime.jsx(ModalHeader, { className: "flex flex-row items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-semibold text-gray-900", children: title }) }),
9575
9582
  /* @__PURE__ */ jsxRuntime.jsxs(ModalBody, { className: "flex-1 min-h-0 overflow-hidden p-0 flex flex-col", children: [
9576
9583
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9577
9584
  DetailContent,