@sarunyu/system-one 4.0.3 → 4.1.0

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
@@ -3869,7 +3869,7 @@ const Table = React.forwardRef(function Table2({ className, responsive = true, .
3869
3869
  return /* @__PURE__ */ jsxRuntime.jsx(TableScrollShadowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: scrollRef, className: "w-full overflow-x-auto", children: table }) });
3870
3870
  });
3871
3871
  const TableRow = React.forwardRef(
3872
- function TableRow2({ className, selected = false, hoverable = false, onMouseEnter, onMouseLeave, ...props }, ref) {
3872
+ function TableRow2({ className, selected = false, hoverable = true, onMouseEnter, onMouseLeave, ...props }, ref) {
3873
3873
  const [hovered, setHovered] = React.useState(false);
3874
3874
  const handleMouseEnter = (e) => {
3875
3875
  if (hoverable) setHovered(true);
@@ -3902,7 +3902,7 @@ const TableHeaderCell = React.forwardRef(
3902
3902
  state = "default",
3903
3903
  sortable = true,
3904
3904
  icon,
3905
- sortDirection = "none",
3905
+ sortDirection,
3906
3906
  onSortChange,
3907
3907
  checkState = false,
3908
3908
  onCheckChange,
@@ -3911,16 +3911,22 @@ const TableHeaderCell = React.forwardRef(
3911
3911
  fixedShadow,
3912
3912
  children = "Title text",
3913
3913
  style: styleProp,
3914
+ onClick: onClickProp,
3914
3915
  ...props
3915
3916
  }, ref) {
3916
3917
  const { hasLeftOverflow, hasRightOverflow } = React.useContext(TableScrollShadowContext);
3918
+ const [internalDirection, setInternalDirection] = React.useState("none");
3919
+ const isControlledSort = sortDirection !== void 0;
3920
+ const currentDirection = isControlledSort ? sortDirection : internalDirection;
3917
3921
  const stateClass = state === "disabled" ? "bg-[var(--bg-default-tertiary,#f3f4f6)] text-[var(--text-default-tertiary,#6a7282)]" : state === "hover" ? "bg-[var(--bg-default-secondary,#f9fafb)] text-[var(--text-default-tertiary,#6a7282)]" : "bg-[var(--bg-default-primary,white)] text-[var(--text-default-tertiary,#6a7282)]";
3918
3922
  const interactiveHoverClass = state === "default" ? "hover:bg-[var(--bg-default-secondary,#f9fafb)]" : "";
3919
- const sortIcon = sortDirection === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(react.ArrowUp, { size: 16, weight: "fill", className: "shrink-0" }) : sortDirection === "desc" ? /* @__PURE__ */ jsxRuntime.jsx(react.ArrowDown, { size: 16, weight: "fill", className: "shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(react.ArrowsDownUp, { size: 16, weight: "fill", className: "shrink-0" });
3920
- const handleSortClick = () => {
3921
- if (!sortable || !onSortChange) return;
3922
- const nextDirection = sortDirection === "none" ? "asc" : sortDirection === "asc" ? "desc" : "none";
3923
- onSortChange(nextDirection);
3923
+ const sortIcon = currentDirection === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(react.ArrowUp, { size: 16, weight: "fill", className: "shrink-0" }) : currentDirection === "desc" ? /* @__PURE__ */ jsxRuntime.jsx(react.ArrowDown, { size: 16, weight: "fill", className: "shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(react.ArrowsDownUp, { size: 16, weight: "fill", className: "shrink-0" });
3924
+ const handleClick = (e) => {
3925
+ onClickProp == null ? void 0 : onClickProp(e);
3926
+ if (type !== "text" || !sortable || state === "disabled") return;
3927
+ const nextDirection = currentDirection === "none" ? "asc" : currentDirection === "asc" ? "desc" : "none";
3928
+ if (!isControlledSort) setInternalDirection(nextDirection);
3929
+ onSortChange == null ? void 0 : onSortChange(nextDirection);
3924
3930
  };
3925
3931
  const content = type === "text" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3926
3932
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-5 font-normal", children }),
@@ -3947,12 +3953,12 @@ const TableHeaderCell = React.forwardRef(
3947
3953
  stateClass,
3948
3954
  interactiveHoverClass,
3949
3955
  fixed && "sticky z-20",
3950
- sortable && type === "text" && onSortChange && "cursor-pointer select-none",
3956
+ sortable && type === "text" && state !== "disabled" && "cursor-pointer select-none",
3951
3957
  className
3952
3958
  ),
3953
3959
  style: { ...fixedStyle, ...styleProp },
3954
3960
  ...props,
3955
- onClick: type === "text" ? handleSortClick : props.onClick,
3961
+ onClick: handleClick,
3956
3962
  children: [
3957
3963
  shadowDirection && shouldShowShadow && /* @__PURE__ */ jsxRuntime.jsx(StickyShadowEdge, { direction: shadowDirection }),
3958
3964
  /* @__PURE__ */ jsxRuntime.jsx(