compote-ui 0.55.3 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/components/data-table-v8/create-table.svelte.js +8 -1
  2. package/dist/components/data-table-v9/column-helper.d.ts +12 -0
  3. package/dist/components/data-table-v9/column-helper.js +42 -0
  4. package/dist/components/data-table-v9/create-table.svelte.d.ts +42 -0
  5. package/dist/components/data-table-v9/create-table.svelte.js +248 -0
  6. package/dist/components/data-table-v9/data-table-cell-content.svelte +66 -0
  7. package/dist/components/data-table-v9/data-table-cell-content.svelte.d.ts +28 -0
  8. package/dist/components/data-table-v9/data-table-foot.svelte +111 -0
  9. package/dist/components/data-table-v9/data-table-foot.svelte.d.ts +32 -0
  10. package/dist/components/{data-table/data-table-head.svelte.md → data-table-v9/data-table-head.svelte} +47 -39
  11. package/dist/components/data-table-v9/data-table-head.svelte.d.ts +32 -0
  12. package/dist/components/data-table-v9/data-table-title.svelte.d.ts +10 -0
  13. package/dist/components/data-table-v9/data-table-utils.d.ts +53 -0
  14. package/dist/components/data-table-v9/data-table-utils.js +181 -0
  15. package/dist/components/data-table-v9/data-table.svelte +151 -0
  16. package/dist/components/data-table-v9/data-table.svelte.d.ts +41 -0
  17. package/dist/components/data-table-v9/features.d.ts +12 -0
  18. package/dist/components/data-table-v9/features.js +14 -0
  19. package/dist/components/data-table-v9/index.d.ts +11 -0
  20. package/dist/components/data-table-v9/index.js +9 -0
  21. package/dist/components/data-table-v9/table-view-state.svelte.d.ts +74 -0
  22. package/dist/components/data-table-v9/table-view-state.svelte.js +182 -0
  23. package/dist/components/data-table-v9/toolbar/data-table-column-filter.svelte +380 -0
  24. package/dist/components/data-table-v9/toolbar/data-table-column-filter.svelte.d.ts +29 -0
  25. package/dist/components/data-table-v9/toolbar/data-table-column-visibility.svelte +73 -0
  26. package/dist/components/data-table-v9/toolbar/data-table-column-visibility.svelte.d.ts +29 -0
  27. package/dist/components/data-table-v9/toolbar/data-table-search.svelte +58 -0
  28. package/dist/components/data-table-v9/toolbar/data-table-search.svelte.d.ts +32 -0
  29. package/dist/components/{data-table/data-table-toolbar.svelte.md → data-table-v9/toolbar/data-table-toolbar.svelte} +14 -15
  30. package/dist/components/data-table-v9/toolbar/data-table-toolbar.svelte.d.ts +12 -0
  31. package/dist/components/data-table-v9/types.d.ts +74 -0
  32. package/dist/components/data-table-v9/types.js +1 -0
  33. package/dist/components/data-table-v9/virtual/data-table-virtual-rows.svelte +131 -0
  34. package/dist/components/data-table-v9/virtual/data-table-virtual-rows.svelte.d.ts +40 -0
  35. package/dist/components/data-table-v9/virtual/data-table-virtualized.svelte +79 -0
  36. package/dist/components/data-table-v9/virtual/data-table-virtualized.svelte.d.ts +41 -0
  37. package/dist/components/data-table-v9/virtual/index.d.ts +3 -0
  38. package/dist/components/data-table-v9/virtual/index.js +2 -0
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.js +4 -0
  41. package/package.json +12 -2
  42. package/dist/components/data-table/column-helper.ts.md +0 -96
  43. package/dist/components/data-table/create-table.ts.md +0 -386
  44. package/dist/components/data-table/data-table-column-filter.svelte.md +0 -249
  45. package/dist/components/data-table/data-table-column-visibility.svelte.md +0 -74
  46. package/dist/components/data-table/data-table-new.svelte.md +0 -245
  47. package/dist/components/data-table/data-table-utils.ts.md +0 -179
  48. package/dist/components/data-table/data-table-virtual-rows.svelte.md +0 -171
  49. package/dist/components/data-table/data-table-virtualized.svelte.md +0 -108
  50. package/dist/components/data-table/data-table.svelte.md +0 -214
  51. package/dist/components/data-table/index.ts.md +0 -22
  52. package/dist/components/data-table/types.ts.md +0 -101
  53. package/dist/components/data-table/virtual/index.ts.md +0 -26
  54. /package/dist/components/{data-table/data-table-title.svelte.md → data-table-v9/data-table-title.svelte} +0 -0
