@farmzone/fz-react-ui 1.0.17 → 1.0.19

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
@@ -751,7 +751,7 @@ function Slider(props) {
751
751
  RadixSlider__namespace.Track,
752
752
  {
753
753
  className: cn(
754
- "relative h-[3px] grow rounded-full bg-blackA7",
754
+ "relative h-[3px] grow rounded-full bg-gray-200",
755
755
  orientation === "vertical" && "w-[3px] h-full",
756
756
  trackClassName
757
757
  ),
@@ -759,7 +759,7 @@ function Slider(props) {
759
759
  RadixSlider__namespace.Range,
760
760
  {
761
761
  className: cn(
762
- "absolute h-full rounded-full bg-white",
762
+ "absolute h-full rounded-full bg-[#009fe3]",
763
763
  orientation === "vertical" && "w-full",
764
764
  rangeClassName
765
765
  )
@@ -767,17 +767,18 @@ function Slider(props) {
767
767
  )
768
768
  }
769
769
  ),
770
- /* @__PURE__ */ jsxRuntime.jsx(
770
+ (value ?? defaultValue).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
771
771
  RadixSlider__namespace.Thumb,
772
772
  {
773
773
  className: cn(
774
- "block size-5 rounded-[10px] bg-white shadow-[0_2px_10px] shadow-blackA4 hover:bg-violet3 focus:shadow-[0_0_0_5px] focus:shadow-blackA5 focus:outline-none",
774
+ "block size-4 rounded-full bg-white border-2 border-[#009fe3] shadow-md hover:border-[#0090cf] focus:outline-none focus:ring-2 focus:ring-[#009fe3]/40 focus:ring-offset-1",
775
775
  disabled && "cursor-not-allowed opacity-50",
776
776
  thumbClassName
777
777
  ),
778
- "aria-label": ariaLabel
779
- }
780
- )
778
+ "aria-label": index === 0 ? ariaLabel : `${ariaLabel} max`
779
+ },
780
+ index
781
+ ))
781
782
  ]
782
783
  }
783
784
  );
@@ -4139,45 +4140,15 @@ function TableHeader(props) {
4139
4140
  };
4140
4141
  };
