@dynamic-labs-sdk/droplet 1.52.3 → 1.52.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/components/ui/data-table/actions-column.d.ts +40 -0
- package/dist/components/ui/data-table/actions-column.d.ts.map +1 -0
- package/dist/components/ui/data-table/data-table-active-filters.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-column-filter.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-column-visibility.d.ts +1 -1
- package/dist/components/ui/data-table/data-table-column-visibility.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-content.d.ts +22 -6
- package/dist/components/ui/data-table/data-table-content.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-context.d.ts +2 -0
- package/dist/components/ui/data-table/data-table-context.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-labels.d.ts +88 -0
- package/dist/components/ui/data-table/data-table-labels.d.ts.map +1 -0
- package/dist/components/ui/data-table/data-table-pagination.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-placeholder-rows.d.ts +3 -1
- package/dist/components/ui/data-table/data-table-placeholder-rows.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-rows.d.ts +5 -2
- package/dist/components/ui/data-table/data-table-rows.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-search.d.ts +1 -1
- package/dist/components/ui/data-table/data-table-search.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table.d.ts +11 -1
- package/dist/components/ui/data-table/data-table.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table.stories.d.ts +4 -1
- package/dist/components/ui/data-table/data-table.stories.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table.types.d.ts +23 -2
- package/dist/components/ui/data-table/data-table.types.d.ts.map +1 -1
- package/dist/components/ui/data-table/is-row-activation.d.ts +10 -0
- package/dist/components/ui/data-table/is-row-activation.d.ts.map +1 -0
- package/dist/components/ui/data-table/selection-column.d.ts.map +1 -1
- package/dist/components/ui/pagination/index.d.ts +1 -1
- package/dist/components/ui/pagination/index.d.ts.map +1 -1
- package/dist/components/ui/pagination/pagination.d.ts +26 -2
- package/dist/components/ui/pagination/pagination.d.ts.map +1 -1
- package/dist/components/ui/table/table.d.ts +6 -1
- package/dist/components/ui/table/table.d.ts.map +1 -1
- package/dist/index.cjs +296 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +295 -87
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2274,6 +2274,11 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ jsxs("sp
|
|
|
2274
2274
|
children: "More pages"
|
|
2275
2275
|
})]
|
|
2276
2276
|
});
|
|
2277
|
+
const DEFAULT_CURSOR_PAGINATION_LABELS = {
|
|
2278
|
+
next: "Go to next page",
|
|
2279
|
+
previous: "Go to previous page",
|
|
2280
|
+
region: "Pagination"
|
|
2281
|
+
};
|
|
2277
2282
|
/**
|
|
2278
2283
|
* Pre-assembled cursor-based pagination bar.
|
|
2279
2284
|
*
|
|
@@ -2293,8 +2298,8 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ jsxs("sp
|
|
|
2293
2298
|
* />
|
|
2294
2299
|
* ```
|
|
2295
2300
|
*/
|
|
2296
|
-
const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, className }) => /* @__PURE__ */ jsxs("nav", {
|
|
2297
|
-
"aria-label":
|
|
2301
|
+
const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, labels = DEFAULT_CURSOR_PAGINATION_LABELS, className }) => /* @__PURE__ */ jsxs("nav", {
|
|
2302
|
+
"aria-label": labels.region,
|
|
2298
2303
|
"data-slot": "cursor-pagination",
|
|
2299
2304
|
className: cn("flex items-center justify-end gap-3", className),
|
|
2300
2305
|
children: [label !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
@@ -2308,7 +2313,7 @@ const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, cla
|
|
|
2308
2313
|
className: "size-8 before:-inset-1",
|
|
2309
2314
|
disabled: !hasPrevious,
|
|
2310
2315
|
onClick: onPrevious,
|
|
2311
|
-
"aria-label":
|
|
2316
|
+
"aria-label": labels.previous,
|
|
2312
2317
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
2313
2318
|
icon: ArrowLeft01Icon,
|
|
2314
2319
|
size: 16,
|
|
@@ -2320,7 +2325,7 @@ const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, cla
|
|
|
2320
2325
|
className: "size-8 before:-inset-1",
|
|
2321
2326
|
disabled: !hasNext,
|
|
2322
2327
|
onClick: onNext,
|
|
2323
|
-
"aria-label":
|
|
2328
|
+
"aria-label": labels.next,
|
|
2324
2329
|
children: /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
2325
2330
|
icon: ArrowRight01Icon,
|
|
2326
2331
|
size: 16,
|
|
@@ -2731,13 +2736,10 @@ const measureShelfTop = ({ scrollArea, table }) => {
|
|
|
2731
2736
|
return body ? body.getBoundingClientRect().top - scrollArea.getBoundingClientRect().top + scrollArea.scrollTop : 0;
|
|
2732
2737
|
};
|
|
2733
2738
|
/**
|
|
2734
|
-
*
|
|
2735
|
-
*
|
|
2736
|
-
* only for static layout: a short fixed grid of values that nobody sorts, filters, pages or selects.
|
|
2737
|
-
*
|
|
2738
|
-
* @deprecated For lists of records, use `DataTable`. Direct use is only for static layout.
|
|
2739
|
+
* The table tray `DataTable` renders. Same as `Table`, without the deprecation that steers apps toward `DataTable`;
|
|
2740
|
+
* only `DataTable` should use it, and it is not exported from the package.
|
|
2739
2741
|
*/
|
|
2740
|
-
const
|
|
2742
|
+
const TableFrame = ({ className, fill = false, scrollAreaProps = {}, stickyFirstColumn = false, viewportRef, ...props }) => {
|
|
2741
2743
|
const scrollAreaRef = useRef(null);
|
|
2742
2744
|
const setViewportRef = useMemo(() => mergeRefs(scrollAreaRef, viewportRef), [viewportRef]);
|
|
2743
2745
|
const [overflow, setOverflow] = useState({
|
|
@@ -2931,6 +2933,14 @@ const Table = ({ className, fill = false, scrollAreaProps = {}, stickyFirstColum
|
|
|
2931
2933
|
})
|
|
2932
2934
|
});
|
|
2933
2935
|
};
|
|
2936
|
+
/**
|
|
2937
|
+
* Render a table in a stable tray with keyboard access only when content overflows.
|
|
2938
|
+
* For any list of records, use `DataTable`, which is built on this. Use `Table` directly
|
|
2939
|
+
* only for static layout: a short fixed grid of values that nobody sorts, filters, pages or selects.
|
|
2940
|
+
*
|
|
2941
|
+
* @deprecated For lists of records, use `DataTable`. Direct use is only for static layout.
|
|
2942
|
+
*/
|
|
2943
|
+
const Table = TableFrame;
|
|
2934
2944
|
const TableHeader = ({ className, ...props }) => {
|
|
2935
2945
|
return /* @__PURE__ */ jsx("thead", {
|
|
2936
2946
|
"data-slot": "table-header",
|
|
@@ -2982,6 +2992,99 @@ const TableCaption = ({ className, ...props }) => {
|
|
|
2982
2992
|
});
|
|
2983
2993
|
};
|
|
2984
2994
|
|
|
2995
|
+
//#endregion
|
|
2996
|
+
//#region src/components/ui/data-table/data-table-context.ts
|
|
2997
|
+
const DataTableContext = createContext(null);
|
|
2998
|
+
/**
|
|
2999
|
+
* Read the state of the nearest `DataTable`, for building custom table parts.
|
|
3000
|
+
* Throws when called outside a `DataTable`.
|
|
3001
|
+
*/
|
|
3002
|
+
const useDataTableContext = () => {
|
|
3003
|
+
const context = useContext(DataTableContext);
|
|
3004
|
+
if (!context) throw new Error("DataTable parts must be used inside a DataTable");
|
|
3005
|
+
return context;
|
|
3006
|
+
};
|
|
3007
|
+
|
|
3008
|
+
//#endregion
|
|
3009
|
+
//#region src/components/ui/data-table/actions-column.tsx
|
|
3010
|
+
/**
|
|
3011
|
+
* Column id of `actionsColumn`, for pinning it or checking for it.
|
|
3012
|
+
*
|
|
3013
|
+
* @example
|
|
3014
|
+
* ```tsx
|
|
3015
|
+
* const options = { columnPinning: { initial: { right: [ACTIONS_COLUMN_ID] } } };
|
|
3016
|
+
* ```
|
|
3017
|
+
* @see actionsColumn
|
|
3018
|
+
* @see useDataTable
|
|
3019
|
+
*/
|
|
3020
|
+
const ACTIONS_COLUMN_ID = "actions";
|
|
3021
|
+
/** Fixed width in px; DataTableContent sizes headers from it when resizing or pinning is on. */
|
|
3022
|
+
const ACTIONS_COLUMN_SIZE = 48;
|
|
3023
|
+
const ActionsCell = ({ column, row }) => {
|
|
3024
|
+
const { labels } = useDataTableContext();
|
|
3025
|
+
const actions = column.columnDef.meta?.rowActions?.(row) ?? [];
|
|
3026
|
+
if (actions.length === 0) return null;
|
|
3027
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3028
|
+
className: "flex justify-end",
|
|
3029
|
+
children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
3030
|
+
asChild: true,
|
|
3031
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
3032
|
+
"aria-label": labels.rowActions,
|
|
3033
|
+
size: "icon-xs",
|
|
3034
|
+
variant: "ghost",
|
|
3035
|
+
children: /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
3036
|
+
icon: MoreHorizontalIcon,
|
|
3037
|
+
"aria-hidden": "true",
|
|
3038
|
+
className: "size-4"
|
|
3039
|
+
})
|
|
3040
|
+
})
|
|
3041
|
+
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
3042
|
+
align: "end",
|
|
3043
|
+
children: actions.map((action) => /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
3044
|
+
disabled: action.disabled,
|
|
3045
|
+
onSelect: action.onSelect,
|
|
3046
|
+
className: action.variant === "danger" ? "text-[var(--text-danger)] focus:text-[var(--text-danger)]" : void 0,
|
|
3047
|
+
children: action.label
|
|
3048
|
+
}, action.label))
|
|
3049
|
+
})] })
|
|
3050
|
+
});
|
|
3051
|
+
};
|
|
3052
|
+
const ActionsHeader = () => /* @__PURE__ */ jsx("span", {
|
|
3053
|
+
className: "sr-only",
|
|
3054
|
+
children: useDataTableContext().labels.rowActions
|
|
3055
|
+
});
|
|
3056
|
+
/**
|
|
3057
|
+
* A narrow last column with a menu of actions for each row, such as edit or delete. Rows with no actions show no menu.
|
|
3058
|
+
* Choosing an action never opens the row, even when `DataTableContent` has `onRowClick`.
|
|
3059
|
+
*
|
|
3060
|
+
* @example
|
|
3061
|
+
* ```tsx
|
|
3062
|
+
* const columns = [
|
|
3063
|
+
* { accessorKey: 'name', header: 'Name' },
|
|
3064
|
+
* actionsColumn<User>({
|
|
3065
|
+
* getActions: (row) => [
|
|
3066
|
+
* { label: 'Edit', onSelect: () => openEditor(row.original) },
|
|
3067
|
+
* { label: 'Delete', onSelect: () => remove(row.original.id), variant: 'danger' },
|
|
3068
|
+
* ],
|
|
3069
|
+
* }),
|
|
3070
|
+
* ];
|
|
3071
|
+
* ```
|
|
3072
|
+
* @returns The column definition to add last to `columns`.
|
|
3073
|
+
* @see DataTableRowAction
|
|
3074
|
+
* @see selectionColumn
|
|
3075
|
+
* @see useDataTable
|
|
3076
|
+
*/
|
|
3077
|
+
const actionsColumn = ({ getActions }) => ({
|
|
3078
|
+
cell: ActionsCell,
|
|
3079
|
+
enableHiding: false,
|
|
3080
|
+
enableResizing: false,
|
|
3081
|
+
enableSorting: false,
|
|
3082
|
+
header: ActionsHeader,
|
|
3083
|
+
id: ACTIONS_COLUMN_ID,
|
|
3084
|
+
meta: { rowActions: getActions },
|
|
3085
|
+
size: ACTIONS_COLUMN_SIZE
|
|
3086
|
+
});
|
|
3087
|
+
|
|
2985
3088
|
//#endregion
|
|
2986
3089
|
//#region src/components/ui/data-table/create-column-helper.ts
|
|
2987
3090
|
/**
|
|
@@ -3003,16 +3106,45 @@ const TableCaption = ({ className, ...props }) => {
|
|
|
3003
3106
|
const createColumnHelper = createColumnHelper$1;
|
|
3004
3107
|
|
|
3005
3108
|
//#endregion
|
|
3006
|
-
//#region src/components/ui/data-table/data-table-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3109
|
+
//#region src/components/ui/data-table/data-table-labels.tsx
|
|
3110
|
+
/** The English text the data table parts use unless `DataTable` is given other `labels`. */
|
|
3111
|
+
const DEFAULT_DATA_TABLE_LABELS = {
|
|
3112
|
+
activeFilters: "Active filters",
|
|
3113
|
+
changeFilter: ({ column, value }) => `Change ${column} filter: ${value}`,
|
|
3114
|
+
clearColumnFilter: "Clear",
|
|
3115
|
+
clearFilters: "Clear filters",
|
|
3116
|
+
columns: "Columns",
|
|
3117
|
+
columnWidth: ({ width }) => `${width} pixels`,
|
|
3118
|
+
emptyFilteredTitle: "No matching results",
|
|
3119
|
+
emptyGroup: "None",
|
|
3120
|
+
emptyTitle: "No results",
|
|
3121
|
+
filterColumn: ({ column, isFiltered }) => isFiltered ? `Filter ${column}, filtered` : `Filter ${column}`,
|
|
3122
|
+
filterNoValues: "No values",
|
|
3123
|
+
filterPlaceholder: "Contains",
|
|
3124
|
+
nextPage: "Go to next page",
|
|
3125
|
+
pagination: "Pagination",
|
|
3126
|
+
previousPage: "Go to previous page",
|
|
3127
|
+
range: ({ end, start, total }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3128
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3129
|
+
className: "text-foreground",
|
|
3130
|
+
children: [
|
|
3131
|
+
start,
|
|
3132
|
+
"–",
|
|
3133
|
+
end
|
|
3134
|
+
]
|
|
3135
|
+
}),
|
|
3136
|
+
" ",
|
|
3137
|
+
"of ",
|
|
3138
|
+
total
|
|
3139
|
+
] }),
|
|
3140
|
+
removeFilter: ({ column }) => `Remove ${column} filter`,
|
|
3141
|
+
removeSearch: "Remove search filter",
|
|
3142
|
+
resizeColumn: ({ column }) => `Resize ${column}`,
|
|
3143
|
+
rowActions: "Row actions",
|
|
3144
|
+
search: "Search",
|
|
3145
|
+
selectAllRows: "Select all rows",
|
|
3146
|
+
selectRow: "Select row",
|
|
3147
|
+
sortPriority: ({ priority }) => `sort priority ${priority}`
|
|
3016
3148
|
};
|
|
3017
3149
|
|
|
3018
3150
|
//#endregion
|
|
@@ -3020,6 +3152,13 @@ const useDataTableContext = () => {
|
|
|
3020
3152
|
/**
|
|
3021
3153
|
* Root of a data table. Holds the table state for `DataTableContent`, `DataTablePagination` and the other parts.
|
|
3022
3154
|
*
|
|
3155
|
+
* Use it for any list of records people sort, filter, page, select or open. Use the plain `Table` only for a short
|
|
3156
|
+
* static list with none of those.
|
|
3157
|
+
* - Turn features on per `useDataTable` option; pass `getRowId` when rows have an id, or selection follows the index.
|
|
3158
|
+
* - Row actions: `actionsColumn({ getActions })`, last in `columns`. Never a hand-made button column.
|
|
3159
|
+
* - Clickable rows: `onRowClick` on `DataTableContent`. Never a link in one cell.
|
|
3160
|
+
* - Text: pass only the strings that change through `labels`, for translation.
|
|
3161
|
+
*
|
|
3023
3162
|
* @example
|
|
3024
3163
|
* ```tsx
|
|
3025
3164
|
* const dataTable = useDataTable({ columns, data });
|
|
@@ -3036,11 +3175,19 @@ const useDataTableContext = () => {
|
|
|
3036
3175
|
* @see DataTableContent
|
|
3037
3176
|
* @see DataTableToolbar
|
|
3038
3177
|
*/
|
|
3039
|
-
const DataTable = ({ children, className, fill = false, table, ...props }) => {
|
|
3178
|
+
const DataTable = ({ children, className, fill = false, labels, table, ...props }) => {
|
|
3040
3179
|
const contextValue = useMemo(() => ({
|
|
3041
3180
|
...table,
|
|
3042
|
-
fill
|
|
3043
|
-
|
|
3181
|
+
fill,
|
|
3182
|
+
labels: {
|
|
3183
|
+
...DEFAULT_DATA_TABLE_LABELS,
|
|
3184
|
+
...labels
|
|
3185
|
+
}
|
|
3186
|
+
}), [
|
|
3187
|
+
table,
|
|
3188
|
+
fill,
|
|
3189
|
+
labels
|
|
3190
|
+
]);
|
|
3044
3191
|
return /* @__PURE__ */ jsx(DataTableContext.Provider, {
|
|
3045
3192
|
value: contextValue,
|
|
3046
3193
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -3085,8 +3232,6 @@ const getColumnLabel = (column) => {
|
|
|
3085
3232
|
|
|
3086
3233
|
//#endregion
|
|
3087
3234
|
//#region src/components/ui/data-table/data-table-column-filter.tsx
|
|
3088
|
-
const TEXT_FILTER_PLACEHOLDER = "Contains";
|
|
3089
|
-
const EMPTY_OPTIONS_TEXT = "No values";
|
|
3090
3235
|
/**
|
|
3091
3236
|
* Turn cell values into checklist options. List-valued cells count as one value each in TanStack's facets, so their items are
|
|
3092
3237
|
* spread out first: a tags column then offers each tag rather than each combination. Empty values offer nothing to check.
|
|
@@ -3108,7 +3253,7 @@ const getFilterOptions = ({ column, selected, table }) => {
|
|
|
3108
3253
|
};
|
|
3109
3254
|
/** The checklist of a `values` filter. The checked values are the filter value; unchecking the last one removes the filter. */
|
|
3110
3255
|
const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
3111
|
-
const { table } = useDataTableContext();
|
|
3256
|
+
const { labels, table } = useDataTableContext();
|
|
3112
3257
|
const selected = Array.isArray(filterValue) ? filterValue.map(String) : [];
|
|
3113
3258
|
const options = getFilterOptions({
|
|
3114
3259
|
column,
|
|
@@ -3121,7 +3266,7 @@ const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
|
3121
3266
|
};
|
|
3122
3267
|
if (options.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
3123
3268
|
className: "text-sm text-muted-foreground",
|
|
3124
|
-
children:
|
|
3269
|
+
children: labels.filterNoValues
|
|
3125
3270
|
});
|
|
3126
3271
|
return /* @__PURE__ */ jsx("div", {
|
|
3127
3272
|
"data-slot": "data-table-column-filter-options",
|
|
@@ -3162,12 +3307,15 @@ const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
|
3162
3307
|
* @see DataTableSearch
|
|
3163
3308
|
*/
|
|
3164
3309
|
const DataTableColumnFilter = ({ className, column }) => {
|
|
3165
|
-
const
|
|
3310
|
+
const { labels } = useDataTableContext();
|
|
3166
3311
|
const isFiltered = column.getIsFiltered();
|
|
3167
3312
|
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
3168
3313
|
asChild: true,
|
|
3169
3314
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
3170
|
-
"aria-label":
|
|
3315
|
+
"aria-label": labels.filterColumn({
|
|
3316
|
+
column: getColumnLabel(column),
|
|
3317
|
+
isFiltered
|
|
3318
|
+
}),
|
|
3171
3319
|
"data-slot": "data-table-column-filter",
|
|
3172
3320
|
"data-filtered": isFiltered || void 0,
|
|
3173
3321
|
size: "icon-xs",
|
|
@@ -3185,18 +3333,22 @@ const DataTableColumnFilter = ({ className, column }) => {
|
|
|
3185
3333
|
};
|
|
3186
3334
|
/** The body of a column's filter popover, shared by the header filter button and the active-filter chips. */
|
|
3187
3335
|
const DataTableColumnFilterContent = ({ column }) => {
|
|
3188
|
-
const
|
|
3336
|
+
const { labels } = useDataTableContext();
|
|
3337
|
+
const filterLabel = labels.filterColumn({
|
|
3338
|
+
column: getColumnLabel(column),
|
|
3339
|
+
isFiltered: false
|
|
3340
|
+
});
|
|
3189
3341
|
const filterValue = column.getFilterValue();
|
|
3190
3342
|
return /* @__PURE__ */ jsxs(PopoverContent, {
|
|
3191
|
-
"aria-label":
|
|
3343
|
+
"aria-label": filterLabel,
|
|
3192
3344
|
align: "start",
|
|
3193
3345
|
className: "flex w-56 flex-col gap-3 p-3",
|
|
3194
3346
|
children: [column.columnDef.meta?.filter === "values" ? /* @__PURE__ */ jsx(DataTableValuesFilter, {
|
|
3195
3347
|
column,
|
|
3196
3348
|
filterValue
|
|
3197
3349
|
}) : /* @__PURE__ */ jsx(Input, {
|
|
3198
|
-
"aria-label":
|
|
3199
|
-
placeholder:
|
|
3350
|
+
"aria-label": filterLabel,
|
|
3351
|
+
placeholder: labels.filterPlaceholder,
|
|
3200
3352
|
value: typeof filterValue === "string" ? filterValue : "",
|
|
3201
3353
|
onChange: (event) => column.setFilterValue(event.target.value)
|
|
3202
3354
|
}), column.getIsFiltered() && /* @__PURE__ */ jsx("div", {
|
|
@@ -3206,7 +3358,7 @@ const DataTableColumnFilterContent = ({ column }) => {
|
|
|
3206
3358
|
size: "sm",
|
|
3207
3359
|
variant: "secondary",
|
|
3208
3360
|
onClick: () => column.setFilterValue(void 0),
|
|
3209
|
-
children:
|
|
3361
|
+
children: labels.clearColumnFilter
|
|
3210
3362
|
})
|
|
3211
3363
|
})]
|
|
3212
3364
|
});
|
|
@@ -3219,6 +3371,7 @@ const toFilterValues = (value) => Array.isArray(value) ? value.map(String) : [St
|
|
|
3219
3371
|
const MAX_SHOWN_VALUES = 2;
|
|
3220
3372
|
const CHIP_CONTROL = "inline-flex h-6 items-center rounded-[4px] outline-none transition-[color,background-color] duration-150 ease-out hover:bg-[var(--overlay-hover)] focus-visible:ring-2 focus-visible:ring-[var(--ring)]";
|
|
3221
3373
|
const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) => {
|
|
3374
|
+
const { labels } = useDataTableContext();
|
|
3222
3375
|
const fullValue = values.join(", ");
|
|
3223
3376
|
const hiddenCount = values.length - MAX_SHOWN_VALUES;
|
|
3224
3377
|
const shownValue = /* @__PURE__ */ jsxs(Fragment$1, { children: [values.slice(0, MAX_SHOWN_VALUES).join(", "), hiddenCount > 0 && /* @__PURE__ */ jsxs("span", {
|
|
@@ -3257,7 +3410,10 @@ const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) =
|
|
|
3257
3410
|
asChild: true,
|
|
3258
3411
|
children: /* @__PURE__ */ jsxs("button", {
|
|
3259
3412
|
type: "button",
|
|
3260
|
-
"aria-label":
|
|
3413
|
+
"aria-label": labels.changeFilter({
|
|
3414
|
+
column: label,
|
|
3415
|
+
value: fullValue
|
|
3416
|
+
}),
|
|
3261
3417
|
className: cn(CHIP_CONTROL, "ms-1 gap-1 ps-1.5 pe-1 font-medium text-[var(--action)]"),
|
|
3262
3418
|
children: [shownValue, /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
3263
3419
|
icon: ArrowDown01Icon,
|
|
@@ -3293,7 +3449,7 @@ const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) =
|
|
|
3293
3449
|
* @see useDataTable
|
|
3294
3450
|
*/
|
|
3295
3451
|
const DataTableActiveFilters = ({ className }) => {
|
|
3296
|
-
const { table } = useDataTableContext();
|
|
3452
|
+
const { labels, table } = useDataTableContext();
|
|
3297
3453
|
const { columnFilters, globalFilter } = table.getState();
|
|
3298
3454
|
const search = typeof globalFilter === "string" ? globalFilter : "";
|
|
3299
3455
|
if (columnFilters.length === 0 && search === "") return null;
|
|
@@ -3302,14 +3458,14 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3302
3458
|
table.setGlobalFilter("");
|
|
3303
3459
|
};
|
|
3304
3460
|
return /* @__PURE__ */ jsxs("fieldset", {
|
|
3305
|
-
"aria-label":
|
|
3461
|
+
"aria-label": labels.activeFilters,
|
|
3306
3462
|
"data-slot": "data-table-active-filters",
|
|
3307
3463
|
className: cn("flex min-w-0 flex-wrap items-center gap-2", className),
|
|
3308
3464
|
children: [
|
|
3309
3465
|
search !== "" && /* @__PURE__ */ jsx(DataTableFilterChip, {
|
|
3310
|
-
label:
|
|
3466
|
+
label: labels.search,
|
|
3311
3467
|
onRemove: () => table.setGlobalFilter(""),
|
|
3312
|
-
removeLabel:
|
|
3468
|
+
removeLabel: labels.removeSearch,
|
|
3313
3469
|
values: [search]
|
|
3314
3470
|
}),
|
|
3315
3471
|
columnFilters.map(({ id, value }) => {
|
|
@@ -3319,7 +3475,7 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3319
3475
|
column: column?.columnDef.meta?.filter ? column : void 0,
|
|
3320
3476
|
label,
|
|
3321
3477
|
onRemove: () => table.setColumnFilters((old) => old.filter((filter) => filter.id !== id)),
|
|
3322
|
-
removeLabel:
|
|
3478
|
+
removeLabel: labels.removeFilter({ column: label }),
|
|
3323
3479
|
values: toFilterValues(value)
|
|
3324
3480
|
}, id);
|
|
3325
3481
|
}),
|
|
@@ -3327,7 +3483,7 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3327
3483
|
className: "text-muted-foreground hover:text-foreground",
|
|
3328
3484
|
variant: "ghost",
|
|
3329
3485
|
onClick: clearAll,
|
|
3330
|
-
children:
|
|
3486
|
+
children: labels.clearFilters
|
|
3331
3487
|
})
|
|
3332
3488
|
]
|
|
3333
3489
|
});
|
|
@@ -3352,8 +3508,8 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3352
3508
|
* @see DataTableToolbar
|
|
3353
3509
|
* @see useDataTable
|
|
3354
3510
|
*/
|
|
3355
|
-
const DataTableColumnVisibility = ({ className, label
|
|
3356
|
-
const { table } = useDataTableContext();
|
|
3511
|
+
const DataTableColumnVisibility = ({ className, label }) => {
|
|
3512
|
+
const { labels, table } = useDataTableContext();
|
|
3357
3513
|
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
3358
3514
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
3359
3515
|
asChild: true,
|
|
@@ -3366,7 +3522,7 @@ const DataTableColumnVisibility = ({ className, label = "Columns" }) => {
|
|
|
3366
3522
|
icon: LayoutThreeColumnIcon,
|
|
3367
3523
|
"aria-hidden": "true"
|
|
3368
3524
|
}),
|
|
3369
|
-
label,
|
|
3525
|
+
label ?? labels.columns,
|
|
3370
3526
|
/* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
3371
3527
|
icon: ArrowDown01Icon,
|
|
3372
3528
|
"aria-hidden": "true"
|
|
@@ -3445,7 +3601,7 @@ const DataTableSkeletonRows = ({ columnCount, rowCount }) => /* @__PURE__ */ jsx
|
|
|
3445
3601
|
}) }, columnIndex))
|
|
3446
3602
|
}, rowIndex)) });
|
|
3447
3603
|
/** Ghost rows keep the table's shape behind an icon and title. */
|
|
3448
|
-
const DataTableEmptyRow = ({ action, columnCount, icon, title }) => /* @__PURE__ */ jsx(TableRow, {
|
|
3604
|
+
const DataTableEmptyRow = ({ action, columnCount, description, icon, title }) => /* @__PURE__ */ jsx(TableRow, {
|
|
3449
3605
|
"data-slot": "data-table-empty",
|
|
3450
3606
|
className: STATIC_ROW,
|
|
3451
3607
|
children: /* @__PURE__ */ jsx(TableCell, {
|
|
@@ -3470,6 +3626,7 @@ const DataTableEmptyRow = ({ action, columnCount, icon, title }) => /* @__PURE__
|
|
|
3470
3626
|
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
3471
3627
|
action,
|
|
3472
3628
|
className: "py-0",
|
|
3629
|
+
description,
|
|
3473
3630
|
icon,
|
|
3474
3631
|
title
|
|
3475
3632
|
})
|
|
@@ -3487,6 +3644,20 @@ const ExpandChevron = ({ isOpen }) => /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
|
3487
3644
|
className: cn("transition-transform duration-150 motion-reduce:transition-none", isOpen && "rotate-90")
|
|
3488
3645
|
});
|
|
3489
3646
|
|
|
3647
|
+
//#endregion
|
|
3648
|
+
//#region src/components/ui/data-table/is-row-activation.ts
|
|
3649
|
+
/** Elements that handle their own clicks, so a click on them must not also open the row. */
|
|
3650
|
+
const INTERACTIVE_SELECTOR = "a, button, input, label, select, summary, textarea, [role=\"checkbox\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [tabindex]";
|
|
3651
|
+
/**
|
|
3652
|
+
* Whether a click or key press on a row should open it: it came from the row itself or plain content inside it,
|
|
3653
|
+
* not from a control such as a checkbox, link or row action menu.
|
|
3654
|
+
*/
|
|
3655
|
+
const isRowActivation = ({ currentTarget, target }) => {
|
|
3656
|
+
if (!(target instanceof Element) || !currentTarget.contains(target)) return false;
|
|
3657
|
+
const interactive = target.closest(INTERACTIVE_SELECTOR);
|
|
3658
|
+
return interactive === null || interactive === currentTarget;
|
|
3659
|
+
};
|
|
3660
|
+
|
|
3490
3661
|
//#endregion
|
|
3491
3662
|
//#region src/components/ui/data-table/get-pinned-cell-props.ts
|
|
3492
3663
|
/** Pinned cells need an opaque base so scrolling text cannot show through; the body overlay still follows row hover and selection. */
|
|
@@ -3531,13 +3702,13 @@ const getAllRowsCheckedState = (table) => {
|
|
|
3531
3702
|
return table.getIsSomePageRowsSelected() ? "indeterminate" : false;
|
|
3532
3703
|
};
|
|
3533
3704
|
const SelectionCell = ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
3534
|
-
"aria-label":
|
|
3705
|
+
"aria-label": useDataTableContext().labels.selectRow,
|
|
3535
3706
|
checked: row.getIsSelected(),
|
|
3536
3707
|
disabled: !row.getCanSelect(),
|
|
3537
3708
|
onCheckedChange: (checked) => row.toggleSelected(checked === true)
|
|
3538
3709
|
});
|
|
3539
3710
|
const SelectionHeader = ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
3540
|
-
"aria-label":
|
|
3711
|
+
"aria-label": useDataTableContext().labels.selectAllRows,
|
|
3541
3712
|
checked: getAllRowsCheckedState(table),
|
|
3542
3713
|
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true)
|
|
3543
3714
|
});
|
|
@@ -3571,22 +3742,30 @@ const FIXED_LAYOUT_CELL_CLASS = "overflow-hidden text-ellipsis";
|
|
|
3571
3742
|
* the visible width and never widens the table.
|
|
3572
3743
|
*/
|
|
3573
3744
|
const STICKY_ROW_CONTENT = "sticky start-0 w-[100cqw] px-4 py-2.5";
|
|
3574
|
-
/**
|
|
3575
|
-
const
|
|
3576
|
-
/** The checkbox column holds one control, so it stays narrow and never clips. */
|
|
3577
|
-
const isControlColumn = (columnId) => columnId === SELECTION_COLUMN_ID;
|
|
3745
|
+
/** The checkbox and row actions columns hold one control each, so they stay narrow and never clip. */
|
|
3746
|
+
const isControlColumn = (columnId) => columnId === SELECTION_COLUMN_ID || columnId === ACTIONS_COLUMN_ID;
|
|
3578
3747
|
/** Rows inside groups step in by 1.25rem per level from the cell's own 1rem padding. */
|
|
3579
3748
|
const getIndent = (depth) => `calc(1rem + ${depth} * 1.25rem)`;
|
|
3580
|
-
const getGroupLabel = ({ groupingColumnId, row }) => {
|
|
3749
|
+
const getGroupLabel = ({ emptyGroupLabel, groupingColumnId, row }) => {
|
|
3581
3750
|
const value = row.getGroupingValue(groupingColumnId);
|
|
3582
|
-
return `${value === void 0 || value === null || value === "" ?
|
|
3751
|
+
return `${value === void 0 || value === null || value === "" ? emptyGroupLabel : String(value)} (${row.getLeafRows().filter((leaf) => !leaf.getIsGrouped()).length})`;
|
|
3583
3752
|
};
|
|
3584
|
-
|
|
3753
|
+
/** Focus draws an inset outline, since a table row cannot take a ring. */
|
|
3754
|
+
const CLICKABLE_ROW_CLASS = "cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--ring)]";
|
|
3755
|
+
const DataTableRow = ({ className, hasFixedLayout, onRowClick, row, rowRef, ...props }) => {
|
|
3585
3756
|
const cells = row.getVisibleCells();
|
|
3586
3757
|
const indentedCellId = row.depth > 0 ? cells.find((cell) => !isControlColumn(cell.column.id))?.id : void 0;
|
|
3587
3758
|
return /* @__PURE__ */ jsx(TableRow, {
|
|
3588
3759
|
ref: rowRef,
|
|
3589
3760
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
3761
|
+
className: cn(onRowClick && CLICKABLE_ROW_CLASS, className),
|
|
3762
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
3763
|
+
onClick: onRowClick ? (event) => {
|
|
3764
|
+
if (isRowActivation(event)) onRowClick(row);
|
|
3765
|
+
} : void 0,
|
|
3766
|
+
onKeyDown: onRowClick ? (event) => {
|
|
3767
|
+
if (event.key === "Enter" && event.target === event.currentTarget) onRowClick(row);
|
|
3768
|
+
} : void 0,
|
|
3590
3769
|
...props,
|
|
3591
3770
|
children: cells.map((cell) => {
|
|
3592
3771
|
const pinned = getPinnedCellProps({
|
|
@@ -3607,6 +3786,7 @@ const DataTableRow = ({ hasFixedLayout, row, rowRef, ...props }) => {
|
|
|
3607
3786
|
};
|
|
3608
3787
|
/** One full-width row naming the group and how many rows it holds, with a button that opens or closes it. */
|
|
3609
3788
|
const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...props }) => {
|
|
3789
|
+
const { labels } = useDataTableContext();
|
|
3610
3790
|
const isOpen = row.getIsExpanded();
|
|
3611
3791
|
return /* @__PURE__ */ jsx(TableRow, {
|
|
3612
3792
|
ref: rowRef,
|
|
@@ -3625,6 +3805,7 @@ const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...prop
|
|
|
3625
3805
|
onClick: row.getToggleExpandedHandler(),
|
|
3626
3806
|
className: "-mx-1.5 inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] [&_svg]:size-3.5",
|
|
3627
3807
|
children: [/* @__PURE__ */ jsx(ExpandChevron, { isOpen }), getGroupLabel({
|
|
3808
|
+
emptyGroupLabel: labels.emptyGroup,
|
|
3628
3809
|
groupingColumnId,
|
|
3629
3810
|
row
|
|
3630
3811
|
})]
|
|
@@ -3634,7 +3815,7 @@ const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...prop
|
|
|
3634
3815
|
});
|
|
3635
3816
|
};
|
|
3636
3817
|
/** One table row, as a group header or a data row. Row props and `rowRef` land on its `<tr>`. */
|
|
3637
|
-
const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
3818
|
+
const DataTableBodyRow = ({ columnCount, hasFixedLayout, onRowClick, row, ...props }) => {
|
|
3638
3819
|
const { groupingColumnId } = row;
|
|
3639
3820
|
if (groupingColumnId) return /* @__PURE__ */ jsx(DataTableGroupRow, {
|
|
3640
3821
|
columnCount,
|
|
@@ -3644,6 +3825,7 @@ const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
|
3644
3825
|
});
|
|
3645
3826
|
return /* @__PURE__ */ jsx(DataTableRow, {
|
|
3646
3827
|
hasFixedLayout,
|
|
3828
|
+
onRowClick,
|
|
3647
3829
|
row,
|
|
3648
3830
|
...props
|
|
3649
3831
|
});
|
|
@@ -3651,8 +3833,6 @@ const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
|
3651
3833
|
|
|
3652
3834
|
//#endregion
|
|
3653
3835
|
//#region src/components/ui/data-table/data-table-content.tsx
|
|
3654
|
-
const DEFAULT_EMPTY_TITLE = "No results";
|
|
3655
|
-
const DEFAULT_EMPTY_FILTERED_TITLE = "No matching results";
|
|
3656
3836
|
const DEFAULT_LOADING_ROW_COUNT = 5;
|
|
3657
3837
|
const ARIA_SORT = {
|
|
3658
3838
|
asc: "ascending",
|
|
@@ -3671,6 +3851,15 @@ const RESIZE_STEP = {
|
|
|
3671
3851
|
const MIN_COLUMN_SIZE = 20;
|
|
3672
3852
|
/** TanStack leaves columns unbounded; screen readers get a usable range instead. */
|
|
3673
3853
|
const MAX_COLUMN_SIZE = 1e3;
|
|
3854
|
+
/** The resize cursor, centered on the gap between its triangles, with the system one as a fallback. */
|
|
3855
|
+
const RESIZE_CURSOR = `url("data:image/svg+xml,${encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M2.5 12L8 8V16ZM21.5 12L16 8V16Z' fill='black' stroke='white' stroke-width='2' stroke-linejoin='round' paint-order='stroke'/></svg>")}") 12 12, col-resize`;
|
|
3856
|
+
/**
|
|
3857
|
+
* The line is hidden until the header is hovered, then shows as a faint 1px line so people see where columns can be
|
|
3858
|
+
* resized before finding the handle. Hovering the handle or dragging it thickens the line to 2px, with round ends, and
|
|
3859
|
+
* darkens it a step; keyboard focus draws it in the focus color. The thickening is a horizontal scale of a 2px line,
|
|
3860
|
+
* not a width change, so it eases smoothly and stays centered in the handle, in the gap between the cursor's triangles.
|
|
3861
|
+
*/
|
|
3862
|
+
const RESIZE_HANDLE_CLASS = "absolute inset-y-0 end-0 w-2 touch-none select-none outline-none after:absolute after:inset-y-2 after:end-[3px] after:w-0.5 after:scale-x-50 after:rounded-full after:bg-[var(--border-divider)] after:opacity-0 after:transition-[opacity,background-color,scale] after:duration-150 after:ease-out motion-reduce:after:transition-none in-[thead:hover]:after:opacity-100 hover:after:scale-x-100 hover:after:bg-[var(--border-hover)] data-[resizing=true]:after:scale-x-100 data-[resizing=true]:after:bg-[var(--border-hover)] data-[resizing=true]:after:opacity-100 focus-visible:after:bg-[var(--ring)] focus-visible:after:opacity-100";
|
|
3674
3863
|
/** Rows rendered beyond each edge of the view when virtualization sets no overscan. */
|
|
3675
3864
|
const DEFAULT_OVERSCAN = 8;
|
|
3676
3865
|
const DefaultEmptyIcon = ({ className, size }) => /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
@@ -3693,26 +3882,38 @@ const DataTableResizeHandle = ({ header }) => {
|
|
|
3693
3882
|
}));
|
|
3694
3883
|
};
|
|
3695
3884
|
const resize = header.getResizeHandler();
|
|
3885
|
+
const { labels } = useDataTableContext();
|
|
3886
|
+
const isResizing = column.getIsResizing();
|
|
3887
|
+
useEffect(() => {
|
|
3888
|
+
if (!isResizing) return void 0;
|
|
3889
|
+
const previousCursor = document.body.style.cursor;
|
|
3890
|
+
document.body.style.cursor = RESIZE_CURSOR;
|
|
3891
|
+
return () => {
|
|
3892
|
+
document.body.style.cursor = previousCursor;
|
|
3893
|
+
};
|
|
3894
|
+
}, [isResizing]);
|
|
3696
3895
|
return /* @__PURE__ */ jsx("div", {
|
|
3697
3896
|
role: "separator",
|
|
3698
|
-
"aria-label":
|
|
3897
|
+
"aria-label": labels.resizeColumn({ column: getColumnLabel(column) }),
|
|
3699
3898
|
"aria-orientation": "vertical",
|
|
3700
3899
|
"aria-valuemax": getMaxColumnSize(column.columnDef.maxSize),
|
|
3701
3900
|
"aria-valuemin": column.columnDef.minSize ?? MIN_COLUMN_SIZE,
|
|
3702
3901
|
"aria-valuenow": size,
|
|
3703
|
-
"aria-valuetext":
|
|
3902
|
+
"aria-valuetext": labels.columnWidth({ width: size }),
|
|
3704
3903
|
tabIndex: 0,
|
|
3705
3904
|
"data-slot": "data-table-resize-handle",
|
|
3706
|
-
"data-resizing":
|
|
3905
|
+
"data-resizing": isResizing || void 0,
|
|
3707
3906
|
onDoubleClick: () => column.resetSize(),
|
|
3708
3907
|
onKeyDown: handleKeyDown,
|
|
3709
3908
|
onMouseDown: resize,
|
|
3710
3909
|
onTouchStart: resize,
|
|
3711
|
-
className:
|
|
3910
|
+
className: RESIZE_HANDLE_CLASS,
|
|
3911
|
+
style: { cursor: RESIZE_CURSOR }
|
|
3712
3912
|
});
|
|
3713
3913
|
};
|
|
3714
3914
|
const DataTableHeadCell = ({ header, hasFixedLayout }) => {
|
|
3715
3915
|
const { column } = header;
|
|
3916
|
+
const { labels } = useDataTableContext();
|
|
3716
3917
|
const sorted = column.getIsSorted();
|
|
3717
3918
|
const sortIndex = column.getSortIndex();
|
|
3718
3919
|
const isMultiSort = header.getContext().table.getState().sorting.length > 1;
|
|
@@ -3749,7 +3950,7 @@ const DataTableHeadCell = ({ header, hasFixedLayout }) => {
|
|
|
3749
3950
|
children: sortPriority
|
|
3750
3951
|
}), /* @__PURE__ */ jsxs("span", {
|
|
3751
3952
|
className: "sr-only",
|
|
3752
|
-
children: [",
|
|
3953
|
+
children: [", ", labels.sortPriority({ priority: sortPriority })]
|
|
3753
3954
|
})] })
|
|
3754
3955
|
]
|
|
3755
3956
|
}) : content,
|
|
@@ -3774,6 +3975,12 @@ const DataTableVirtualSpacer = ({ columnCount, height }) => /* @__PURE__ */ jsx(
|
|
|
3774
3975
|
/**
|
|
3775
3976
|
* The table itself: headers, rows, and the loading and empty states.
|
|
3776
3977
|
*
|
|
3978
|
+
* - Always give it an `aria-label` that names the records, such as "Users".
|
|
3979
|
+
* - `onRowClick` when a row opens something: rows become focusable, Enter opens, clicks on controls in the row do not.
|
|
3980
|
+
* - `emptyTitle` in the records' own words; `emptyDescription` only when it says what to do; `emptyAction` when the
|
|
3981
|
+
* first row can be created here. When filters hide every row, `emptyFilteredTitle` and Clear filters show instead.
|
|
3982
|
+
* - Never put a placeholder row in the data or a banner inside the table: banners go beside it as siblings.
|
|
3983
|
+
*
|
|
3777
3984
|
* @example
|
|
3778
3985
|
* ```tsx
|
|
3779
3986
|
* const dataTable = useDataTable({ columns, data, sorting: { mode: 'client' } });
|
|
@@ -3787,8 +3994,8 @@ const DataTableVirtualSpacer = ({ columnCount, height }) => /* @__PURE__ */ jsx(
|
|
|
3787
3994
|
* @see useDataTable
|
|
3788
3995
|
* @see DataTablePagination
|
|
3789
3996
|
*/
|
|
3790
|
-
const DataTableContent = ({ className,
|
|
3791
|
-
const { fill, loading, table, virtualization } = useDataTableContext();
|
|
3997
|
+
const DataTableContent = ({ className, emptyAction, emptyDescription, emptyFilteredTitle, emptyIcon = DefaultEmptyIcon, emptyTitle, loadingRowCount = DEFAULT_LOADING_ROW_COUNT, onRowClick, style, ...props }) => {
|
|
3998
|
+
const { fill, labels, loading, table, virtualization } = useDataTableContext();
|
|
3792
3999
|
const viewportRef = useRef(null);
|
|
3793
4000
|
const hasFixedLayout = table.options.enableColumnResizing === true || table.options.enableColumnPinning === true || virtualization !== void 0;
|
|
3794
4001
|
const columnCount = table.getVisibleLeafColumns().length;
|
|
@@ -3824,6 +4031,7 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3824
4031
|
columnCount,
|
|
3825
4032
|
"data-index": index,
|
|
3826
4033
|
hasFixedLayout,
|
|
4034
|
+
onRowClick,
|
|
3827
4035
|
row,
|
|
3828
4036
|
rowRef: virtualizer.measureElement
|
|
3829
4037
|
}, row.id);
|
|
@@ -3837,9 +4045,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3837
4045
|
const renderEmptyRow = () => {
|
|
3838
4046
|
const { columnFilters, globalFilter } = table.getState();
|
|
3839
4047
|
if (columnFilters.length === 0 && globalFilter === "") return /* @__PURE__ */ jsx(DataTableEmptyRow, {
|
|
4048
|
+
action: emptyAction,
|
|
3840
4049
|
columnCount,
|
|
4050
|
+
description: emptyDescription,
|
|
3841
4051
|
icon: emptyIcon,
|
|
3842
|
-
title: emptyTitle
|
|
4052
|
+
title: emptyTitle ?? labels.emptyTitle
|
|
3843
4053
|
});
|
|
3844
4054
|
const clearFilters = () => {
|
|
3845
4055
|
table.setColumnFilters([]);
|
|
@@ -3850,11 +4060,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3850
4060
|
variant: "outline",
|
|
3851
4061
|
size: "sm",
|
|
3852
4062
|
onClick: clearFilters,
|
|
3853
|
-
children:
|
|
4063
|
+
children: labels.clearFilters
|
|
3854
4064
|
}),
|
|
3855
4065
|
columnCount,
|
|
3856
4066
|
icon: emptyIcon,
|
|
3857
|
-
title: emptyFilteredTitle
|
|
4067
|
+
title: emptyFilteredTitle ?? labels.emptyFilteredTitle
|
|
3858
4068
|
});
|
|
3859
4069
|
};
|
|
3860
4070
|
const renderBody = () => {
|
|
@@ -3867,10 +4077,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3867
4077
|
return rows.map((row) => /* @__PURE__ */ jsx(DataTableBodyRow, {
|
|
3868
4078
|
columnCount,
|
|
3869
4079
|
hasFixedLayout,
|
|
4080
|
+
onRowClick,
|
|
3870
4081
|
row
|
|
3871
4082
|
}, row.id));
|
|
3872
4083
|
};
|
|
3873
|
-
return /* @__PURE__ */ jsxs(
|
|
4084
|
+
return /* @__PURE__ */ jsxs(TableFrame, {
|
|
3874
4085
|
fill,
|
|
3875
4086
|
"aria-busy": loading || void 0,
|
|
3876
4087
|
"aria-rowcount": isVirtualized ? rows.length + headerRowCount : void 0,
|
|
@@ -3915,7 +4126,7 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3915
4126
|
* @see DataTable
|
|
3916
4127
|
*/
|
|
3917
4128
|
const DataTablePagination = ({ className }) => {
|
|
3918
|
-
const { table } = useDataTableContext();
|
|
4129
|
+
const { labels, table } = useDataTableContext();
|
|
3919
4130
|
if (!table.options.getPaginationRowModel && !table.options.manualPagination) return null;
|
|
3920
4131
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
3921
4132
|
const rowCount = table.getRowCount();
|
|
@@ -3925,19 +4136,16 @@ const DataTablePagination = ({ className }) => {
|
|
|
3925
4136
|
className,
|
|
3926
4137
|
hasNext: table.getCanNextPage(),
|
|
3927
4138
|
hasPrevious: table.getCanPreviousPage(),
|
|
3928
|
-
label: rowCount > 0 ?
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
"of ",
|
|
3939
|
-
rowCount
|
|
3940
|
-
] }) : void 0,
|
|
4139
|
+
label: rowCount > 0 ? labels.range({
|
|
4140
|
+
end,
|
|
4141
|
+
start,
|
|
4142
|
+
total: rowCount
|
|
4143
|
+
}) : void 0,
|
|
4144
|
+
labels: {
|
|
4145
|
+
next: labels.nextPage,
|
|
4146
|
+
previous: labels.previousPage,
|
|
4147
|
+
region: labels.pagination
|
|
4148
|
+
},
|
|
3941
4149
|
onNext: () => table.nextPage(),
|
|
3942
4150
|
onPrevious: () => table.previousPage()
|
|
3943
4151
|
});
|
|
@@ -3965,8 +4173,8 @@ const DataTablePagination = ({ className }) => {
|
|
|
3965
4173
|
* @see DataTableActiveFilters
|
|
3966
4174
|
* @see useDataTable
|
|
3967
4175
|
*/
|
|
3968
|
-
const DataTableSearch = ({ className, placeholder
|
|
3969
|
-
const { table } = useDataTableContext();
|
|
4176
|
+
const DataTableSearch = ({ className, placeholder }) => {
|
|
4177
|
+
const { labels, table } = useDataTableContext();
|
|
3970
4178
|
if (!table.options.enableGlobalFilter) return null;
|
|
3971
4179
|
const { globalFilter } = table.getState();
|
|
3972
4180
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -3979,8 +4187,8 @@ const DataTableSearch = ({ className, placeholder = "Search" }) => {
|
|
|
3979
4187
|
className: "pointer-events-none absolute start-2 top-1/2 -translate-y-1/2 text-muted-foreground/70"
|
|
3980
4188
|
}), /* @__PURE__ */ jsx(Input, {
|
|
3981
4189
|
type: "search",
|
|
3982
|
-
"aria-label": placeholder,
|
|
3983
|
-
placeholder,
|
|
4190
|
+
"aria-label": placeholder ?? labels.search,
|
|
4191
|
+
placeholder: placeholder ?? labels.search,
|
|
3984
4192
|
value: typeof globalFilter === "string" ? globalFilter : "",
|
|
3985
4193
|
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
3986
4194
|
className: "ps-8"
|
|
@@ -7190,5 +7398,5 @@ const UsersIcon = forwardRef((props, ref) => /* @__PURE__ */ jsx(AnimatedIcon, {
|
|
|
7190
7398
|
UsersIcon.displayName = "UsersIcon";
|
|
7191
7399
|
|
|
7192
7400
|
//#endregion
|
|
7193
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedIcon, ArrowUpRightIcon, AskAIAction, AssetIcon, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartBarIncreasingIcon, CheckIcon, Checkbox, ChevronDownIcon, ChevronRightIcon, ClaudeLogo, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CopyButton, CopyCheckIcon, CopyIcon, CursorLogo, CursorPagination, DangerZone, DataTable, DataTableActiveFilters, DataTableColumnFilter, DataTableColumnVisibility, DataTableContent, DataTablePagination, DataTableSearch, DataTableToolbar, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DollarSignIcon, DomainList, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Field, FingerprintIcon, FlushCardStack, HomeIcon, Icon, IconConfigProvider, InfoBanner, Input, Kbd, KeyIcon, Label, LayoutPanelTopIcon, LinkIcon, MetricCard, MoonIcon, OpenAILogo, PageHeader, PageSkeleton, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PanelLeftCloseIcon, PanelLeftOpenIcon, PlusIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ProductPageLayout, Progress, Radio, RadioField, RadioGroup, RadioGroupItem, RefreshCWIcon, SELECTION_COLUMN_ID, ScrollArea, ScrollBar, SearchIcon, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectableCard, Separator, SettingsIcon, SettingsSection, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, ShieldCheckIcon, Skeleton, Slider, Spinner, StatCardSkeleton, Stepper, SunIcon, Switch, TabNavigation, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, TerminalIcon, Textarea, Toaster, ToggleCard, ToggleGroup, ToggleGroupItem, ToggleRow, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UnsavedChangesBar, UsersIcon, VSCodeLogo, WebhooksAction, Well, WellReveal, WindsurfLogo, badgeVariants, buttonVariants, cn, createColumnHelper, selectionColumn, toast, useDataTable, useIconConfig, useUnsavedChanges };
|
|
7401
|
+
export { ACTIONS_COLUMN_ID, Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedIcon, ArrowUpRightIcon, AskAIAction, AssetIcon, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartBarIncreasingIcon, CheckIcon, Checkbox, ChevronDownIcon, ChevronRightIcon, ClaudeLogo, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CopyButton, CopyCheckIcon, CopyIcon, CursorLogo, CursorPagination, DangerZone, DataTable, DataTableActiveFilters, DataTableColumnFilter, DataTableColumnVisibility, DataTableContent, DataTablePagination, DataTableSearch, DataTableToolbar, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DollarSignIcon, DomainList, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Field, FingerprintIcon, FlushCardStack, HomeIcon, Icon, IconConfigProvider, InfoBanner, Input, Kbd, KeyIcon, Label, LayoutPanelTopIcon, LinkIcon, MetricCard, MoonIcon, OpenAILogo, PageHeader, PageSkeleton, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PanelLeftCloseIcon, PanelLeftOpenIcon, PlusIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ProductPageLayout, Progress, Radio, RadioField, RadioGroup, RadioGroupItem, RefreshCWIcon, SELECTION_COLUMN_ID, ScrollArea, ScrollBar, SearchIcon, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectableCard, Separator, SettingsIcon, SettingsSection, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, ShieldCheckIcon, Skeleton, Slider, Spinner, StatCardSkeleton, Stepper, SunIcon, Switch, TabNavigation, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, TerminalIcon, Textarea, Toaster, ToggleCard, ToggleGroup, ToggleGroupItem, ToggleRow, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UnsavedChangesBar, UsersIcon, VSCodeLogo, WebhooksAction, Well, WellReveal, WindsurfLogo, actionsColumn, badgeVariants, buttonVariants, cn, createColumnHelper, selectionColumn, toast, useDataTable, useIconConfig, useUnsavedChanges };
|
|
7194
7402
|
//# sourceMappingURL=index.esm.js.map
|