mig-schema-table 3.0.69 → 3.0.71

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.
@@ -24,6 +24,10 @@ function getSortByValue(propSchema, propConfig) {
24
24
  propSchema.type === "integer" ||
25
25
  !!(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell));
26
26
  }
27
+ function getIsColumnSortable(isTableSortable, propSchema, propConfig) {
28
+ return !!(isTableSortable &&
29
+ (propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
30
+ }
27
31
  function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, getRowClassName, getRowSelected, isColumnFilterable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, rowHeight = 36, schema, searchPlaceholder, style, useFilterStateHash, width, }) {
28
32
  const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
29
33
  const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
@@ -320,6 +324,12 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
320
324
  if (x === y) {
321
325
  return 0;
322
326
  }
327
+ if (!x) {
328
+ return sortAsc ? -1 : 1;
329
+ }
330
+ if (!y) {
331
+ return sortAsc ? 1 : -1;
332
+ }
323
333
  return (x < y ? 1 : -1) * (sortAsc ? -1 : 1);
324
334
  });
325
335
  }, [
@@ -381,11 +391,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
381
391
  if (columnFilterMap[propName] !== undefined) {
382
392
  columnFilterStatus = EColumnFilterStatus.ACTIVE;
383
393
  }
384
- const isColumnSortable = !!(isSortable &&
385
- (propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
386
394
  return (_jsx(SchemaTableTh, { columnFilterStatus: columnFilterStatus,
387
395
  // disableColumnFilter={disableColumnFilter}
388
- isAllChecked: isAllRowsChecked, isSortable: isColumnSortable, numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length, onSelectAllIndexesHandler: onSelectAllIndexesHandler, propConfig: propConfig, propIsRequired: required.includes(propName), propName: propName, schema: propSchema, setMenuConfig: setSchemaTableThMenuConfig, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style }));
396
+ isAllChecked: isAllRowsChecked, isSortable: getIsColumnSortable(!!isSortable, propSchema, propConfig), numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length, onSelectAllIndexesHandler: onSelectAllIndexesHandler, propConfig: propConfig, propIsRequired: required.includes(propName), propName: propName, schema: propSchema, setMenuConfig: setSchemaTableThMenuConfig, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style }));
389
397
  }, [
390
398
  checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
391
399
  columnFilterMap,
@@ -531,6 +539,6 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
531
539
  backgroundColor: "#CCC",
532
540
  alignItems: "center",
533
541
  justifyContent: "center",
534
- } }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), schemaTableThMenuConfig ? (_jsx(SchemaTableThMenu, { isFilterable: !!isColumnFilterable, isSortable: !!isSortable, onChange: onSchemaColumnFilterChange, onClose: onPopoverClose, onInputKeyDown: onInputKeyDown, propConfig: schemaTableThMenuConfig.propConfig, propIsRequired: schemaTableThMenuConfig.propIsRequired, propName: schemaTableThMenuConfig.propName, propSchema: schema.properties[schemaTableThMenuConfig.propName], referenceElement: schemaTableThMenuConfig.referenceElement, setSortAsc: setSortAsc, setSortColumn: setSortColumn, value: columnFilterMap[schemaTableThMenuConfig.propName] })) : null] })));
542
+ } }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), schemaTableThMenuConfig ? (_jsx(SchemaTableThMenu, { isFilterable: !!isColumnFilterable, isSortable: getIsColumnSortable(!!isSortable, schema.properties[schemaTableThMenuConfig.propName], schemaTableThMenuConfig.propConfig), onChange: onSchemaColumnFilterChange, onClose: onPopoverClose, onInputKeyDown: onInputKeyDown, propConfig: schemaTableThMenuConfig.propConfig, propIsRequired: schemaTableThMenuConfig.propIsRequired, propName: schemaTableThMenuConfig.propName, propSchema: schema.properties[schemaTableThMenuConfig.propName], referenceElement: schemaTableThMenuConfig.referenceElement, setSortAsc: setSortAsc, setSortColumn: setSortColumn, value: columnFilterMap[schemaTableThMenuConfig.propName] })) : null] })));
535
543
  }
536
544
  export default React.memo(SchemaTable);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.69",
3
+ "version": "3.0.71",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"