mig-schema-table 3.0.79 → 3.0.81
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/Td/index.d.ts +2 -1
- package/dist/SchemaTable/Td/index.js +4 -4
- package/dist/SchemaTable/Th/index.d.ts +2 -1
- package/dist/SchemaTable/Th/index.js +13 -7
- package/dist/SchemaTable/ThMenu/FilterMenuComponent/index.d.ts +2 -3
- package/dist/SchemaTable/ThMenu/FilterMenuComponent/index.js +3 -7
- package/dist/SchemaTable/ThMenu/index.d.ts +2 -1
- package/dist/SchemaTable/ThMenu/index.js +2 -2
- package/dist/SchemaTable/index.d.ts +2 -1
- package/dist/SchemaTable/index.js +11 -13
- package/dist/inc/string.d.ts +1 -1
- package/dist/inc/string.js +1 -1
- package/dist/index.css +8 -0
- package/package.json +1 -1
|
@@ -18,7 +18,8 @@ interface ITdProps<T> {
|
|
|
18
18
|
propSchema?: oas31.SchemaObject;
|
|
19
19
|
sortedRenderData?: IRenderData[];
|
|
20
20
|
style: React.CSSProperties;
|
|
21
|
+
translate: (key: string, ...args: Array<string | number>) => string;
|
|
21
22
|
}
|
|
22
|
-
declare function Td<T>({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, onRowDoubleClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }: ITdProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
declare function Td<T>({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, onRowDoubleClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, translate, }: ITdProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
23
24
|
declare const _default: typeof Td;
|
|
24
25
|
export default _default;
|
|
@@ -2,9 +2,8 @@ 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
|
|
6
|
-
|
|
7
|
-
function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, onRowDoubleClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }) {
|
|
5
|
+
import { DEFAULT_DATE_TIME_FORMAT } from "../../inc/constant";
|
|
6
|
+
function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, onRowDoubleClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, translate, }) {
|
|
8
7
|
const onTdClick = React.useCallback((e) => {
|
|
9
8
|
if (!sortedRenderData || !onRowClick) {
|
|
10
9
|
return;
|
|
@@ -43,7 +42,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
43
42
|
? "Asia/Jakarta"
|
|
44
43
|
: "Europe/Amsterdam";
|
|
45
44
|
if (date) {
|
|
46
|
-
title = `${localeFormatInTimeZone(date, alternativeTimeZone, DEFAULT_DATE_TIME_FORMAT)} (${
|
|
45
|
+
title = `${localeFormatInTimeZone(date, alternativeTimeZone, DEFAULT_DATE_TIME_FORMAT)} (${translate(alternativeTimeZone)})`;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
const classNames = [
|
|
@@ -82,6 +81,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
82
81
|
rowIndex,
|
|
83
82
|
sortedRenderData,
|
|
84
83
|
style,
|
|
84
|
+
translate,
|
|
85
85
|
]);
|
|
86
86
|
if (!row || !tdDivProps) {
|
|
87
87
|
return null;
|
|
@@ -22,6 +22,7 @@ interface IThProps {
|
|
|
22
22
|
setSortColumn: Dispatch<SetStateAction<string>>;
|
|
23
23
|
sortAsc?: boolean;
|
|
24
24
|
style: CSSProperties;
|
|
25
|
+
translate: (key: string, ...args: Array<string | number>) => string;
|
|
25
26
|
}
|
|
26
|
-
declare const _default: ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows, onSelectAllIndexesHandler, propConfig, propIsRequired, propName, schema, setMenuConfig, setSortAsc, setSortColumn, sortAsc, style, }: IThProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
declare const _default: ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows, onSelectAllIndexesHandler, propConfig, propIsRequired, propName, schema, setMenuConfig, setSortAsc, setSortColumn, sortAsc, style, translate, }: IThProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
export default _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { t, uncamel } from "../../inc/string";
|
|
4
3
|
import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
5
4
|
import { timeZone } from "../../inc/date";
|
|
6
5
|
export var EColumnFilterStatus;
|
|
@@ -9,7 +8,7 @@ export var EColumnFilterStatus;
|
|
|
9
8
|
EColumnFilterStatus["AVAILABLE"] = "AVAILABLE";
|
|
10
9
|
EColumnFilterStatus["ACTIVE"] = "ACTIVE";
|
|
11
10
|
})(EColumnFilterStatus || (EColumnFilterStatus = {}));
|
|
12
|
-
const Th = ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows, onSelectAllIndexesHandler, propConfig, propIsRequired, propName, schema, setMenuConfig, setSortAsc, setSortColumn, sortAsc, style, }) => {
|
|
11
|
+
const Th = ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows, onSelectAllIndexesHandler, propConfig, propIsRequired, propName, schema, setMenuConfig, setSortAsc, setSortColumn, sortAsc, style, translate, }) => {
|
|
13
12
|
const classNames = [
|
|
14
13
|
`schema-table__th`,
|
|
15
14
|
`schema-table__th--filter-${columnFilterStatus}`,
|
|
@@ -58,18 +57,25 @@ const Th = ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows
|
|
|
58
57
|
if ((schema === null || schema === void 0 ? void 0 : schema.format) &&
|
|
59
58
|
schema.format === "date-time" &&
|
|
60
59
|
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones) !== false) {
|
|
61
|
-
return `${
|
|
60
|
+
return `${translate(propName)} (${translate(timeZone)})`;
|
|
62
61
|
}
|
|
63
|
-
return
|
|
64
|
-
}, [
|
|
62
|
+
return translate(propName);
|
|
63
|
+
}, [
|
|
64
|
+
propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones,
|
|
65
|
+
propConfig === null || propConfig === void 0 ? void 0 : propConfig.title,
|
|
66
|
+
propName,
|
|
67
|
+
schema === null || schema === void 0 ? void 0 : schema.format,
|
|
68
|
+
translate,
|
|
69
|
+
]);
|
|
65
70
|
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
66
71
|
return (_jsx("div", Object.assign({ style: style, className: classNames.join(" ") }, { children: _jsx("div", Object.assign({ style: {
|
|
67
72
|
width: "100%",
|
|
68
73
|
textAlign: "center",
|
|
69
74
|
}, title: `${numberOfSelectedRows || 0} selected` }, { children: _jsx("input", { type: "checkbox", checked: isAllChecked, onChange: onSelectAllIndexesHandler }) })) })));
|
|
70
75
|
}
|
|
76
|
+
const title = typeof labelBody === "string" ? labelBody : undefined;
|
|
71
77
|
if (!schema && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell)) {
|
|
72
|
-
return _jsx("div", { style: style, className: classNames.join(" ") });
|
|
78
|
+
return _jsx("div", { style: style, className: classNames.join(" "), title: title });
|
|
73
79
|
}
|
|
74
80
|
switch (schema === null || schema === void 0 ? void 0 : schema.type) {
|
|
75
81
|
case "boolean":
|
|
@@ -84,6 +90,6 @@ const Th = ({ columnFilterStatus, isAllChecked, isSortable, numberOfSelectedRows
|
|
|
84
90
|
classNames.push(`text-${propConfig.align}`);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
|
-
return (_jsxs("div", Object.assign({ style: style, className: classNames.join(" ") }, { children: [_jsxs("div", Object.assign({ className: "schema-table__th__label-body", style: { lineHeight: "44px" }, onClick: onLabelClick }, { children: [_jsx("span", Object.assign({ className: "schema-table__th__label-body-text" }, { children: labelBody })), sortAsc === undefined ? null : (_jsx("span", Object.assign({ className: "schema-table__th__sort-icon" }, { children: sortAsc ? "↓" : "↑" })))] })), isSortable || columnFilterStatus !== EColumnFilterStatus.UNAVAILABLE ? (_jsx("button", Object.assign({ className: "schema-table__th__trigger-el", onClick: onTriggerClick }, { children: _jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#404040", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, { children: _jsx("polyline", { points: "6 9 12 15 18 9" }) })) }))) : null] })));
|
|
93
|
+
return (_jsxs("div", Object.assign({ style: style, className: classNames.join(" "), title: title }, { children: [_jsxs("div", Object.assign({ className: "schema-table__th__label-body", style: { lineHeight: "44px" }, onClick: onLabelClick }, { children: [_jsx("span", Object.assign({ className: "schema-table__th__label-body-text" }, { children: labelBody })), sortAsc === undefined ? null : (_jsx("span", Object.assign({ className: "schema-table__th__sort-icon" }, { children: sortAsc ? "↓" : "↑" })))] })), isSortable || columnFilterStatus !== EColumnFilterStatus.UNAVAILABLE ? (_jsx("button", Object.assign({ className: "schema-table__th__trigger-el", onClick: onTriggerClick }, { children: _jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#404040", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, { children: _jsx("polyline", { points: "6 9 12 15 18 9" }) })) }))) : null] })));
|
|
88
94
|
};
|
|
89
95
|
export default React.memo(Th);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { oas31 } from "openapi3-ts";
|
|
3
3
|
import { TColumnFilterValue } from "../../index";
|
|
4
|
-
import { IColumnConfig } from "../../../types";
|
|
5
4
|
export interface IFilterMenuComponentProps {
|
|
6
5
|
columnFilterValue: TColumnFilterValue;
|
|
7
6
|
onChange: (newValue: TColumnFilterValue | undefined, persistState: boolean) => void;
|
|
8
7
|
onInputKeyDown: (e: React.KeyboardEvent) => void;
|
|
9
|
-
propConfig?: IColumnConfig<any>;
|
|
10
8
|
propIsRequired: boolean;
|
|
11
9
|
propName: string;
|
|
12
10
|
propSchema?: oas31.SchemaObject;
|
|
11
|
+
translate: (key: string, ...args: Array<string | number>) => string;
|
|
13
12
|
}
|
|
14
|
-
declare const _default: React.MemoExoticComponent<({ columnFilterValue, onChange, onInputKeyDown,
|
|
13
|
+
declare const _default: React.MemoExoticComponent<({ columnFilterValue, onChange, onInputKeyDown, propIsRequired, propName, propSchema, translate, }: IFilterMenuComponentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
14
|
export default _default;
|
|
@@ -11,12 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import React from "react";
|
|
14
|
-
import { t } from "../../../inc/string";
|
|
15
14
|
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../../inc/constant";
|
|
16
15
|
import DatePicker from "react-datepicker";
|
|
17
16
|
import nl from "date-fns/locale/nl";
|
|
18
17
|
import { endOfDay } from "date-fns";
|
|
19
|
-
const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown,
|
|
18
|
+
const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, propIsRequired, propName, propSchema, translate, }) => {
|
|
20
19
|
const { type, format, minimum, maximum } = propSchema || {};
|
|
21
20
|
const value = columnFilterValue;
|
|
22
21
|
const isDateTime = format === "date-time";
|
|
@@ -53,11 +52,8 @@ const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
|
|
|
53
52
|
if (propSchema === null || propSchema === void 0 ? void 0 : propSchema.enum) {
|
|
54
53
|
return (_jsx("ol", Object.assign({ className: "schema-table-menu schema-table__th-menu__filter-menu-component" }, { children: _jsx("li", { children: _jsxs("select", Object.assign({ autoFocus: true, className: "form-select", value: value, "data-prop-name": propName, onChange: (e) => {
|
|
55
54
|
onChange(e.currentTarget.value || undefined, true);
|
|
56
|
-
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), propSchema.enum.map((
|
|
57
|
-
|
|
58
|
-
? name
|
|
59
|
-
: t(name, propConfig.translation);
|
|
60
|
-
return (_jsx("option", Object.assign({ value: rowName }, { children: rowName }), `column-filter-select-${rowName}`));
|
|
55
|
+
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), propSchema.enum.map((value) => {
|
|
56
|
+
return (_jsx("option", Object.assign({ value: value }, { children: translate(value) }), `column-filter-select-${value}`));
|
|
61
57
|
})] })) }) })));
|
|
62
58
|
}
|
|
63
59
|
if (isDateTime || format === "date") {
|
|
@@ -18,7 +18,8 @@ type TThMenuProps = IThMenuConfig & {
|
|
|
18
18
|
propSchema: oas31.SchemaObject;
|
|
19
19
|
setSortAsc: Dispatch<SetStateAction<boolean>>;
|
|
20
20
|
setSortColumn: Dispatch<SetStateAction<string>>;
|
|
21
|
+
translate: (key: string, ...args: Array<string | number>) => string;
|
|
21
22
|
value: TColumnFilterValue;
|
|
22
23
|
};
|
|
23
|
-
declare const _default: React.MemoExoticComponent<({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, value, }: TThMenuProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
24
|
+
declare const _default: React.MemoExoticComponent<({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, translate, value, }: TThMenuProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
24
25
|
export default _default;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import FilterMenuComponent from "./FilterMenuComponent";
|
|
4
4
|
import { usePopper } from "react-popper";
|
|
5
|
-
const ThMenu = ({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, value, }) => {
|
|
5
|
+
const ThMenu = ({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, translate, value, }) => {
|
|
6
6
|
const [menu, setMenu] = React.useState(null);
|
|
7
7
|
const [subMenu, setSubMenu] = React.useState(null);
|
|
8
8
|
const [subMenuReferenceElement, setSubMenuReferenceElement] = React.useState(null);
|
|
@@ -51,6 +51,6 @@ const ThMenu = ({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, p
|
|
|
51
51
|
}
|
|
52
52
|
return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ className: "schema-table__th-menu", ref: setMenu, style: menuPopper.styles.popper }, menuPopper.attributes.popper, { children: _jsxs("ol", Object.assign({ className: "schema-table-menu" }, { children: [isSortable ? (_jsxs("li", Object.assign({ onClick: onSortAscendingClick, style: { padding: 8 } }, { children: [_jsx("span", Object.assign({ className: "schema-table__th-menu__icon" }, { children: "\u2193" })), " Sort ascending"] }))) : null, isSortable ? (_jsxs("li", Object.assign({ onClick: onSortDescendingClick, style: { padding: 8 } }, { children: [_jsx("span", Object.assign({ className: "schema-table__th-menu__icon" }, { children: "\u2191" })), " Sort descending"] }))) : null, isFilterable ? (_jsxs("li", Object.assign({ style: { padding: 8 }, onMouseOver: (e) => {
|
|
53
53
|
setSubMenuReferenceElement(e.currentTarget);
|
|
54
|
-
} }, { children: [_jsx("span", Object.assign({ className: "schema-table__th-menu__icon" }, { children: _jsx("input", { type: "checkbox", id: "schema-table__th-menu__filters", checked: value !== undefined, disabled: value === undefined, onChange: onFilterCheckboxChange }) })), _jsx("label", Object.assign({ htmlFor: "schema-table__th-menu__filters" }, { children: "Filters" })), _jsx("div", Object.assign({ className: "schema-table__th-menu__sub-menu-indicator" }, { children: ">" }))] }))) : null] })) })), subMenuReferenceElement ? (_jsx("div", Object.assign({ className: "schema-table__th-menu__sub-menu", ref: setSubMenu, style: subMenuPopper.styles.popper }, subMenuPopper.attributes.popper, { children: _jsx(FilterMenu, { columnFilterValue: value, onChange: onChange, onInputKeyDown: onInputKeyDown,
|
|
54
|
+
} }, { children: [_jsx("span", Object.assign({ className: "schema-table__th-menu__icon" }, { children: _jsx("input", { type: "checkbox", id: "schema-table__th-menu__filters", checked: value !== undefined, disabled: value === undefined, onChange: onFilterCheckboxChange }) })), _jsx("label", Object.assign({ htmlFor: "schema-table__th-menu__filters" }, { children: "Filters" })), _jsx("div", Object.assign({ className: "schema-table__th-menu__sub-menu-indicator" }, { children: ">" }))] }))) : null] })) })), subMenuReferenceElement ? (_jsx("div", Object.assign({ className: "schema-table__th-menu__sub-menu", ref: setSubMenu, style: subMenuPopper.styles.popper }, subMenuPopper.attributes.popper, { children: _jsx(FilterMenu, { columnFilterValue: value, onChange: onChange, onInputKeyDown: onInputKeyDown, propIsRequired: propIsRequired, propName: propName, propSchema: propSchema, translate: translate }) }))) : null] }));
|
|
55
55
|
};
|
|
56
56
|
export default React.memo(ThMenu);
|
|
@@ -39,6 +39,7 @@ export interface ISchemaTableProps<T> {
|
|
|
39
39
|
schema: oas31.SchemaObject;
|
|
40
40
|
searchPlaceholder?: string;
|
|
41
41
|
style?: React.CSSProperties;
|
|
42
|
+
translate?: (key: string, ...args: Array<string | number>) => string;
|
|
42
43
|
useFilterStateHash?: boolean;
|
|
43
44
|
width: number;
|
|
44
45
|
}
|
|
@@ -48,6 +49,6 @@ export interface IDateColumnFilterValue {
|
|
|
48
49
|
filterEmpty?: true;
|
|
49
50
|
}
|
|
50
51
|
export type TColumnFilterValue = string | number | boolean | IDateColumnFilterValue;
|
|
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;
|
|
52
|
+
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, translate, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
52
53
|
declare const _default: typeof SchemaTable;
|
|
53
54
|
export default _default;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import React from "react";
|
|
14
14
|
import { VariableSizeGrid, VariableSizeList } from "react-window";
|
|
15
15
|
import { localeFormat } from "../inc/date";
|
|
16
|
-
import {
|
|
16
|
+
import { defaultTranslate } from "../inc/string";
|
|
17
17
|
import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
|
|
18
18
|
import Td from "./Td";
|
|
19
19
|
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
|
|
@@ -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, rowHeight = 36, schema, searchPlaceholder, style, useFilterStateHash, width, }) {
|
|
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, 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();
|
|
@@ -138,16 +138,13 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
138
138
|
prev[propName] = "";
|
|
139
139
|
return prev;
|
|
140
140
|
}
|
|
141
|
-
const
|
|
142
|
-
const rawValue = !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.translation)
|
|
143
|
-
? val
|
|
144
|
-
: t(val, propConfig.translation);
|
|
141
|
+
const rawValue = object[propName];
|
|
145
142
|
switch (schema.type) {
|
|
146
143
|
case "array":
|
|
147
144
|
prev[propName] =
|
|
148
145
|
((_a = schema.items) === null || _a === void 0 ? void 0 : _a.type) === "string" &&
|
|
149
146
|
rawValue
|
|
150
|
-
? rawValue.map(
|
|
147
|
+
? rawValue.map(translate).join(", ")
|
|
151
148
|
: JSON.stringify(rawValue);
|
|
152
149
|
return prev;
|
|
153
150
|
case "boolean":
|
|
@@ -178,7 +175,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
178
175
|
return prev;
|
|
179
176
|
}
|
|
180
177
|
if (schema.enum) {
|
|
181
|
-
prev[propName] = rawValue ?
|
|
178
|
+
prev[propName] = rawValue ? translate(rawValue) : "";
|
|
182
179
|
return prev;
|
|
183
180
|
}
|
|
184
181
|
// fallthrough
|
|
@@ -187,7 +184,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
187
184
|
return prev;
|
|
188
185
|
}
|
|
189
186
|
}, { _index: rowIndex }))
|
|
190
|
-
: undefined, [columnNames,
|
|
187
|
+
: undefined, [sourceData, columnNames, properties, config, translate]);
|
|
191
188
|
const columnCount = columnNames.length;
|
|
192
189
|
const { dynamicWidthColumnCount, fixedWidthColumnsWidth } = React.useMemo(() => {
|
|
193
190
|
let fixedWidthColumnsWidth = 0;
|
|
@@ -417,13 +414,12 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
417
414
|
}
|
|
418
415
|
return (_jsx(Th, { columnFilterStatus: columnFilterStatus,
|
|
419
416
|
// disableColumnFilter={disableColumnFilter}
|
|
420
|
-
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: setThMenuConfig, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style }));
|
|
417
|
+
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: setThMenuConfig, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style, translate: translate }));
|
|
421
418
|
}, [
|
|
422
419
|
checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
|
|
423
420
|
columnFilterMap,
|
|
424
421
|
columnNames,
|
|
425
422
|
config,
|
|
426
|
-
// disableColumnFilter,
|
|
427
423
|
isAllRowsChecked,
|
|
428
424
|
isColumnFilterable,
|
|
429
425
|
isSortable,
|
|
@@ -434,13 +430,14 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
434
430
|
required,
|
|
435
431
|
sortAsc,
|
|
436
432
|
sortColumn,
|
|
433
|
+
translate,
|
|
437
434
|
]);
|
|
438
435
|
const SchemaTableTd = React.useCallback(({ columnIndex, rowIndex, style }) => {
|
|
439
436
|
const propName = columnNames[columnIndex];
|
|
440
437
|
const propSchema = (propName === SELECT_ALL_COLUMN_NAME
|
|
441
438
|
? { type: "boolean" }
|
|
442
439
|
: properties[propName]);
|
|
443
|
-
return sourceData ? (_jsx(Td, { checkedIndexes: checkedIndexes, disabledCheckedIndexes: disabledCheckedIndexes, columnIndex: columnIndex, data: sourceData, getRowClassName: getRowClassName, getRowSelected: getRowSelected, onCheckedIndexesChange: onCheckedIndexesChange, onRowClick: onRowClick, onRowDoubleClick: onRowDoubleClick, propConfig: config ? config[propName] : undefined, propName: propName, propSchema: propSchema, rowHeight: rowHeight, rowIndex: rowIndex, sortedRenderData: sortedRenderData, style: style })) : null;
|
|
440
|
+
return sourceData ? (_jsx(Td, { checkedIndexes: checkedIndexes, disabledCheckedIndexes: disabledCheckedIndexes, columnIndex: columnIndex, data: sourceData, getRowClassName: getRowClassName, getRowSelected: getRowSelected, onCheckedIndexesChange: onCheckedIndexesChange, onRowClick: onRowClick, onRowDoubleClick: onRowDoubleClick, propConfig: config ? config[propName] : undefined, propName: propName, propSchema: propSchema, rowHeight: rowHeight, rowIndex: rowIndex, sortedRenderData: sortedRenderData, style: style, translate: translate })) : null;
|
|
444
441
|
}, [
|
|
445
442
|
columnNames,
|
|
446
443
|
properties,
|
|
@@ -455,6 +452,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
455
452
|
config,
|
|
456
453
|
rowHeight,
|
|
457
454
|
sortedRenderData,
|
|
455
|
+
translate,
|
|
458
456
|
]);
|
|
459
457
|
const onSearchChange = React.useCallback((e) => {
|
|
460
458
|
if (isDataFunction) {
|
|
@@ -578,6 +576,6 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
578
576
|
backgroundColor: "#CCC",
|
|
579
577
|
alignItems: "center",
|
|
580
578
|
justifyContent: "center",
|
|
581
|
-
} }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), thMenuConfig ? (_jsx(ThMenu, { isFilterable: !!isColumnFilterable, isSortable: getIsColumnSortable(!!isSortable, schema.properties[thMenuConfig.propName], thMenuConfig.propConfig), onChange: onSchemaColumnFilterChange, onClose: onPopoverClose, onInputKeyDown: onInputKeyDown, propConfig: thMenuConfig.propConfig, propIsRequired: thMenuConfig.propIsRequired, propName: thMenuConfig.propName, propSchema: schema.properties[thMenuConfig.propName], referenceElement: thMenuConfig.referenceElement, setSortAsc: setSortAsc, setSortColumn: setSortColumn, value: columnFilterMap[thMenuConfig.propName] })) : null] })));
|
|
579
|
+
} }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), thMenuConfig ? (_jsx(ThMenu, { isFilterable: !!isColumnFilterable, isSortable: getIsColumnSortable(!!isSortable, schema.properties[thMenuConfig.propName], thMenuConfig.propConfig), onChange: onSchemaColumnFilterChange, onClose: onPopoverClose, onInputKeyDown: onInputKeyDown, propConfig: thMenuConfig.propConfig, propIsRequired: thMenuConfig.propIsRequired, propName: thMenuConfig.propName, propSchema: schema.properties[thMenuConfig.propName], referenceElement: thMenuConfig.referenceElement, setSortAsc: setSortAsc, setSortColumn: setSortColumn, translate: translate, value: columnFilterMap[thMenuConfig.propName] })) : null] })));
|
|
582
580
|
}
|
|
583
581
|
export default React.memo(SchemaTable);
|
package/dist/inc/string.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function uncamel(camel: string): string;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function defaultTranslate(key: string, ...args: any[]): string;
|
package/dist/inc/string.js
CHANGED
|
@@ -21,7 +21,7 @@ const db = {
|
|
|
21
21
|
"Asia/Jakarta": "JKT",
|
|
22
22
|
"Asia/Bangkok": "JKT",
|
|
23
23
|
};
|
|
24
|
-
export function
|
|
24
|
+
export function defaultTranslate(key, ...args) {
|
|
25
25
|
let string = db[key] || uncamel(key);
|
|
26
26
|
args.forEach((arg, index) => {
|
|
27
27
|
string = string.replace(`{${index}}`, arg);
|
package/dist/index.css
CHANGED
|
@@ -98,6 +98,11 @@
|
|
|
98
98
|
font-size: 14px;
|
|
99
99
|
align-items: center;
|
|
100
100
|
}
|
|
101
|
+
.schema-table__th__label-body-text {
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
white-space: nowrap;
|
|
104
|
+
text-overflow: ellipsis;
|
|
105
|
+
}
|
|
101
106
|
.schema-table__th__trigger-el {
|
|
102
107
|
display: none;
|
|
103
108
|
position: absolute;
|
|
@@ -125,6 +130,9 @@
|
|
|
125
130
|
.schema-table__th:hover .schema-table__th__trigger-el {
|
|
126
131
|
display: block !important;
|
|
127
132
|
}
|
|
133
|
+
.schema-table__th svg {
|
|
134
|
+
vertical-align: baseline;
|
|
135
|
+
}
|
|
128
136
|
|
|
129
137
|
.schema-table__th-menu {
|
|
130
138
|
background-color: white;
|