mig-schema-table 3.0.101 → 3.0.103
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/SchemaTable/index.js +14 -8
- package/dist/inc/data.d.ts +1 -1
- package/dist/inc/data.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -46,6 +46,7 @@ function getSortByValue(propSchema, propConfig) {
|
|
|
46
46
|
}
|
|
47
47
|
function getIsColumnSortable(isTableSortable, propSchema, propConfig) {
|
|
48
48
|
return !!(isTableSortable &&
|
|
49
|
+
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.isSortable) !== false &&
|
|
49
50
|
(propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
|
|
50
51
|
}
|
|
51
52
|
function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus = true, enableRowCounter = true, getRowClassName, getRowSelected, isColumnFilterable = true, isExportable = true, isResizable = true, isSearchable = true, isSortable = true, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight = 36, schema, searchPlaceholder, style, translate = defaultTranslate, useFilterStateHash, width, }) {
|
|
@@ -55,9 +56,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
55
56
|
const isDataFunction = data instanceof Function;
|
|
56
57
|
const [sourceData, setSourceData] = React.useState(isDataFunction ? undefined : data);
|
|
57
58
|
const [columnWidths, setColumnWidths] = React.useState();
|
|
58
|
-
const [locationHash, setLocationHash] = React.useState(useFilterStateHash ? parseLocationHash(window.location.hash) :
|
|
59
|
-
const [searchQuery, setSearchQuery] = React.useState(locationHash.searchQuery || "");
|
|
60
|
-
const [columnFilterMap, setColumnFilterMap] = React.useState(locationHash.columnFilterMap || defaultColumnFilters);
|
|
59
|
+
const [locationHash, setLocationHash] = React.useState(useFilterStateHash ? parseLocationHash(window.location.hash) : null);
|
|
60
|
+
const [searchQuery, setSearchQuery] = React.useState((locationHash === null || locationHash === void 0 ? void 0 : locationHash.searchQuery) || "");
|
|
61
|
+
const [columnFilterMap, setColumnFilterMap] = React.useState((locationHash === null || locationHash === void 0 ? void 0 : locationHash.columnFilterMap) || defaultColumnFilters);
|
|
61
62
|
const [isDirty, setIsDirty] = React.useState(false);
|
|
62
63
|
React.useEffect(() => {
|
|
63
64
|
if (isDataFunction) {
|
|
@@ -312,6 +313,10 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
312
313
|
// fall through
|
|
313
314
|
default:
|
|
314
315
|
// fallback by looking at the render value
|
|
316
|
+
if (propSchema === null || propSchema === void 0 ? void 0 : propSchema.enum) {
|
|
317
|
+
result = rawValue === columnFilterValue;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
315
320
|
result = `${item[propName]}`
|
|
316
321
|
.toLowerCase()
|
|
317
322
|
.includes(`${columnFilterValue}`.toLowerCase());
|
|
@@ -538,9 +543,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
538
543
|
if (!useFilterStateHash) {
|
|
539
544
|
return;
|
|
540
545
|
}
|
|
541
|
-
setColumnFilterMap(locationHash.columnFilterMap ||
|
|
542
|
-
setSearchQuery(locationHash.searchQuery || "");
|
|
543
|
-
}, [locationHash, useFilterStateHash]);
|
|
546
|
+
setColumnFilterMap((locationHash === null || locationHash === void 0 ? void 0 : locationHash.columnFilterMap) || defaultColumnFilters);
|
|
547
|
+
setSearchQuery((locationHash === null || locationHash === void 0 ? void 0 : locationHash.searchQuery) || "");
|
|
548
|
+
}, [locationHash, useFilterStateHash, defaultColumnFilters]);
|
|
544
549
|
const onSchemaColumnFilterChange = React.useCallback((newColumnFilterValue, persistState) => {
|
|
545
550
|
if (!thMenuConfig) {
|
|
546
551
|
return;
|
|
@@ -574,10 +579,11 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
574
579
|
setSearchQuery("");
|
|
575
580
|
}, [useFilterStateHash]);
|
|
576
581
|
const onSearchBlur = React.useCallback(() => {
|
|
582
|
+
const oldSearchQuery = (locationHash === null || locationHash === void 0 ? void 0 : locationHash.searchQuery) || "";
|
|
577
583
|
if (useFilterStateHash &&
|
|
578
584
|
// prevent hash change for undefined vs empty string compare
|
|
579
|
-
(searchQuery ||
|
|
580
|
-
searchQuery !==
|
|
585
|
+
(searchQuery || oldSearchQuery) &&
|
|
586
|
+
searchQuery !== oldSearchQuery) {
|
|
581
587
|
window.location.hash = serializeLocationHash(Object.assign(Object.assign({}, locationHash), { searchQuery }));
|
|
582
588
|
}
|
|
583
589
|
}, [locationHash, searchQuery, useFilterStateHash]);
|
package/dist/inc/data.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const parseLocationHash: <T extends {}>(search: string) => T;
|
|
1
|
+
export declare const parseLocationHash: <T extends {}>(search: string) => T | null;
|
|
2
2
|
export declare const serializeLocationHash: (params: {}) => string;
|
package/dist/inc/data.js
CHANGED
package/dist/types.d.ts
CHANGED