@antscorp/antsomi-ui 1.3.5-beta.477 → 1.3.5-beta.478
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.
|
@@ -28,12 +28,12 @@ export const FilterItem = props => {
|
|
|
28
28
|
if (dayjs(value).isValid()) {
|
|
29
29
|
return dayjs(value).format(DATE_TIME_FORMAT.FILTER_CONDITION);
|
|
30
30
|
}
|
|
31
|
-
// Check value is an array
|
|
32
|
-
if (Array.isArray(value)
|
|
33
|
-
return value.map(item => item.title).join(', ');
|
|
31
|
+
// Check value is an array
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
return value.map(item => item.title || item).join(', ');
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
36
|
-
}, [
|
|
36
|
+
}, [value]);
|
|
37
37
|
const serializeOperator = useMemo(() => {
|
|
38
38
|
var _a;
|
|
39
39
|
const operatorLabel = ((_a = Object.values(OPERATORS_OPTION).find(({ value }) => value === operator)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
// Libraries
|
|
22
|
-
import React, { useCallback,
|
|
22
|
+
import React, { useCallback, useState } from 'react';
|
|
23
23
|
import { Link } from 'react-router-dom';
|
|
24
24
|
import { isEmpty, pick } from 'lodash';
|
|
25
25
|
import { useQueryClient } from '@tanstack/react-query';
|
|
@@ -92,12 +92,12 @@ export function useDataTableListing(props) {
|
|
|
92
92
|
? apiMatchesAny === null || apiMatchesAny === void 0 ? void 0 : apiMatchesAny[`${selectedFilterItem === null || selectedFilterItem === void 0 ? void 0 : selectedFilterItem.column}`.toLowerCase()]
|
|
93
93
|
: apiMatchesAny === null || apiMatchesAny === void 0 ? void 0 : apiMatchesAny.general;
|
|
94
94
|
// Memos
|
|
95
|
-
const mapObject =
|
|
95
|
+
const mapObject = useDeepCompareMemo(() => ({
|
|
96
96
|
objType: object === null || object === void 0 ? void 0 : object.type,
|
|
97
97
|
objId: object === null || object === void 0 ? void 0 : object.objectId,
|
|
98
98
|
}), [object === null || object === void 0 ? void 0 : object.objectId, object === null || object === void 0 ? void 0 : object.type]);
|
|
99
|
-
const localStorageKey =
|
|
100
|
-
const localStorageValues =
|
|
99
|
+
const localStorageKey = useDeepCompareMemo(() => `${TABLE_LISTING_PREFIX}${name}`, [name]);
|
|
100
|
+
const localStorageValues = useDeepCompareMemo(() => parseJSONFromLocalStorage(localStorageKey) || {}, [localStorageKey]);
|
|
101
101
|
// Queries
|
|
102
102
|
const getColumnMetrics = useGetColumnMetrics({
|
|
103
103
|
args: {
|
|
@@ -248,7 +248,7 @@ export function useDataTableListing(props) {
|
|
|
248
248
|
name: filterName,
|
|
249
249
|
removable: true,
|
|
250
250
|
}))) || []), [savedFiltersData]);
|
|
251
|
-
const tableColumns =
|
|
251
|
+
const tableColumns = useDeepCompareMemo(() => {
|
|
252
252
|
let data = [];
|
|
253
253
|
const { columns } = tableProps || {};
|
|
254
254
|
// Check if has column toggle then add toggle switch column
|
|
@@ -296,7 +296,7 @@ export function useDataTableListing(props) {
|
|
|
296
296
|
const { itemMapKeys, icon, link } = searchProps || {};
|
|
297
297
|
return ((searchListingBody === null || searchListingBody === void 0 ? void 0 : searchListingBody.map(searchItem => (Object.assign(Object.assign({}, Object.entries(itemMapKeys || {}).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: searchItem[value] })), {})), { icon: typeof icon === 'function' ? icon(searchItem) : icon, link: typeof link === 'function' ? link(searchItem) : link })))) || []);
|
|
298
298
|
}, [searchListingData, searchProps]);
|
|
299
|
-
const matchesAnyList =
|
|
299
|
+
const matchesAnyList = useDeepCompareMemo(() => {
|
|
300
300
|
/**
|
|
301
301
|
* If `selectedFilterItem` has a column, the function will attempt to find a matching property in the `matchesAny`
|
|
302
302
|
* object by converting the column name to lowercase. If such a property does not exist, it will default to using
|
|
@@ -160,7 +160,7 @@ export const renderValueField = ({ filterMetric, operator, value, matchesAny, on
|
|
|
160
160
|
case OPERATORS_CODE.MATCHES_ANY:
|
|
161
161
|
case OPERATORS_CODE.NOT_MATCHES: {
|
|
162
162
|
const { list, isLoading } = matchesAny || {};
|
|
163
|
-
return (React.createElement(MatchesAnySelect, { selectedItems: value, popupClassName: EXCEPTION_OFF_FILTER_CLASS, objectName: name, items: list, loading: isLoading, onChange: onChangeValue }));
|
|
163
|
+
return (React.createElement(MatchesAnySelect, { selectedItems: Array.isArray(value) ? value : [], popupClassName: EXCEPTION_OFF_FILTER_CLASS, objectName: name, items: list, loading: isLoading, onChange: onChangeValue }));
|
|
164
164
|
}
|
|
165
165
|
case OPERATORS_CODE.AFTER:
|
|
166
166
|
case OPERATORS_CODE.AFTER_DATE:
|
package/es/utils/common.js
CHANGED
|
@@ -449,7 +449,7 @@ export const removeAccent = (str) => {
|
|
|
449
449
|
return str;
|
|
450
450
|
};
|
|
451
451
|
/** Remove all accents and convert string to lower case, remove leading and trailing white space */
|
|
452
|
-
export const simplifyString = (str) => removeAccent(str
|
|
452
|
+
export const simplifyString = (str) => removeAccent(`${str || ''}`.toLowerCase().trim()) || '';
|
|
453
453
|
/**
|
|
454
454
|
* @param str target string
|
|
455
455
|
* @param queryStr search query
|