package/dist/index.js CHANGED
@@ -17,6 +17,10 @@ export { default as DateInput } from './components/date-input/date-input.svelte'
17
17
  export { default as DatePicker } from './components/date-picker/date-picker.svelte';
18
18
  export * as Dialog from './components/dialog';
19
19
  export { default as AlertDialog } from './components/dialog/alert-dialog.svelte';
20
+ export * as DataTable from './components/data-table-v9';
21
+ export * as VirtualDataTable from './components/data-table-v9/virtual';
22
+ export * as DataTableV8 from './components/data-table-v8';
23
+ export * as VirtualDataTableV8 from './components/data-table-v8/virtual';
20
24
  export * as Drawer from './components/drawer';
21
25
  export { default as FileUploadDropzone } from './components/file-upload/file-upload-dropzone.svelte';
22
26
  export { default as FileUpload } from './components/file-upload/file-upload.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.55.3",
3
+ "version": "0.56.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",
@@ -33,16 +33,25 @@
33
33
  "svelte": "./dist/index.js"
34
34
  },
35
35
  "./data-table": {
36
+ "types": "./dist/components/data-table-v9/index.d.ts",
37
+ "svelte": "./dist/components/data-table-v9/index.js"
38
+ },
39
+ "./data-table/virtual": {
40
+ "types": "./dist/components/data-table-v9/virtual/index.d.ts",
41
+ "svelte": "./dist/components/data-table-v9/virtual/index.js"
42
+ },
43
+ "./data-table-v8": {
36
44
  "types": "./dist/components/data-table-v8/index.d.ts",
37
45
  "svelte": "./dist/components/data-table-v8/index.js"
38
46
  },
39
- "./data-table/virtual": {
47
+ "./data-table-v8/virtual": {
40
48
  "types": "./dist/components/data-table-v8/virtual/index.d.ts",
41
49
  "svelte": "./dist/components/data-table-v8/virtual/index.js"
42
50
  },
43
51
  "./theme.css": "./dist/theme.css"
44
52
  },
