arengibook 2.0.13-table → 2.0.14-table
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/index.js +125 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47294,6 +47294,8 @@ var DeviseBodyCell = function DeviseBodyCell(_ref) {
|
|
|
47294
47294
|
var rowData = _ref.rowData,
|
|
47295
47295
|
col = _ref.col,
|
|
47296
47296
|
editable = _ref.editable,
|
|
47297
|
+
_ref$isRowEditing = _ref.isRowEditing,
|
|
47298
|
+
isRowEditing = _ref$isRowEditing === void 0 ? false : _ref$isRowEditing,
|
|
47297
47299
|
onSave = _ref.onSave;
|
|
47298
47300
|
var _useState = useState(false),
|
|
47299
47301
|
_useState2 = _slicedToArray$c(_useState, 2),
|
|
@@ -47329,6 +47331,21 @@ var DeviseBodyCell = function DeviseBodyCell(_ref) {
|
|
|
47329
47331
|
setDevise(initialDevise);
|
|
47330
47332
|
setEditing(true);
|
|
47331
47333
|
};
|
|
47334
|
+
|
|
47335
|
+
// Sync avec le mode row edit : auto-ouvrir / fermer
|
|
47336
|
+
useEffect(function () {
|
|
47337
|
+
if (isRowEditing && !editing) {
|
|
47338
|
+
var _displayCell$value2, _ref4, _ref5, _displayCell$devise2;
|
|
47339
|
+
setAmount((_displayCell$value2 = displayCell === null || displayCell === void 0 ? void 0 : displayCell.value) !== null && _displayCell$value2 !== void 0 ? _displayCell$value2 : '');
|
|
47340
|
+
var initialDevise = (_ref4 = (_ref5 = (_displayCell$devise2 = displayCell === null || displayCell === void 0 ? void 0 : displayCell.devise) !== null && _displayCell$devise2 !== void 0 ? _displayCell$devise2 : col.currency) !== null && _ref5 !== void 0 ? _ref5 : devises[0]) !== null && _ref4 !== void 0 ? _ref4 : null;
|
|
47341
|
+
deviseRef.current = initialDevise;
|
|
47342
|
+
setDevise(initialDevise);
|
|
47343
|
+
setEditing(true);
|
|
47344
|
+
} else if (!isRowEditing && editing) {
|
|
47345
|
+
setEditing(false);
|
|
47346
|
+
}
|
|
47347
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47348
|
+
}, [isRowEditing]);
|
|
47332
47349
|
var handleSave = function handleSave() {
|
|
47333
47350
|
var _devises$find;
|
|
47334
47351
|
var currentDevise = deviseRef.current;
|
|
@@ -47344,7 +47361,7 @@ var DeviseBodyCell = function DeviseBodyCell(_ref) {
|
|
|
47344
47361
|
setEditing(false);
|
|
47345
47362
|
};
|
|
47346
47363
|
useEffect(function () {
|
|
47347
|
-
if (!editing) return;
|
|
47364
|
+
if (!editing || isRowEditing) return;
|
|
47348
47365
|
var handler = function handler(e) {
|
|
47349
47366
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
47350
47367
|
setEditing(false);
|
|
@@ -47354,7 +47371,7 @@ var DeviseBodyCell = function DeviseBodyCell(_ref) {
|
|
|
47354
47371
|
return function () {
|
|
47355
47372
|
return document.removeEventListener('mousedown', handler);
|
|
47356
47373
|
};
|
|
47357
|
-
}, [editing]);
|
|
47374
|
+
}, [editing, isRowEditing]);
|
|
47358
47375
|
if (editing) {
|
|
47359
47376
|
var devisesOptions = devises.map(function (d) {
|
|
47360
47377
|
return {
|
|
@@ -47418,11 +47435,13 @@ var DeviseBodyCell = function DeviseBodyCell(_ref) {
|
|
|
47418
47435
|
className: "span-sub"
|
|
47419
47436
|
}, "".concat(numberWithSpaces(value), " ").concat(cellDevise.code)));
|
|
47420
47437
|
};
|
|
47421
|
-
var TreeSelectBodyCell = function TreeSelectBodyCell(
|
|
47422
|
-
var rowData =
|
|
47423
|
-
col =
|
|
47424
|
-
editable =
|
|
47425
|
-
|
|
47438
|
+
var TreeSelectBodyCell = function TreeSelectBodyCell(_ref6) {
|
|
47439
|
+
var rowData = _ref6.rowData,
|
|
47440
|
+
col = _ref6.col,
|
|
47441
|
+
editable = _ref6.editable,
|
|
47442
|
+
_ref6$isRowEditing = _ref6.isRowEditing,
|
|
47443
|
+
isRowEditing = _ref6$isRowEditing === void 0 ? false : _ref6$isRowEditing,
|
|
47444
|
+
onSave = _ref6.onSave;
|
|
47426
47445
|
var _useState9 = useState(false),
|
|
47427
47446
|
_useState0 = _slicedToArray$c(_useState9, 2),
|
|
47428
47447
|
editing = _useState0[0],
|
|
@@ -47448,6 +47467,17 @@ var TreeSelectBodyCell = function TreeSelectBodyCell(_ref4) {
|
|
|
47448
47467
|
setEditValue(savedValue);
|
|
47449
47468
|
setEditing(true);
|
|
47450
47469
|
};
|
|
47470
|
+
|
|
47471
|
+
// Sync avec le mode row edit : auto-ouvrir / fermer
|
|
47472
|
+
useEffect(function () {
|
|
47473
|
+
if (isRowEditing && !editing) {
|
|
47474
|
+
setEditValue(savedValue);
|
|
47475
|
+
setEditing(true);
|
|
47476
|
+
} else if (!isRowEditing && editing) {
|
|
47477
|
+
setEditing(false);
|
|
47478
|
+
}
|
|
47479
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47480
|
+
}, [isRowEditing]);
|
|
47451
47481
|
var handleChange = function handleChange(e) {
|
|
47452
47482
|
var val = e.value;
|
|
47453
47483
|
if (val == null || val === '' || _typeof$f(val) === 'object' && Object.keys(val).length === 0) return;
|
|
@@ -47456,7 +47486,7 @@ var TreeSelectBodyCell = function TreeSelectBodyCell(_ref4) {
|
|
|
47456
47486
|
onSave(val);
|
|
47457
47487
|
};
|
|
47458
47488
|
useEffect(function () {
|
|
47459
|
-
if (!editing) return;
|
|
47489
|
+
if (!editing || isRowEditing) return;
|
|
47460
47490
|
var handler = function handler(e) {
|
|
47461
47491
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
47462
47492
|
if (e.target.closest('.p-treeselect-panel')) return;
|
|
@@ -47467,7 +47497,7 @@ var TreeSelectBodyCell = function TreeSelectBodyCell(_ref4) {
|
|
|
47467
47497
|
return function () {
|
|
47468
47498
|
return document.removeEventListener('mousedown', handler);
|
|
47469
47499
|
};
|
|
47470
|
-
}, [editing]);
|
|
47500
|
+
}, [editing, isRowEditing]);
|
|
47471
47501
|
if (editing) {
|
|
47472
47502
|
var _col$selectionMode, _col$filter, _col$display;
|
|
47473
47503
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -47516,10 +47546,10 @@ var TreeSelectBodyCell = function TreeSelectBodyCell(_ref4) {
|
|
|
47516
47546
|
}, label);
|
|
47517
47547
|
}));
|
|
47518
47548
|
};
|
|
47519
|
-
var DocumentEditorCell = function DocumentEditorCell(
|
|
47549
|
+
var DocumentEditorCell = function DocumentEditorCell(_ref7) {
|
|
47520
47550
|
var _options$value;
|
|
47521
|
-
var options =
|
|
47522
|
-
col =
|
|
47551
|
+
var options = _ref7.options,
|
|
47552
|
+
col = _ref7.col;
|
|
47523
47553
|
var _useState13 = useState(false),
|
|
47524
47554
|
_useState14 = _slicedToArray$c(_useState13, 2),
|
|
47525
47555
|
uploading = _useState14[0],
|
|
@@ -47527,7 +47557,7 @@ var DocumentEditorCell = function DocumentEditorCell(_ref5) {
|
|
|
47527
47557
|
var fileInputRef = useRef(null);
|
|
47528
47558
|
var docs = (_options$value = options.value) !== null && _options$value !== void 0 ? _options$value : [];
|
|
47529
47559
|
var handleFileChange = /*#__PURE__*/function () {
|
|
47530
|
-
var
|
|
47560
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(e) {
|
|
47531
47561
|
var file, formData, res, data;
|
|
47532
47562
|
return _regenerator().w(function (_context) {
|
|
47533
47563
|
while (1) switch (_context.n) {
|
|
@@ -47566,7 +47596,7 @@ var DocumentEditorCell = function DocumentEditorCell(_ref5) {
|
|
|
47566
47596
|
}, _callee, null, [[2,, 5, 6]]);
|
|
47567
47597
|
}));
|
|
47568
47598
|
return function handleFileChange(_x) {
|
|
47569
|
-
return
|
|
47599
|
+
return _ref8.apply(this, arguments);
|
|
47570
47600
|
};
|
|
47571
47601
|
}();
|
|
47572
47602
|
var handleDelete = function handleDelete(id) {
|
|
@@ -47615,28 +47645,30 @@ var DocumentEditorCell = function DocumentEditorCell(_ref5) {
|
|
|
47615
47645
|
onChange: handleFileChange
|
|
47616
47646
|
}));
|
|
47617
47647
|
};
|
|
47618
|
-
var Table = function Table(
|
|
47619
|
-
var
|
|
47620
|
-
value =
|
|
47621
|
-
|
|
47622
|
-
columns =
|
|
47623
|
-
|
|
47624
|
-
paginator =
|
|
47625
|
-
|
|
47626
|
-
rows =
|
|
47627
|
-
|
|
47628
|
-
loading =
|
|
47629
|
-
|
|
47630
|
-
stripedRows =
|
|
47631
|
-
|
|
47632
|
-
selectionMode =
|
|
47633
|
-
selection =
|
|
47634
|
-
onSelectionChange =
|
|
47635
|
-
|
|
47636
|
-
editable =
|
|
47637
|
-
|
|
47638
|
-
|
|
47639
|
-
|
|
47648
|
+
var Table = function Table(_ref9) {
|
|
47649
|
+
var _ref9$value = _ref9.value,
|
|
47650
|
+
value = _ref9$value === void 0 ? [] : _ref9$value,
|
|
47651
|
+
_ref9$columns = _ref9.columns,
|
|
47652
|
+
columns = _ref9$columns === void 0 ? [] : _ref9$columns,
|
|
47653
|
+
_ref9$paginator = _ref9.paginator,
|
|
47654
|
+
paginator = _ref9$paginator === void 0 ? true : _ref9$paginator,
|
|
47655
|
+
_ref9$rows = _ref9.rows,
|
|
47656
|
+
rows = _ref9$rows === void 0 ? 25 : _ref9$rows,
|
|
47657
|
+
_ref9$loading = _ref9.loading,
|
|
47658
|
+
loading = _ref9$loading === void 0 ? false : _ref9$loading,
|
|
47659
|
+
_ref9$stripedRows = _ref9.stripedRows,
|
|
47660
|
+
stripedRows = _ref9$stripedRows === void 0 ? false : _ref9$stripedRows,
|
|
47661
|
+
_ref9$selectionMode = _ref9.selectionMode,
|
|
47662
|
+
selectionMode = _ref9$selectionMode === void 0 ? null : _ref9$selectionMode,
|
|
47663
|
+
selection = _ref9.selection,
|
|
47664
|
+
onSelectionChange = _ref9.onSelectionChange,
|
|
47665
|
+
_ref9$editable = _ref9.editable,
|
|
47666
|
+
editable = _ref9$editable === void 0 ? false : _ref9$editable,
|
|
47667
|
+
_ref9$rowEdit = _ref9.rowEdit,
|
|
47668
|
+
rowEdit = _ref9$rowEdit === void 0 ? true : _ref9$rowEdit,
|
|
47669
|
+
onChange = _ref9.onChange,
|
|
47670
|
+
onCellChange = _ref9.onCellChange,
|
|
47671
|
+
carto = _ref9.carto;
|
|
47640
47672
|
var _useState15 = useState(value),
|
|
47641
47673
|
_useState16 = _slicedToArray$c(_useState15, 2),
|
|
47642
47674
|
data = _useState16[0],
|
|
@@ -47650,21 +47682,41 @@ var Table = function Table(_ref7) {
|
|
|
47650
47682
|
return updated;
|
|
47651
47683
|
});
|
|
47652
47684
|
}, [onChange]);
|
|
47685
|
+
var _useState17 = useState({}),
|
|
47686
|
+
_useState18 = _slicedToArray$c(_useState17, 2),
|
|
47687
|
+
editingRows = _useState18[0],
|
|
47688
|
+
setEditingRows = _useState18[1];
|
|
47689
|
+
var onRowEditChange = useCallback(function (e) {
|
|
47690
|
+
setEditingRows(e.data);
|
|
47691
|
+
}, []);
|
|
47692
|
+
var onRowEditComplete = useCallback(function (e) {
|
|
47693
|
+
var newData = e.newData,
|
|
47694
|
+
index = e.index;
|
|
47695
|
+
var updated = data.map(function (row, i) {
|
|
47696
|
+
return i === index ? newData : row;
|
|
47697
|
+
});
|
|
47698
|
+
setData(updated);
|
|
47699
|
+
onChange === null || onChange === void 0 || onChange(updated);
|
|
47700
|
+
onCellChange === null || onCellChange === void 0 || onCellChange({
|
|
47701
|
+
rowData: data[index],
|
|
47702
|
+
newRowData: newData
|
|
47703
|
+
});
|
|
47704
|
+
}, [data, onChange, onCellChange]);
|
|
47653
47705
|
var STORAGE_KEY = useMemo(function () {
|
|
47654
47706
|
return carto ? "Table:visibleColumns:".concat(carto) : "Table:visibleColumns";
|
|
47655
47707
|
}, [carto]);
|
|
47656
|
-
var
|
|
47657
|
-
_useState18 = _slicedToArray$c(_useState17, 2),
|
|
47658
|
-
visibleColumns = _useState18[0],
|
|
47659
|
-
setVisibleColumns = _useState18[1];
|
|
47660
|
-
var _useState19 = useState(false),
|
|
47708
|
+
var _useState19 = useState(columns),
|
|
47661
47709
|
_useState20 = _slicedToArray$c(_useState19, 2),
|
|
47662
|
-
|
|
47663
|
-
|
|
47664
|
-
var _useState21 = useState(
|
|
47710
|
+
visibleColumns = _useState20[0],
|
|
47711
|
+
setVisibleColumns = _useState20[1];
|
|
47712
|
+
var _useState21 = useState(false),
|
|
47665
47713
|
_useState22 = _slicedToArray$c(_useState21, 2),
|
|
47666
|
-
|
|
47667
|
-
|
|
47714
|
+
showColumnPicker = _useState22[0],
|
|
47715
|
+
setShowColumnPicker = _useState22[1];
|
|
47716
|
+
var _useState23 = useState(''),
|
|
47717
|
+
_useState24 = _slicedToArray$c(_useState23, 2),
|
|
47718
|
+
globalFilter = _useState24[0],
|
|
47719
|
+
setGlobalFilter = _useState24[1];
|
|
47668
47720
|
useEffect(function () {
|
|
47669
47721
|
var nextVisible = columns;
|
|
47670
47722
|
var defaultVisible = columns.filter(function (c) {
|
|
@@ -47687,9 +47739,9 @@ var Table = function Table(_ref7) {
|
|
|
47687
47739
|
|
|
47688
47740
|
var linkTemplate = useCallback(function (col) {
|
|
47689
47741
|
return function (rowData) {
|
|
47690
|
-
var
|
|
47742
|
+
var _ref0, _col$href;
|
|
47691
47743
|
var label = rowData[col.field];
|
|
47692
|
-
var href = typeof col.href === 'function' ? col.href(rowData) : (
|
|
47744
|
+
var href = typeof col.href === 'function' ? col.href(rowData) : (_ref0 = (_col$href = col.href) !== null && _col$href !== void 0 ? _col$href : rowData[col.field + 'Url']) !== null && _ref0 !== void 0 ? _ref0 : '#';
|
|
47693
47745
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
47694
47746
|
className: "arengi-table-grey-title-box"
|
|
47695
47747
|
}, /*#__PURE__*/React__default.createElement("a", {
|
|
@@ -47847,13 +47899,14 @@ var Table = function Table(_ref7) {
|
|
|
47847
47899
|
return /*#__PURE__*/React__default.createElement(DeviseBodyCell, {
|
|
47848
47900
|
rowData: rowData,
|
|
47849
47901
|
col: col,
|
|
47850
|
-
editable: editable && col.editable !== false,
|
|
47902
|
+
editable: editable || rowEdit && col.editable !== false,
|
|
47903
|
+
isRowEditing: rowEdit && !!editingRows[rowData.id],
|
|
47851
47904
|
onSave: function onSave(newVal) {
|
|
47852
47905
|
return updateRow(rowData.id, col.field, newVal);
|
|
47853
47906
|
}
|
|
47854
47907
|
});
|
|
47855
47908
|
};
|
|
47856
|
-
}, [editable, updateRow]);
|
|
47909
|
+
}, [editable, rowEdit, editingRows, updateRow]);
|
|
47857
47910
|
var deviseEditor = useCallback(function () {
|
|
47858
47911
|
return undefined;
|
|
47859
47912
|
}, []);
|
|
@@ -47977,13 +48030,14 @@ var Table = function Table(_ref7) {
|
|
|
47977
48030
|
return /*#__PURE__*/React__default.createElement(TreeSelectBodyCell, {
|
|
47978
48031
|
rowData: rowData,
|
|
47979
48032
|
col: col,
|
|
47980
|
-
editable: editable && col.editable !== false,
|
|
48033
|
+
editable: editable || rowEdit && col.editable !== false,
|
|
48034
|
+
isRowEditing: rowEdit && !!editingRows[rowData.id],
|
|
47981
48035
|
onSave: function onSave(newVal) {
|
|
47982
48036
|
return updateRow(rowData.id, col.field, newVal);
|
|
47983
48037
|
}
|
|
47984
48038
|
});
|
|
47985
48039
|
};
|
|
47986
|
-
}, [editable, updateRow]);
|
|
48040
|
+
}, [editable, rowEdit, editingRows, updateRow]);
|
|
47987
48041
|
var treeSelectEditor = useCallback(function () {
|
|
47988
48042
|
return undefined;
|
|
47989
48043
|
}, []);
|
|
@@ -48012,6 +48066,7 @@ var Table = function Table(_ref7) {
|
|
|
48012
48066
|
}
|
|
48013
48067
|
}, [editable, textEditor, dateEditor, selectEditor, selectMultipleEditor, numericEditor, documentEditor, deviseEditor, treeSelectEditor]);
|
|
48014
48068
|
var onCellEditComplete = useCallback(function (e) {
|
|
48069
|
+
if (rowEdit) return;
|
|
48015
48070
|
var rowData = e.rowData,
|
|
48016
48071
|
newRowData = e.newRowData,
|
|
48017
48072
|
field = e.field;
|
|
@@ -48030,7 +48085,7 @@ var Table = function Table(_ref7) {
|
|
|
48030
48085
|
field: field,
|
|
48031
48086
|
newValue: newRowData[field]
|
|
48032
48087
|
});
|
|
48033
|
-
}, [data, onChange, onCellChange, columns]);
|
|
48088
|
+
}, [data, onChange, onCellChange, columns, rowEdit]);
|
|
48034
48089
|
|
|
48035
48090
|
/** Get the body renderer for a column based on its type */
|
|
48036
48091
|
var getBodyTemplate = useCallback(function (col) {
|
|
@@ -48183,9 +48238,12 @@ var Table = function Table(_ref7) {
|
|
|
48183
48238
|
selection: selection,
|
|
48184
48239
|
onSelectionChange: onSelectionChange,
|
|
48185
48240
|
globalFilter: globalFilter,
|
|
48186
|
-
editMode: editable || columns.some(function (c) {
|
|
48241
|
+
editMode: editable || rowEdit || columns.some(function (c) {
|
|
48187
48242
|
return c.editable === true;
|
|
48188
|
-
}) ? 'cell' : undefined,
|
|
48243
|
+
}) ? rowEdit ? 'row' : 'cell' : undefined,
|
|
48244
|
+
editingRows: rowEdit ? editingRows : undefined,
|
|
48245
|
+
onRowEditChange: rowEdit ? onRowEditChange : undefined,
|
|
48246
|
+
onRowEditComplete: rowEdit ? onRowEditComplete : undefined,
|
|
48189
48247
|
dataKey: "id",
|
|
48190
48248
|
tableClassName: '',
|
|
48191
48249
|
resizableColumns: true,
|
|
@@ -48205,12 +48263,23 @@ var Table = function Table(_ref7) {
|
|
|
48205
48263
|
header: col.header,
|
|
48206
48264
|
body: getBodyTemplate(col),
|
|
48207
48265
|
editor: getEditorTemplate(col),
|
|
48208
|
-
onCellEditComplete: (editable ? col.editable !== false : col.editable === true) ? onCellEditComplete : undefined,
|
|
48266
|
+
onCellEditComplete: !rowEdit && (editable ? col.editable !== false : col.editable === true) ? onCellEditComplete : undefined,
|
|
48209
48267
|
className: col.field === 'nom' ? 'arengi-table-grey-title' : 'hide1time',
|
|
48210
48268
|
style: {
|
|
48211
48269
|
minWidth: (_col$minWidth = col.minWidth) !== null && _col$minWidth !== void 0 ? _col$minWidth : '200px'
|
|
48212
48270
|
}
|
|
48213
48271
|
});
|
|
48272
|
+
}), rowEdit && /*#__PURE__*/React__default.createElement(Column, {
|
|
48273
|
+
rowEditor: true,
|
|
48274
|
+
headerStyle: {
|
|
48275
|
+
width: '6rem',
|
|
48276
|
+
minWidth: '6rem'
|
|
48277
|
+
},
|
|
48278
|
+
bodyStyle: {
|
|
48279
|
+
textAlign: 'center'
|
|
48280
|
+
},
|
|
48281
|
+
frozen: true,
|
|
48282
|
+
alignFrozen: "right"
|
|
48214
48283
|
})));
|
|
48215
48284
|
};
|
|
48216
48285
|
|