@dynamic-labs-sdk/droplet 1.52.2 → 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.cjs
CHANGED
|
@@ -2309,6 +2309,11 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ (0, reac
|
|
|
2309
2309
|
children: "More pages"
|
|
2310
2310
|
})]
|
|
2311
2311
|
});
|
|
2312
|
+
const DEFAULT_CURSOR_PAGINATION_LABELS = {
|
|
2313
|
+
next: "Go to next page",
|
|
2314
|
+
previous: "Go to previous page",
|
|
2315
|
+
region: "Pagination"
|
|
2316
|
+
};
|
|
2312
2317
|
/**
|
|
2313
2318
|
* Pre-assembled cursor-based pagination bar.
|
|
2314
2319
|
*
|
|
@@ -2328,8 +2333,8 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ (0, reac
|
|
|
2328
2333
|
* />
|
|
2329
2334
|
* ```
|
|
2330
2335
|
*/
|
|
2331
|
-
const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
2332
|
-
"aria-label":
|
|
2336
|
+
const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, labels = DEFAULT_CURSOR_PAGINATION_LABELS, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
2337
|
+
"aria-label": labels.region,
|
|
2333
2338
|
"data-slot": "cursor-pagination",
|
|
2334
2339
|
className: cn("flex items-center justify-end gap-3", className),
|
|
2335
2340
|
children: [label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -2343,7 +2348,7 @@ const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, cla
|
|
|
2343
2348
|
className: "size-8 before:-inset-1",
|
|
2344
2349
|
disabled: !hasPrevious,
|
|
2345
2350
|
onClick: onPrevious,
|
|
2346
|
-
"aria-label":
|
|
2351
|
+
"aria-label": labels.previous,
|
|
2347
2352
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
2348
2353
|
icon: _hugeicons_core_free_icons.ArrowLeft01Icon,
|
|
2349
2354
|
size: 16,
|
|
@@ -2355,7 +2360,7 @@ const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, cla
|
|
|
2355
2360
|
className: "size-8 before:-inset-1",
|
|
2356
2361
|
disabled: !hasNext,
|
|
2357
2362
|
onClick: onNext,
|
|
2358
|
-
"aria-label":
|
|
2363
|
+
"aria-label": labels.next,
|
|
2359
2364
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
2360
2365
|
icon: _hugeicons_core_free_icons.ArrowRight01Icon,
|
|
2361
2366
|
size: 16,
|
|
@@ -2766,13 +2771,10 @@ const measureShelfTop = ({ scrollArea, table }) => {
|
|
|
2766
2771
|
return body ? body.getBoundingClientRect().top - scrollArea.getBoundingClientRect().top + scrollArea.scrollTop : 0;
|
|
2767
2772
|
};
|
|
2768
2773
|
/**
|
|
2769
|
-
*
|
|
2770
|
-
*
|
|
2771
|
-
* only for static layout: a short fixed grid of values that nobody sorts, filters, pages or selects.
|
|
2772
|
-
*
|
|
2773
|
-
* @deprecated For lists of records, use `DataTable`. Direct use is only for static layout.
|
|
2774
|
+
* The table tray `DataTable` renders. Same as `Table`, without the deprecation that steers apps toward `DataTable`;
|
|
2775
|
+
* only `DataTable` should use it, and it is not exported from the package.
|
|
2774
2776
|
*/
|
|
2775
|
-
const
|
|
2777
|
+
const TableFrame = ({ className, fill = false, scrollAreaProps = {}, stickyFirstColumn = false, viewportRef, ...props }) => {
|
|
2776
2778
|
const scrollAreaRef = (0, react.useRef)(null);
|
|
2777
2779
|
const setViewportRef = (0, react.useMemo)(() => mergeRefs(scrollAreaRef, viewportRef), [viewportRef]);
|
|
2778
2780
|
const [overflow, setOverflow] = (0, react.useState)({
|
|
@@ -2966,6 +2968,14 @@ const Table = ({ className, fill = false, scrollAreaProps = {}, stickyFirstColum
|
|
|
2966
2968
|
})
|
|
2967
2969
|
});
|
|
2968
2970
|
};
|
|
2971
|
+
/**
|
|
2972
|
+
* Render a table in a stable tray with keyboard access only when content overflows.
|
|
2973
|
+
* For any list of records, use `DataTable`, which is built on this. Use `Table` directly
|
|
2974
|
+
* only for static layout: a short fixed grid of values that nobody sorts, filters, pages or selects.
|
|
2975
|
+
*
|
|
2976
|
+
* @deprecated For lists of records, use `DataTable`. Direct use is only for static layout.
|
|
2977
|
+
*/
|
|
2978
|
+
const Table = TableFrame;
|
|
2969
2979
|
const TableHeader = ({ className, ...props }) => {
|
|
2970
2980
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
|
|
2971
2981
|
"data-slot": "table-header",
|
|
@@ -3017,6 +3027,99 @@ const TableCaption = ({ className, ...props }) => {
|
|
|
3017
3027
|
});
|
|
3018
3028
|
};
|
|
3019
3029
|
|
|
3030
|
+
//#endregion
|
|
3031
|
+
//#region src/components/ui/data-table/data-table-context.ts
|
|
3032
|
+
const DataTableContext = (0, react.createContext)(null);
|
|
3033
|
+
/**
|
|
3034
|
+
* Read the state of the nearest `DataTable`, for building custom table parts.
|
|
3035
|
+
* Throws when called outside a `DataTable`.
|
|
3036
|
+
*/
|
|
3037
|
+
const useDataTableContext = () => {
|
|
3038
|
+
const context = (0, react.useContext)(DataTableContext);
|
|
3039
|
+
if (!context) throw new Error("DataTable parts must be used inside a DataTable");
|
|
3040
|
+
return context;
|
|
3041
|
+
};
|
|
3042
|
+
|
|
3043
|
+
//#endregion
|
|
3044
|
+
//#region src/components/ui/data-table/actions-column.tsx
|
|
3045
|
+
/**
|
|
3046
|
+
* Column id of `actionsColumn`, for pinning it or checking for it.
|
|
3047
|
+
*
|
|
3048
|
+
* @example
|
|
3049
|
+
* ```tsx
|
|
3050
|
+
* const options = { columnPinning: { initial: { right: [ACTIONS_COLUMN_ID] } } };
|
|
3051
|
+
* ```
|
|
3052
|
+
* @see actionsColumn
|
|
3053
|
+
* @see useDataTable
|
|
3054
|
+
*/
|
|
3055
|
+
const ACTIONS_COLUMN_ID = "actions";
|
|
3056
|
+
/** Fixed width in px; DataTableContent sizes headers from it when resizing or pinning is on. */
|
|
3057
|
+
const ACTIONS_COLUMN_SIZE = 48;
|
|
3058
|
+
const ActionsCell = ({ column, row }) => {
|
|
3059
|
+
const { labels } = useDataTableContext();
|
|
3060
|
+
const actions = column.columnDef.meta?.rowActions?.(row) ?? [];
|
|
3061
|
+
if (actions.length === 0) return null;
|
|
3062
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3063
|
+
className: "flex justify-end",
|
|
3064
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
|
|
3065
|
+
asChild: true,
|
|
3066
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3067
|
+
"aria-label": labels.rowActions,
|
|
3068
|
+
size: "icon-xs",
|
|
3069
|
+
variant: "ghost",
|
|
3070
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
3071
|
+
icon: _hugeicons_core_free_icons.MoreHorizontalIcon,
|
|
3072
|
+
"aria-hidden": "true",
|
|
3073
|
+
className: "size-4"
|
|
3074
|
+
})
|
|
3075
|
+
})
|
|
3076
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuContent, {
|
|
3077
|
+
align: "end",
|
|
3078
|
+
children: actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuItem, {
|
|
3079
|
+
disabled: action.disabled,
|
|
3080
|
+
onSelect: action.onSelect,
|
|
3081
|
+
className: action.variant === "danger" ? "text-[var(--text-danger)] focus:text-[var(--text-danger)]" : void 0,
|
|
3082
|
+
children: action.label
|
|
3083
|
+
}, action.label))
|
|
3084
|
+
})] })
|
|
3085
|
+
});
|
|
3086
|
+
};
|
|
3087
|
+
const ActionsHeader = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3088
|
+
className: "sr-only",
|
|
3089
|
+
children: useDataTableContext().labels.rowActions
|
|
3090
|
+
});
|
|
3091
|
+
/**
|
|
3092
|
+
* A narrow last column with a menu of actions for each row, such as edit or delete. Rows with no actions show no menu.
|
|
3093
|
+
* Choosing an action never opens the row, even when `DataTableContent` has `onRowClick`.
|
|
3094
|
+
*
|
|
3095
|
+
* @example
|
|
3096
|
+
* ```tsx
|
|
3097
|
+
* const columns = [
|
|
3098
|
+
* { accessorKey: 'name', header: 'Name' },
|
|
3099
|
+
* actionsColumn<User>({
|
|
3100
|
+
* getActions: (row) => [
|
|
3101
|
+
* { label: 'Edit', onSelect: () => openEditor(row.original) },
|
|
3102
|
+
* { label: 'Delete', onSelect: () => remove(row.original.id), variant: 'danger' },
|
|
3103
|
+
* ],
|
|
3104
|
+
* }),
|
|
3105
|
+
* ];
|
|
3106
|
+
* ```
|
|
3107
|
+
* @returns The column definition to add last to `columns`.
|
|
3108
|
+
* @see DataTableRowAction
|
|
3109
|
+
* @see selectionColumn
|
|
3110
|
+
* @see useDataTable
|
|
3111
|
+
*/
|
|
3112
|
+
const actionsColumn = ({ getActions }) => ({
|
|
3113
|
+
cell: ActionsCell,
|
|
3114
|
+
enableHiding: false,
|
|
3115
|
+
enableResizing: false,
|
|
3116
|
+
enableSorting: false,
|
|
3117
|
+
header: ActionsHeader,
|
|
3118
|
+
id: ACTIONS_COLUMN_ID,
|
|
3119
|
+
meta: { rowActions: getActions },
|
|
3120
|
+
size: ACTIONS_COLUMN_SIZE
|
|
3121
|
+
});
|
|
3122
|
+
|
|
3020
3123
|
//#endregion
|
|
3021
3124
|
//#region src/components/ui/data-table/create-column-helper.ts
|
|
3022
3125
|
/**
|
|
@@ -3038,16 +3141,45 @@ const TableCaption = ({ className, ...props }) => {
|
|
|
3038
3141
|
const createColumnHelper = _tanstack_react_table.createColumnHelper;
|
|
3039
3142
|
|
|
3040
3143
|
//#endregion
|
|
3041
|
-
//#region src/components/ui/data-table/data-table-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3144
|
+
//#region src/components/ui/data-table/data-table-labels.tsx
|
|
3145
|
+
/** The English text the data table parts use unless `DataTable` is given other `labels`. */
|
|
3146
|
+
const DEFAULT_DATA_TABLE_LABELS = {
|
|
3147
|
+
activeFilters: "Active filters",
|
|
3148
|
+
changeFilter: ({ column, value }) => `Change ${column} filter: ${value}`,
|
|
3149
|
+
clearColumnFilter: "Clear",
|
|
3150
|
+
clearFilters: "Clear filters",
|
|
3151
|
+
columns: "Columns",
|
|
3152
|
+
columnWidth: ({ width }) => `${width} pixels`,
|
|
3153
|
+
emptyFilteredTitle: "No matching results",
|
|
3154
|
+
emptyGroup: "None",
|
|
3155
|
+
emptyTitle: "No results",
|
|
3156
|
+
filterColumn: ({ column, isFiltered }) => isFiltered ? `Filter ${column}, filtered` : `Filter ${column}`,
|
|
3157
|
+
filterNoValues: "No values",
|
|
3158
|
+
filterPlaceholder: "Contains",
|
|
3159
|
+
nextPage: "Go to next page",
|
|
3160
|
+
pagination: "Pagination",
|
|
3161
|
+
previousPage: "Go to previous page",
|
|
3162
|
+
range: ({ end, start, total }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3163
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3164
|
+
className: "text-foreground",
|
|
3165
|
+
children: [
|
|
3166
|
+
start,
|
|
3167
|
+
"–",
|
|
3168
|
+
end
|
|
3169
|
+
]
|
|
3170
|
+
}),
|
|
3171
|
+
" ",
|
|
3172
|
+
"of ",
|
|
3173
|
+
total
|
|
3174
|
+
] }),
|
|
3175
|
+
removeFilter: ({ column }) => `Remove ${column} filter`,
|
|
3176
|
+
removeSearch: "Remove search filter",
|
|
3177
|
+
resizeColumn: ({ column }) => `Resize ${column}`,
|
|
3178
|
+
rowActions: "Row actions",
|
|
3179
|
+
search: "Search",
|
|
3180
|
+
selectAllRows: "Select all rows",
|
|
3181
|
+
selectRow: "Select row",
|
|
3182
|
+
sortPriority: ({ priority }) => `sort priority ${priority}`
|
|
3051
3183
|
};
|
|
3052
3184
|
|
|
3053
3185
|
//#endregion
|
|
@@ -3055,6 +3187,13 @@ const useDataTableContext = () => {
|
|
|
3055
3187
|
/**
|
|
3056
3188
|
* Root of a data table. Holds the table state for `DataTableContent`, `DataTablePagination` and the other parts.
|
|
3057
3189
|
*
|
|
3190
|
+
* Use it for any list of records people sort, filter, page, select or open. Use the plain `Table` only for a short
|
|
3191
|
+
* static list with none of those.
|
|
3192
|
+
* - Turn features on per `useDataTable` option; pass `getRowId` when rows have an id, or selection follows the index.
|
|
3193
|
+
* - Row actions: `actionsColumn({ getActions })`, last in `columns`. Never a hand-made button column.
|
|
3194
|
+
* - Clickable rows: `onRowClick` on `DataTableContent`. Never a link in one cell.
|
|
3195
|
+
* - Text: pass only the strings that change through `labels`, for translation.
|
|
3196
|
+
*
|
|
3058
3197
|
* @example
|
|
3059
3198
|
* ```tsx
|
|
3060
3199
|
* const dataTable = useDataTable({ columns, data });
|
|
@@ -3071,11 +3210,19 @@ const useDataTableContext = () => {
|
|
|
3071
3210
|
* @see DataTableContent
|
|
3072
3211
|
* @see DataTableToolbar
|
|
3073
3212
|
*/
|
|
3074
|
-
const DataTable = ({ children, className, fill = false, table, ...props }) => {
|
|
3213
|
+
const DataTable = ({ children, className, fill = false, labels, table, ...props }) => {
|
|
3075
3214
|
const contextValue = (0, react.useMemo)(() => ({
|
|
3076
3215
|
...table,
|
|
3077
|
-
fill
|
|
3078
|
-
|
|
3216
|
+
fill,
|
|
3217
|
+
labels: {
|
|
3218
|
+
...DEFAULT_DATA_TABLE_LABELS,
|
|
3219
|
+
...labels
|
|
3220
|
+
}
|
|
3221
|
+
}), [
|
|
3222
|
+
table,
|
|
3223
|
+
fill,
|
|
3224
|
+
labels
|
|
3225
|
+
]);
|
|
3079
3226
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableContext.Provider, {
|
|
3080
3227
|
value: contextValue,
|
|
3081
3228
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3120,8 +3267,6 @@ const getColumnLabel = (column) => {
|
|
|
3120
3267
|
|
|
3121
3268
|
//#endregion
|
|
3122
3269
|
//#region src/components/ui/data-table/data-table-column-filter.tsx
|
|
3123
|
-
const TEXT_FILTER_PLACEHOLDER = "Contains";
|
|
3124
|
-
const EMPTY_OPTIONS_TEXT = "No values";
|
|
3125
3270
|
/**
|
|
3126
3271
|
* Turn cell values into checklist options. List-valued cells count as one value each in TanStack's facets, so their items are
|
|
3127
3272
|
* spread out first: a tags column then offers each tag rather than each combination. Empty values offer nothing to check.
|
|
@@ -3143,7 +3288,7 @@ const getFilterOptions = ({ column, selected, table }) => {
|
|
|
3143
3288
|
};
|
|
3144
3289
|
/** The checklist of a `values` filter. The checked values are the filter value; unchecking the last one removes the filter. */
|
|
3145
3290
|
const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
3146
|
-
const { table } = useDataTableContext();
|
|
3291
|
+
const { labels, table } = useDataTableContext();
|
|
3147
3292
|
const selected = Array.isArray(filterValue) ? filterValue.map(String) : [];
|
|
3148
3293
|
const options = getFilterOptions({
|
|
3149
3294
|
column,
|
|
@@ -3156,7 +3301,7 @@ const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
|
3156
3301
|
};
|
|
3157
3302
|
if (options.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3158
3303
|
className: "text-sm text-muted-foreground",
|
|
3159
|
-
children:
|
|
3304
|
+
children: labels.filterNoValues
|
|
3160
3305
|
});
|
|
3161
3306
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3162
3307
|
"data-slot": "data-table-column-filter-options",
|
|
@@ -3197,12 +3342,15 @@ const DataTableValuesFilter = ({ column, filterValue }) => {
|
|
|
3197
3342
|
* @see DataTableSearch
|
|
3198
3343
|
*/
|
|
3199
3344
|
const DataTableColumnFilter = ({ className, column }) => {
|
|
3200
|
-
const
|
|
3345
|
+
const { labels } = useDataTableContext();
|
|
3201
3346
|
const isFiltered = column.getIsFiltered();
|
|
3202
3347
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
|
|
3203
3348
|
asChild: true,
|
|
3204
3349
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
|
|
3205
|
-
"aria-label":
|
|
3350
|
+
"aria-label": labels.filterColumn({
|
|
3351
|
+
column: getColumnLabel(column),
|
|
3352
|
+
isFiltered
|
|
3353
|
+
}),
|
|
3206
3354
|
"data-slot": "data-table-column-filter",
|
|
3207
3355
|
"data-filtered": isFiltered || void 0,
|
|
3208
3356
|
size: "icon-xs",
|
|
@@ -3220,18 +3368,22 @@ const DataTableColumnFilter = ({ className, column }) => {
|
|
|
3220
3368
|
};
|
|
3221
3369
|
/** The body of a column's filter popover, shared by the header filter button and the active-filter chips. */
|
|
3222
3370
|
const DataTableColumnFilterContent = ({ column }) => {
|
|
3223
|
-
const
|
|
3371
|
+
const { labels } = useDataTableContext();
|
|
3372
|
+
const filterLabel = labels.filterColumn({
|
|
3373
|
+
column: getColumnLabel(column),
|
|
3374
|
+
isFiltered: false
|
|
3375
|
+
});
|
|
3224
3376
|
const filterValue = column.getFilterValue();
|
|
3225
3377
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PopoverContent, {
|
|
3226
|
-
"aria-label":
|
|
3378
|
+
"aria-label": filterLabel,
|
|
3227
3379
|
align: "start",
|
|
3228
3380
|
className: "flex w-56 flex-col gap-3 p-3",
|
|
3229
3381
|
children: [column.columnDef.meta?.filter === "values" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableValuesFilter, {
|
|
3230
3382
|
column,
|
|
3231
3383
|
filterValue
|
|
3232
3384
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input, {
|
|
3233
|
-
"aria-label":
|
|
3234
|
-
placeholder:
|
|
3385
|
+
"aria-label": filterLabel,
|
|
3386
|
+
placeholder: labels.filterPlaceholder,
|
|
3235
3387
|
value: typeof filterValue === "string" ? filterValue : "",
|
|
3236
3388
|
onChange: (event) => column.setFilterValue(event.target.value)
|
|
3237
3389
|
}), column.getIsFiltered() && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3241,7 +3393,7 @@ const DataTableColumnFilterContent = ({ column }) => {
|
|
|
3241
3393
|
size: "sm",
|
|
3242
3394
|
variant: "secondary",
|
|
3243
3395
|
onClick: () => column.setFilterValue(void 0),
|
|
3244
|
-
children:
|
|
3396
|
+
children: labels.clearColumnFilter
|
|
3245
3397
|
})
|
|
3246
3398
|
})]
|
|
3247
3399
|
});
|
|
@@ -3254,6 +3406,7 @@ const toFilterValues = (value) => Array.isArray(value) ? value.map(String) : [St
|
|
|
3254
3406
|
const MAX_SHOWN_VALUES = 2;
|
|
3255
3407
|
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)]";
|
|
3256
3408
|
const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) => {
|
|
3409
|
+
const { labels } = useDataTableContext();
|
|
3257
3410
|
const fullValue = values.join(", ");
|
|
3258
3411
|
const hiddenCount = values.length - MAX_SHOWN_VALUES;
|
|
3259
3412
|
const shownValue = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [values.slice(0, MAX_SHOWN_VALUES).join(", "), hiddenCount > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
@@ -3292,7 +3445,10 @@ const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) =
|
|
|
3292
3445
|
asChild: true,
|
|
3293
3446
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3294
3447
|
type: "button",
|
|
3295
|
-
"aria-label":
|
|
3448
|
+
"aria-label": labels.changeFilter({
|
|
3449
|
+
column: label,
|
|
3450
|
+
value: fullValue
|
|
3451
|
+
}),
|
|
3296
3452
|
className: cn(CHIP_CONTROL, "ms-1 gap-1 ps-1.5 pe-1 font-medium text-[var(--action)]"),
|
|
3297
3453
|
children: [shownValue, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
3298
3454
|
icon: _hugeicons_core_free_icons.ArrowDown01Icon,
|
|
@@ -3328,7 +3484,7 @@ const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) =
|
|
|
3328
3484
|
* @see useDataTable
|
|
3329
3485
|
*/
|
|
3330
3486
|
const DataTableActiveFilters = ({ className }) => {
|
|
3331
|
-
const { table } = useDataTableContext();
|
|
3487
|
+
const { labels, table } = useDataTableContext();
|
|
3332
3488
|
const { columnFilters, globalFilter } = table.getState();
|
|
3333
3489
|
const search = typeof globalFilter === "string" ? globalFilter : "";
|
|
3334
3490
|
if (columnFilters.length === 0 && search === "") return null;
|
|
@@ -3337,14 +3493,14 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3337
3493
|
table.setGlobalFilter("");
|
|
3338
3494
|
};
|
|
3339
3495
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
|
|
3340
|
-
"aria-label":
|
|
3496
|
+
"aria-label": labels.activeFilters,
|
|
3341
3497
|
"data-slot": "data-table-active-filters",
|
|
3342
3498
|
className: cn("flex min-w-0 flex-wrap items-center gap-2", className),
|
|
3343
3499
|
children: [
|
|
3344
3500
|
search !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableFilterChip, {
|
|
3345
|
-
label:
|
|
3501
|
+
label: labels.search,
|
|
3346
3502
|
onRemove: () => table.setGlobalFilter(""),
|
|
3347
|
-
removeLabel:
|
|
3503
|
+
removeLabel: labels.removeSearch,
|
|
3348
3504
|
values: [search]
|
|
3349
3505
|
}),
|
|
3350
3506
|
columnFilters.map(({ id, value }) => {
|
|
@@ -3354,7 +3510,7 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3354
3510
|
column: column?.columnDef.meta?.filter ? column : void 0,
|
|
3355
3511
|
label,
|
|
3356
3512
|
onRemove: () => table.setColumnFilters((old) => old.filter((filter) => filter.id !== id)),
|
|
3357
|
-
removeLabel:
|
|
3513
|
+
removeLabel: labels.removeFilter({ column: label }),
|
|
3358
3514
|
values: toFilterValues(value)
|
|
3359
3515
|
}, id);
|
|
3360
3516
|
}),
|
|
@@ -3362,7 +3518,7 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3362
3518
|
className: "text-muted-foreground hover:text-foreground",
|
|
3363
3519
|
variant: "ghost",
|
|
3364
3520
|
onClick: clearAll,
|
|
3365
|
-
children:
|
|
3521
|
+
children: labels.clearFilters
|
|
3366
3522
|
})
|
|
3367
3523
|
]
|
|
3368
3524
|
});
|
|
@@ -3387,8 +3543,8 @@ const DataTableActiveFilters = ({ className }) => {
|
|
|
3387
3543
|
* @see DataTableToolbar
|
|
3388
3544
|
* @see useDataTable
|
|
3389
3545
|
*/
|
|
3390
|
-
const DataTableColumnVisibility = ({ className, label
|
|
3391
|
-
const { table } = useDataTableContext();
|
|
3546
|
+
const DataTableColumnVisibility = ({ className, label }) => {
|
|
3547
|
+
const { labels, table } = useDataTableContext();
|
|
3392
3548
|
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
3393
3549
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
|
|
3394
3550
|
asChild: true,
|
|
@@ -3401,7 +3557,7 @@ const DataTableColumnVisibility = ({ className, label = "Columns" }) => {
|
|
|
3401
3557
|
icon: _hugeicons_core_free_icons.LayoutThreeColumnIcon,
|
|
3402
3558
|
"aria-hidden": "true"
|
|
3403
3559
|
}),
|
|
3404
|
-
label,
|
|
3560
|
+
label ?? labels.columns,
|
|
3405
3561
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
3406
3562
|
icon: _hugeicons_core_free_icons.ArrowDown01Icon,
|
|
3407
3563
|
"aria-hidden": "true"
|
|
@@ -3480,7 +3636,7 @@ const DataTableSkeletonRows = ({ columnCount, rowCount }) => /* @__PURE__ */ (0,
|
|
|
3480
3636
|
}) }, columnIndex))
|
|
3481
3637
|
}, rowIndex)) });
|
|
3482
3638
|
/** Ghost rows keep the table's shape behind an icon and title. */
|
|
3483
|
-
const DataTableEmptyRow = ({ action, columnCount, icon, title }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
|
|
3639
|
+
const DataTableEmptyRow = ({ action, columnCount, description, icon, title }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
|
|
3484
3640
|
"data-slot": "data-table-empty",
|
|
3485
3641
|
className: STATIC_ROW,
|
|
3486
3642
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, {
|
|
@@ -3505,6 +3661,7 @@ const DataTableEmptyRow = ({ action, columnCount, icon, title }) => /* @__PURE__
|
|
|
3505
3661
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmptyState, {
|
|
3506
3662
|
action,
|
|
3507
3663
|
className: "py-0",
|
|
3664
|
+
description,
|
|
3508
3665
|
icon,
|
|
3509
3666
|
title
|
|
3510
3667
|
})
|
|
@@ -3522,6 +3679,20 @@ const ExpandChevron = ({ isOpen }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)
|
|
|
3522
3679
|
className: cn("transition-transform duration-150 motion-reduce:transition-none", isOpen && "rotate-90")
|
|
3523
3680
|
});
|
|
3524
3681
|
|
|
3682
|
+
//#endregion
|
|
3683
|
+
//#region src/components/ui/data-table/is-row-activation.ts
|
|
3684
|
+
/** Elements that handle their own clicks, so a click on them must not also open the row. */
|
|
3685
|
+
const INTERACTIVE_SELECTOR = "a, button, input, label, select, summary, textarea, [role=\"checkbox\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [tabindex]";
|
|
3686
|
+
/**
|
|
3687
|
+
* Whether a click or key press on a row should open it: it came from the row itself or plain content inside it,
|
|
3688
|
+
* not from a control such as a checkbox, link or row action menu.
|
|
3689
|
+
*/
|
|
3690
|
+
const isRowActivation = ({ currentTarget, target }) => {
|
|
3691
|
+
if (!(target instanceof Element) || !currentTarget.contains(target)) return false;
|
|
3692
|
+
const interactive = target.closest(INTERACTIVE_SELECTOR);
|
|
3693
|
+
return interactive === null || interactive === currentTarget;
|
|
3694
|
+
};
|
|
3695
|
+
|
|
3525
3696
|
//#endregion
|
|
3526
3697
|
//#region src/components/ui/data-table/get-pinned-cell-props.ts
|
|
3527
3698
|
/** Pinned cells need an opaque base so scrolling text cannot show through; the body overlay still follows row hover and selection. */
|
|
@@ -3566,13 +3737,13 @@ const getAllRowsCheckedState = (table) => {
|
|
|
3566
3737
|
return table.getIsSomePageRowsSelected() ? "indeterminate" : false;
|
|
3567
3738
|
};
|
|
3568
3739
|
const SelectionCell = ({ row }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
|
|
3569
|
-
"aria-label":
|
|
3740
|
+
"aria-label": useDataTableContext().labels.selectRow,
|
|
3570
3741
|
checked: row.getIsSelected(),
|
|
3571
3742
|
disabled: !row.getCanSelect(),
|
|
3572
3743
|
onCheckedChange: (checked) => row.toggleSelected(checked === true)
|
|
3573
3744
|
});
|
|
3574
3745
|
const SelectionHeader = ({ table }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
|
|
3575
|
-
"aria-label":
|
|
3746
|
+
"aria-label": useDataTableContext().labels.selectAllRows,
|
|
3576
3747
|
checked: getAllRowsCheckedState(table),
|
|
3577
3748
|
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true)
|
|
3578
3749
|
});
|
|
@@ -3606,22 +3777,30 @@ const FIXED_LAYOUT_CELL_CLASS = "overflow-hidden text-ellipsis";
|
|
|
3606
3777
|
* the visible width and never widens the table.
|
|
3607
3778
|
*/
|
|
3608
3779
|
const STICKY_ROW_CONTENT = "sticky start-0 w-[100cqw] px-4 py-2.5";
|
|
3609
|
-
/**
|
|
3610
|
-
const
|
|
3611
|
-
/** The checkbox column holds one control, so it stays narrow and never clips. */
|
|
3612
|
-
const isControlColumn = (columnId) => columnId === SELECTION_COLUMN_ID;
|
|
3780
|
+
/** The checkbox and row actions columns hold one control each, so they stay narrow and never clip. */
|
|
3781
|
+
const isControlColumn = (columnId) => columnId === SELECTION_COLUMN_ID || columnId === ACTIONS_COLUMN_ID;
|
|
3613
3782
|
/** Rows inside groups step in by 1.25rem per level from the cell's own 1rem padding. */
|
|
3614
3783
|
const getIndent = (depth) => `calc(1rem + ${depth} * 1.25rem)`;
|
|
3615
|
-
const getGroupLabel = ({ groupingColumnId, row }) => {
|
|
3784
|
+
const getGroupLabel = ({ emptyGroupLabel, groupingColumnId, row }) => {
|
|
3616
3785
|
const value = row.getGroupingValue(groupingColumnId);
|
|
3617
|
-
return `${value === void 0 || value === null || value === "" ?
|
|
3786
|
+
return `${value === void 0 || value === null || value === "" ? emptyGroupLabel : String(value)} (${row.getLeafRows().filter((leaf) => !leaf.getIsGrouped()).length})`;
|
|
3618
3787
|
};
|
|
3619
|
-
|
|
3788
|
+
/** Focus draws an inset outline, since a table row cannot take a ring. */
|
|
3789
|
+
const CLICKABLE_ROW_CLASS = "cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--ring)]";
|
|
3790
|
+
const DataTableRow = ({ className, hasFixedLayout, onRowClick, row, rowRef, ...props }) => {
|
|
3620
3791
|
const cells = row.getVisibleCells();
|
|
3621
3792
|
const indentedCellId = row.depth > 0 ? cells.find((cell) => !isControlColumn(cell.column.id))?.id : void 0;
|
|
3622
3793
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
|
|
3623
3794
|
ref: rowRef,
|
|
3624
3795
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
3796
|
+
className: cn(onRowClick && CLICKABLE_ROW_CLASS, className),
|
|
3797
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
3798
|
+
onClick: onRowClick ? (event) => {
|
|
3799
|
+
if (isRowActivation(event)) onRowClick(row);
|
|
3800
|
+
} : void 0,
|
|
3801
|
+
onKeyDown: onRowClick ? (event) => {
|
|
3802
|
+
if (event.key === "Enter" && event.target === event.currentTarget) onRowClick(row);
|
|
3803
|
+
} : void 0,
|
|
3625
3804
|
...props,
|
|
3626
3805
|
children: cells.map((cell) => {
|
|
3627
3806
|
const pinned = getPinnedCellProps({
|
|
@@ -3642,6 +3821,7 @@ const DataTableRow = ({ hasFixedLayout, row, rowRef, ...props }) => {
|
|
|
3642
3821
|
};
|
|
3643
3822
|
/** One full-width row naming the group and how many rows it holds, with a button that opens or closes it. */
|
|
3644
3823
|
const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...props }) => {
|
|
3824
|
+
const { labels } = useDataTableContext();
|
|
3645
3825
|
const isOpen = row.getIsExpanded();
|
|
3646
3826
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
|
|
3647
3827
|
ref: rowRef,
|
|
@@ -3660,6 +3840,7 @@ const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...prop
|
|
|
3660
3840
|
onClick: row.getToggleExpandedHandler(),
|
|
3661
3841
|
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",
|
|
3662
3842
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandChevron, { isOpen }), getGroupLabel({
|
|
3843
|
+
emptyGroupLabel: labels.emptyGroup,
|
|
3663
3844
|
groupingColumnId,
|
|
3664
3845
|
row
|
|
3665
3846
|
})]
|
|
@@ -3669,7 +3850,7 @@ const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...prop
|
|
|
3669
3850
|
});
|
|
3670
3851
|
};
|
|
3671
3852
|
/** One table row, as a group header or a data row. Row props and `rowRef` land on its `<tr>`. */
|
|
3672
|
-
const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
3853
|
+
const DataTableBodyRow = ({ columnCount, hasFixedLayout, onRowClick, row, ...props }) => {
|
|
3673
3854
|
const { groupingColumnId } = row;
|
|
3674
3855
|
if (groupingColumnId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableGroupRow, {
|
|
3675
3856
|
columnCount,
|
|
@@ -3679,6 +3860,7 @@ const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
|
3679
3860
|
});
|
|
3680
3861
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableRow, {
|
|
3681
3862
|
hasFixedLayout,
|
|
3863
|
+
onRowClick,
|
|
3682
3864
|
row,
|
|
3683
3865
|
...props
|
|
3684
3866
|
});
|
|
@@ -3686,8 +3868,6 @@ const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
|
|
|
3686
3868
|
|
|
3687
3869
|
//#endregion
|
|
3688
3870
|
//#region src/components/ui/data-table/data-table-content.tsx
|
|
3689
|
-
const DEFAULT_EMPTY_TITLE = "No results";
|
|
3690
|
-
const DEFAULT_EMPTY_FILTERED_TITLE = "No matching results";
|
|
3691
3871
|
const DEFAULT_LOADING_ROW_COUNT = 5;
|
|
3692
3872
|
const ARIA_SORT = {
|
|
3693
3873
|
asc: "ascending",
|
|
@@ -3706,6 +3886,15 @@ const RESIZE_STEP = {
|
|
|
3706
3886
|
const MIN_COLUMN_SIZE = 20;
|
|
3707
3887
|
/** TanStack leaves columns unbounded; screen readers get a usable range instead. */
|
|
3708
3888
|
const MAX_COLUMN_SIZE = 1e3;
|
|
3889
|
+
/** The resize cursor, centered on the gap between its triangles, with the system one as a fallback. */
|
|
3890
|
+
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`;
|
|
3891
|
+
/**
|
|
3892
|
+
* The line is hidden until the header is hovered, then shows as a faint 1px line so people see where columns can be
|
|
3893
|
+
* resized before finding the handle. Hovering the handle or dragging it thickens the line to 2px, with round ends, and
|
|
3894
|
+
* darkens it a step; keyboard focus draws it in the focus color. The thickening is a horizontal scale of a 2px line,
|
|
3895
|
+
* not a width change, so it eases smoothly and stays centered in the handle, in the gap between the cursor's triangles.
|
|
3896
|
+
*/
|
|
3897
|
+
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";
|
|
3709
3898
|
/** Rows rendered beyond each edge of the view when virtualization sets no overscan. */
|
|
3710
3899
|
const DEFAULT_OVERSCAN = 8;
|
|
3711
3900
|
const DefaultEmptyIcon = ({ className, size }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
|
|
@@ -3728,26 +3917,38 @@ const DataTableResizeHandle = ({ header }) => {
|
|
|
3728
3917
|
}));
|
|
3729
3918
|
};
|
|
3730
3919
|
const resize = header.getResizeHandler();
|
|
3920
|
+
const { labels } = useDataTableContext();
|
|
3921
|
+
const isResizing = column.getIsResizing();
|
|
3922
|
+
(0, react.useEffect)(() => {
|
|
3923
|
+
if (!isResizing) return void 0;
|
|
3924
|
+
const previousCursor = document.body.style.cursor;
|
|
3925
|
+
document.body.style.cursor = RESIZE_CURSOR;
|
|
3926
|
+
return () => {
|
|
3927
|
+
document.body.style.cursor = previousCursor;
|
|
3928
|
+
};
|
|
3929
|
+
}, [isResizing]);
|
|
3731
3930
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3732
3931
|
role: "separator",
|
|
3733
|
-
"aria-label":
|
|
3932
|
+
"aria-label": labels.resizeColumn({ column: getColumnLabel(column) }),
|
|
3734
3933
|
"aria-orientation": "vertical",
|
|
3735
3934
|
"aria-valuemax": getMaxColumnSize(column.columnDef.maxSize),
|
|
3736
3935
|
"aria-valuemin": column.columnDef.minSize ?? MIN_COLUMN_SIZE,
|
|
3737
3936
|
"aria-valuenow": size,
|
|
3738
|
-
"aria-valuetext":
|
|
3937
|
+
"aria-valuetext": labels.columnWidth({ width: size }),
|
|
3739
3938
|
tabIndex: 0,
|
|
3740
3939
|
"data-slot": "data-table-resize-handle",
|
|
3741
|
-
"data-resizing":
|
|
3940
|
+
"data-resizing": isResizing || void 0,
|
|
3742
3941
|
onDoubleClick: () => column.resetSize(),
|
|
3743
3942
|
onKeyDown: handleKeyDown,
|
|
3744
3943
|
onMouseDown: resize,
|
|
3745
3944
|
onTouchStart: resize,
|
|
3746
|
-
className:
|
|
3945
|
+
className: RESIZE_HANDLE_CLASS,
|
|
3946
|
+
style: { cursor: RESIZE_CURSOR }
|
|
3747
3947
|
});
|
|
3748
3948
|
};
|
|
3749
3949
|
const DataTableHeadCell = ({ header, hasFixedLayout }) => {
|
|
3750
3950
|
const { column } = header;
|
|
3951
|
+
const { labels } = useDataTableContext();
|
|
3751
3952
|
const sorted = column.getIsSorted();
|
|
3752
3953
|
const sortIndex = column.getSortIndex();
|
|
3753
3954
|
const isMultiSort = header.getContext().table.getState().sorting.length > 1;
|
|
@@ -3784,7 +3985,7 @@ const DataTableHeadCell = ({ header, hasFixedLayout }) => {
|
|
|
3784
3985
|
children: sortPriority
|
|
3785
3986
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3786
3987
|
className: "sr-only",
|
|
3787
|
-
children: [",
|
|
3988
|
+
children: [", ", labels.sortPriority({ priority: sortPriority })]
|
|
3788
3989
|
})] })
|
|
3789
3990
|
]
|
|
3790
3991
|
}) : content,
|
|
@@ -3809,6 +4010,12 @@ const DataTableVirtualSpacer = ({ columnCount, height }) => /* @__PURE__ */ (0,
|
|
|
3809
4010
|
/**
|
|
3810
4011
|
* The table itself: headers, rows, and the loading and empty states.
|
|
3811
4012
|
*
|
|
4013
|
+
* - Always give it an `aria-label` that names the records, such as "Users".
|
|
4014
|
+
* - `onRowClick` when a row opens something: rows become focusable, Enter opens, clicks on controls in the row do not.
|
|
4015
|
+
* - `emptyTitle` in the records' own words; `emptyDescription` only when it says what to do; `emptyAction` when the
|
|
4016
|
+
* first row can be created here. When filters hide every row, `emptyFilteredTitle` and Clear filters show instead.
|
|
4017
|
+
* - Never put a placeholder row in the data or a banner inside the table: banners go beside it as siblings.
|
|
4018
|
+
*
|
|
3812
4019
|
* @example
|
|
3813
4020
|
* ```tsx
|
|
3814
4021
|
* const dataTable = useDataTable({ columns, data, sorting: { mode: 'client' } });
|
|
@@ -3822,8 +4029,8 @@ const DataTableVirtualSpacer = ({ columnCount, height }) => /* @__PURE__ */ (0,
|
|
|
3822
4029
|
* @see useDataTable
|
|
3823
4030
|
* @see DataTablePagination
|
|
3824
4031
|
*/
|
|
3825
|
-
const DataTableContent = ({ className,
|
|
3826
|
-
const { fill, loading, table, virtualization } = useDataTableContext();
|
|
4032
|
+
const DataTableContent = ({ className, emptyAction, emptyDescription, emptyFilteredTitle, emptyIcon = DefaultEmptyIcon, emptyTitle, loadingRowCount = DEFAULT_LOADING_ROW_COUNT, onRowClick, style, ...props }) => {
|
|
4033
|
+
const { fill, labels, loading, table, virtualization } = useDataTableContext();
|
|
3827
4034
|
const viewportRef = (0, react.useRef)(null);
|
|
3828
4035
|
const hasFixedLayout = table.options.enableColumnResizing === true || table.options.enableColumnPinning === true || virtualization !== void 0;
|
|
3829
4036
|
const columnCount = table.getVisibleLeafColumns().length;
|
|
@@ -3859,6 +4066,7 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3859
4066
|
columnCount,
|
|
3860
4067
|
"data-index": index,
|
|
3861
4068
|
hasFixedLayout,
|
|
4069
|
+
onRowClick,
|
|
3862
4070
|
row,
|
|
3863
4071
|
rowRef: virtualizer.measureElement
|
|
3864
4072
|
}, row.id);
|
|
@@ -3872,9 +4080,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3872
4080
|
const renderEmptyRow = () => {
|
|
3873
4081
|
const { columnFilters, globalFilter } = table.getState();
|
|
3874
4082
|
if (columnFilters.length === 0 && globalFilter === "") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableEmptyRow, {
|
|
4083
|
+
action: emptyAction,
|
|
3875
4084
|
columnCount,
|
|
4085
|
+
description: emptyDescription,
|
|
3876
4086
|
icon: emptyIcon,
|
|
3877
|
-
title: emptyTitle
|
|
4087
|
+
title: emptyTitle ?? labels.emptyTitle
|
|
3878
4088
|
});
|
|
3879
4089
|
const clearFilters = () => {
|
|
3880
4090
|
table.setColumnFilters([]);
|
|
@@ -3885,11 +4095,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3885
4095
|
variant: "outline",
|
|
3886
4096
|
size: "sm",
|
|
3887
4097
|
onClick: clearFilters,
|
|
3888
|
-
children:
|
|
4098
|
+
children: labels.clearFilters
|
|
3889
4099
|
}),
|
|
3890
4100
|
columnCount,
|
|
3891
4101
|
icon: emptyIcon,
|
|
3892
|
-
title: emptyFilteredTitle
|
|
4102
|
+
title: emptyFilteredTitle ?? labels.emptyFilteredTitle
|
|
3893
4103
|
});
|
|
3894
4104
|
};
|
|
3895
4105
|
const renderBody = () => {
|
|
@@ -3902,10 +4112,11 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3902
4112
|
return rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableBodyRow, {
|
|
3903
4113
|
columnCount,
|
|
3904
4114
|
hasFixedLayout,
|
|
4115
|
+
onRowClick,
|
|
3905
4116
|
row
|
|
3906
4117
|
}, row.id));
|
|
3907
4118
|
};
|
|
3908
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
4119
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TableFrame, {
|
|
3909
4120
|
fill,
|
|
3910
4121
|
"aria-busy": loading || void 0,
|
|
3911
4122
|
"aria-rowcount": isVirtualized ? rows.length + headerRowCount : void 0,
|
|
@@ -3950,7 +4161,7 @@ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTER
|
|
|
3950
4161
|
* @see DataTable
|
|
3951
4162
|
*/
|
|
3952
4163
|
const DataTablePagination = ({ className }) => {
|
|
3953
|
-
const { table } = useDataTableContext();
|
|
4164
|
+
const { labels, table } = useDataTableContext();
|
|
3954
4165
|
if (!table.options.getPaginationRowModel && !table.options.manualPagination) return null;
|
|
3955
4166
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
3956
4167
|
const rowCount = table.getRowCount();
|
|
@@ -3960,19 +4171,16 @@ const DataTablePagination = ({ className }) => {
|
|
|
3960
4171
|
className,
|
|
3961
4172
|
hasNext: table.getCanNextPage(),
|
|
3962
4173
|
hasPrevious: table.getCanPreviousPage(),
|
|
3963
|
-
label: rowCount > 0 ?
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
"of ",
|
|
3974
|
-
rowCount
|
|
3975
|
-
] }) : void 0,
|
|
4174
|
+
label: rowCount > 0 ? labels.range({
|
|
4175
|
+
end,
|
|
4176
|
+
start,
|
|
4177
|
+
total: rowCount
|
|
4178
|
+
}) : void 0,
|
|
4179
|
+
labels: {
|
|
4180
|
+
next: labels.nextPage,
|
|
4181
|
+
previous: labels.previousPage,
|
|
4182
|
+
region: labels.pagination
|
|
4183
|
+
},
|
|
3976
4184
|
onNext: () => table.nextPage(),
|
|
3977
4185
|
onPrevious: () => table.previousPage()
|
|
3978
4186
|
});
|
|
@@ -4000,8 +4208,8 @@ const DataTablePagination = ({ className }) => {
|
|
|
4000
4208
|
* @see DataTableActiveFilters
|
|
4001
4209
|
* @see useDataTable
|
|
4002
4210
|
*/
|
|
4003
|
-
const DataTableSearch = ({ className, placeholder
|
|
4004
|
-
const { table } = useDataTableContext();
|
|
4211
|
+
const DataTableSearch = ({ className, placeholder }) => {
|
|
4212
|
+
const { labels, table } = useDataTableContext();
|
|
4005
4213
|
if (!table.options.enableGlobalFilter) return null;
|
|
4006
4214
|
const { globalFilter } = table.getState();
|
|
4007
4215
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4014,8 +4222,8 @@ const DataTableSearch = ({ className, placeholder = "Search" }) => {
|
|
|
4014
4222
|
className: "pointer-events-none absolute start-2 top-1/2 -translate-y-1/2 text-muted-foreground/70"
|
|
4015
4223
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input, {
|
|
4016
4224
|
type: "search",
|
|
4017
|
-
"aria-label": placeholder,
|
|
4018
|
-
placeholder,
|
|
4225
|
+
"aria-label": placeholder ?? labels.search,
|
|
4226
|
+
placeholder: placeholder ?? labels.search,
|
|
4019
4227
|
value: typeof globalFilter === "string" ? globalFilter : "",
|
|
4020
4228
|
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
4021
4229
|
className: "ps-8"
|
|
@@ -7225,6 +7433,7 @@ const UsersIcon = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, reac
|
|
|
7225
7433
|
UsersIcon.displayName = "UsersIcon";
|
|
7226
7434
|
|
|
7227
7435
|
//#endregion
|
|
7436
|
+
exports.ACTIONS_COLUMN_ID = ACTIONS_COLUMN_ID;
|
|
7228
7437
|
exports.Accordion = Accordion;
|
|
7229
7438
|
exports.AccordionContent = AccordionContent;
|
|
7230
7439
|
exports.AccordionItem = AccordionItem;
|
|
@@ -7435,6 +7644,7 @@ exports.WebhooksAction = WebhooksAction;
|
|
|
7435
7644
|
exports.Well = Well;
|
|
7436
7645
|
exports.WellReveal = WellReveal;
|
|
7437
7646
|
exports.WindsurfLogo = WindsurfLogo;
|
|
7647
|
+
exports.actionsColumn = actionsColumn;
|
|
7438
7648
|
exports.badgeVariants = badgeVariants;
|
|
7439
7649
|
exports.buttonVariants = buttonVariants;
|
|
7440
7650
|
exports.cn = cn;
|