@snack-uikit/table 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.22.0 (2024-08-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **DPS-0000:** add row value to renderDescription ([752d6f2](https://github.com/cloud-ru-tech/snack-uikit/commit/752d6f2399fb734e3ffd9b9c0c79b3c2b735960c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.21.1 (2024-08-21)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -156,7 +156,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
156
156
  | mapStatusToAppearance* | `MapStatusToAppearanceFnType` | - | Маппинг значений статуса на цвета |
157
157
  | accessorKey* | `string` | - | Имя ключа соответствующее полю в data |
158
158
  | enableSorting | `boolean` | true | Включение/выключение сортировки |
159
- | renderDescription | `(cellValue: string) => string` | - | Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса |
159
+ | renderDescription | `(cellValue: string, row: TData) => string` | - | Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса |
160
160
  | size | `number` | - | Размер ячейки |
161
161
  | minSize | `number` | - | |
162
162
  | maxSize | `number` | - | |
@@ -229,7 +229,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
229
229
  | mapStatusToAppearance* | `MapStatusToAppearanceFnType` | - | Маппинг значений статуса на цвета |
230
230
  | accessorKey* | `string` | - | Имя ключа соответствующее полю в data |
231
231
  | enableSorting | `boolean` | true | Включение/выключение сортировки |
232
- | renderDescription | `(cellValue: string) => string` | - | Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса |
232
+ | renderDescription | `(cellValue: string, row: TData) => string` | - | Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса |
233
233
  | size | `number` | - | Размер ячейки |
234
234
  | minSize | `number` | - | |
235
235
  | maxSize | `number` | - | |
@@ -22,7 +22,7 @@ type StatusColumnDef = BaseStatusColumnDef & {
22
22
  };
23
23
  type StatusColumnDefWithDescription<TData> = BaseStatusColumnDef & {
24
24
  /** Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса */
25
- renderDescription(cellValue: string): string;
25
+ renderDescription(cellValue: string, row: TData): string;
26
26
  /** Размер ячейки */
27
27
  size: number;
28
28
  minSize?: number;
@@ -30,7 +30,7 @@ export function getStatusColumnDef({ header, accessorKey, mapStatusToAppearance,
30
30
  enableResizing: enableResizing !== null && enableResizing !== void 0 ? enableResizing : hasDescription,
31
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
32
  accessorFn: (row) => renderDescription && Object.hasOwn(row, accessorKey)
33
- ? renderDescription(row[accessorKey])
33
+ ? renderDescription(row[accessorKey], row)
34
34
  : undefined,
35
35
  cell: cell => {
36
36
  const value = typeof cell.row.original === 'object' && Object.hasOwn(cell.row.original, accessorKey)
@@ -39,7 +39,7 @@ export function getStatusColumnDef({ header, accessorKey, mapStatusToAppearance,
39
39
  cell.row.original[accessorKey]
40
40
  : cell.getValue();
41
41
  const appearance = mapStatusToAppearance(value);
42
- return _jsx(StatusCell, { appearance: appearance, label: renderDescription ? renderDescription(value) : undefined });
42
+ return (_jsx(StatusCell, { appearance: appearance, label: renderDescription ? renderDescription(value, cell.row.original) : undefined }));
43
43
  },
44
44
  };
45
45
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.21.1",
7
+ "version": "0.22.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -57,5 +57,5 @@
57
57
  "peerDependencies": {
58
58
  "@snack-uikit/locale": "*"
59
59
  },
60
- "gitHead": "f28082de935a68b3cd19966d62b18ad6b98f4197"
60
+ "gitHead": "8ca2bb800b3ab6f9fa2f1e60719885520190cdf6"
61
61
  }
@@ -38,7 +38,7 @@ type StatusColumnDef = BaseStatusColumnDef & {
38
38
 
39
39
  type StatusColumnDefWithDescription<TData> = BaseStatusColumnDef & {
40
40
  /** Функция для отрисовки текста, если не передана, то будет отрисован только индикатор статуса */
41
- renderDescription(cellValue: string): string;
41
+ renderDescription(cellValue: string, row: TData): string;
42
42
  /** Размер ячейки */
43
43
  size: number;
44
44
  minSize?: number;
@@ -107,7 +107,7 @@ export function getStatusColumnDef<TData>({
107
107
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
108
  accessorFn: (row: any) =>
109
109
  renderDescription && Object.hasOwn(row as object, accessorKey)
110
- ? renderDescription(row[accessorKey] as string)
110
+ ? renderDescription(row[accessorKey] as string, row)
111
111
  : undefined,
112
112
  cell: cell => {
113
113
  const value =
@@ -119,7 +119,12 @@ export function getStatusColumnDef<TData>({
119
119
 
120
120
  const appearance = mapStatusToAppearance(value);
121
121
 
122
- return <StatusCell appearance={appearance} label={renderDescription ? renderDescription(value) : undefined} />;
122
+ return (
123
+ <StatusCell
124
+ appearance={appearance}
125
+ label={renderDescription ? renderDescription(value, cell.row.original) : undefined}
126
+ />
127
+ );
123
128
  },
124
129
  };
125
130
  }