mig-schema-table 3.0.91 → 3.0.93

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.
@@ -25,6 +25,7 @@ export interface ISchemaTableProps<T> {
25
25
  defaultSortColumn?: keyof T;
26
26
  disabledCheckedIndexes?: number[];
27
27
  enableAutoFocus?: boolean;
28
+ enableRowCounter?: boolean;
28
29
  getRowClassName?: (rowData: T, dataIndex: number, filteredSortedData: IRenderData[]) => string;
29
30
  getRowSelected?: (rowData: T, dataIndex: number) => boolean;
30
31
  isColumnFilterable?: boolean;
@@ -50,6 +51,6 @@ export interface IDateColumnFilterValue {
50
51
  filterEmpty?: true;
51
52
  }
52
53
  export type TColumnFilterValue = string | number | boolean | IDateColumnFilterValue;
53
- declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, getRowClassName, getRowSelected, isColumnFilterable, isExportable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight, schema, searchPlaceholder, style, translate, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
54
+ declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, enableRowCounter, getRowClassName, getRowSelected, isColumnFilterable, isExportable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight, schema, searchPlaceholder, style, translate, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
54
55
  declare const _default: typeof SchemaTable;
55
56
  export default _default;
@@ -46,7 +46,7 @@ function getIsColumnSortable(isTableSortable, propSchema, propConfig) {
46
46
  return !!(isTableSortable &&
47
47
  (propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
48
48
  }
49
- function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, getRowClassName, getRowSelected, isColumnFilterable = true, isExportable = true, isSearchable = true, isSortable = true, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight = 36, schema, searchPlaceholder, style, translate = defaultTranslate, useFilterStateHash, width, }) {
49
+ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus = true, enableRowCounter = true, getRowClassName, getRowSelected, isColumnFilterable = true, isExportable = true, isSearchable = true, isSortable = true, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight = 36, schema, searchPlaceholder, style, translate = defaultTranslate, useFilterStateHash, width, }) {
50
50
  const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
51
51
  const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
52
52
  const [thMenuConfig, setThMenuConfig] = React.useState();
@@ -532,12 +532,6 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
532
532
  thMenuConfig,
533
533
  useFilterStateHash,
534
534
  ]);
535
- const searchInputAutoFocus = React.useMemo(() => {
536
- if (enableAutoFocus === undefined) {
537
- return true;
538
- }
539
- return enableAutoFocus;
540
- }, [enableAutoFocus]);
541
535
  const onClearFiltersButtonClick = React.useCallback(() => {
542
536
  if (useFilterStateHash) {
543
537
  window.location.hash = "";
@@ -551,15 +545,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
551
545
  // prevent hash change for undefined vs empty string compare
552
546
  (searchQuery || locationHash.searchQuery) &&
553
547
  searchQuery !== locationHash.searchQuery) {
554
- const currentLocationHref = window.location.href;
555
- // use setTimeout() so any button clickhandler is still executed before the hash is changed
556
- setTimeout(() => {
557
- // Did we not move away? Apply search info to location.hash
558
- if (currentLocationHref === window.location.href) {
559
- window.location.hash = serializeLocationHash(Object.assign(Object.assign({}, locationHash), { searchQuery }));
560
- }
561
- // 1 is not enough?!
562
- }, 400);
548
+ window.location.hash = serializeLocationHash(Object.assign(Object.assign({}, locationHash), { searchQuery }));
563
549
  }
564
550
  }, [locationHash, searchQuery, useFilterStateHash]);
565
551
  const onExportDataClick = React.useCallback((e) => {
@@ -577,7 +563,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
577
563
  type: "text/csv;charset=utf-8",
578
564
  }), "export.csv");
579
565
  }, [sortedRenderData]);
