@trackunit/react-table-helpers 1.3.145 → 1.3.148
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/index.cjs.js +6 -2
- package/index.esm.js +6 -2
- package/package.json +10 -8
- package/src/useColumnDefinitionsFromCustomFieldDefinition/useColumnDefinitionsFromCustomFieldDefinition.d.ts +3 -1
- /package/src/useColumnDefinitionsFromCustomFieldDefinition/{customFiledToTableCell.d.ts → customFieldToCell.d.ts} +0 -0
package/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
5
5
|
var customFieldComponents = require('@trackunit/custom-field-components');
|
|
6
|
+
var filtersGraphqlHook = require('@trackunit/filters-graphql-hook');
|
|
6
7
|
var reactTable = require('@trackunit/react-table');
|
|
7
8
|
var react = require('react');
|
|
8
9
|
var polyfill = require('@js-temporal/polyfill');
|
|
@@ -101,7 +102,7 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
101
102
|
* @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
|
|
102
103
|
* @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
|
|
103
104
|
*/
|
|
104
|
-
const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, unitPreference, language, }) => {
|
|
105
|
+
const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, unitPreference, language, filterBarDefinition, }) => {
|
|
105
106
|
const { unitTranslation } = customFieldComponents.useUnitTranslation();
|
|
106
107
|
return react.useMemo(() => {
|
|
107
108
|
const columnHelper = reactTable.createColumnHelper();
|
|
@@ -111,6 +112,8 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
111
112
|
customFieldDefinition.node.id &&
|
|
112
113
|
customFieldDefinition.node.title &&
|
|
113
114
|
customFieldDefinition.node.__typename) {
|
|
115
|
+
const id = filtersGraphqlHook.CustomFieldPrefix + customFieldDefinition.node.id;
|
|
116
|
+
const isKeyFound = filterBarDefinition ? !!filterBarDefinition[id] : false;
|
|
114
117
|
const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
|
|
115
118
|
return field?.node?.definition.id === customFieldDefinition.node?.id;
|
|
116
119
|
})?.node, {
|
|
@@ -120,6 +123,7 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
120
123
|
meta: {
|
|
121
124
|
hiddenByDefault: true,
|
|
122
125
|
isCustomField: true,
|
|
126
|
+
filterName: isKeyFound && filterBarDefinition ? filterBarDefinition[id]?.filterKey : undefined,
|
|
123
127
|
},
|
|
124
128
|
cell: cell => {
|
|
125
129
|
const cellValue = cell.getValue();
|
|
@@ -130,7 +134,7 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
130
134
|
}
|
|
131
135
|
});
|
|
132
136
|
return result;
|
|
133
|
-
}, [
|
|
137
|
+
}, [filterBarDefinition, customFieldDefinitions, unitTranslation, unitPreference, language]);
|
|
134
138
|
};
|
|
135
139
|
|
|
136
140
|
/*
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { useUnitTranslation } from '@trackunit/custom-field-components';
|
|
4
|
+
import { CustomFieldPrefix } from '@trackunit/filters-graphql-hook';
|
|
4
5
|
import { createColumnHelper } from '@trackunit/react-table';
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
import { Temporal } from '@js-temporal/polyfill';
|
|
@@ -99,7 +100,7 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
99
100
|
* @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
|
|
100
101
|
* @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
|
|
101
102
|
*/
|
|
102
|
-
const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, unitPreference, language, }) => {
|
|
103
|
+
const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, unitPreference, language, filterBarDefinition, }) => {
|
|
103
104
|
const { unitTranslation } = useUnitTranslation();
|
|
104
105
|
return useMemo(() => {
|
|
105
106
|
const columnHelper = createColumnHelper();
|
|
@@ -109,6 +110,8 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
109
110
|
customFieldDefinition.node.id &&
|
|
110
111
|
customFieldDefinition.node.title &&
|
|
111
112
|
customFieldDefinition.node.__typename) {
|
|
113
|
+
const id = CustomFieldPrefix + customFieldDefinition.node.id;
|
|
114
|
+
const isKeyFound = filterBarDefinition ? !!filterBarDefinition[id] : false;
|
|
112
115
|
const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
|
|
113
116
|
return field?.node?.definition.id === customFieldDefinition.node?.id;
|
|
114
117
|
})?.node, {
|
|
@@ -118,6 +121,7 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
118
121
|
meta: {
|
|
119
122
|
hiddenByDefault: true,
|
|
120
123
|
isCustomField: true,
|
|
124
|
+
filterName: isKeyFound && filterBarDefinition ? filterBarDefinition[id]?.filterKey : undefined,
|
|
121
125
|
},
|
|
122
126
|
cell: cell => {
|
|
123
127
|
const cellValue = cell.getValue();
|
|
@@ -128,7 +132,7 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
128
132
|
}
|
|
129
133
|
});
|
|
130
134
|
return result;
|
|
131
|
-
}, [
|
|
135
|
+
}, [filterBarDefinition, customFieldDefinitions, unitTranslation, unitPreference, language]);
|
|
132
136
|
};
|
|
133
137
|
|
|
134
138
|
/*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-helpers",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.148",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
11
|
"@js-temporal/polyfill": "^0.4.4",
|
|
12
|
-
"@trackunit/
|
|
13
|
-
"@trackunit/
|
|
14
|
-
"@trackunit/
|
|
15
|
-
"@trackunit/
|
|
16
|
-
"@trackunit/
|
|
17
|
-
"@trackunit/
|
|
18
|
-
"@trackunit/react-table": "1.3.
|
|
12
|
+
"@trackunit/filters-filter-bar": "1.3.154",
|
|
13
|
+
"@trackunit/filters-graphql-hook": "1.5.29",
|
|
14
|
+
"@trackunit/i18n-library-translation": "1.3.108",
|
|
15
|
+
"@trackunit/custom-field-components": "1.3.143",
|
|
16
|
+
"@trackunit/iris-app-runtime-core": "1.4.103",
|
|
17
|
+
"@trackunit/react-core-contexts-api": "1.4.101",
|
|
18
|
+
"@trackunit/react-table-base-components": "1.3.133",
|
|
19
|
+
"@trackunit/iris-app-runtime-core-api": "1.3.103",
|
|
20
|
+
"@trackunit/react-table": "1.3.141"
|
|
19
21
|
},
|
|
20
22
|
"module": "./index.esm.js",
|
|
21
23
|
"main": "./index.cjs.js",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FilterBarDefinition } from "@trackunit/filters-filter-bar";
|
|
1
2
|
import { SystemOfMeasurementType } from "@trackunit/react-core-contexts-api";
|
|
2
3
|
import { ColumnDef } from "@trackunit/react-table";
|
|
3
4
|
import { CustomFieldData, CustomFieldDefinitionArray, DataWithCustomFields } from "./types";
|
|
@@ -5,6 +6,7 @@ export interface UseColumnDefinitionsFromCustomFieldDefinitionProps {
|
|
|
5
6
|
customFieldDefinitions?: CustomFieldDefinitionArray;
|
|
6
7
|
unitPreference: SystemOfMeasurementType | null | undefined;
|
|
7
8
|
language?: string;
|
|
9
|
+
filterBarDefinition?: FilterBarDefinition;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Generates an array of table column definitions based on custom field definitions.
|
|
@@ -13,4 +15,4 @@ export interface UseColumnDefinitionsFromCustomFieldDefinitionProps {
|
|
|
13
15
|
* @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
|
|
14
16
|
* @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
|
|
15
17
|
*/
|
|
16
|
-
export declare const useColumnDefinitionsFromCustomFieldDefinition: <TDataType extends DataWithCustomFields>({ customFieldDefinitions, unitPreference, language, }: UseColumnDefinitionsFromCustomFieldDefinitionProps) => ColumnDef<TDataType, CustomFieldData | undefined>[];
|
|
18
|
+
export declare const useColumnDefinitionsFromCustomFieldDefinition: <TDataType extends DataWithCustomFields>({ customFieldDefinitions, unitPreference, language, filterBarDefinition, }: UseColumnDefinitionsFromCustomFieldDefinitionProps) => ColumnDef<TDataType, CustomFieldData | undefined>[];
|
|
File without changes
|