@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 +21 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/src/components/table.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3850,7 +3850,7 @@ const Table = forwardRef(function Table2({ className, responsive = true, ...prop
|
|
|
3850
3850
|
return /* @__PURE__ */ jsx(TableScrollShadowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { ref: scrollRef, className: "w-full overflow-x-auto", children: table }) });
|
|
3851
3851
|
});
|
|
3852
3852
|
const TableRow = forwardRef(
|
|
3853
|
-
function TableRow2({ className, selected = false, hoverable =
|
|
3853
|
+
function TableRow2({ className, selected = false, hoverable = true, onMouseEnter, onMouseLeave, ...props }, ref) {
|
|
3854
3854
|
const [hovered, setHovered] = useState(false);
|
|
3855
3855
|
const handleMouseEnter = (e) => {
|
|
3856
3856
|
if (hoverable) setHovered(true);
|
|
@@ -3883,7 +3883,7 @@ const TableHeaderCell = forwardRef(
|
|
|
3883
3883
|
state = "default",
|
|
3884
3884
|
sortable = true,
|
|
3885
3885
|
icon,
|
|
3886
|
-
sortDirection
|
|
3886
|
+
sortDirection,
|
|
3887
3887
|
onSortChange,
|
|
3888
3888
|
checkState = false,
|
|
3889
3889
|
onCheckChange,
|
|
@@ -3892,16 +3892,22 @@ const TableHeaderCell = forwardRef(
|
|
|
3892
3892
|
fixedShadow,
|
|
3893
3893
|
children = "Title text",
|
|
3894
3894
|
style: styleProp,
|
|
3895
|
+
onClick: onClickProp,
|
|
3895
3896
|
...props
|
|
3896
3897
|
}, ref) {
|
|
3897
3898
|
const { hasLeftOverflow, hasRightOverflow } = useContext(TableScrollShadowContext);
|
|
3899
|
+
const [internalDirection, setInternalDirection] = useState("none");
|
|
3900
|
+
const isControlledSort = sortDirection !== void 0;
|
|
3901
|
+
const currentDirection = isControlledSort ? sortDirection : internalDirection;
|
|
3898
3902
|
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)]";
|
|
3899
3903
|
const interactiveHoverClass = state === "default" ? "hover:bg-[var(--bg-default-secondary,#f9fafb)]" : "";
|
|
3900
|
-
const sortIcon =
|
|
3901
|
-
const
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3904
|
+
const sortIcon = currentDirection === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { size: 16, weight: "fill", className: "shrink-0" }) : currentDirection === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { size: 16, weight: "fill", className: "shrink-0" }) : /* @__PURE__ */ jsx(ArrowsDownUp, { size: 16, weight: "fill", className: "shrink-0" });
|
|
3905
|
+
const handleClick = (e) => {
|
|
3906
|
+
onClickProp == null ? void 0 : onClickProp(e);
|
|
3907
|
+
if (type !== "text" || !sortable || state === "disabled") return;
|
|
3908
|
+
const nextDirection = currentDirection === "none" ? "asc" : currentDirection === "asc" ? "desc" : "none";
|
|
3909
|
+
if (!isControlledSort) setInternalDirection(nextDirection);
|
|
3910
|
+
onSortChange == null ? void 0 : onSortChange(nextDirection);
|
|
3905
3911
|
};
|
|
3906
3912
|
const content = type === "text" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3907
3913
|
/* @__PURE__ */ jsx("span", { className: "text-sm leading-5 font-normal", children }),
|
|
@@ -3928,12 +3934,12 @@ const TableHeaderCell = forwardRef(
|
|
|
3928
3934
|
stateClass,
|
|
3929
3935
|
interactiveHoverClass,
|
|
3930
3936
|
fixed && "sticky z-20",
|
|
3931
|
-
sortable && type === "text" &&
|
|
3937
|
+
sortable && type === "text" && state !== "disabled" && "cursor-pointer select-none",
|
|
3932
3938
|
className
|
|
3933
3939
|
),
|
|
3934
3940
|
style: { ...fixedStyle, ...styleProp },
|
|
3935
3941
|
...props,
|
|
3936
|
-
onClick:
|
|
3942
|
+
onClick: handleClick,
|
|
3937
3943
|
children: [
|
|
3938
3944
|
shadowDirection && shouldShowShadow && /* @__PURE__ */ jsx(StickyShadowEdge, { direction: shadowDirection }),
|
|
3939
3945
|
/* @__PURE__ */ jsx(
|
|
@@ -3957,7 +3963,7 @@ const TableCell = forwardRef(function TableCell2({
|
|
|
3957
3963
|
textStyle = "default",
|
|
3958
3964
|
selected,
|
|
3959
3965
|
hovered,
|
|
3960
|
-
label
|
|
3966
|
+
label,
|
|
3961
3967
|
description = "Text Description",
|
|
3962
3968
|
imageSrc,
|
|
3963
3969
|
tagText = "Tag",
|
|
@@ -3968,6 +3974,7 @@ const TableCell = forwardRef(function TableCell2({
|
|
|
3968
3974
|
fixedOffset = 0,
|
|
3969
3975
|
fixedShadow,
|
|
3970
3976
|
style: styleProp,
|
|
3977
|
+
children,
|
|
3971
3978
|
...props
|
|
3972
3979
|
}, ref) {
|
|
3973
3980
|
const { hasLeftOverflow, hasRightOverflow } = useContext(TableScrollShadowContext);
|
|
@@ -3982,6 +3989,7 @@ const TableCell = forwardRef(function TableCell2({
|
|
|
3982
3989
|
const fixedStyle = fixed === "left" ? { left: fixedOffset } : fixed === "right" ? { right: fixedOffset } : void 0;
|
|
3983
3990
|
const shadowDirection = resolveStickyShadowDirection(fixed, fixedShadow);
|
|
3984
3991
|
const shouldShowShadow = shadowDirection === "right" ? hasLeftOverflow : shadowDirection === "left" ? hasRightOverflow : false;
|
|
3992
|
+
const primaryContent = children ?? label ?? "Text label";
|
|
3985
3993
|
return /* @__PURE__ */ jsxs(
|
|
3986
3994
|
"td",
|
|
3987
3995
|
{
|
|
@@ -3999,13 +4007,13 @@ const TableCell = forwardRef(function TableCell2({
|
|
|
3999
4007
|
children: [
|
|
4000
4008
|
shadowDirection && shouldShowShadow && /* @__PURE__ */ jsx(StickyShadowEdge, { direction: shadowDirection }),
|
|
4001
4009
|
type === "default" && /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
4002
|
-
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children:
|
|
4010
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
|
|
4003
4011
|
hasDescription && /* @__PURE__ */ jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
|
|
4004
4012
|
] }),
|
|
4005
4013
|
type === "text-icon" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4006
4014
|
icon ?? /* @__PURE__ */ jsx(Circle, { size: iconSize, weight: "regular", className: "shrink-0 text-subtle-text" }),
|
|
4007
4015
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
4008
|
-
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children:
|
|
4016
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
|
|
4009
4017
|
hasDescription && /* @__PURE__ */ jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
|
|
4010
4018
|
] })
|
|
4011
4019
|
] }),
|
|
@@ -4019,7 +4027,7 @@ const TableCell = forwardRef(function TableCell2({
|
|
|
4019
4027
|
}
|
|
4020
4028
|
) : /* @__PURE__ */ jsx("div", { className: "size-full bg-hover-bg" }) }),
|
|
4021
4029
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
4022
|
-
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children:
|
|
4030
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-sm leading-5", primaryTextClass), children: primaryContent }),
|
|
4023
4031
|
hasDescription && /* @__PURE__ */ jsx("span", { className: "text-xs leading-4 font-normal text-subtle-text", children: description })
|
|
4024
4032
|
] })
|
|
4025
4033
|
] }),
|