580
- return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }), role: "table" }, { children: [_jsxs("div", Object.assign({ className: "schema-table__action-container" }, { children: [_jsx("div", { children: isSearchable ? (_jsx("input", { className: "schema-table__search", type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, onKeyDown: onInputKeyDown, autoFocus: searchInputAutoFocus, onBlur: onSearchBlur })) : null }), customElement || (_jsx("div", { className: "schema-table__custom_element_placeholder" })), isExportable ? (_jsx("button", Object.assign({ onClick: onExportDataClick, style: { marginLeft: 8 }, disabled: !(sortedRenderData === null || sortedRenderData === void 0 ? void 0 : sortedRenderData.length) }, { children: "Export data" }))) : null, isSearchable || isColumnFilterable ? (_jsx("button", Object.assign({ onClick: onClearFiltersButtonClick, style: { marginLeft: 8 }, disabled: Object.keys(columnFilterMap).length + searchQuery.length === 0 }, { children: "Clear filters" }))) : null] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: ConfiguredTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), sourceData && !isDirty ? (_jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: rowWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: rowCount }, { children: SchemaTableTd }), `tbody_${tableBodyHeight}_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)) : (_jsx("div", Object.assign({ style: {
566
+ return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }), role: "table" }, { children: [_jsxs("div", Object.assign({ className: "schema-table__action-container" }, { children: [_jsx("div", { children: isSearchable ? (_jsx("input", { className: "schema-table__search", type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, onKeyDown: onInputKeyDown, autoFocus: enableAutoFocus, onBlur: onSearchBlur })) : null }), customElement || (_jsx("div", { className: "schema-table__custom_element_placeholder" })), enableRowCounter ? (_jsx("span", Object.assign({ className: "schema-table__row_counter" }, { children: translate("showingFilteredCountOfTotalCount", (sortedRenderData === null || sortedRenderData === void 0 ? void 0 : sortedRenderData.length) || 0, data.length) }))) : null, isExportable ? (_jsx("button", Object.assign({ onClick: onExportDataClick, style: { marginLeft: 8 }, disabled: !(sortedRenderData === null || sortedRenderData === void 0 ? void 0 : sortedRenderData.length) }, { children: translate("exportData") }))) : null, isSearchable || isColumnFilterable ? (_jsx("button", Object.assign({ onClick: onClearFiltersButtonClick, style: { marginLeft: 8 }, disabled: Object.keys(columnFilterMap).length + searchQuery.length === 0 }, { children: translate("clearFilters") }))) : null] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: ConfiguredTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), sourceData && !isDirty ? (_jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: rowWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: rowCount }, { children: SchemaTableTd }), `tbody_${tableBodyHeight}_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)) : (_jsx("div", Object.assign({ style: {
581
567
  width: rowWidth,
582
568
  height: Math.max(50, tableBodyHeight),
583
569
  border: "1px solid #BBB",
@@ -20,6 +20,7 @@ const db = {
20
20
  "Europe/Berlin": "AMS",
21
21
  "Asia/Jakarta": "JKT",
22
22
  "Asia/Bangkok": "JKT",
23
+ showingFilteredCountOfTotalCount: "Showing {0} of {1}",
23
24
  };
24
25
  export function defaultTranslate(key, ...args) {
25
26
  let string = db[key] || uncamel(key);
package/dist/index.css CHANGED
@@ -44,6 +44,9 @@
44
44
  padding-bottom: 1rem;
45
45
  align-items: center;
46
46
  }
47
+ .schema-table__row_counter {
48
+ font-size: 0.835rem;
49
+ }
47
50
 
48
51
  .schema-table__th {
49
52
  background-color: #fcfcfc;
package/dist/types.d.ts CHANGED
@@ -18,9 +18,6 @@ export interface IColumnConfig<T> {
18
18
  sortByValue?: boolean;
19
19
  sortable?: boolean;
20
20
  title?: string | React.ReactElement;
21
- translation?: {
22
- [keyName: string]: string;
23
- };
24
21
  width?: number;
25
22
  }
26
23
  export interface IRenderData {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.91",
3
+ "version": "3.0.93",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"