@agilemotion/oui-react-js 1.8.20 → 1.8.22
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/components/DataGrid.css +19 -9
- package/dist/components/DataGrid.js +36 -2
- package/dist/components/DataGridColumn.js +85 -3
- package/dist/components/DataGridHeading.js +2 -0
- package/dist/components/TableCellContent.js +1 -1
- package/dist/components/form/BaseField.js +7 -0
- package/package.json +1 -1
|
@@ -43,7 +43,11 @@ table.responsive-table thead {
|
|
|
43
43
|
text-align: left;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.
|
|
46
|
+
.tableCellContentContainer td {
|
|
47
|
+
overflow: hidden !important;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.tableCellContentContainerNoWrap td {
|
|
47
51
|
white-space: nowrap;
|
|
48
52
|
overflow: hidden !important;
|
|
49
53
|
text-overflow: ellipsis;
|
|
@@ -59,6 +63,10 @@ table.responsive-table thead {
|
|
|
59
63
|
padding: 0 !important;
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
.ouiTable .oui-table-row {
|
|
67
|
+
border-bottom: 1px solid #e2e2e2;
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
.ouiTable td {
|
|
63
71
|
padding: 16px 0 12px 8px;
|
|
64
72
|
height: 54px;
|
|
@@ -68,13 +76,10 @@ table.responsive-table thead {
|
|
|
68
76
|
text-align: left;
|
|
69
77
|
font-weight: 500;
|
|
70
78
|
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
|
|
71
|
-
border-bottom: 1px solid #e2e2e2;
|
|
72
79
|
letter-spacing: 0.01071em;
|
|
73
80
|
vertical-align: inherit;
|
|
74
81
|
color: rgba(0, 0, 0, 0.87);
|
|
75
|
-
white-space: nowrap;
|
|
76
82
|
overflow: hidden;
|
|
77
|
-
text-overflow: ellipsis;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
.cellError, .editCellError {
|
|
@@ -154,27 +159,32 @@ table.responsive-table thead {
|
|
|
154
159
|
overflow: auto;
|
|
155
160
|
}
|
|
156
161
|
|
|
157
|
-
.tableCellContentContainer:hover
|
|
162
|
+
.tableCellContentContainer:hover,
|
|
163
|
+
.tableCellContentContainerNoWrap:hover{
|
|
158
164
|
background-color: transparent !important;
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
.tableCellContentContainer
|
|
167
|
+
.tableCellContentContainer,
|
|
168
|
+
.tableCellContentContainerNoWrap {
|
|
162
169
|
width: 100%;
|
|
163
170
|
background-color: transparent !important;
|
|
164
171
|
}
|
|
165
172
|
|
|
166
|
-
.tableCellContentContainer td
|
|
173
|
+
.tableCellContentContainer td,
|
|
174
|
+
.tableCellContentContainerNoWrap td {
|
|
167
175
|
padding: 0 4px 0 0 !important;
|
|
168
176
|
height: auto !important;
|
|
169
177
|
border: none !important;
|
|
170
178
|
background-color: transparent !important;
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
.tableCellContentContainer td:hover
|
|
181
|
+
.tableCellContentContainer td:hover,
|
|
182
|
+
.tableCellContentContainerNoWrap td:hover {
|
|
174
183
|
background-color: transparent !important;
|
|
175
184
|
}
|
|
176
185
|
|
|
177
|
-
.tableCellContentContainer td:first-child
|
|
186
|
+
.tableCellContentContainer td:first-child,
|
|
187
|
+
.tableCellContentContainerNoWrap td:first-child {
|
|
178
188
|
padding-left: 0 !important;
|
|
179
189
|
}
|
|
180
190
|
|
|
@@ -27,6 +27,8 @@ var _Alert = _interopRequireDefault(require("react-bootstrap/Alert"));
|
|
|
27
27
|
var _ApplicationManager = _interopRequireDefault(require("../ApplicationManager"));
|
|
28
28
|
var _Layout = require("./layout/Layout");
|
|
29
29
|
var _DynamicJS = _interopRequireDefault(require("../DynamicJS"));
|
|
30
|
+
var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
|
|
31
|
+
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
30
32
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
33
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
34
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -130,9 +132,19 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
130
132
|
const [editorHandles] = _react.default.useState({});
|
|
131
133
|
const [rowErrorMap] = _react.default.useState({});
|
|
132
134
|
const [visible, setVisible] = _react.default.useState(true);
|
|
135
|
+
const [wrap, setWrap] = _react.default.useState(false);
|
|
133
136
|
const rowCount = _react.default.useRef(-1);
|
|
134
137
|
const rowsRef = _react.default.useRef([]);
|
|
135
138
|
let noteKey = 0;
|
|
139
|
+
const columnWidths = _react.default.useRef({});
|
|
140
|
+
function updateColumnWidths() {
|
|
141
|
+
for (let col of config.columns) {
|
|
142
|
+
if (columnWidths.current[col.id]) {
|
|
143
|
+
col.attributes.width = columnWidths.current[col.id];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
setRows([...rows]);
|
|
147
|
+
}
|
|
136
148
|
const api = () => {
|
|
137
149
|
return {
|
|
138
150
|
get id() {
|
|
@@ -776,6 +788,24 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
776
788
|
xs: 12,
|
|
777
789
|
spacing: 1
|
|
778
790
|
}, renderTiles())))) : /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
791
|
+
style: {
|
|
792
|
+
width: '100%',
|
|
793
|
+
padding: '4px 8px 0 8px',
|
|
794
|
+
borderBottom: '1px solid #e2e2e2'
|
|
795
|
+
}
|
|
796
|
+
}, /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
|
|
797
|
+
control: /*#__PURE__*/_react.default.createElement(_Switch.default, {
|
|
798
|
+
checked: wrap,
|
|
799
|
+
onChange: e => setWrap(e.target.checked),
|
|
800
|
+
color: "primary"
|
|
801
|
+
}),
|
|
802
|
+
sx: {
|
|
803
|
+
'& .MuiFormControlLabel-label': {
|
|
804
|
+
fontSize: '0.75rem'
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
label: "Wrap table text"
|
|
808
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
779
809
|
className: "responsive-table",
|
|
780
810
|
style: {
|
|
781
811
|
height: props.height
|
|
@@ -809,7 +839,10 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
809
839
|
scrollWidth: scrollWidth,
|
|
810
840
|
onSelectAllClick: handleSelectAllClick,
|
|
811
841
|
onRequestSort: handleRequestSort,
|
|
812
|
-
rowCount: totalNumberOfRows
|
|
842
|
+
rowCount: totalNumberOfRows,
|
|
843
|
+
resizeHandler: () => {
|
|
844
|
+
setRows([...rows]);
|
|
845
|
+
}
|
|
813
846
|
})), /*#__PURE__*/_react.default.createElement(_reactSuperResponsiveTable.Tbody, {
|
|
814
847
|
className: classes.tableBody,
|
|
815
848
|
style: {
|
|
@@ -833,7 +866,7 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
833
866
|
key: index,
|
|
834
867
|
id: 'ROW-' + row.id,
|
|
835
868
|
selected: isItemSelected,
|
|
836
|
-
className: (highlightRowSelection.current ? isItemSelected ? classes.tableSelected : classes.tableRow : '') + (row.className ? ' ' + row.className : '')
|
|
869
|
+
className: 'oui-table-row ' + ((highlightRowSelection.current ? isItemSelected ? classes.tableSelected : classes.tableRow : '') + (row.className ? ' ' + row.className : ''))
|
|
837
870
|
}, config.selectionMode === 'MULTIPLE' ? /*#__PURE__*/_react.default.createElement(_reactSuperResponsiveTable.Td, {
|
|
838
871
|
padding: "checkbox",
|
|
839
872
|
width: MULTI_SELECT_CHECKBOX_COL_WIDTH + 'px',
|
|
@@ -870,6 +903,7 @@ const DataGrid = exports.DataGrid = /*#__PURE__*/_react.default.memo(/*#__PURE__
|
|
|
870
903
|
key: index + "_" + column.id,
|
|
871
904
|
onClick: event => handleCellClick(event, row.id, column)
|
|
872
905
|
}, /*#__PURE__*/_react.default.createElement(_TableCellContent.default, {
|
|
906
|
+
wrap: wrap,
|
|
873
907
|
onRowError: rowErrorHandler,
|
|
874
908
|
handle: createCellEditorHandle(column),
|
|
875
909
|
viewId: props.viewId,
|
|
@@ -28,6 +28,73 @@ const DataGridColumn = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.defa
|
|
|
28
28
|
const [postfix, setPostfix] = _react.default.useState('');
|
|
29
29
|
const [required, setRequired] = _react.default.useState(false);
|
|
30
30
|
const classes = useStyles();
|
|
31
|
+
const columnWidths = _react.default.useRef({});
|
|
32
|
+
const resizingCol = _react.default.useRef(null);
|
|
33
|
+
const startX = _react.default.useRef(0);
|
|
34
|
+
const startWidth = _react.default.useRef(0);
|
|
35
|
+
const originalWidths = _react.default.useRef({});
|
|
36
|
+
const MIN_WIDTH = 5;
|
|
37
|
+
const MAX_WIDTH = 90;
|
|
38
|
+
function handleResizeStart(e, columnId) {
|
|
39
|
+
if (props.columns.length <= 1) return;
|
|
40
|
+
resizingCol.current = columnId;
|
|
41
|
+
startX.current = e.clientX;
|
|
42
|
+
startWidth.current = e.target.parentElement.offsetWidth;
|
|
43
|
+
originalWidths.current = {};
|
|
44
|
+
for (let col of props.columns) {
|
|
45
|
+
const width = parseFloat(col.attributes.width?.replace('%', '') || 100 / props.columns.length);
|
|
46
|
+
originalWidths.current[col.id] = width;
|
|
47
|
+
}
|
|
48
|
+
document.addEventListener('mousemove', handleResizeMove);
|
|
49
|
+
document.addEventListener('mouseup', handleResizeEnd);
|
|
50
|
+
}
|
|
51
|
+
function handleResizeMove(e) {
|
|
52
|
+
if (!resizingCol.current) return;
|
|
53
|
+
const dx = e.clientX - startX.current;
|
|
54
|
+
const table = document.querySelector('.ouiTable');
|
|
55
|
+
const tableWidth = table.offsetWidth;
|
|
56
|
+
let newWidthPx = startWidth.current + dx;
|
|
57
|
+
let newWidthPercent = newWidthPx / tableWidth * 100;
|
|
58
|
+
const resizedColId = resizingCol.current;
|
|
59
|
+
const resizedColIndex = props.columns.findIndex(col => col.id === resizedColId);
|
|
60
|
+
if (resizedColIndex === -1 || resizedColIndex === props.columns.length - 1) return;
|
|
61
|
+
const adjacentCol = props.columns[resizedColIndex + 1];
|
|
62
|
+
const adjacentColId = adjacentCol.id;
|
|
63
|
+
const originalResizedWidth = originalWidths.current[resizedColId];
|
|
64
|
+
const originalAdjacentWidth = originalWidths.current[adjacentColId];
|
|
65
|
+
let delta = newWidthPercent - originalResizedWidth;
|
|
66
|
+
let newAdjacentWidth = originalAdjacentWidth - delta;
|
|
67
|
+
if (newWidthPercent < MIN_WIDTH) {
|
|
68
|
+
delta = MIN_WIDTH - originalResizedWidth;
|
|
69
|
+
newWidthPercent = MIN_WIDTH;
|
|
70
|
+
newAdjacentWidth = originalAdjacentWidth - delta;
|
|
71
|
+
}
|
|
72
|
+
if (newAdjacentWidth < MIN_WIDTH) {
|
|
73
|
+
delta = originalAdjacentWidth - MIN_WIDTH;
|
|
74
|
+
newWidthPercent = originalResizedWidth + delta;
|
|
75
|
+
newAdjacentWidth = MIN_WIDTH;
|
|
76
|
+
}
|
|
77
|
+
newWidthPercent = Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, newWidthPercent));
|
|
78
|
+
newAdjacentWidth = Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, newAdjacentWidth));
|
|
79
|
+
columnWidths.current = {
|
|
80
|
+
[resizedColId]: newWidthPercent.toFixed(2) + '%',
|
|
81
|
+
[adjacentColId]: newAdjacentWidth.toFixed(2) + '%'
|
|
82
|
+
};
|
|
83
|
+
updateColumnWidths();
|
|
84
|
+
}
|
|
85
|
+
function handleResizeEnd() {
|
|
86
|
+
document.removeEventListener('mousemove', handleResizeMove);
|
|
87
|
+
document.removeEventListener('mouseup', handleResizeEnd);
|
|
88
|
+
resizingCol.current = null;
|
|
89
|
+
}
|
|
90
|
+
function updateColumnWidths() {
|
|
91
|
+
for (let col of props.columns) {
|
|
92
|
+
if (columnWidths.current[col.id]) {
|
|
93
|
+
col.attributes.width = columnWidths.current[col.id];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
props.resizeHandler();
|
|
97
|
+
}
|
|
31
98
|
_react.default.useEffect(() => {
|
|
32
99
|
props.handle.api = api();
|
|
33
100
|
if (_Utils.default.isNull(config)) {
|
|
@@ -61,11 +128,26 @@ const DataGridColumn = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.defa
|
|
|
61
128
|
padding: 'default',
|
|
62
129
|
className: config.cellFormat === 'MONEY' || config.cellFormat === 'NUMBER' ? classes.tableHeaderCellNumeric : classes.tableHeaderCell,
|
|
63
130
|
style: {
|
|
64
|
-
width: config.attributes.width,
|
|
131
|
+
width: config.attributes.width || 'auto',
|
|
65
132
|
display: 'flex',
|
|
66
|
-
alignItems: 'center'
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
position: 'relative',
|
|
135
|
+
whiteSpace: 'nowrap',
|
|
136
|
+
overflow: 'hidden',
|
|
137
|
+
textOverflow: 'ellipsis'
|
|
67
138
|
}
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
139
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
style: {
|
|
141
|
+
position: 'absolute',
|
|
142
|
+
top: 0,
|
|
143
|
+
right: 0,
|
|
144
|
+
height: '100%',
|
|
145
|
+
width: '5px',
|
|
146
|
+
cursor: 'col-resize',
|
|
147
|
+
zIndex: 10
|
|
148
|
+
},
|
|
149
|
+
onMouseDown: e => handleResizeStart(e, props.config.id)
|
|
150
|
+
}), /*#__PURE__*/_react.default.createElement(_TableSortLabel.default, {
|
|
69
151
|
active: config.attributes['sortable'] === true,
|
|
70
152
|
direction: 'desc',
|
|
71
153
|
onClick: props.createSortHandler(config.id)
|
|
@@ -75,6 +75,8 @@ const DataGridHeading = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.def
|
|
|
75
75
|
config: column,
|
|
76
76
|
handle: createColumnHandle(),
|
|
77
77
|
ref: /*#__PURE__*/_react.default.createRef(),
|
|
78
|
+
columns: props.config.columns,
|
|
79
|
+
resizeHandler: props.resizeHandler,
|
|
78
80
|
createSortHandler: createSortHandler
|
|
79
81
|
})));
|
|
80
82
|
}));
|
|
@@ -189,7 +189,7 @@ const TableCellContent = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.de
|
|
|
189
189
|
updateErrors(error);
|
|
190
190
|
let hasError = !_Utils.default.isNull(error);
|
|
191
191
|
return /*#__PURE__*/_react.default.createElement("table", {
|
|
192
|
-
className: 'tableCellContentContainer',
|
|
192
|
+
className: props.wrap ? 'tableCellContentContainer' : 'tableCellContentContainerNoWrap',
|
|
193
193
|
border: "0"
|
|
194
194
|
}, /*#__PURE__*/_react.default.createElement("tbody", null, /*#__PURE__*/_react.default.createElement("tr", null, hasError ? /*#__PURE__*/_react.default.createElement("td", {
|
|
195
195
|
style: {
|
|
@@ -34,6 +34,10 @@ const BaseField = props => {
|
|
|
34
34
|
const ref = _react.default.useRef(null);
|
|
35
35
|
const valid = _react.default.useRef(false);
|
|
36
36
|
_react.default.useEffect(() => {
|
|
37
|
+
initialValueBound.current = false;
|
|
38
|
+
bind();
|
|
39
|
+
}, [valueObject]);
|
|
40
|
+
function bind() {
|
|
37
41
|
let boundValue = valueObject[valueProperty];
|
|
38
42
|
if (boundValue && !initialValueBound.current) {
|
|
39
43
|
initialValueBound.current = true;
|
|
@@ -51,6 +55,9 @@ const BaseField = props => {
|
|
|
51
55
|
valueRef.current = boundValue;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
58
|
+
}
|
|
59
|
+
_react.default.useEffect(() => {
|
|
60
|
+
bind();
|
|
54
61
|
}, [valueObject[valueProperty]]);
|
|
55
62
|
|
|
56
63
|
// Change the required value and re-validate field if necessary
|