mig-schema-table 3.0.53 → 3.0.55

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.
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { SELECT_ALL_COLUMN_NAME } from "../constants";
4
4
  import { localeFormatInTimeZone, timeZone } from "../../inc/date";
5
- import { DEFAULT_DATE_TIME_FORMAT } from "../../inc/constant";
5
+ import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../inc/constant";
6
6
  import { t } from "../../inc/string";
7
7
  function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, onRowDoubleClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }) {
8
8
  const onTdClick = React.useCallback((e) => {
@@ -43,7 +43,9 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
43
43
  ? "Asia/Jakarta"
44
44
  : "Europe/Amsterdam";
45
45
  if (date) {
46
- title = `${localeFormatInTimeZone(date, alternativeTimeZone, DEFAULT_DATE_TIME_FORMAT)} (${t(alternativeTimeZone)})`;
46
+ title = `${localeFormatInTimeZone(date, alternativeTimeZone, propSchema.format === "date"
47
+ ? DEFAULT_DATE_FORMAT
48
+ : DEFAULT_DATE_TIME_FORMAT)} (${t(alternativeTimeZone)})`;
47
49
  }
48
50
  }
49
51
  return {
@@ -9,6 +9,9 @@ export interface IGetDataProps {
9
9
  sortColumn?: string;
10
10
  sortAsc: boolean;
11
11
  }
12
+ interface IColumnFilterMap {
13
+ [propName: string]: TColumnFilterValue;
14
+ }
12
15
  export interface ISchemaTableProps<T> {
13
16
  Heading?: any;
14
17
  checkedIndexes?: number[];
@@ -18,6 +21,7 @@ export interface ISchemaTableProps<T> {
18
21
  };
19
22
  customElement?: React.ReactNode;
20
23
  data: T[] | ((getDataProps: IGetDataProps) => Promise<T[]>);
24
+ defaultColumnFilters?: IColumnFilterMap;
21
25
  defaultSortAsc?: boolean;
22
26
  defaultSortColumn?: keyof T;
23
27
  getRowClassName?: (rowData: T, dataIndex: number, filteredSortedData: IRenderData[]) => string;
@@ -40,6 +44,6 @@ export type TColumnFilterValue = string | number | boolean | {
40
44
  from?: Date;
41
45
  to?: Date;
42
46
  };
43
- declare function SchemaTable<T>({ Heading, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
47
+ declare function SchemaTable<T>({ Heading, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
44
48
  declare const _default: typeof SchemaTable;
45
49
  export default _default;
@@ -9,11 +9,11 @@ import Td from "./Td";
9
9
  import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
10
10
  import SchemaColumnFilterPopover from "./SchemaColumnFilterPopover";
11
11
  const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
12
- function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }) {
12
+ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }) {
13
13
  const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
14
14
  const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
15
15
  const [searchQuery, setSearchQuery] = React.useState("");
16
- const [columnFilterMap, setColumnFilterMap] = React.useState({});
16
+ const [columnFilterMap, setColumnFilterMap] = React.useState(defaultColumnFilters);
17
17
  const [popoverConfig, setPopoverConfig] = React.useState();
18
18
  const isDataFunction = data instanceof Function;
19
19
  const [sourceData, setSourceData] = React.useState(isDataFunction ? undefined : data);
@@ -208,7 +208,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
208
208
  const propSchema = properties[propName];
209
209
  // @ts-ignore
210
210
  const rawValue = sourceData[item._index][propName];
211
- switch (propSchema.type) {
211
+ switch (propSchema === null || propSchema === void 0 ? void 0 : propSchema.type) {
212
212
  case "boolean":
213
213
  case "integer":
214
214
  result = rawValue === columnFilterValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.53",
3
+ "version": "3.0.55",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"