@dynostack/react-grid 0.3.2 → 0.5.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/README.md +1089 -1028
- package/dist/index.cjs +175 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -10
- package/dist/index.d.ts +71 -10
- package/dist/index.js +175 -104
- package/dist/index.js.map +1 -1
- package/dist/styles.css +274 -220
- package/dist/tailwind-content.js +3 -0
- package/package.json +87 -81
package/dist/index.js
CHANGED
|
@@ -281,15 +281,21 @@ function PopoverContent({
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
// src/export.ts
|
|
284
|
+
function sanitizeSpreadsheetValue(value) {
|
|
285
|
+
if (value == null) return "";
|
|
286
|
+
const text = String(value);
|
|
287
|
+
if (typeof value === "string" && (/^[\s\u0000-\u001f]*[=+\-@=+-@]/u.test(text) || /^[\t\r\n]/.test(text))) return `'${text}`;
|
|
288
|
+
return text;
|
|
289
|
+
}
|
|
284
290
|
function escapeCsv(value) {
|
|
285
291
|
if (value === null || value === void 0) return "";
|
|
286
|
-
const s =
|
|
292
|
+
const s = sanitizeSpreadsheetValue(value);
|
|
287
293
|
if (/[",\n\r]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
|
|
288
294
|
return s;
|
|
289
295
|
}
|
|
290
296
|
function escapeHtml(value) {
|
|
291
297
|
if (value === null || value === void 0) return "";
|
|
292
|
-
return
|
|
298
|
+
return sanitizeSpreadsheetValue(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
293
299
|
}
|
|
294
300
|
function getExportRows(table) {
|
|
295
301
|
const visible = table.getVisibleLeafColumns().filter((c) => {
|
|
@@ -1899,7 +1905,7 @@ function EditableCell({
|
|
|
1899
1905
|
if (typeof flag === "function") return flag(row.original);
|
|
1900
1906
|
return flag;
|
|
1901
1907
|
})();
|
|
1902
|
-
if (!isEditing) {
|
|
1908
|
+
if (!isEditing || !isEditable) {
|
|
1903
1909
|
const display = renderDisplay(initial, editor, meta);
|
|
1904
1910
|
return /* @__PURE__ */ jsx(
|
|
1905
1911
|
"div",
|
|
@@ -1916,7 +1922,9 @@ function EditableCell({
|
|
|
1916
1922
|
}
|
|
1917
1923
|
);
|
|
1918
1924
|
}
|
|
1919
|
-
const commit = (value) =>
|
|
1925
|
+
const commit = (value) => {
|
|
1926
|
+
if (isEditable) onCommit(value);
|
|
1927
|
+
};
|
|
1920
1928
|
const handleKey = (e) => {
|
|
1921
1929
|
if (e.key === "Enter") commit(local);
|
|
1922
1930
|
else if (e.key === "Escape") onCancel();
|
|
@@ -2046,6 +2054,9 @@ var TOKEN_TO_VAR = {
|
|
|
2046
2054
|
radius: "--radius",
|
|
2047
2055
|
fontFamily: "--font-family"
|
|
2048
2056
|
};
|
|
2057
|
+
function isSafeToken(value) {
|
|
2058
|
+
return typeof value === "string" && !/[;{}<>@\\\u0000-\u001f]/.test(value) && !/\/\*|\*\/|url\s*\(|expression\s*\(/i.test(value);
|
|
2059
|
+
}
|
|
2049
2060
|
function isModed(theme) {
|
|
2050
2061
|
if (!theme) return false;
|
|
2051
2062
|
return "light" in theme || "dark" in theme;
|
|
@@ -2054,8 +2065,8 @@ function tokensToStyle(tokens) {
|
|
|
2054
2065
|
if (!tokens) return {};
|
|
2055
2066
|
const out = {};
|
|
2056
2067
|
for (const [k, v] of Object.entries(tokens)) {
|
|
2057
|
-
if (v
|
|
2058
|
-
const cssVar = TOKEN_TO_VAR[k];
|
|
2068
|
+
if (!isSafeToken(v)) continue;
|
|
2069
|
+
const cssVar = Object.prototype.hasOwnProperty.call(TOKEN_TO_VAR, k) ? TOKEN_TO_VAR[k] : void 0;
|
|
2059
2070
|
if (cssVar) out[cssVar] = v;
|
|
2060
2071
|
}
|
|
2061
2072
|
return out;
|
|
@@ -2094,7 +2105,7 @@ function buildPreset(hue, chroma = 0.03) {
|
|
|
2094
2105
|
border: `oklch(0.9 ${c * 0.8} ${hue})`,
|
|
2095
2106
|
input: `oklch(0.9 ${c * 0.8} ${hue})`,
|
|
2096
2107
|
ring: `oklch(0.55 0.2 ${hue} / 0.5)`,
|
|
2097
|
-
radius: "0.
|
|
2108
|
+
radius: "0.375rem"
|
|
2098
2109
|
},
|
|
2099
2110
|
dark: {
|
|
2100
2111
|
background: `oklch(0.16 ${c * 0.6} ${hue})`,
|
|
@@ -2116,7 +2127,7 @@ function buildPreset(hue, chroma = 0.03) {
|
|
|
2116
2127
|
border: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2117
2128
|
input: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2118
2129
|
ring: `oklch(0.7 0.18 ${hue} / 0.5)`,
|
|
2119
|
-
radius: "0.
|
|
2130
|
+
radius: "0.375rem"
|
|
2120
2131
|
}
|
|
2121
2132
|
};
|
|
2122
2133
|
}
|
|
@@ -2129,8 +2140,8 @@ function tokensToCssBlock(tokens) {
|
|
|
2129
2140
|
if (!tokens) return "";
|
|
2130
2141
|
const parts = [];
|
|
2131
2142
|
for (const [k, v] of Object.entries(tokens)) {
|
|
2132
|
-
if (v
|
|
2133
|
-
const cssVar = TOKEN_TO_VAR[k];
|
|
2143
|
+
if (!isSafeToken(v)) continue;
|
|
2144
|
+
const cssVar = Object.prototype.hasOwnProperty.call(TOKEN_TO_VAR, k) ? TOKEN_TO_VAR[k] : void 0;
|
|
2134
2145
|
if (cssVar) parts.push(`${cssVar}:${v}`);
|
|
2135
2146
|
}
|
|
2136
2147
|
return parts.join(";");
|
|
@@ -2156,7 +2167,7 @@ var neutral = {
|
|
|
2156
2167
|
border: "oklch(0.922 0 0)",
|
|
2157
2168
|
input: "oklch(0.922 0 0)",
|
|
2158
2169
|
ring: "oklch(0.708 0 0)",
|
|
2159
|
-
radius: "0.
|
|
2170
|
+
radius: "0.375rem"
|
|
2160
2171
|
},
|
|
2161
2172
|
dark: {
|
|
2162
2173
|
background: "oklch(0.145 0 0)",
|
|
@@ -2178,11 +2189,38 @@ var neutral = {
|
|
|
2178
2189
|
border: "oklch(0.269 0 0)",
|
|
2179
2190
|
input: "oklch(0.269 0 0)",
|
|
2180
2191
|
ring: "oklch(0.439 0 0)",
|
|
2181
|
-
radius: "0.
|
|
2192
|
+
radius: "0.375rem"
|
|
2182
2193
|
}
|
|
2183
2194
|
};
|
|
2184
2195
|
var themePresets = {
|
|
2185
2196
|
neutral,
|
|
2197
|
+
graphite: {
|
|
2198
|
+
light: {
|
|
2199
|
+
...neutral.light,
|
|
2200
|
+
background: "#fafafa",
|
|
2201
|
+
card: "#ffffff",
|
|
2202
|
+
border: "#e5e5e5",
|
|
2203
|
+
radius: "0.375rem",
|
|
2204
|
+
fontFamily: "'Geist', sans-serif"
|
|
2205
|
+
},
|
|
2206
|
+
dark: {
|
|
2207
|
+
...neutral.dark,
|
|
2208
|
+
background: "#101112",
|
|
2209
|
+
card: "#101112",
|
|
2210
|
+
popover: "#17191b",
|
|
2211
|
+
border: "#292c2f",
|
|
2212
|
+
input: "#303438",
|
|
2213
|
+
muted: "#1b1e21",
|
|
2214
|
+
mutedForeground: "#9ba2aa",
|
|
2215
|
+
accent: "#24282d",
|
|
2216
|
+
primary: "#edf0f3",
|
|
2217
|
+
primaryForeground: "#101112",
|
|
2218
|
+
ring: "#84b8ff",
|
|
2219
|
+
destructive: "#fb7185",
|
|
2220
|
+
radius: "0.375rem",
|
|
2221
|
+
fontFamily: "'Geist', sans-serif"
|
|
2222
|
+
}
|
|
2223
|
+
},
|
|
2186
2224
|
light: { light: neutral.light },
|
|
2187
2225
|
dark: { light: neutral.dark },
|
|
2188
2226
|
violet: buildPreset(285),
|
|
@@ -2546,22 +2584,18 @@ function getPinningStyles(column) {
|
|
|
2546
2584
|
boxShadow: isLast ? "1px 0 0 0 var(--border)" : isFirst ? "-1px 0 0 0 var(--border)" : void 0
|
|
2547
2585
|
};
|
|
2548
2586
|
}
|
|
2549
|
-
var DataTableEditingContext = createContext(
|
|
2550
|
-
null
|
|
2551
|
-
);
|
|
2587
|
+
var DataTableEditingContext = createContext(null);
|
|
2552
2588
|
function useEditingContext() {
|
|
2553
2589
|
const ctx = useContext(DataTableEditingContext);
|
|
2554
2590
|
if (!ctx) throw new Error("DataTable editing context missing");
|
|
2555
2591
|
return ctx;
|
|
2556
2592
|
}
|
|
2593
|
+
function DefaultCellHost(ctx) {
|
|
2594
|
+
const value = ctx.getValue();
|
|
2595
|
+
return value == null ? null : String(value);
|
|
2596
|
+
}
|
|
2557
2597
|
function EditableCellHost(ctx) {
|
|
2558
|
-
const {
|
|
2559
|
-
editingCell,
|
|
2560
|
-
editingRowId,
|
|
2561
|
-
setEditingCell,
|
|
2562
|
-
setRowDraft,
|
|
2563
|
-
onCellEdit
|
|
2564
|
-
} = useEditingContext();
|
|
2598
|
+
const { editingCell, editingRowId, setEditingCell, setRowDraft, onCellEdit } = useEditingContext();
|
|
2565
2599
|
const colId = ctx.column.id;
|
|
2566
2600
|
const rowId = ctx.row.id;
|
|
2567
2601
|
const isCellEdit = editingCell?.rowId === rowId && editingCell.colId === colId;
|
|
@@ -2675,6 +2709,7 @@ var DENSITY_CLASS = {
|
|
|
2675
2709
|
default: "",
|
|
2676
2710
|
comfortable: "[&_tbody_td]:py-2"
|
|
2677
2711
|
};
|
|
2712
|
+
var EMPTY_DATA = [];
|
|
2678
2713
|
function DataTable({
|
|
2679
2714
|
data,
|
|
2680
2715
|
columns,
|
|
@@ -2698,6 +2733,12 @@ function DataTable({
|
|
|
2698
2733
|
pageSizeOptions,
|
|
2699
2734
|
initialColumnPinning,
|
|
2700
2735
|
initialColumnVisibility,
|
|
2736
|
+
initialSorting,
|
|
2737
|
+
onSelectionChange,
|
|
2738
|
+
ariaLabel = "Data table",
|
|
2739
|
+
striped = false,
|
|
2740
|
+
stickyHeader = false,
|
|
2741
|
+
maxHeight,
|
|
2701
2742
|
globalFilter: globalFilterProp,
|
|
2702
2743
|
onGlobalFilterChange,
|
|
2703
2744
|
className,
|
|
@@ -2731,12 +2772,13 @@ function DataTable({
|
|
|
2731
2772
|
() => `dyno-grid-${rawInstanceId.replace(/[^a-zA-Z0-9]/g, "")}`,
|
|
2732
2773
|
[rawInstanceId]
|
|
2733
2774
|
);
|
|
2734
|
-
const { lightStyle, darkCss } = useMemo(() => {
|
|
2775
|
+
const { lightStyle, lightCss, darkCss } = useMemo(() => {
|
|
2735
2776
|
const { light, dark } = splitTheme(theme);
|
|
2736
2777
|
const lightTokens = isolate ? { ...ISOLATE_LIGHT_TOKENS, ...light ?? {} } : light;
|
|
2737
2778
|
const darkTokens = isolate ? { ...ISOLATE_DARK_TOKENS, ...dark ?? light ?? {} } : dark;
|
|
2738
2779
|
return {
|
|
2739
2780
|
lightStyle: tokensToStyle(lightTokens),
|
|
2781
|
+
lightCss: tokensToCssBlock(lightTokens),
|
|
2740
2782
|
darkCss: darkTokens ? tokensToCssBlock(darkTokens) : null
|
|
2741
2783
|
};
|
|
2742
2784
|
}, [theme, isolate]);
|
|
@@ -2774,7 +2816,7 @@ function DataTable({
|
|
|
2774
2816
|
}
|
|
2775
2817
|
setConfirmCtx(null);
|
|
2776
2818
|
};
|
|
2777
|
-
const [sorting, setSorting] = useState([]);
|
|
2819
|
+
const [sorting, setSorting] = useState(initialSorting ?? []);
|
|
2778
2820
|
const [columnFilters, setColumnFilters] = useState([]);
|
|
2779
2821
|
const [internalGlobalFilter, setInternalGlobalFilter] = useState("");
|
|
2780
2822
|
const isControlledFilter = globalFilterProp !== void 0;
|
|
@@ -2786,19 +2828,17 @@ function DataTable({
|
|
|
2786
2828
|
const [columnVisibility, setColumnVisibility] = useState(
|
|
2787
2829
|
initialColumnVisibility ?? {}
|
|
2788
2830
|
);
|
|
2789
|
-
const [columnPinning, setColumnPinning] = useState(
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
left.splice(idx + 1, 0, "__expand");
|
|
2798
|
-
}
|
|
2799
|
-
return { left, right };
|
|
2831
|
+
const [columnPinning, setColumnPinning] = useState(() => {
|
|
2832
|
+
const base = initialColumnPinning ?? { left: [], right: [] };
|
|
2833
|
+
const left = [...base.left ?? []];
|
|
2834
|
+
const right = [...base.right ?? []];
|
|
2835
|
+
const hasExpandColumn = !!(renderSubRow || getSubRows);
|
|
2836
|
+
if (hasExpandColumn && left.includes("__select") && !left.includes("__expand")) {
|
|
2837
|
+
const idx = left.indexOf("__select");
|
|
2838
|
+
left.splice(idx + 1, 0, "__expand");
|
|
2800
2839
|
}
|
|
2801
|
-
|
|
2840
|
+
return { left, right };
|
|
2841
|
+
});
|
|
2802
2842
|
const [columnSizing, setColumnSizing] = useState({});
|
|
2803
2843
|
const [rowSelection, setRowSelection] = useState({});
|
|
2804
2844
|
const [expanded, setExpanded] = useState({});
|
|
@@ -2870,7 +2910,7 @@ function DataTable({
|
|
|
2870
2910
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2871
2911
|
...dataSourceDeps
|
|
2872
2912
|
]);
|
|
2873
|
-
const baseData = dataSourceEnabled ? sourceRows : data ??
|
|
2913
|
+
const baseData = dataSourceEnabled ? sourceRows : data ?? EMPTY_DATA;
|
|
2874
2914
|
const effectiveIsLoading = dataSourceEnabled ? sourceLoading : isLoading;
|
|
2875
2915
|
const effectiveIsFetching = dataSourceEnabled ? sourceFetching : isFetching;
|
|
2876
2916
|
const effectiveOnRefresh = dataSourceEnabled ? () => setSourceRefreshKey((key) => key + 1) : onRefresh;
|
|
@@ -2914,7 +2954,7 @@ function DataTable({
|
|
|
2914
2954
|
title: headerLabel
|
|
2915
2955
|
}
|
|
2916
2956
|
),
|
|
2917
|
-
cell: hasEditor ? EditableCellHost : original
|
|
2957
|
+
cell: hasEditor ? EditableCellHost : original ?? DefaultCellHost
|
|
2918
2958
|
};
|
|
2919
2959
|
};
|
|
2920
2960
|
const built = columns.map(wrap);
|
|
@@ -2984,7 +3024,9 @@ function DataTable({
|
|
|
2984
3024
|
customRowActions?.length
|
|
2985
3025
|
]);
|
|
2986
3026
|
const [columnOrder, setColumnOrder] = useState(
|
|
2987
|
-
() => augmentedColumns.map(
|
|
3027
|
+
() => augmentedColumns.map(
|
|
3028
|
+
(c) => c.id ?? c.accessorKey ?? ""
|
|
3029
|
+
)
|
|
2988
3030
|
);
|
|
2989
3031
|
useEffect(() => {
|
|
2990
3032
|
const next = augmentedColumns.map(
|
|
@@ -3026,10 +3068,10 @@ function DataTable({
|
|
|
3026
3068
|
enableColumnFilters: f.filtering,
|
|
3027
3069
|
enableColumnResizing: f.resizing,
|
|
3028
3070
|
columnResizeMode: "onChange",
|
|
3029
|
-
enableRowSelection:
|
|
3071
|
+
enableRowSelection: enableSelection,
|
|
3030
3072
|
enableExpanding: !!(renderSubRow || getSubRows),
|
|
3031
3073
|
enablePinning: f.pinning,
|
|
3032
|
-
manualPagination: isServerSideDataSource,
|
|
3074
|
+
manualPagination: isServerSideDataSource || !f.pagination,
|
|
3033
3075
|
manualSorting: isServerSideDataSource,
|
|
3034
3076
|
manualFiltering: isServerSideDataSource,
|
|
3035
3077
|
pageCount: isServerSideDataSource ? Math.max(1, Math.ceil(effectiveTotalRecords / pagination.pageSize)) : void 0,
|
|
@@ -3119,6 +3161,13 @@ function DataTable({
|
|
|
3119
3161
|
setEditingRowId(tempId);
|
|
3120
3162
|
} : void 0;
|
|
3121
3163
|
const rows = table.getRowModel().rows;
|
|
3164
|
+
const selectionCallback = useRef(onSelectionChange);
|
|
3165
|
+
selectionCallback.current = onSelectionChange;
|
|
3166
|
+
useEffect(() => {
|
|
3167
|
+
selectionCallback.current?.(
|
|
3168
|
+
table.getSelectedRowModel().flatRows.map((row) => row.original)
|
|
3169
|
+
);
|
|
3170
|
+
}, [rowSelection, mergedData, table]);
|
|
3122
3171
|
const visibleLeafCount = table.getVisibleLeafColumns().length;
|
|
3123
3172
|
const editingContextValue = useMemo(
|
|
3124
3173
|
() => ({
|
|
@@ -3169,12 +3218,15 @@ function DataTable({
|
|
|
3169
3218
|
DENSITY_CLASS[density],
|
|
3170
3219
|
className
|
|
3171
3220
|
),
|
|
3172
|
-
style: lightStyle,
|
|
3221
|
+
style: darkCss ? void 0 : lightStyle,
|
|
3173
3222
|
children: [
|
|
3174
3223
|
darkCss && /* @__PURE__ */ jsxs("style", { children: [
|
|
3224
|
+
`[data-dyno-grid="${instanceId}"]{${lightCss}}`,
|
|
3175
3225
|
`@media (prefers-color-scheme: dark){[data-dyno-grid="${instanceId}"]{${darkCss}}}`,
|
|
3176
3226
|
`.dark [data-dyno-grid="${instanceId}"]{${darkCss}}`,
|
|
3177
|
-
|
|
3227
|
+
`.light [data-dyno-grid="${instanceId}"]{${lightCss}}`,
|
|
3228
|
+
`[data-dyno-grid="${instanceId}"].dark{${darkCss}}`,
|
|
3229
|
+
`[data-dyno-grid="${instanceId}"].light{${lightCss}}`
|
|
3178
3230
|
] }),
|
|
3179
3231
|
/* @__PURE__ */ jsx(
|
|
3180
3232
|
DataTableToolbar,
|
|
@@ -3196,75 +3248,88 @@ function DataTable({
|
|
|
3196
3248
|
labels
|
|
3197
3249
|
}
|
|
3198
3250
|
),
|
|
3199
|
-
/* @__PURE__ */ jsxs("div", { className: "relative w-full overflow-auto", children: [
|
|
3251
|
+
/* @__PURE__ */ jsxs("div", { className: "relative w-full overflow-auto", style: { maxHeight }, children: [
|
|
3200
3252
|
/* @__PURE__ */ jsxs(
|
|
3201
3253
|
"table",
|
|
3202
3254
|
{
|
|
3203
|
-
|
|
3255
|
+
"aria-label": ariaLabel,
|
|
3256
|
+
className: cn(
|
|
3257
|
+
"w-full caption-bottom text-sm",
|
|
3258
|
+
striped && "[&_tbody>tr:nth-child(even)]:bg-muted/25"
|
|
3259
|
+
),
|
|
3204
3260
|
style: {
|
|
3205
3261
|
width: table.getCenterTotalSize() ? void 0 : "100%",
|
|
3206
3262
|
minWidth: "100%"
|
|
3207
3263
|
},
|
|
3208
3264
|
children: [
|
|
3209
|
-
/* @__PURE__ */ jsx(
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
GripVerticalIcon,
|
|
3242
|
-
{
|
|
3243
|
-
className: "-ml-1 size-3 shrink-0 text-muted-foreground/40 opacity-0 transition group-hover/th:opacity-100",
|
|
3244
|
-
"aria-hidden": "true"
|
|
3245
|
-
}
|
|
3265
|
+
/* @__PURE__ */ jsx(
|
|
3266
|
+
"thead",
|
|
3267
|
+
{
|
|
3268
|
+
className: cn("bg-card", stickyHeader && "sticky top-0 z-10"),
|
|
3269
|
+
children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsx("tr", { className: "border-b", children: hg.headers.map((header) => {
|
|
3270
|
+
const meta = header.column.columnDef.meta;
|
|
3271
|
+
const isUtility = header.column.id === "__select" || header.column.id === "__expand" || header.column.id === "__actions";
|
|
3272
|
+
const isPinned = !!header.column.getIsPinned();
|
|
3273
|
+
const canReorder = !isUtility && f.reordering;
|
|
3274
|
+
const isDropTarget = canReorder && dragOverColId === header.column.id;
|
|
3275
|
+
const isBeingDragged = canReorder && activeReorderId === header.column.id;
|
|
3276
|
+
return /* @__PURE__ */ jsxs(
|
|
3277
|
+
"th",
|
|
3278
|
+
{
|
|
3279
|
+
colSpan: header.colSpan,
|
|
3280
|
+
"data-col-id": header.column.id,
|
|
3281
|
+
onPointerDown: canReorder ? onHeaderPointerDown(header.column.id) : void 0,
|
|
3282
|
+
onPointerMove: canReorder ? onHeaderPointerMove : void 0,
|
|
3283
|
+
onPointerUp: canReorder ? onHeaderPointerUp : void 0,
|
|
3284
|
+
onPointerCancel: canReorder ? onHeaderPointerUp : void 0,
|
|
3285
|
+
style: {
|
|
3286
|
+
width: header.getSize(),
|
|
3287
|
+
...getPinningStyles(header.column),
|
|
3288
|
+
...isPinned ? { zIndex: 2 } : {}
|
|
3289
|
+
},
|
|
3290
|
+
className: cn(
|
|
3291
|
+
"group/th relative h-9 px-2 text-left align-middle text-xs font-medium text-muted-foreground select-none",
|
|
3292
|
+
canReorder && "cursor-grab active:cursor-grabbing",
|
|
3293
|
+
isPinned && "bg-card",
|
|
3294
|
+
isBeingDragged && "opacity-50",
|
|
3295
|
+
isDropTarget && "bg-primary/10 ring-2 ring-primary/40 ring-inset",
|
|
3296
|
+
meta?.headerClassName
|
|
3246
3297
|
),
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3298
|
+
children: [
|
|
3299
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3300
|
+
canReorder && /* @__PURE__ */ jsx(
|
|
3301
|
+
GripVerticalIcon,
|
|
3302
|
+
{
|
|
3303
|
+
className: "-ml-1 size-3 shrink-0 text-muted-foreground/40 opacity-0 transition group-hover/th:opacity-100",
|
|
3304
|
+
"aria-hidden": "true"
|
|
3305
|
+
}
|
|
3306
|
+
),
|
|
3307
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: header.isPlaceholder ? null : flexRender(
|
|
3308
|
+
header.column.columnDef.header,
|
|
3309
|
+
header.getContext()
|
|
3310
|
+
) })
|
|
3311
|
+
] }),
|
|
3312
|
+
header.column.getCanResize() && /* @__PURE__ */ jsx(
|
|
3313
|
+
"span",
|
|
3314
|
+
{
|
|
3315
|
+
"data-no-drag": true,
|
|
3316
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
3317
|
+
onMouseDown: header.getResizeHandler(),
|
|
3318
|
+
onTouchStart: header.getResizeHandler(),
|
|
3319
|
+
onDoubleClick: () => header.column.resetSize(),
|
|
3320
|
+
className: cn(
|
|
3321
|
+
"absolute top-0 right-0 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors select-none hover:bg-primary/40",
|
|
3322
|
+
header.column.getIsResizing() && "bg-primary"
|
|
3323
|
+
)
|
|
3324
|
+
}
|
|
3260
3325
|
)
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3326
|
+
]
|
|
3327
|
+
},
|
|
3328
|
+
header.id
|
|
3329
|
+
);
|
|
3330
|
+
}) }, hg.id))
|
|
3331
|
+
}
|
|
3332
|
+
),
|
|
3268
3333
|
/* @__PURE__ */ jsx("tbody", { children: effectiveIsLoading ? renderSkeleton(visibleLeafCount, pagination.pageSize) : sourceError && rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
3269
3334
|
"td",
|
|
3270
3335
|
{
|
|
@@ -3308,7 +3373,13 @@ function DataTable({
|
|
|
3308
3373
|
labels.refreshing
|
|
3309
3374
|
] })
|
|
3310
3375
|
] }),
|
|
3311
|
-
f.pagination && /* @__PURE__ */ jsx(
|
|
3376
|
+
f.pagination && /* @__PURE__ */ jsx(
|
|
3377
|
+
DataTablePagination,
|
|
3378
|
+
{
|
|
3379
|
+
table,
|
|
3380
|
+
pageSizeOptions
|
|
3381
|
+
}
|
|
3382
|
+
),
|
|
3312
3383
|
/* @__PURE__ */ jsx(
|
|
3313
3384
|
DataTableViewSheet,
|
|
3314
3385
|
{
|
|
@@ -3382,6 +3453,6 @@ function renderSkeleton(cols, rows) {
|
|
|
3382
3453
|
return Array.from({ length: rows }).map((_, r) => /* @__PURE__ */ jsx("tr", { className: "border-b", children: Array.from({ length: cols }).map((__, c) => /* @__PURE__ */ jsx("td", { className: "px-2 py-2", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }) }, c)) }, r));
|
|
3383
3454
|
}
|
|
3384
3455
|
|
|
3385
|
-
export { ColumnFilterPanel, DataTable, DataTableColumnHeader, DataTablePagination, DataTableRowActions, DataTableToolbar, EditableCell, ISOLATE_DARK_TOKENS, ISOLATE_LIGHT_TOKENS, PortalContainerContext, booleanFilterFn, buildPreset, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, splitTheme, textFilterFn, themePresets, themeToStyle, tokensToCssBlock, tokensToStyle, usePortalContainer };
|
|
3456
|
+
export { ColumnFilterPanel, DataTable, DataTableColumnHeader, DataTablePagination, DataTableRowActions, DataTableToolbar, EditableCell, ISOLATE_DARK_TOKENS, ISOLATE_LIGHT_TOKENS, PortalContainerContext, booleanFilterFn, buildPreset, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, sanitizeSpreadsheetValue, setFilterFn, splitTheme, textFilterFn, themePresets, themeToStyle, tokensToCssBlock, tokensToStyle, usePortalContainer };
|
|
3386
3457
|
//# sourceMappingURL=index.js.map
|
|
3387
3458
|
//# sourceMappingURL=index.js.map
|