@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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +93 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -43
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -220,8 +220,9 @@ interface TableProps<T = any> {
|
|
|
220
220
|
striped?: boolean;
|
|
221
221
|
hoverable?: boolean;
|
|
222
222
|
className?: string;
|
|
223
|
+
responsive?: boolean;
|
|
223
224
|
}
|
|
224
|
-
declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
|
|
225
|
+
declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, responsive, }: TableProps<T>): react_jsx_runtime.JSX.Element;
|
|
225
226
|
|
|
226
227
|
interface PaginationProps {
|
|
227
228
|
currentPage: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -220,8 +220,9 @@ interface TableProps<T = any> {
|
|
|
220
220
|
striped?: boolean;
|
|
221
221
|
hoverable?: boolean;
|
|
222
222
|
className?: string;
|
|
223
|
+
responsive?: boolean;
|
|
223
224
|
}
|
|
224
|
-
declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
|
|
225
|
+
declare function Table<T extends Record<string, any>>({ columns, data, keyField, striped, hoverable, className, responsive, }: TableProps<T>): react_jsx_runtime.JSX.Element;
|
|
225
226
|
|
|
226
227
|
interface PaginationProps {
|
|
227
228
|
currentPage: number;
|
package/dist/index.js
CHANGED
|
@@ -2078,49 +2078,79 @@ function Table({
|
|
|
2078
2078
|
keyField = "id",
|
|
2079
2079
|
striped = false,
|
|
2080
2080
|
hoverable = true,
|
|
2081
|
-
className = ""
|
|
2081
|
+
className = "",
|
|
2082
|
+
responsive = true
|
|
2082
2083
|
}) {
|
|
2083
2084
|
const { theme } = useTheme();
|
|
2084
|
-
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
|
|
2085
|
-
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("
|
|
2086
|
-
/* @__PURE__ */ (0, import_jsx_runtime90.
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
|
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: `${responsive ? "hidden md:block" : ""} overflow-x-auto ${className}`, children: [
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("table", { className: "w-full text-left", children: [
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)("thead", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tr", { children: columns.map((column, colIndex) => {
|
|
2089
|
+
const isLast = colIndex === columns.length - 1;
|
|
2090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
2091
|
+
"th",
|
|
2092
|
+
{
|
|
2093
|
+
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",
|
|
2094
|
+
style: { width: column.width },
|
|
2095
|
+
children: column.title
|
|
2096
|
+
},
|
|
2097
|
+
column.key
|
|
2098
|
+
);
|
|
2099
|
+
}) }) }),
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)("tbody", { className: "bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700", children: data.map((row, rowIndex) => {
|
|
2101
|
+
const rowClasses = [
|
|
2102
|
+
striped && rowIndex % 2 === 1 ? "bg-gray-50 dark:bg-gray-800/50" : "",
|
|
2103
|
+
hoverable ? "hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" : ""
|
|
2104
|
+
].filter(Boolean).join(" ");
|
|
2105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
2106
|
+
"tr",
|
|
2107
|
+
{
|
|
2108
|
+
className: rowClasses,
|
|
2109
|
+
children: columns.map((column, colIndex) => {
|
|
2110
|
+
const isLast = colIndex === columns.length - 1;
|
|
2111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
2112
|
+
"td",
|
|
2113
|
+
{
|
|
2114
|
+
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",
|
|
2115
|
+
children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
|
|
2116
|
+
},
|
|
2117
|
+
column.key
|
|
2118
|
+
);
|
|
2119
|
+
})
|
|
2120
|
+
},
|
|
2121
|
+
row[keyField] || rowIndex
|
|
2122
|
+
);
|
|
2123
|
+
}) })
|
|
2124
|
+
] }),
|
|
2125
|
+
data.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
|
|
2126
|
+
] }),
|
|
2127
|
+
responsive && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: `md:hidden space-y-4 ${className}`, children: [
|
|
2128
|
+
data.map((row, rowIndex) => {
|
|
2129
|
+
const cardClasses = [
|
|
2130
|
+
"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4 shadow-sm",
|
|
2131
|
+
hoverable ? "hover:shadow-md transition-shadow" : ""
|
|
2102
2132
|
].filter(Boolean).join(" ");
|
|
2103
2133
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
2104
|
-
"
|
|
2134
|
+
"div",
|
|
2105
2135
|
{
|
|
2106
|
-
className:
|
|
2107
|
-
children: columns.map((column
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
"
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
children: column.render ? column.render(row[column.key], row, rowIndex) : row[column.key]
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2136
|
+
className: cardClasses,
|
|
2137
|
+
children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
|
|
2138
|
+
"div",
|
|
2139
|
+
{
|
|
2140
|
+
className: "flex justify-between items-start py-2 border-b border-gray-100 dark:border-gray-800 last:border-b-0",
|
|
2141
|
+
children: [
|
|
2142
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider flex-shrink-0 mr-4", children: column.title }),
|
|
2143
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)("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] })
|
|
2144
|
+
]
|
|
2145
|
+
},
|
|
2146
|
+
column.key
|
|
2147
|
+
))
|
|
2118
2148
|
},
|
|
2119
2149
|
row[keyField] || rowIndex
|
|
2120
2150
|
);
|
|
2121
|
-
})
|
|
2122
|
-
|
|
2123
|
-
|
|
2151
|
+
}),
|
|
2152
|
+
data.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: "No data available" })
|
|
2153
|
+
] })
|
|
2124
2154
|
] });
|
|
2125
2155
|
}
|
|
2126
2156
|
|
|
@@ -3095,15 +3125,22 @@ var Slider = ({
|
|
|
3095
3125
|
setInternalValue(newValue);
|
|
3096
3126
|
onChange?.(newValue);
|
|
3097
3127
|
};
|
|
3098
|
-
const
|
|
3128
|
+
const handleRangeStart = (clientX, handle) => {
|
|
3099
3129
|
if (disabled) return;
|
|
3100
|
-
e.preventDefault();
|
|
3101
3130
|
setIsDragging(handle);
|
|
3102
3131
|
};
|
|
3103
|
-
const
|
|
3132
|
+
const handleRangeMouseDown = (e, handle) => {
|
|
3133
|
+
e.preventDefault();
|
|
3134
|
+
handleRangeStart(e.clientX, handle);
|
|
3135
|
+
};
|
|
3136
|
+
const handleRangeTouchStart = (e, handle) => {
|
|
3137
|
+
e.preventDefault();
|
|
3138
|
+
handleRangeStart(e.touches[0].clientX, handle);
|
|
3139
|
+
};
|
|
3140
|
+
const updateRangeValue = (clientX) => {
|
|
3104
3141
|
if (!isDragging || !trackRef.current || disabled) return;
|
|
3105
3142
|
const rect = trackRef.current.getBoundingClientRect();
|
|
3106
|
-
const percentage2 = Math.max(0, Math.min(100, (
|
|
3143
|
+
const percentage2 = Math.max(0, Math.min(100, (clientX - rect.left) / rect.width * 100));
|
|
3107
3144
|
const newValue = Math.round(percentage2 / 100 * (max - min) / step) * step + min;
|
|
3108
3145
|
if (isDragging === "min") {
|
|
3109
3146
|
const newMin = Math.min(newValue, rangeValue[1] - step);
|
|
@@ -3117,16 +3154,28 @@ var Slider = ({
|
|
|
3117
3154
|
onRangeChange?.(newRange);
|
|
3118
3155
|
}
|
|
3119
3156
|
};
|
|
3120
|
-
const
|
|
3157
|
+
const handleRangeMouseMove = (e) => {
|
|
3158
|
+
updateRangeValue(e.clientX);
|
|
3159
|
+
};
|
|
3160
|
+
const handleRangeTouchMove = (e) => {
|
|
3161
|
+
if (e.touches.length > 0) {
|
|
3162
|
+
updateRangeValue(e.touches[0].clientX);
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
const handleRangeEnd = () => {
|
|
3121
3166
|
setIsDragging(null);
|
|
3122
3167
|
};
|
|
3123
3168
|
import_react18.default.useEffect(() => {
|
|
3124
3169
|
if (isDragging) {
|
|
3125
3170
|
document.addEventListener("mousemove", handleRangeMouseMove);
|
|
3126
|
-
document.addEventListener("mouseup",
|
|
3171
|
+
document.addEventListener("mouseup", handleRangeEnd);
|
|
3172
|
+
document.addEventListener("touchmove", handleRangeTouchMove);
|
|
3173
|
+
document.addEventListener("touchend", handleRangeEnd);
|
|
3127
3174
|
return () => {
|
|
3128
3175
|
document.removeEventListener("mousemove", handleRangeMouseMove);
|
|
3129
|
-
document.removeEventListener("mouseup",
|
|
3176
|
+
document.removeEventListener("mouseup", handleRangeEnd);
|
|
3177
|
+
document.removeEventListener("touchmove", handleRangeTouchMove);
|
|
3178
|
+
document.removeEventListener("touchend", handleRangeEnd);
|
|
3130
3179
|
};
|
|
3131
3180
|
}
|
|
3132
3181
|
}, [isDragging, rangeValue]);
|
|
@@ -3163,6 +3212,7 @@ var Slider = ({
|
|
|
3163
3212
|
`,
|
|
3164
3213
|
style: { left: `${minPercentage}%` },
|
|
3165
3214
|
onMouseDown: (e) => handleRangeMouseDown(e, "min"),
|
|
3215
|
+
onTouchStart: (e) => handleRangeTouchStart(e, "min"),
|
|
3166
3216
|
role: "slider",
|
|
3167
3217
|
"aria-label": `${label ? label + " " : ""}minimum value`,
|
|
3168
3218
|
"aria-valuemin": min,
|
|
@@ -3179,6 +3229,7 @@ var Slider = ({
|
|
|
3179
3229
|
`,
|
|
3180
3230
|
style: { left: `${maxPercentage}%` },
|
|
3181
3231
|
onMouseDown: (e) => handleRangeMouseDown(e, "max"),
|
|
3232
|
+
onTouchStart: (e) => handleRangeTouchStart(e, "max"),
|
|
3182
3233
|
role: "slider",
|
|
3183
3234
|
"aria-label": `${label ? label + " " : ""}maximum value`,
|
|
3184
3235
|
"aria-valuemin": rangeValue[0],
|