4141
4142
  const renderColumnTitle = (column, isClickableHead) => {
4142
- const baseClasses = "pt-0.5 select-none";
4143
+ const baseClasses = "pt-0.5 select-none truncate";
4143
4144
  const subTitleClasses = column.key === "subTitle" ? "inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800" : "";
4144
- if (column.align === "left") {
4145
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex item-center w-full", children: [
4146
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: `pl-3 truncate ${baseClasses} ${isClickableHead} ${subTitleClasses}`, children: column.title }) }),
4147
- column.sortable && /* @__PURE__ */ jsxRuntime.jsx(
4148
- "div",
4149
- {
4150
- className: `w-5 flex flex-col gap-[1.5px] items-center justify-center cursor-pointer ${isClickableHead}`,
4151
- children: renderSortIcon(column.key)
4152
- }
4153
- )
4154
- ] });
4155
- }
4156
- if (column.align === "center") {
4157
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center w-full", children: [
4158
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex items-center justify-center ${column.sortable ? "pl-5" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: `whitespace-nowrap ${baseClasses} ${isClickableHead} ${subTitleClasses}`, children: column.title }) }),
4159
- column.sortable && /* @__PURE__ */ jsxRuntime.jsx(
4160
- "div",
4161
- {
4162
- className: `w-5 flex flex-col gap-[1.5px] items-center justify-center cursor-pointer ${isClickableHead}`,
4163
- children: renderSortIcon(column.key)
4164
- }
4165
- )
4166
- ] });
4167
- }
4168
- if (column.align === "right") {
4169
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end w-full", children: [
4170
- column.sortable && /* @__PURE__ */ jsxRuntime.jsx(
4171
- "div",
4172
- {
4173
- className: `w-5 flex flex-col gap-[1.5px] items-center justify-center cursor-pointer ${isClickableHead}`,
4174
- children: renderSortIcon(column.key)
4175
- }
4176
- ),
4177
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: `pr-3 truncate ${baseClasses} ${isClickableHead} ${subTitleClasses}`, children: column.title }) })
4178
- ] });
4179
- }
4180
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `px-1.5 truncate ${baseClasses} ${isClickableHead} ${subTitleClasses}`, children: column.title });
4145
+ const hasSortIcon = column.sortable;
4146
+ const textAlignClass = column.align === "center" ? "text-center" : column.align === "right" ? "text-right" : "text-left";
4147
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center w-full", children: [
4148
+ hasSortIcon && column.align === "center" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 shrink-0" }),
4149
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `flex-1 px-3 ${textAlignClass} ${baseClasses} ${isClickableHead} ${subTitleClasses}`, children: column.title }),
4150
+ hasSortIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-6 shrink-0 flex items-center justify-center cursor-pointer ${isClickableHead}`, children: renderSortIcon(column.key) })
4151
+ ] });
4181
4152
  };
4182
4153
  const createGroupHeaders = () => {
4183
4154
  const mainGroups2 = {};
@@ -4597,32 +4568,64 @@ function TableEmpty(props) {
4597
4568
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-md text-gray-500", children: "\uB4F1\uB85D\uB41C \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." })
4598
4569
  ] }) }) });
4599
4570
  }
4571
+ function TableCellTooltip({ children, content }) {
4572
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Provider, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipPrimitive__namespace.Root, { children: [
4573
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { asChild: true, children }),
4574
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4575
+ TooltipPrimitive__namespace.Content,
4576
+ {
4577
+ side: "bottom",
4578
+ sideOffset: 5,
4579
+ collisionPadding: 8,
4580
+ className: "relative animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 z-50 w-full max-w-[500px] origin-(--radix-tooltip-content-transform-origin) rounded-md bg-neutral-700 text-sm font-medium text-white",
4581
+ style: { zIndex: Z_INDEX.TOOLTIP },
4582
+ children: [
4583
+ /* @__PURE__ */ jsxRuntime.jsx(
4584
+ "div",
4585
+ {
4586
+ className: "px-3 py-[5px] break-words whitespace-normal custom-view-scrollbar",
4587
+ style: { overflowY: "auto", maxHeight: "250px" },
4588
+ children: content
4589
+ }
4590
+ ),
4591
+ /* @__PURE__ */ jsxRuntime.jsx(
4592
+ TooltipPrimitive__namespace.Arrow,
4593
+ {
4594
+ className: cn(
4595
+ "z-50 w-2.5 h-2.5 translate-y-[calc(-50%_-_0px)] rotate-45 rounded-[2px]",
4596
+ "bg-neutral-700 !fill-neutral-700"
4597
+ ),
4598
+ style: { fill: "currentColor" }
4599
+ }
4600
+ )
4601
+ ]
4602
+ }
4603
+ ) })
4604
+ ] }) });
4605
+ }
4600
4606
  function TableCellContent(props) {
4601
4607
  const { cellContent, tooltipText, align, tooltipConfig, onCellClick } = props;
4602
- const textRef = React6.useRef(null);
4603
4608
  const [isOverflowing, setIsOverflowing] = React6.useState(false);
4604
- React6.useEffect(() => {
4605
- if (tooltipConfig !== "overflow") return;
4606
- const el = textRef.current;
4607
- if (!el) return;
4608
- const check = () => setIsOverflowing(el.scrollWidth > el.clientWidth);
4609
- check();
4610
- const observer = new ResizeObserver(check);
4611
- observer.observe(el);
4612
- return () => observer.disconnect();
4613
- }, [tooltipConfig]);
4609
+ const observerRef = React6.useRef(null);
4610
+ const refCallback = React6.useCallback(
4611
+ (el) => {
4612
+ observerRef.current?.disconnect();
4613
+ observerRef.current = null;
4614
+ if (!el || tooltipConfig !== "overflow") return;
4615
+ const check = () => setIsOverflowing(el.scrollWidth > el.clientWidth);
4616
+ const observer = new ResizeObserver(check);
4617
+ observer.observe(el);
4618
+ observerRef.current = observer;
4619
+ },
4620
+ [tooltipConfig]
4621
+ );
4614
4622
  const shouldShowTooltip = tooltipConfig === "always" || tooltipConfig === "overflow" && isOverflowing;
4615
4623
  const textAlign = align === "center" ? "center" : align === "right" ? "right" : "left";
4616
- return /* @__PURE__ */ jsxRuntime.jsx(
4617
- "div",
4618
- {
4619
- ref: textRef,
4620
- className: `ellipsis-1-line table-item w-full min-w-0 ${onCellClick ? "hover:text-main cursor-pointer" : "cursor-default"}`,
4621
- style: { textAlign },
4622
- onClick: onCellClick,
4623
- children: shouldShowTooltip ? /* @__PURE__ */ jsxRuntime.jsx(Tooltip2, { content: tooltipText, position: "bottom", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: cellContent }) }) : cellContent
4624
- }
4625
- );
4624
+ const divClassName = `ellipsis-1-line table-item w-full min-w-0 ${onCellClick ? "hover:text-main cursor-pointer" : "cursor-default"}`;
4625
+ if (!shouldShowTooltip) {
4626
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: refCallback, className: divClassName, style: { textAlign }, onClick: onCellClick, children: cellContent });
4627
+ }
4628
+ return /* @__PURE__ */ jsxRuntime.jsx(TableCellTooltip, { content: tooltipText, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: refCallback, className: divClassName, style: { textAlign }, onClick: onCellClick, children: cellContent }) });
4626
4629
  }
4627
4630
 
4628
4631
  // src/components/Table/config/utils.ts
@@ -5052,6 +5055,11 @@ function Table(props) {
5052
5055
  }
5053
5056
  }
5054
5057
  }, [orderedColumns]);
5058
+ const tableMinWidth = React6.useMemo(() => {
5059
+ const allUserColsHaveWidth = orderedColumns.every((col) => col.key === "__checkbox__" || col.width !== void 0);
5060
+ if (!allUserColsHaveWidth) return void 0;
5061
+ return orderedColumns.reduce((sum, col) => sum + parseColPx(col), 0);
5062
+ }, [orderedColumns]);
5055
5063
  const estimatedLeadingPinnedWidth = React6.useMemo(
5056
5064
  () => leadingPinnedCols.reduce((sum, col) => sum + parseColPx(col), 0),
5057
5065
  [leadingPinnedCols]
@@ -5221,51 +5229,63 @@ function Table(props) {
5221
5229
  ref: scrollRef,
5222
5230
  className: "relative w-full overflow-y-auto overflow-x-auto custom-view-scrollbar bg-white",
5223
5231
  style: { height: `${tableHeight}px` },
5224
- children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed border-spacing-0", children: [
5225
- /* @__PURE__ */ jsxRuntime.jsx(
5226
- TableHeader,
5227
- {
5228
- columns: orderedColumns,
5229
- getAlignStyle,
5230
- sortOption,
5231
- onSortChange,
5232
- onColumnDragStartCapture: handleColumnDragStartCapture,
5233
- onColumnDragStart: handleColumnDragStart,
5234
- onColumnDrop: handleColumnDrop,
5235
- onColumnDragEnd: handleColumnDragEnd,
5236
- onColumnDragOver: handleColumnDragOver,
5237
- isColumnDraggable
5238
- }
5239
- ),
5240
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "hover:bg-gray-50", children: [
5241
- leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5242
- leftColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5243
- virtualItems.map((vc) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5244
- rightColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5245
- trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col }, `trailing-${idx}`))
5246
- ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsxRuntime.jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5247
- const rowId = String(getRowKey(row.original, row.index));
5248
- return /* @__PURE__ */ jsxRuntime.jsx(
5249
- TableDataRow,
5250
- {
5251
- record: row.original,
5252
- rowIdx: row.index,
5253
- rowId,
5254
- draggable: rowDraggable && !showSkeleton,
5255
- onDragStart: handleRowDragStart,
5256
- onDragOver: handleRowDragOver,
5257
- onDrop: handleRowDrop,
5258
- onDragEnd: handleRowDragEnd,
5259
- leftColspan,
5260
- rightColspan,
5261
- renderLeadingPinnedCols,
5262
- renderVisibleGroupCols,
5263
- renderTrailingPinnedCols
5264
- },
5265
- row.id
5266
- );
5267
- }) })
5268
- ] })
5232
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
5233
+ "table",
5234
+ {
5235
+ className: `table-fixed border-spacing-0${tableMinWidth === void 0 ? " w-full" : ""}`,
5236
+ style: tableMinWidth !== void 0 ? { width: tableMinWidth, minWidth: tableMinWidth } : {
5237
+ minWidth: orderedColumns.reduce(
5238
+ (sum, col) => sum + (col.key === "__checkbox__" || col.width !== void 0 ? parseColPx(col) : 80),
5239
+ 0
5240
+ )
5241
+ },
5242
+ children: [
5243
+ /* @__PURE__ */ jsxRuntime.jsx(
5244
+ TableHeader,
5245
+ {
5246
+ columns: orderedColumns,
5247
+ getAlignStyle,
5248
+ sortOption,
5249
+ onSortChange,
5250
+ onColumnDragStartCapture: handleColumnDragStartCapture,
5251
+ onColumnDragStart: handleColumnDragStart,
5252
+ onColumnDrop: handleColumnDrop,
5253
+ onColumnDragEnd: handleColumnDragEnd,
5254
+ onColumnDragOver: handleColumnDragOver,
5255
+ isColumnDraggable
5256
+ }
5257
+ ),
5258
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "w-full h-full", children: showSkeleton ? Array.from({ length: 3 }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "hover:bg-gray-50", children: [
5259
+ leadingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col, showSquare: idx === 0 && !!checkboxInfo }, `leading-${idx}`)),
5260
+ leftColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: leftColspan, style: { padding: 0, border: "none" } }),
5261
+ virtualItems.map((vc) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col: groupCols[vc.index] }, `group-${vc.index}`)),
5262
+ rightColspan > 0 && /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: rightColspan, style: { padding: 0, border: "none" } }),
5263
+ trailingPinnedCols.map((col, idx) => /* @__PURE__ */ jsxRuntime.jsx(SkeletonTd, { col }, `trailing-${idx}`))
5264
+ ] }, rowIdx)) : showEmpty ? /* @__PURE__ */ jsxRuntime.jsx(TableEmpty, { columnCount: allColumns.length }) : rows.map((row) => {
5265
+ const rowId = String(getRowKey(row.original, row.index));
5266
+ return /* @__PURE__ */ jsxRuntime.jsx(
5267
+ TableDataRow,
5268
+ {
5269
+ record: row.original,
5270
+ rowIdx: row.index,
5271
+ rowId,
5272
+ draggable: rowDraggable && !showSkeleton,
5273
+ onDragStart: handleRowDragStart,
5274
+ onDragOver: handleRowDragOver,
5275
+ onDrop: handleRowDrop,
5276
+ onDragEnd: handleRowDragEnd,
5277
+ leftColspan,
5278
+ rightColspan,
5279
+ renderLeadingPinnedCols,
5280
+ renderVisibleGroupCols,
5281
+ renderTrailingPinnedCols
5282
+ },
5283
+ row.id
5284
+ );
5285
+ }) })
5286
+ ]
5287
+ }
5288
+ )
5269
5289
  }
5270
5290
  ),
5271
5291
  !showSkeleton && (paginationInfo || renderFooter?.renderLeft || renderFooter?.renderRight) && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: footerRef, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -6129,7 +6149,7 @@ function FilePreviewViewerSession(props) {
6129
6149
  React6.useEffect(() => {
6130
6150
  if (!showNavigation) return;
6131
6151
  const [prevIndex, nextIndex] = getAdjacentIndexes(currentIndex, fileArray.length);
6132
- const urlsToPreload = [prevIndex, nextIndex].filter((idx) => idx !== currentIndex).map((idx) => fileArray[idx]);
6152
+ const urlsToPreload = [prevIndex, nextIndex].filter((idx) => idx !== currentIndex).map((idx) => fileArray[idx]).filter((url) => url !== void 0);
6133
6153
  preloadPreviewImages(urlsToPreload);
6134
6154
  }, [showNavigation, currentIndex, fileArray]);
6135
6155
  React6.useEffect(() => {
@@ -7765,7 +7785,7 @@ var SubmitForm = Object.assign(SubmitFormRoot, {
7765
7785
  function LabeledFilterOption(props) {
7766
7786
  const { label, children, gap } = props;
7767
7787
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginLeft: gap }, className: "flex flex-row items-center gap-4", children: [
7768
- label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium text-gray-60 shrink-0", children: label }),
7788
+ label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium text-gray-60 shrink-0 select-none", children: label }),
7769
7789
  children
7770
7790
  ] });
7771
7791
  }
@@ -7784,15 +7804,26 @@ function PageFilter(props) {
7784
7804
  primaryColor
7785
7805
  } = props;
7786
7806
  const initialValuesRef = React6.useRef(values);
7807
+ const pendingAutoSubmitRef = React6.useRef(null);
7808
+ const onSubmitRef = React6.useRef(onSubmit);
7809
+ onSubmitRef.current = onSubmit;
7810
+ React6.useEffect(() => {
7811
+ const pending = pendingAutoSubmitRef.current;
7812
+ if (pending && String(values[pending.key] ?? "") === pending.value) {
7813
+ pendingAutoSubmitRef.current = null;
7814
+ onSubmitRef.current();
7815
+ }
7816
+ }, [values]);
7787
7817
  const handleInputChange = (key) => (e) => {
7788
7818
  onChange({ [key]: e.target.value });
7789
7819
  };
7790
7820
  const handleSelectChange = (key, autoSubmit) => (value) => {
7791
7821
  onChange({ [key]: value });
7792
- if (autoSubmit) onSubmit();
7822
+ if (autoSubmit) pendingAutoSubmitRef.current = { key, value };
7793
7823
  };
7794
- const handleRadioChange = (key) => (value) => {
7824
+ const handleRadioChange = (key, autoSubmit) => (value) => {
7795
7825
  onChange({ [key]: value });
7826
+ if (autoSubmit) pendingAutoSubmitRef.current = { key, value };
7796
7827
  };
7797
7828
  const handleDateChange = (key) => (date) => {
7798
7829
  onChange({ [key]: date });
@@ -7800,13 +7831,17 @@ function PageFilter(props) {
7800
7831
  const handleRangeChangeCurried = (startKey, endKey) => (start, end) => {
7801
7832
  onChange({ [startKey]: start, [endKey]: end });
7802
7833
  };
7803
- const handleCheckboxChange = (key) => (checked) => {
7804
- onChange({ [key]: checked ? "true" : "false" });
7834
+ const handleCheckboxChange = (key, autoSubmit) => (checked) => {
7835
+ const value = checked ? "true" : "false";
7836
+ onChange({ [key]: value });
7837
+ if (autoSubmit) pendingAutoSubmitRef.current = { key, value };
7805
7838
  };
7806
7839
  const handleSubmit = () => {
7840
+ pendingAutoSubmitRef.current = null;
7807
7841
  onSubmit();
7808
7842
  };
7809
7843
  const handleReset = () => {
7844
+ pendingAutoSubmitRef.current = null;
7810
7845
  onChange(initialValuesRef.current);
7811
7846
  onReset?.();
7812
7847
  };
@@ -7845,7 +7880,7 @@ function PageFilter(props) {
7845
7880
  {
7846
7881
  name: String(optionKey),
7847
7882
  value: currentValue,
7848
- onChange: handleRadioChange(optionKey),
7883
+ onChange: handleRadioChange(optionKey, option.autoSubmit),
7849
7884
  options: option.options,
7850
7885
  direction: "horizontal"
7851
7886
  }
@@ -7877,7 +7912,7 @@ function PageFilter(props) {
7877
7912
  checked: currentValue === "true",
7878
7913
  name: String(optionKey),
7879
7914
  value: currentValue,
7880
- onChange: handleCheckboxChange(optionKey)
7915
+ onChange: handleCheckboxChange(optionKey, option.autoSubmit)
7881
7916
  }
7882
7917
  ) }, String(optionKey));
7883
7918
  default: {