@marcoschwartz/lite-ui 0.18.1 → 0.20.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.mjs CHANGED
@@ -1927,49 +1927,81 @@ function Table({
1927
1927
  keyField = "id",
1928
1928
  striped = false,
1929
1929
  hoverable = true,
1930
- className = ""
1930
+ className = "",
1931
+ responsive = true
1931
1932
  }) {
1932
1933
  const { theme } = useTheme();
1933
- return /* @__PURE__ */ jsxs18("div", { className: `overflow-x-auto ${className}`, children: [
1934
- /* @__PURE__ */ jsxs18("table", { className: "w-full text-left", children: [
1935
- /* @__PURE__ */ jsx90("thead", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx90("tr", { children: columns.map((column, colIndex) => {
1936
- const isLast = colIndex === columns.length - 1;
1937
- return /* @__PURE__ */ jsx90(
1938
- "th",
1939
- {
1940
- className: isLast ? "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider relative" : "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider",
1941
- style: { width: column.width },
1942
- children: column.title
1943
- },
1944
- column.key
1945
- );
1946
- }) }) }),
1947
- /* @__PURE__ */ jsx90("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: data.map((row, rowIndex) => {
1948
- const rowClasses = [
1949
- striped && rowIndex % 2 === 1 ? "bg-gray-50 dark:bg-gray-800/50" : "",
1950
- hoverable ? "hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" : ""
1934
+ return /* @__PURE__ */ jsxs18("div", { className, children: [
1935
+ /* @__PURE__ */ jsxs18("div", { className: `${responsive ? "hidden md:block" : ""} overflow-x-auto`, children: [
1936
+ /* @__PURE__ */ jsxs18("table", { className: "w-full text-left", children: [
1937
+ /* @__PURE__ */ jsx90("thead", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx90("tr", { children: columns.map((column, colIndex) => {
1938
+ const isLast = colIndex === columns.length - 1;
1939
+ return /* @__PURE__ */ jsx90(
1940
+ "th",
1941
+ {
1942
+ className: isLast ? "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider relative" : "px-6 py-3 text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider",
1943
+ style: { width: column.width },
1944
+ children: column.title
1945
+ },
1946
+ column.key
1947
+ );
1948
+ }) }) }),
1949
+ /* @__PURE__ */ jsx90("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: data.map((row, rowIndex) => {
1950
+ const rowClasses = [
1951
+ striped && rowIndex % 2 === 1 ? "bg-gray-50 dark:bg-gray-800/50" : "",
1952
+ hoverable ? "hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" : ""
1953
+ ].filter(Boolean).join(" ");
1954
+ return /* @__PURE__ */ jsx90(
1955
+ "tr",
1956
+ {
1957
+ className: rowClasses,
1958
+ children: columns.map((column, colIndex) => {
1959
+ const isLast = colIndex === columns.length - 1;
1960
+ return /* @__PURE__ */ jsx90(
1961
+ "td",
1962
+ {
1963
+ className: isLast ? "px-6 py-4 text-sm text-gray-900 dark:text-gray-100 overflow-visible" : "px-6 py-4 text-sm text-gray-900 dark:text-gray-100",
1964
+ children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
1965
+ },
1966
+ column.key
1967
+ );
1968
+ })
1969
+ },
1970
+ row[keyField] || rowIndex
1971
+ );
1972
+ }) })
1973
+ ] }),
1974
+ data.length === 0 && /* @__PURE__ */ jsx90("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
1975
+ ] }),
1976
+ responsive && /* @__PURE__ */ jsxs18("div", { className: "md:hidden space-y-3", children: [
1977
+ data.map((row, rowIndex) => {
1978
+ const cardClasses = [
1979
+ "bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4 shadow-sm",
1980
+ hoverable ? "hover:shadow-md transition-shadow" : "",
1981
+ "relative isolate"
1982
+ // Ensure cards are isolated layers
1951
1983
  ].filter(Boolean).join(" ");
1952
1984
  return /* @__PURE__ */ jsx90(
1953
- "tr",
1985
+ "div",
1954
1986
  {
1955
- className: rowClasses,
1956
- children: columns.map((column, colIndex) => {
1957
- const isLast = colIndex === columns.length - 1;
1958
- return /* @__PURE__ */ jsx90(
1959
- "td",
1960
- {
1961
- className: isLast ? "px-6 py-4 text-sm text-gray-900 dark:text-gray-100 overflow-visible" : "px-6 py-4 text-sm text-gray-900 dark:text-gray-100",
1962
- children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
1963
- },
1964
- column.key
1965
- );
1966
- })
1987
+ className: cardClasses,
1988
+ children: columns.map((column) => /* @__PURE__ */ jsxs18(
1989
+ "div",
1990
+ {
1991
+ className: "flex justify-between items-start py-2 border-b border-gray-100 dark:border-gray-800 last:border-b-0",
1992
+ children: [
1993
+ /* @__PURE__ */ jsx90("span", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider flex-shrink-0 mr-4", children: column.title }),
1994
+ /* @__PURE__ */ jsx90("span", { className: "text-sm text-gray-900 dark:text-gray-100 text-right", children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key] })
1995
+ ]
1996
+ },
1997
+ column.key
1998
+ ))
1967
1999
  },
1968
2000
  row[keyField] || rowIndex
1969
2001
  );
1970
- }) })
1971
- ] }),
1972
- data.length === 0 && /* @__PURE__ */ jsx90("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2002
+ }),
2003
+ data.length === 0 && /* @__PURE__ */ jsx90("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2004
+ ] })
1973
2005
  ] });
