@sarunyu/system-one 4.0.2 → 4.0.4

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(
@@ -3976,7 +3982,7 @@ const TableCell = React.forwardRef(function TableCell2({
3976
3982
  textStyle = "default",
3977
3983
  selected,
3978
3984
  hovered,
3979
- label = "Text label",
3985
+ label,
3980
3986
  description = "Text Description",
3981
3987
  imageSrc,
3982
3988
  tagText = "Tag",
@@ -3987,6 +3993,7 @@ const TableCell = React.forwardRef(function TableCell2({
3987
3993
  fixedOffset = 0,
3988
3994
  fixedShadow,
3989
3995
  style: styleProp,
3996
+ children,
3990
3997
  ...props
3991
3998
  }, ref) {
3992
3999
  const { hasLeftOverflow, hasRightOverflow } = React.useContext(TableScrollShadowContext);
@@ -4001,6 +4008,7 @@ const TableCell = React.forwardRef(function TableCell2({
4001
4008
  const fixedStyle = fixed === "left" ? { left: fixedOffset } : fixed === "right" ? { right: fixedOffset } : void 0;
4002
4009
  const shadowDirection = resolveStickyShadowDirection(fixed, fixedShadow);
4003
4010
  const shouldShowShadow = shadowDirection === "right" ? hasLeftOverflow : shadowDirection === "left" ? hasRightOverflow : false;
4011
+ const primaryContent = children ?? label ?? "Text label";
4004
4012
  return /* @__PURE__ */ jsxRuntime.jsxs(
4005
4013
  "td",
4006
4014
  {
@@ -4018,13 +4026,13 @@ const TableCell = React.forwardRef(function TableCell2({
4018
4026
  children: [
4019
4027
  shadowDirection && shouldShowShadow && /* @__PURE__ */ jsxRuntime.jsx(StickyShadowEdge, { direction: shadowDirection }),
4020
4028
  type === "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [
4021
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: label }),
4029
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
4022
4030
  hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
4023
4031
  ] }),
4024
4032
  type === "text-icon" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
4025
4033
  icon ?? /* @__PURE__ */ jsxRuntime.jsx(react.Circle, { size: iconSize, weight: "regular", className: "shrink-0 text-subtle-text" }),
4026
4034
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [
4027
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: label }),
4035
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
4028
4036
  hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
4029
4037
  ] })
4030
4038
  ] }),
@@ -4038,7 +4046,7 @@ const TableCell = React.forwardRef(function TableCell2({
4038
4046
  }
4039
4047
  ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-full bg-hover-bg" }) }),
4040
4048
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [
4041
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: label }),
4049
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
4042
4050
  hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
4043
4051
  ] })
4044
4052
  ] }),