@marcoschwartz/lite-ui 0.18.0 → 0.19.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
@@ -1920,56 +1920,86 @@ var Tabs = ({
1920
1920
  };
1921
1921
 
1922
1922
  // src/components/Table.tsx
1923
- import { jsx as jsx90, jsxs as jsxs18 } from "react/jsx-runtime";
1923
+ import { Fragment as Fragment14, jsx as jsx90, jsxs as jsxs18 } from "react/jsx-runtime";
1924
1924
  function Table({
1925
1925
  columns,
1926
1926
  data,
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(Fragment14, { children: [
1935
+ /* @__PURE__ */ jsxs18("div", { className: `${responsive ? "hidden md:block" : ""} overflow-x-auto ${className}`, 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-4 ${className}`, 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" : ""
1951
1981
  ].filter(Boolean).join(" ");
1952
1982
  return /* @__PURE__ */ jsx90(
1953
- "tr",
1983
+ "div",
1954
1984
  {
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
- })
1985
+ className: cardClasses,
1986
+ children: columns.map((column) => /* @__PURE__ */ jsxs18(
1987
+ "div",
1988
+ {
1989
+ className: "flex justify-between items-start py-2 border-b border-gray-100 dark:border-gray-800 last:border-b-0",
1990
+ children: [
1991
+ /* @__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 }),
1992
+ /* @__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] })
1993
+ ]
1994
+ },
1995
+ column.key
1996
+ ))
1967
1997
  },
1968
1998
  row[keyField] || rowIndex
1969
1999
  );
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" })
2000
+ }),
2001
+ data.length === 0 && /* @__PURE__ */ jsx90("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
2002
+ ] })
1973
2003
  ] });
1974
2004
  }
1975
2005
 
@@ -2944,15 +2974,22 @@ var Slider = ({
2944
2974
  setInternalValue(newValue);
2945
2975
  onChange?.(newValue);
2946
2976
  };
2947
- const handleRangeMouseDown = (e, handle) => {
2977
+ const handleRangeStart = (clientX, handle) => {
2948
2978
  if (disabled) return;
2949
- e.preventDefault();
2950
2979
  setIsDragging(handle);
2951
2980
  };
2952
- const handleRangeMouseMove = (e) => {
2981
+ const handleRangeMouseDown = (e, handle) => {
2982
+ e.preventDefault();
2983
+ handleRangeStart(e.clientX, handle);
2984
+ };
2985
+ const handleRangeTouchStart = (e, handle) => {
2986
+ e.preventDefault();
2987
+ handleRangeStart(e.touches[0].clientX, handle);
2988
+ };
2989
+ const updateRangeValue = (clientX) => {
2953
2990
  if (!isDragging || !trackRef.current || disabled) return;
2954
2991
  const rect = trackRef.current.getBoundingClientRect();
2955
- const percentage2 = Math.max(0, Math.min(100, (e.clientX - rect.left) / rect.width * 100));
2992
+ const percentage2 = Math.max(0, Math.min(100, (clientX - rect.left) / rect.width * 100));
2956
2993
  const newValue = Math.round(percentage2 / 100 * (max - min) / step) * step + min;
2957
2994
  if (isDragging === "min") {
2958
2995
  const newMin = Math.min(newValue, rangeValue[1] - step);
@@ -2966,16 +3003,28 @@ var Slider = ({
2966
3003
  onRangeChange?.(newRange);
2967
3004
  }
2968
3005
  };
2969
- const handleRangeMouseUp = () => {
3006
+ const handleRangeMouseMove = (e) => {
3007
+ updateRangeValue(e.clientX);
3008
+ };
3009
+ const handleRangeTouchMove = (e) => {
3010
+ if (e.touches.length > 0) {
3011
+ updateRangeValue(e.touches[0].clientX);
3012
+ }
3013
+ };
3014
+ const handleRangeEnd = () => {
2970
3015
  setIsDragging(null);
2971
3016
  };
2972
3017
  React18.useEffect(() => {
2973
3018
  if (isDragging) {
2974
3019
  document.addEventListener("mousemove", handleRangeMouseMove);
2975
- document.addEventListener("mouseup", handleRangeMouseUp);
3020
+ document.addEventListener("mouseup", handleRangeEnd);
3021
+ document.addEventListener("touchmove", handleRangeTouchMove);
3022
+ document.addEventListener("touchend", handleRangeEnd);
2976
3023
  return () => {
2977
3024
  document.removeEventListener("mousemove", handleRangeMouseMove);
2978
- document.removeEventListener("mouseup", handleRangeMouseUp);
3025
+ document.removeEventListener("mouseup", handleRangeEnd);
3026
+ document.removeEventListener("touchmove", handleRangeTouchMove);
3027
+ document.removeEventListener("touchend", handleRangeEnd);
2979
3028
  };
2980
3029
  }
2981
3030
  }, [isDragging, rangeValue]);
@@ -3012,6 +3061,7 @@ var Slider = ({
3012
3061
  `,
3013
3062
  style: { left: `${minPercentage}%` },
3014
3063
  onMouseDown: (e) => handleRangeMouseDown(e, "min"),
3064
+ onTouchStart: (e) => handleRangeTouchStart(e, "min"),
3015
3065
  role: "slider",
3016
3066
  "aria-label": `${label ? label + " " : ""}minimum value`,
3017
3067
  "aria-valuemin": min,
@@ -3028,6 +3078,7 @@ var Slider = ({
3028
3078
  `,
3029
3079
  style: { left: `${maxPercentage}%` },
3030
3080
  onMouseDown: (e) => handleRangeMouseDown(e, "max"),
3081
+ onTouchStart: (e) => handleRangeTouchStart(e, "max"),
3031
3082
  role: "slider",
3032
3083
  "aria-label": `${label ? label + " " : ""}maximum value`,
3033
3084
  "aria-valuemin": rangeValue[0],