1974
2006
  }
1975
2007
 
@@ -3928,48 +3960,87 @@ var Stepper = ({
3928
3960
  steps,
3929
3961
  currentStep,
3930
3962
  orientation = "horizontal",
3931
- className = ""
3963
+ className = "",
3964
+ compact = false
3932
3965
  }) => {
3933
3966
  const isHorizontal = orientation === "horizontal";
3934
- return /* @__PURE__ */ jsx103("div", { className: `${isHorizontal ? "flex items-center" : "flex flex-col"} ${className}`, children: steps.map((step, index) => {
3967
+ const getStepVisibility = (index) => {
3968
+ if (!isHorizontal || steps.length <= 3) {
3969
+ return { mobile: true, desktop: true };
3970
+ }
3935
3971
  const stepNumber = index + 1;
3936
- const isActive = stepNumber === currentStep;
3937
- const isCompleted = stepNumber < currentStep;
3938
- const isLast = index === steps.length - 1;
3939
- return /* @__PURE__ */ jsxs30(React22.Fragment, { children: [
3940
- /* @__PURE__ */ jsxs30("div", { className: `flex ${isHorizontal ? "flex-col items-center" : "flex-row items-start"} ${isHorizontal ? "" : "flex-1"}`, children: [
3941
- /* @__PURE__ */ jsx103("div", { className: "flex items-center", children: /* @__PURE__ */ jsx103(
3942
- "div",
3943
- {
3944
- className: `flex items-center justify-center w-10 h-10 rounded-full border-2 transition-all ${isCompleted ? "bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500" : isActive ? "border-blue-600 bg-white dark:border-blue-500 dark:bg-gray-800" : "border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800"}`,
3945
- children: isCompleted ? /* @__PURE__ */ jsx103(CheckIcon, { size: "sm", className: "text-white" }) : /* @__PURE__ */ jsx103(
3946
- "span",
3972
+ const distance = Math.abs(stepNumber - currentStep);
3973
+ const mobileVisible = distance <= 1;
3974
+ const desktopVisible = !compact;
3975
+ return { mobile: mobileVisible, desktop: desktopVisible };
3976
+ };
3977
+ const shouldShowCounter = isHorizontal && steps.length > 3;
3978
+ return /* @__PURE__ */ jsxs30("div", { className: `${isHorizontal ? "flex items-start w-full" : "flex flex-col"} ${className}`, children: [
3979
+ shouldShowCounter && /* @__PURE__ */ jsx103("div", { className: "md:hidden flex items-center mr-4 flex-shrink-0", children: /* @__PURE__ */ jsxs30("span", { className: "text-sm font-medium text-gray-600 dark:text-gray-400", children: [
3980
+ currentStep,
3981
+ "/",
3982
+ steps.length
3983
+ ] }) }),
3984
+ steps.map((step, index) => {
3985
+ const stepNumber = index + 1;
3986
+ const isActive = stepNumber === currentStep;
3987
+ const isCompleted = stepNumber < currentStep;
3988
+ const isLast = index === steps.length - 1;
3989
+ const visibility = getStepVisibility(index);
3990
+ const visibleMobileSteps = steps.filter((_, i) => getStepVisibility(i).mobile);
3991
+ const isLastVisibleMobile = index === steps.map((_, i) => i).filter((i) => getStepVisibility(i).mobile).slice(-1)[0];
3992
+ return /* @__PURE__ */ jsxs30(React22.Fragment, { children: [
3993
+ /* @__PURE__ */ jsxs30("div", { className: `
3994
+ flex ${isHorizontal ? "flex-col items-center flex-shrink-0" : "flex-row items-start"}
3995
+ ${isHorizontal ? "" : isLast ? "" : "mb-6"}
3996
+ ${!visibility.mobile ? "hidden md:flex" : ""}
3997
+ ${!visibility.desktop && visibility.mobile ? "md:hidden" : ""}
3998
+ `, children: [
3999
+ /* @__PURE__ */ jsxs30("div", { className: `flex ${isHorizontal ? "flex-col items-center" : "flex-col items-center flex-shrink-0"}`, children: [
4000
+ /* @__PURE__ */ jsx103(
4001
+ "div",
3947
4002
  {
3948
- className: `text-sm font-semibold ${isActive ? "text-blue-600 dark:text-blue-400" : "text-gray-500 dark:text-gray-400"}`,
3949
- children: stepNumber
4003
+ className: `flex items-center justify-center w-10 h-10 rounded-full border-2 transition-all ${isCompleted ? "bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500" : isActive ? "border-blue-600 bg-white dark:border-blue-500 dark:bg-gray-800" : "border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800"}`,
4004
+ children: isCompleted ? /* @__PURE__ */ jsx103(CheckIcon, { size: "sm", className: "text-white" }) : /* @__PURE__ */ jsx103(
4005
+ "span",
4006
+ {
4007
+ className: `text-sm font-semibold ${isActive ? "text-blue-600 dark:text-blue-400" : "text-gray-500 dark:text-gray-400"}`,
4008
+ children: stepNumber
4009
+ }
4010
+ )
4011
+ }
4012
+ ),
4013
+ !isLast && !isHorizontal && /* @__PURE__ */ jsx103(
4014
+ "div",
4015
+ {
4016
+ className: `w-0.5 flex-1 min-h-[24px] ${isCompleted ? "bg-blue-600 dark:bg-blue-500" : "bg-gray-300 dark:bg-gray-600"}`
3950
4017
  }
3951
4018
  )
4019
+ ] }),
4020
+ /* @__PURE__ */ jsxs30("div", { className: `${isHorizontal ? "mt-3 text-center" : "ml-4 flex-1 min-h-[40px] flex flex-col justify-center"}`, children: [
4021
+ /* @__PURE__ */ jsx103(
4022
+ "p",
4023
+ {
4024
+ className: `text-sm font-medium whitespace-nowrap ${isActive || isCompleted ? "text-gray-900 dark:text-gray-100" : "text-gray-500 dark:text-gray-400"}`,
4025
+ children: step.label
4026
+ }
4027
+ ),
4028
+ step.description && /* @__PURE__ */ jsx103("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 whitespace-nowrap", children: step.description })
4029
+ ] })
4030
+ ] }),
4031
+ !isLast && isHorizontal && /* @__PURE__ */ jsx103("div", { className: `
4032
+ flex items-start pt-5 mx-4 min-w-[80px] max-w-[200px] flex-1
4033
+ ${!visibility.mobile || isLastVisibleMobile ? "hidden md:flex" : ""}
4034
+ ${!visibility.desktop && visibility.mobile ? "md:hidden" : ""}
4035
+ `, children: /* @__PURE__ */ jsx103(
4036
+ "div",
4037
+ {
4038
+ className: `h-0.5 w-full ${isCompleted ? "bg-blue-600 dark:bg-blue-500" : "bg-gray-300 dark:bg-gray-600"}`
3952
4039
  }
3953
- ) }),
3954
- /* @__PURE__ */ jsxs30("div", { className: `${isHorizontal ? "mt-2 text-center" : "ml-4 pb-8"} ${isLast && !isHorizontal ? "pb-0" : ""}`, children: [
3955
- /* @__PURE__ */ jsx103(
3956
- "p",
3957
- {
3958
- className: `text-sm font-medium ${isActive || isCompleted ? "text-gray-900 dark:text-gray-100" : "text-gray-500 dark:text-gray-400"}`,
3959
- children: step.label
3960
- }
3961
- ),
3962
- step.description && /* @__PURE__ */ jsx103("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: step.description })
3963
- ] })
3964
- ] }),
3965
- !isLast && /* @__PURE__ */ jsx103(
3966
- "div",
3967
- {
3968
- className: `${isHorizontal ? "flex-1 h-0.5 mx-4" : "w-0.5 h-full ml-5 -mt-8"} ${isCompleted || isActive && stepNumber < currentStep ? "bg-blue-600 dark:bg-blue-500" : "bg-gray-300 dark:bg-gray-600"}`
3969
- }
3970
- )
3971
- ] }, index);
3972
- }) });
4040
+ ) })
4041
+ ] }, index);
4042
+ })
4043
+ ] });
3973
4044
  };
3974
4045
 
3975
4046
  // src/components/Divider.tsx