mig-schema-table 3.0.71 → 3.0.72
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,6 +28,7 @@ export interface ISchemaTableProps<T> {
|
|
|
28
28
|
getRowClassName?: (rowData: T, dataIndex: number, filteredSortedData: IRenderData[]) => string;
|
|
29
29
|
getRowSelected?: (rowData: T, dataIndex: number) => boolean;
|
|
30
30
|
isColumnFilterable?: boolean;
|
|
31
|
+
isExportable?: boolean;
|
|
31
32
|
isSearchable?: boolean;
|
|
32
33
|
isSortable?: boolean;
|
|
33
34
|
maxHeight?: number;
|
|
@@ -47,6 +48,6 @@ export interface IDateColumnFilterValue {
|
|
|
47
48
|
filterEmpty?: true;
|
|
48
49
|
}
|
|
49
50
|
export type TColumnFilterValue = string | number | boolean | IDateColumnFilterValue;
|
|
50
|
-
declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, getRowClassName, getRowSelected, isColumnFilterable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, rowHeight, schema, searchPlaceholder, style, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, getRowClassName, getRowSelected, isColumnFilterable, isExportable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, rowHeight, schema, searchPlaceholder, style, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
51
52
|
declare const _default: typeof SchemaTable;
|
|
52
53
|
export default _default;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
import React from "react";
|
|
3
14
|
import { VariableSizeGrid, VariableSizeList } from "react-window";
|
|
@@ -9,6 +20,8 @@ import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
|
|
|
9
20
|
import { parseLocationHash, serializeLocationHash } from "../inc/data";
|
|
10
21
|
import SchemaTableTh, { EColumnFilterStatus } from "./SchemaTableTh";
|
|
11
22
|
import SchemaTableThMenu from "./SchemaTableThMenu";
|
|
23
|
+
import { saveAs } from "file-saver";
|
|
24
|
+
import { unparse } from "papaparse";
|
|
12
25
|
const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
|
|
13
26
|
function getSortByValue(propSchema, propConfig) {
|
|
14
27
|
var _a;
|
|
@@ -28,7 +41,7 @@ function getIsColumnSortable(isTableSortable, propSchema, propConfig) {
|
|
|
28
41
|
return !!(isTableSortable &&
|
|
29
42
|
(propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
|
|
30
43
|
}
|
|
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, }) {
|
|
44
|
+
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, rowHeight = 36, schema, searchPlaceholder, style, useFilterStateHash, width, }) {
|
|
32
45
|
const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
|
|
33
46
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
34
47
|
const [schemaTableThMenuConfig, setSchemaTableThMenuConfig] = React.useState();
|
|
@@ -530,7 +543,22 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
530
543
|
window.location.hash = serializeLocationHash(Object.assign(Object.assign({}, locationHash), { searchQuery }));
|
|
531
544
|
}
|
|
532
545
|
}, [locationHash, searchQuery, useFilterStateHash]);
|
|
533
|
-
|
|
546
|
+
const onExportDataClick = React.useCallback((e) => {
|
|
547
|
+
e.preventDefault();
|
|
548
|
+
e.stopPropagation();
|
|
549
|
+
if (!sortedRenderData) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
saveAs(new Blob([
|
|
553
|
+
unparse(sortedRenderData.map((row) => {
|
|
554
|
+
const { _index, SELECT_ALL_COLUMN_NAME } = row, data = __rest(row, ["_index", "SELECT_ALL_COLUMN_NAME"]);
|
|
555
|
+
return data;
|
|
556
|
+
})),
|
|
557
|
+
], {
|
|
558
|
+
type: "text/csv;charset=utf-8",
|
|
559
|
+
}), "export.csv");
|
|
560
|
+
}, [sortedRenderData]);
|
|
561
|
+
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", Object.assign({ style: { flex: 1 } }, { children: isSearchable ? (_jsx("input", { type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, onKeyDown: onInputKeyDown, autoFocus: searchInputAutoFocus, onBlur: onSearchBlur })) : null })), customElement, isExportable ? (_jsx("button", Object.assign({ onClick: onExportDataClick, 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: ConfiguredSchemaTableTh }), `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: {
|
|
534
562
|
width: rowWidth,
|
|
535
563
|
height: Math.max(50, tableBodyHeight),
|
|
536
564
|
border: "1px solid #BBB",
|
package/dist/inc/string.d.ts
CHANGED
package/dist/inc/string.js
CHANGED
|
@@ -15,11 +15,16 @@ export function uncamel(camel) {
|
|
|
15
15
|
return ` ${nextIsUppercase ? letter : letter.toLowerCase()}`;
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const db = {
|
|
19
19
|
"Europe/Amsterdam": "AMS",
|
|
20
20
|
"Europe/Berlin": "AMS",
|
|
21
21
|
"Asia/Jakarta": "JKT",
|
|
22
22
|
"Asia/Bangkok": "JKT",
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
};
|
|
24
|
+
export function t(key, ...args) {
|
|
25
|
+
let string = db[key] || uncamel(key);
|
|
26
|
+
args.forEach((arg, index) => {
|
|
27
|
+
string = string.replace(`{${index}}`, arg);
|
|
28
|
+
});
|
|
29
|
+
return string;
|
|
25
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mig-schema-table",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.72",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/"
|
|
@@ -8,15 +8,19 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"private": false,
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@types/file-saver": "^2.0.7",
|
|
11
12
|
"@types/jest": "^27.5.2",
|
|
12
13
|
"@types/node": "^16.18.31",
|
|
14
|
+
"@types/papaparse": "^5.3.14",
|
|
13
15
|
"@types/react": "^18.2.6",
|
|
14
16
|
"@types/react-datepicker": "^4.11.2",
|
|
15
17
|
"@types/react-dom": "^18.2.4",
|
|
16
18
|
"date-fns": "^2.30.0",
|
|
17
19
|
"date-fns-tz": "^2.0.0",
|
|
20
|
+
"file-saver": "^2.0.5",
|
|
18
21
|
"lodash": "^4.17.21",
|
|
19
22
|
"openapi3-ts": "^4.1.2",
|
|
23
|
+
"papaparse": "^5.4.1",
|
|
20
24
|
"react": "^18.2.0",
|
|
21
25
|
"react-datepicker": "^4.14.0",
|
|
22
26
|
"react-dom": "^18.2.0",
|