mig-schema-table 3.0.67 → 3.0.68
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/SchemaTableTh/index.js +5 -1
- package/dist/SchemaTable/SchemaTableThMenu/index.d.ts +5 -3
- package/dist/SchemaTable/SchemaTableThMenu/index.js +6 -3
- package/dist/SchemaTable/Td/index.js +1 -2
- package/dist/SchemaTable/index.js +7 -3
- package/dist/index.css +2 -1
- package/package.json +1 -1
|
@@ -19,6 +19,9 @@ const SchemaTableTh = ({ columnFilterStatus, isAllChecked, isSortable, numberOfS
|
|
|
19
19
|
classNames.push("schema-table-th--sorted");
|
|
20
20
|
}
|
|
21
21
|
const onLabelClick = React.useCallback(() => {
|
|
22
|
+
if (!isSortable) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
22
25
|
if (sortAsc === undefined) {
|
|
23
26
|
setSortColumn(propName);
|
|
24
27
|
setSortAsc(!(propConfig === null || propConfig === void 0 ? void 0 : propConfig.defaultSortDesc));
|
|
@@ -26,6 +29,7 @@ const SchemaTableTh = ({ columnFilterStatus, isAllChecked, isSortable, numberOfS
|
|
|
26
29
|
}
|
|
27
30
|
setSortAsc((sortAsc) => !sortAsc);
|
|
28
31
|
}, [
|
|
32
|
+
isSortable,
|
|
29
33
|
propConfig === null || propConfig === void 0 ? void 0 : propConfig.defaultSortDesc,
|
|
30
34
|
propName,
|
|
31
35
|
setSortAsc,
|
|
@@ -79,6 +83,6 @@ const SchemaTableTh = ({ columnFilterStatus, isAllChecked, isSortable, numberOfS
|
|
|
79
83
|
classNames.push(`text-${propConfig.align}`);
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
|
-
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 ? "↓" : "↑" })))] })), _jsx("button", Object.assign({ className: "schema-table-th__trigger-el", onClick: onTriggerClick }, { children: "
|
|
86
|
+
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] })));
|
|
83
87
|
};
|
|
84
88
|
export default React.memo(SchemaTableTh);
|
|
@@ -9,14 +9,16 @@ export interface ISchemaTableThMenuConfig {
|
|
|
9
9
|
propIsRequired: boolean;
|
|
10
10
|
}
|
|
11
11
|
type TSchemaTableThMenuProps = ISchemaTableThMenuConfig & {
|
|
12
|
+
isSortable: boolean;
|
|
13
|
+
isFilterable: boolean;
|
|
12
14
|
onChange: (newValue: TColumnFilterValue | undefined, persistState: boolean) => void;
|
|
15
|
+
onClose: (e: MouseEvent | React.MouseEvent) => void;
|
|
13
16
|
onInputKeyDown: (e: React.KeyboardEvent) => void;
|
|
14
17
|
propIsRequired: boolean;
|
|
15
18
|
propSchema: oas31.SchemaObject;
|
|
16
|
-
setSortColumn: Dispatch<SetStateAction<string>>;
|
|
17
19
|
setSortAsc: Dispatch<SetStateAction<boolean>>;
|
|
20
|
+
setSortColumn: Dispatch<SetStateAction<string>>;
|
|
18
21
|
value: TColumnFilterValue;
|
|
19
|
-
onClose: (e: MouseEvent | React.MouseEvent) => void;
|
|
20
22
|
};
|
|
21
|
-
declare const _default: React.MemoExoticComponent<({ onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, value, }: TSchemaTableThMenuProps) => import("react/jsx-runtime").JSX.Element>;
|
|
23
|
+
declare const _default: React.MemoExoticComponent<({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, value, }: TSchemaTableThMenuProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
22
24
|
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 SchemaTableThMenu = ({ onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, value, }) => {
|
|
5
|
+
const SchemaTableThMenu = ({ isSortable, isFilterable, onChange, onClose, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, referenceElement, setSortAsc, setSortColumn, 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);
|
|
@@ -46,8 +46,11 @@ const SchemaTableThMenu = ({ onChange, onClose, onInputKeyDown, propConfig, prop
|
|
|
46
46
|
const onFilterCheckboxChange = React.useCallback(() => {
|
|
47
47
|
onChange(undefined, true);
|
|
48
48
|
}, [onChange]);
|
|
49
|
-
|
|
49
|
+
if (!isSortable && !isFilterable) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
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) => {
|
|
50
53
|
setSubMenuReferenceElement(e.currentTarget);
|
|
51
|
-
} }, { 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: ">" }))] }))] })) })), 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, propConfig: propConfig, propIsRequired: propIsRequired, propName: propName, propSchema: propSchema }) }))) : null] }));
|
|
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, propConfig: propConfig, propIsRequired: propIsRequired, propName: propName, propSchema: propSchema }) }))) : null] }));
|
|
52
55
|
};
|
|
53
56
|
export default React.memo(SchemaTableThMenu);
|
|
@@ -53,7 +53,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
53
53
|
"data-column-index": columnIndex,
|
|
54
54
|
key: propName,
|
|
55
55
|
style: Object.assign(Object.assign({}, style), { lineHeight: `${rowHeight}px` }),
|
|
56
|
-
onClick:
|
|
56
|
+
onClick: onTdClick,
|
|
57
57
|
onDoubleClick: onTdDoubleClick,
|
|
58
58
|
className: `schema-table__td schema-table__td--${rowIndex % 2 ? "odd" : "even"}${getRowSelected && getRowSelected(data[row._index], row._index)
|
|
59
59
|
? " schema-table__td--selected"
|
|
@@ -69,7 +69,6 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
69
69
|
getRowSelected,
|
|
70
70
|
onTdClick,
|
|
71
71
|
onTdDoubleClick,
|
|
72
|
-
propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell,
|
|
73
72
|
propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones,
|
|
74
73
|
propName,
|
|
75
74
|
propSchema === null || propSchema === void 0 ? void 0 : propSchema.format,
|
|
@@ -113,7 +113,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
113
113
|
return prev;
|
|
114
114
|
}
|
|
115
115
|
if (!schema || propName === SELECT_ALL_COLUMN_NAME) {
|
|
116
|
-
prev[propName] = "
|
|
116
|
+
prev[propName] = "";
|
|
117
117
|
return prev;
|
|
118
118
|
}
|
|
119
119
|
const val = object[propName];
|
|
@@ -381,9 +381,13 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
381
381
|
if (columnFilterMap[propName] !== undefined) {
|
|
382
382
|
columnFilterStatus = EColumnFilterStatus.ACTIVE;
|
|
383
383
|
}
|
|
384
|
+
const isColumnSortable = !!(isSortable &&
|
|
385
|
+
(propSchema ||
|
|
386
|
+
((propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue) && propConfig.renderData) ||
|
|
387
|
+
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.sort)));
|
|
384
388
|
return (_jsx(SchemaTableTh, { columnFilterStatus: columnFilterStatus,
|
|
385
389
|
// disableColumnFilter={disableColumnFilter}
|
|
386
|
-
isAllChecked: isAllRowsChecked, isSortable:
|
|
390
|
+
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 }));
|
|
387
391
|
}, [
|
|
388
392
|
checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
|
|
389
393
|
columnFilterMap,
|
|
@@ -529,6 +533,6 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
529
533
|
backgroundColor: "#CCC",
|
|
530
534
|
alignItems: "center",
|
|
531
535
|
justifyContent: "center",
|
|
532
|
-
} }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), schemaTableThMenuConfig ? (_jsx(SchemaTableThMenu, { 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] })));
|
|
536
|
+
} }, { 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] })));
|
|
533
537
|
}
|
|
534
538
|
export default React.memo(SchemaTable);
|
package/dist/index.css
CHANGED
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
.schema-table-th {
|
|
69
|
+
background-color: #fcfcfc;
|
|
69
70
|
border-right: 1px solid #ddd;
|
|
70
71
|
border-top: 1px solid #ddd;
|
|
71
72
|
border-bottom: 1px solid #ddd;
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
color: #666;
|
|
111
112
|
font-size: 28px;
|
|
112
113
|
text-align: center;
|
|
113
|
-
padding: 0 0
|
|
114
|
+
padding: 5px 0 0 !important;
|
|
114
115
|
}
|
|
115
116
|
.schema-table-th__sort-icon {
|
|
116
117
|
font-size: 24px;
|