45
53
  "peerDependencies": {
54
+ "@tanstack/svelte-table": ">=9.0.0-beta.6 <10",
46
55
  "@tanstack/table-core": ">=8.0.0",
47
56
  "@tanstack/svelte-virtual": ">=3.0.0",
48
57
  "svelte": "^5.0.0"
@@ -65,6 +74,7 @@
65
74
  "@sveltejs/package": "^2.5.8",
66
75
  "@sveltejs/vite-plugin-svelte": "7.1.2",
67
76
  "@tailwindcss/vite": "^4.2.4",
77
+ "@tanstack/svelte-table": "9.0.0-beta.6",
68
78
  "@tanstack/svelte-virtual": "^3.13.28",
69
79
  "@tanstack/table-core": "^8.21.3",
70
80
  "@types/node": "^22.19.18",
@@ -1,96 +0,0 @@
1
- import type { RowData } from '@tanstack/svelte-table';
2
- import type {
3
- DataTableAccessorFnColumn,
4
- DataTableAccessorKeyColumn,
5
- DataTableColumn,
6
- DataTableGroupColumn
7
- } from './types';
8
-
9
- type AccessorKeyColumnOptions<T extends RowData> = Omit<
10
- DataTableAccessorKeyColumn<T>,
11
- 'accessorKey' | 'accessorFn' | 'columns'
12
-
13
- > ;
14
-
15
- type AccessorFnColumnOptions<T extends RowData> = Omit<
16
- DataTableAccessorFnColumn<T>,
17
- 'accessorFn' | 'accessorKey' | 'columns'
18
-
19
- > ;
20
-
21
- type GroupColumnOptions<T extends RowData> = Omit<
22
- DataTableGroupColumn<T>,
23
- | 'columns'
24
- | 'accessorKey'
25
- | 'accessorFn'
26
- | 'cell'
27
- | 'cellComponent'
28
- | 'cellProps'
29
- | 'cellSnippet'
30
- | 'type'
31
- | 'formatOptions'
32
- | 'formatLocale'
33
-
34
- > ;
35
-
36
- type TypeDefaults = { align?: string; size?: number; enableSorting?: boolean };
37
-
38
- const TYPE_DEFAULTS: Partial<Record<string, TypeDefaults>> = {
39
- number: { align: 'right' },
40
- currency: { align: 'right' },
41
- percent: { align: 'right' },
42
- date: { align: 'center', size: 110 },
43
- time: { align: 'center', size: 80 },
44
- 'date-time': { align: 'center', size: 160 },
45
- boolean: { align: 'center', size: 90 },
46
- url: { align: 'center', size: 60, enableSorting: false }
47
- };
48
-
49
- function applyTypeDefaults<T extends { type?: string; align?: string; enableSorting?: boolean }>(
50
- options: T
51
- ): T {
52
- const defaults = options.type ? TYPE_DEFAULTS[options.type] : undefined;
53
- if (!defaults) return options;
54
- return { ...defaults, ...options };
55
- }
56
-
57
- export function createDataTableColumnHelper<T extends RowData>() {
58
- return {
59
- accessor<K extends Extract<keyof T, string>>(
60
- accessorKey: K,
61
- options: AccessorKeyColumnOptions<T>
62
- ): DataTableAccessorKeyColumn<T> {
63
- return {
64
- ...applyTypeDefaults(options),
65
- accessorKey
66
- };
67
- },
68
-
69
- accessorFn(
70
- accessorFn: (row: T) => unknown,
71
- options: AccessorFnColumnOptions<T>
72
- ): DataTableAccessorFnColumn<T> {
73
- return {
74
- ...applyTypeDefaults(options),
75
- accessorFn
76
- };
77
- },
78
-
79
- group(
80
- header: string,
81
- columns: DataTableColumn<T>[],
82
- options: Omit<GroupColumnOptions<T>, 'header'> = {}
83
- ): DataTableGroupColumn<T> {
84
- return {
85
- ...options,
86
- header,
87
- columns
88
- };
89
- },
90
-
91
- columns(columns: DataTableColumn<T>[]): DataTableColumn<T>[] {
92
- return columns;
93
- }
94
- };
95
-
96
- }
@@ -1,386 +0,0 @@
1
- import {
2
- columnVisibilityFeature,
3
- columnResizingFeature,
4
- columnSizingFeature,
5
- columnFilteringFeature,
6
- columnFacetingFeature,
7
- columnPinningFeature,
8
- columnOrderingFeature,
9
- createSortedRowModel,
10
- createFilteredRowModel,
11
- // createFacetedRowModel,
12
- // createFacetedMinMaxValues,
13
- // createFacetedUniqueValues,
14
- createTable as createTanStackTable,
15
- filterFns,
16
- renderComponent,
17
- renderSnippet,
18
- rowSelectionFeature,
19
- rowSortingFeature,
20
- sortFns,
21
- tableFeatures,
22
- type CellContext,
23
- type CellData,
24
- type ColumnDef,
25
- type ColumnPinningState,
26
- type ColumnResizeMode,
27
- type ColumnSizingState,
28
- type ColumnVisibilityState,
29
- type Row,
30
- type RowData,
31
- type SvelteTable,
32
- type TableState
33
- } from '@tanstack/svelte-table';
34
- import { createAtom } from '@tanstack/svelte-store';
35
- import type { Component } from 'svelte';
36
- import { useLocaleContext } from '@ark-ui/svelte/locale';
37
- import type {
38
- DataTableColumn,
39
- DataTableColumnType,
40
- DataTableGroupColumn,
41
- DataTableLeafColumn
42
- } from './types';
43
-
44
- const dataTableFeatures = tableFeatures({
45
- columnVisibilityFeature,
46
- columnSizingFeature,
47
- columnResizingFeature,
48
- columnFilteringFeature,
49
- columnFacetingFeature,
50
- columnPinningFeature,
51
- columnOrderingFeature,
52
- rowSelectionFeature,
53
- rowSortingFeature
54
- });
55
-
56
- export type DataTableFeatures = typeof dataTableFeatures;
57
- export type DataTableSelectedState = Pick<
58
- TableState<DataTableFeatures>,
59
- | 'columnVisibility'
60
- | 'columnSizing'
61
- | 'columnResizing'
62
- | 'rowSelection'
63
- | 'sorting'
64
- | 'columnFilters'
65
-
66
- > ;
67
-
68
- function oneOfFilterFn(
69
- row: Row<DataTableFeatures, RowData>,
70
- columnId: string,
71
- filterValue: string[]
72
- ): boolean {
73
- return filterValue.includes(String(row.getValue(columnId)));
74
- }
75
- oneOfFilterFn.autoRemove = (val: unknown): boolean => !Array.isArray(val) || val.length === 0;
76
- export type DataTableInstance<T extends RowData> = SvelteTable<
77
- DataTableFeatures,
78
- T,
79
- DataTableSelectedState
80
-
81
- > ;
82
-
83
- export type CreateDataTableOptions<T extends RowData> = {
84
- data: T[];
85
- columns: DataTableColumn<T>[];
86
- columnResizeMode?: ColumnResizeMode;
87
- initialState?: Partial<TableState<DataTableFeatures>>;
88
- getRowId?: (row: T, index: number, parent?: Row<DataTableFeatures, T>) => string;
89
- enableRowSelection?: boolean | ((row: Row<DataTableFeatures, T>) => boolean);
90
- enableMultiRowSelection?: boolean | ((row: Row<DataTableFeatures, T>) => boolean);
91
- enableSorting?: boolean;
92
- debugTable?: boolean;
93
- onColumnVisibilityChange?: (visibility: ColumnVisibilityState) => void;
94
- };
95
-
96
- export function createTable<T extends RowData>(options: CreateDataTableOptions<T>) {
97
- const localeCtx = useLocaleContext();
98
-
99
- const initialColumnVisibility = {
100
- ...createColumnVisibility(options.columns),
101
- ...options.initialState?.columnVisibility
102
- };
103
-
104
- const columnVisibilityAtom = options.onColumnVisibilityChange
105
- ? createAtom<ColumnVisibilityState>(initialColumnVisibility)
106
- : undefined;
107
-
108
- const table = createTanStackTable(
109
- {
110
- _features: dataTableFeatures,
111
- _rowModels: {
112
- sortedRowModel: createSortedRowModel(sortFns),
113
- filteredRowModel: createFilteredRowModel({ ...filterFns, oneOf: oneOfFilterFn })
114
- // facetedRowModel: createFacetedRowModel(),
115
- // facetedMinMaxValues: createFacetedMinMaxValues(),
116
- // facetedUniqueValues: createFacetedUniqueValues()
117
- },
118
- columnResizeMode: options.columnResizeMode,
119
- getRowId: options.getRowId,
120
- enableRowSelection: options.enableRowSelection ?? false,
121
- enableMultiRowSelection: options.enableMultiRowSelection,
122
- enableSorting: options.enableSorting,
123
- debugTable: options.debugTable,
124
- get data() {
125
- return options.data;
126
- },
127
- columns: createColumns(options.columns, localeCtx),
128
- ...(columnVisibilityAtom ? { atoms: { columnVisibility: columnVisibilityAtom } } : {}),
129
- initialState: {
130
- ...options.initialState,
131
- columnVisibility: initialColumnVisibility,
132
- columnSizing: {
133
- ...createColumnSizing(options.columns),
134
- ...options.initialState?.columnSizing
135
- },
136
- columnPinning: options.initialState?.columnPinning ?? createColumnPinning(options.columns),
137
- rowSelection: options.initialState?.rowSelection ?? {},
138
- sorting: options.initialState?.sorting ?? [],
139
- columnFilters: options.initialState?.columnFilters ?? []
140
- }
141
- },
142
- (state): DataTableSelectedState => ({
143
- columnVisibility: state.columnVisibility,
144
- columnSizing: state.columnSizing,
145
- columnResizing: state.columnResizing,
146
- rowSelection: state.rowSelection,
147
- sorting: state.sorting,
148
- columnFilters: state.columnFilters
149
- })
150
- );
151
-
152
- if (columnVisibilityAtom && options.onColumnVisibilityChange) {
153
- const { onColumnVisibilityChange } = options;
154
- let initialized = false;
155
- columnVisibilityAtom.subscribe((value) => {
156
- if (!initialized) {
157
- initialized = true;
158
- return;
159
- }
160
- onColumnVisibilityChange(value);
161
- });
162
- }
163
-
164
- return table;
165
-
166
- }
167
-
168
- function createColumnVisibility<T extends RowData>(columns: DataTableColumn<T>[]) {
169
- return getLeafColumns(columns).reduce<ColumnVisibilityState>((visibility, column) => {
170
- visibility[getColumnId(column)] = true;
171
- return visibility;
172
- }, {});
173
- }
174
-
175
- function createColumnSizing<T extends RowData>(columns: DataTableColumn<T>[]) {
176
- return getLeafColumns(columns).reduce<ColumnSizingState>((sizes, column) => {
177
- if (typeof column.size === 'number') {
178
- sizes[getColumnId(column)] = column.size;
179
- }
180
-
181
- return sizes;
182
- }, {});
183
-
184
- }
185
-
186
- function createColumnPinning<T extends RowData>(columns: DataTableColumn<T>[]): ColumnPinningState {
187
- const leafCols = getLeafColumns(columns);
188
- return {
189
- left: leafCols.filter((c) => c.pinned === 'left').map(getColumnId),
190
- right: leafCols.filter((c) => c.pinned === 'right').map(getColumnId)
191
- };
192
- }
193
-
194
- function createColumns<T extends RowData>(
195
- columns: DataTableColumn<T>[],
196
- localeCtx: ReturnType<typeof useLocaleContext>
197
- ): ColumnDef<DataTableFeatures, T, CellData>[] {
198
- return columns.map((column) => {
199
- if (isGroupColumn(column)) {
200
- return {
201
- id: getGroupColumnId(column),
202
- header: column.header,
203
- columns: createColumns(column.columns, localeCtx),
204
- meta: {
205
- align: column.align
206
- }
207
- };
208
- }
209
-
210
- const columnId = getColumnId(column);
211
- const derivedFilterFn = column.filterFn ?? getFilterFnForType(column.type);
212
- const columnDef = {
213
- id: columnId,
214
- header: column.header,
215
- size: column.size,
216
- minSize: column.minSize,
217
- maxSize: column.maxSize,
218
- enableResizing: column.enableResizing,
219
- enableHiding: getColumnEnableHiding(column, columnId),
220
- enableSorting: column.enableSorting,
221
- enableColumnFilter: column.enableColumnFilter,
222
- sortDescFirst: column.sortDescFirst,
223
- ...(derivedFilterFn !== undefined ? { filterFn: derivedFilterFn as never } : {}),
224
- meta: {
225
- align: column.align,
226
- type: column.type,
227
- formatOptions: column.formatOptions,
228
- formatLocale: column.formatLocale,
229
- grow: column.grow
230
- }
231
- } satisfies Partial<ColumnDef<DataTableFeatures, T, CellData>>;
232
-
233
- if (typeof column.accessorFn === 'function') {
234
- return {
235
- ...columnDef,
236
- accessorFn: column.accessorFn,
237
- cell: (context: CellContext<DataTableFeatures, T, CellData>) =>
238
- formatCellValue(column, context.getValue(), context.row.original, localeCtx)
239
- };
240
- }
241
-
242
- return {
243
- ...columnDef,
244
- accessorKey: column.accessorKey,
245
- cell: (context: CellContext<DataTableFeatures, T, CellData>) =>
246
- formatCellValue(column, context.getValue(), context.row.original, localeCtx)
247
- };
248
- }) as ColumnDef<DataTableFeatures, T, CellData>[];
249
-
250
- }
251
-
252
- function isGroupColumn<T extends RowData>(
253
- column: DataTableColumn<T>
254
- ): column is DataTableGroupColumn<T> {
255
- return Array.isArray(column.columns);
256
- }
257
-
258
- function getLeafColumns<T extends RowData>(
259
- columns: DataTableColumn<T>[]
260
- ): DataTableLeafColumn<T>[] {
261
- return columns.flatMap((column) =>
262
- isGroupColumn(column) ? getLeafColumns(column.columns) : column
263
- );
264
- }
265
-
266
- function getGroupColumnId<T extends RowData>(column: DataTableGroupColumn<T>) {
267
- return column.id ?? column.header;
268
- }
269
-
270
- function getColumnEnableHiding<T extends RowData>(
271
- column: DataTableLeafColumn<T>,
272
- columnId: string
273
- ) {
274
- if (column.enableHiding !== undefined) return column.enableHiding;
275
- if (columnId === 'id') return false;
276
- return undefined;
277
- }
278
-
279
- export function getColumnId<T extends RowData>(column: DataTableLeafColumn<T>): string {
280
- if (column.id !== undefined) return column.id;
281
- if ('accessorKey' in column && column.accessorKey !== undefined) return column.accessorKey;
282
- throw new Error('DataTableColumn with accessorFn requires an id.');
283
- }
284
-
285
- const TYPE_FORMAT_DEFAULTS: Partial<Record<DataTableColumnType, Intl.NumberFormatOptions>> = {
286
- currency: { style: 'currency', currency: 'USD' },
287
- percent: { style: 'percent' },
288
- number: {}
289
- };
290
-
291
- const TYPE_DATE_FORMAT_DEFAULTS: Record<'date' | 'time' | 'date-time', Intl.DateTimeFormatOptions> =
292
- {
293
- date: { day: '2-digit', month: '2-digit', year: 'numeric' },
294
- time: { hour: '2-digit', minute: '2-digit' },
295
- 'date-time': {
296
- day: '2-digit',
297
- month: '2-digit',
298
- year: 'numeric',
299
- hour: '2-digit',
300
- minute: '2-digit'
301
- }
302
- };
303
-
304
- function getFilterFnForType(type: DataTableColumnType | undefined): string | undefined {
305
- switch (type) {
306
- case 'number':
307
- case 'currency':
308
- case 'percent':
309
- return 'inNumberRange';
310
- case 'boolean':
311
- return 'equals';
312
- case 'select':
313
- return 'oneOf';
314
- default:
315
- return undefined;
316
- }
317
- }
318
-
319
- function applyTypeFormat<T extends RowData>(
320
- column: DataTableLeafColumn<T>,
321
- value: unknown,
322
- localeCtx: ReturnType<typeof useLocaleContext>
323
- ): string | number | boolean | null | undefined {
324
- if (value === null || value === undefined || value === '') return undefined;
325
-
326
- const numDefaults = column.type ? TYPE_FORMAT_DEFAULTS[column.type] : undefined;
327
- if (numDefaults !== undefined) {
328
- const locale = column.formatLocale ?? localeCtx().locale;
329
- return new Intl.NumberFormat(locale, {
330
- ...numDefaults,
331
- ...(column.formatOptions as Intl.NumberFormatOptions | undefined)
332
- }).format(Number(value));
333
- }
334
-
335
- if (column.type === 'date' || column.type === 'time' || column.type === 'date-time') {
336
- const dateValue = value instanceof Date ? value : new Date(value as string | number);
337
- if (isNaN(dateValue.getTime())) return undefined;
338
- const locale = column.formatLocale ?? localeCtx().locale;
339
- return new Intl.DateTimeFormat(locale, {
340
- ...TYPE_DATE_FORMAT_DEFAULTS[column.type],
341
- ...(column.formatOptions as Intl.DateTimeFormatOptions | undefined)
342
- }).format(dateValue);
343
- }
344
-
345
- if (column.type === 'boolean') return value ? 'Yes' : 'No';
346
-
347
- return value as string | number | boolean;
348
-
349
- }
350
-
351
- function formatCellValue<T extends RowData>(
352
- column: DataTableLeafColumn<T>,
353
- value: unknown,
354
- row: T,
355
- localeCtx: ReturnType<typeof useLocaleContext>
356
- ) {
357
- if (column.cellComponent) {
358
- return renderComponent(
359
- column.cellComponent as Component<Record<string, unknown>>,
360
- getCellComponentProps(column, value, row)
361
- );
362
- }
363
-
364
- if (column.cellSnippet) {
365
- return renderSnippet(column.cellSnippet, { value, row });
366
- }
367
-
368
- const rendered = column.cell
369
- ? column.cell(value, row)
370
- : applyTypeFormat(column, value, localeCtx);
371
-
372
- if (rendered === null || rendered === undefined || rendered === '') {
373
- return '-';
374
- }
375
-
376
- return String(rendered);
377
-
378
- }
379
-
380
- function getCellComponentProps<T extends RowData>(
381
- column: DataTableLeafColumn<T>,
382
- value: unknown,
383
- row: T
384
- ) {
385
- return column.cellProps ? column.cellProps(value, row) : { value, row };
386
- }