arengibook 3.1.311-main → 3.1.313-main
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 +124 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37028,6 +37028,7 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37028
37028
|
optionLabel = _ref$optionLabel === void 0 ? 'label' : _ref$optionLabel,
|
|
37029
37029
|
_ref$optionValue = _ref.optionValue,
|
|
37030
37030
|
optionValue = _ref$optionValue === void 0 ? 'value' : _ref$optionValue,
|
|
37031
|
+
optionsUrl = _ref.optionsUrl,
|
|
37031
37032
|
_ref$invalid = _ref.invalid,
|
|
37032
37033
|
invalid = _ref$invalid === void 0 ? false : _ref$invalid,
|
|
37033
37034
|
_ref$errorMessage = _ref.errorMessage,
|
|
@@ -37115,6 +37116,94 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37115
37116
|
style: styleLabel
|
|
37116
37117
|
}, option === null || option === void 0 ? void 0 : option[optionLabel])));
|
|
37117
37118
|
};
|
|
37119
|
+
|
|
37120
|
+
// 🔹 Chargement des options depuis une URL (même contrat que MultiSelectMetaAsync)
|
|
37121
|
+
var fetchOptionsFromUrl = /*#__PURE__*/function () {
|
|
37122
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
37123
|
+
var search,
|
|
37124
|
+
_ref4,
|
|
37125
|
+
_ref4$page,
|
|
37126
|
+
page,
|
|
37127
|
+
length,
|
|
37128
|
+
start,
|
|
37129
|
+
queryParams,
|
|
37130
|
+
response,
|
|
37131
|
+
responseJSON,
|
|
37132
|
+
dataAjax,
|
|
37133
|
+
mappedOptions,
|
|
37134
|
+
hasMore,
|
|
37135
|
+
_args = arguments,
|
|
37136
|
+
_t;
|
|
37137
|
+
return _regenerator().w(function (_context) {
|
|
37138
|
+
while (1) switch (_context.n) {
|
|
37139
|
+
case 0:
|
|
37140
|
+
search = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
37141
|
+
_ref4 = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}, _ref4$page = _ref4.page, page = _ref4$page === void 0 ? 1 : _ref4$page;
|
|
37142
|
+
_context.p = 1;
|
|
37143
|
+
length = 25;
|
|
37144
|
+
start = (page - 1) * length;
|
|
37145
|
+
queryParams = new URLSearchParams();
|
|
37146
|
+
if (search) queryParams.append('search[value]', search);
|
|
37147
|
+
queryParams.append('start', start);
|
|
37148
|
+
queryParams.append('length', length);
|
|
37149
|
+
_context.n = 2;
|
|
37150
|
+
return fetch("".concat(optionsUrl, "?").concat(queryParams.toString()));
|
|
37151
|
+
case 2:
|
|
37152
|
+
response = _context.v;
|
|
37153
|
+
if (response.ok) {
|
|
37154
|
+
_context.n = 4;
|
|
37155
|
+
break;
|
|
37156
|
+
}
|
|
37157
|
+
if (!(response.status === 404)) {
|
|
37158
|
+
_context.n = 3;
|
|
37159
|
+
break;
|
|
37160
|
+
}
|
|
37161
|
+
return _context.a(2, {
|
|
37162
|
+
options: [],
|
|
37163
|
+
hasMore: false
|
|
37164
|
+
});
|
|
37165
|
+
case 3:
|
|
37166
|
+
throw new Error("Erreur HTTP: ".concat(response.status));
|
|
37167
|
+
case 4:
|
|
37168
|
+
_context.n = 5;
|
|
37169
|
+
return response.json();
|
|
37170
|
+
case 5:
|
|
37171
|
+
responseJSON = _context.v;
|
|
37172
|
+
dataAjax = responseJSON.data || [];
|
|
37173
|
+
mappedOptions = dataAjax.map(function (opt) {
|
|
37174
|
+
if (opt.hasOwnProperty('color') && opt.color !== null && opt.color.length > 0) {
|
|
37175
|
+
opt.color = opt.color.toLowerCase();
|
|
37176
|
+
} else {
|
|
37177
|
+
delete opt.color;
|
|
37178
|
+
}
|
|
37179
|
+
opt.label = opt.nom !== undefined && opt.nom !== null ? opt.nom : opt.label;
|
|
37180
|
+
opt.value = opt.id;
|
|
37181
|
+
return opt;
|
|
37182
|
+
});
|
|
37183
|
+
hasMore = start + dataAjax.length < responseJSON.recordsTotal;
|
|
37184
|
+
return _context.a(2, {
|
|
37185
|
+
options: mappedOptions,
|
|
37186
|
+
hasMore: hasMore,
|
|
37187
|
+
additional: {
|
|
37188
|
+
page: page + 1
|
|
37189
|
+
}
|
|
37190
|
+
});
|
|
37191
|
+
case 6:
|
|
37192
|
+
_context.p = 6;
|
|
37193
|
+
_t = _context.v;
|
|
37194
|
+
console.error("Erreur lors de la récupération des options :", _t);
|
|
37195
|
+
return _context.a(2, {
|
|
37196
|
+
options: [],
|
|
37197
|
+
hasMore: false
|
|
37198
|
+
});
|
|
37199
|
+
}
|
|
37200
|
+
}, _callee, null, [[1, 6]]);
|
|
37201
|
+
}));
|
|
37202
|
+
return function fetchOptionsFromUrl() {
|
|
37203
|
+
return _ref3.apply(this, arguments);
|
|
37204
|
+
};
|
|
37205
|
+
}();
|
|
37206
|
+
var loadOptions = typeof options === 'function' ? options : fetchOptionsFromUrl;
|
|
37118
37207
|
var isInvalidEffective = invalid || showRequiredError;
|
|
37119
37208
|
var style = {
|
|
37120
37209
|
border: isInvalidEffective ? '1px solid red' : '1px solid #ccc',
|
|
@@ -37127,17 +37216,17 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37127
37216
|
useEffect(function () {
|
|
37128
37217
|
setOptionSelected(objValue ? objValue === null || objValue === void 0 ? void 0 : objValue[optionValue] : value !== null && value !== void 0 ? value : null);
|
|
37129
37218
|
var loadInitialOptions = /*#__PURE__*/function () {
|
|
37130
|
-
var
|
|
37219
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
37131
37220
|
var result, _result$options, exists;
|
|
37132
|
-
return _regenerator().w(function (
|
|
37133
|
-
while (1) switch (
|
|
37221
|
+
return _regenerator().w(function (_context2) {
|
|
37222
|
+
while (1) switch (_context2.n) {
|
|
37134
37223
|
case 0:
|
|
37135
|
-
|
|
37136
|
-
return
|
|
37224
|
+
_context2.n = 1;
|
|
37225
|
+
return loadOptions('', [], {
|
|
37137
37226
|
page: 1
|
|
37138
37227
|
});
|
|
37139
37228
|
case 1:
|
|
37140
|
-
result =
|
|
37229
|
+
result = _context2.v;
|
|
37141
37230
|
setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
|
|
37142
37231
|
if (objValue) {
|
|
37143
37232
|
exists = result === null || result === void 0 || (_result$options = result.options) === null || _result$options === void 0 ? void 0 : _result$options.some(function (opt) {
|
|
@@ -37150,12 +37239,12 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37150
37239
|
}
|
|
37151
37240
|
}
|
|
37152
37241
|
case 2:
|
|
37153
|
-
return
|
|
37242
|
+
return _context2.a(2);
|
|
37154
37243
|
}
|
|
37155
|
-
},
|
|
37244
|
+
}, _callee2);
|
|
37156
37245
|
}));
|
|
37157
37246
|
return function loadInitialOptions() {
|
|
37158
|
-
return
|
|
37247
|
+
return _ref5.apply(this, arguments);
|
|
37159
37248
|
};
|
|
37160
37249
|
}();
|
|
37161
37250
|
loadInitialOptions();
|
|
@@ -37163,7 +37252,7 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37163
37252
|
return function () {
|
|
37164
37253
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
37165
37254
|
};
|
|
37166
|
-
}, [options, objValue, value]);
|
|
37255
|
+
}, [options, optionsUrl, objValue, value]);
|
|
37167
37256
|
var handleClickOutside = function handleClickOutside(event) {
|
|
37168
37257
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
37169
37258
|
setIsEditing(false);
|
|
@@ -37198,51 +37287,51 @@ var DropdownSelectMetaAsync = function DropdownSelectMetaAsync(_ref) {
|
|
|
37198
37287
|
setOptionSelected(null);
|
|
37199
37288
|
setInputValue('');
|
|
37200
37289
|
if (onChange) onChange(null);
|
|
37201
|
-
|
|
37290
|
+
loadOptions('', [], {
|
|
37202
37291
|
page: 1
|
|
37203
37292
|
}).then(function (result) {
|
|
37204
37293
|
setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
|
|
37205
37294
|
});
|
|
37206
37295
|
};
|
|
37207
37296
|
var handleInputChange = /*#__PURE__*/function () {
|
|
37208
|
-
var
|
|
37297
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(e) {
|
|
37209
37298
|
var search, result, _result$options2, _result, filteredOptions;
|
|
37210
|
-
return _regenerator().w(function (
|
|
37211
|
-
while (1) switch (
|
|
37299
|
+
return _regenerator().w(function (_context3) {
|
|
37300
|
+
while (1) switch (_context3.n) {
|
|
37212
37301
|
case 0:
|
|
37213
37302
|
search = e.target.value;
|
|
37214
37303
|
setInputValue(search);
|
|
37215
37304
|
if (search) {
|
|
37216
|
-
|
|
37305
|
+
_context3.n = 2;
|
|
37217
37306
|
break;
|
|
37218
37307
|
}
|
|
37219
|
-
|
|
37220
|
-
return
|
|
37308
|
+
_context3.n = 1;
|
|
37309
|
+
return loadOptions('', [], {
|
|
37221
37310
|
page: 1
|
|
37222
37311
|
});
|
|
37223
37312
|
case 1:
|
|
37224
|
-
result =
|
|
37313
|
+
result = _context3.v;
|
|
37225
37314
|
setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
|
|
37226
|
-
|
|
37315
|
+
_context3.n = 4;
|
|
37227
37316
|
break;
|
|
37228
37317
|
case 2:
|
|
37229
|
-
|
|
37230
|
-
return
|
|
37318
|
+
_context3.n = 3;
|
|
37319
|
+
return loadOptions(search, [], {
|
|
37231
37320
|
page: 1
|
|
37232
37321
|
});
|
|
37233
37322
|
case 3:
|
|
37234
|
-
_result =
|
|
37323
|
+
_result = _context3.v;
|
|
37235
37324
|
filteredOptions = (_result === null || _result === void 0 || (_result$options2 = _result.options) === null || _result$options2 === void 0 ? void 0 : _result$options2.filter(function (opt) {
|
|
37236
37325
|
return opt[optionLabel].toLowerCase().includes(search.toLowerCase());
|
|
37237
37326
|
})) || [];
|
|
37238
37327
|
setLoadedOptions(filteredOptions);
|
|
37239
37328
|
case 4:
|
|
37240
|
-
return
|
|
37329
|
+
return _context3.a(2);
|
|
37241
37330
|
}
|
|
37242
|
-
},
|
|
37331
|
+
}, _callee3);
|
|
37243
37332
|
}));
|
|
37244
37333
|
return function handleInputChange(_x) {
|
|
37245
|
-
return
|
|
37334
|
+
return _ref6.apply(this, arguments);
|
|
37246
37335
|
};
|
|
37247
37336
|
}();
|
|
37248
37337
|
var selectedOption = loadedOptions.find(function (opt) {
|
|
@@ -37519,10 +37608,11 @@ var Dropdown = function Dropdown(props) {
|
|
|
37519
37608
|
_props$subItem = props.subItem,
|
|
37520
37609
|
subItem = _props$subItem === void 0 ? false : _props$subItem,
|
|
37521
37610
|
_props$required = props.required,
|
|
37522
|
-
required = _props$required === void 0 ? false : _props$required
|
|
37611
|
+
required = _props$required === void 0 ? false : _props$required,
|
|
37612
|
+
optionsUrl = props.optionsUrl;
|
|
37523
37613
|
|
|
37524
37614
|
// --- Async delegation ---
|
|
37525
|
-
var isAsyncOptions = typeof options === 'function';
|
|
37615
|
+
var isAsyncOptions = typeof options === 'function' || optionsUrl;
|
|
37526
37616
|
if (isAsyncOptions) {
|
|
37527
37617
|
return /*#__PURE__*/React__default.createElement(DropdownSelectMetaAsync, props);
|
|
37528
37618
|
}
|
|
@@ -55781,25 +55871,15 @@ var Table$1 = function Table(_ref13) {
|
|
|
55781
55871
|
return updated;
|
|
55782
55872
|
});
|
|
55783
55873
|
};
|
|
55784
|
-
var attributeDataFields = useCallback(function (row, field) {
|
|
55785
|
-
var _row$attributeData;
|
|
55786
|
-
var col = columns.find(function (c) {
|
|
55787
|
-
return c.field === field;
|
|
55788
|
-
});
|
|
55789
|
-
if (!col || col.attributeData === undefined) return {};
|
|
55790
|
-
return {
|
|
55791
|
-
attributeData: _objectSpread2(_objectSpread2({}, (_row$attributeData = row === null || row === void 0 ? void 0 : row.attributeData) !== null && _row$attributeData !== void 0 ? _row$attributeData : {}), {}, _defineProperty$g({}, field, col.attributeData))
|
|
55792
|
-
};
|
|
55793
|
-
}, [columns]);
|
|
55794
55874
|
var updateRow = useCallback(function (rowId, field, newVal) {
|
|
55795
55875
|
setData(function (prev) {
|
|
55796
55876
|
var updated = prev.map(function (row) {
|
|
55797
|
-
return row.id === rowId ? _objectSpread2(_objectSpread2({}, row), {}, _defineProperty$g({}, field, newVal)
|
|
55877
|
+
return row.id === rowId ? _objectSpread2(_objectSpread2({}, row), {}, _defineProperty$g({}, field, newVal)) : row;
|
|
55798
55878
|
});
|
|
55799
55879
|
onChange === null || onChange === void 0 || onChange(updated);
|
|
55800
55880
|
return updated;
|
|
55801
55881
|
});
|
|
55802
|
-
}, [onChange
|
|
55882
|
+
}, [onChange]);
|
|
55803
55883
|
var handleAddRow = useCallback(function () {
|
|
55804
55884
|
// id temporaire négatif pour éviter les collisions avec les id BDD positifs
|
|
55805
55885
|
var newRow = {
|
|
@@ -56804,7 +56884,6 @@ var Table$1 = function Table(_ref13) {
|
|
|
56804
56884
|
enrichedRow = _objectSpread2(_objectSpread2({}, newRowData), extra);
|
|
56805
56885
|
}
|
|
56806
56886
|
}
|
|
56807
|
-
enrichedRow = _objectSpread2(_objectSpread2({}, enrichedRow), attributeDataFields(rowData, field));
|
|
56808
56887
|
var updated = data.map(function (row) {
|
|
56809
56888
|
return row.id === rowData.id ? enrichedRow : row;
|
|
56810
56889
|
});
|
|
@@ -56815,7 +56894,7 @@ var Table$1 = function Table(_ref13) {
|
|
|
56815
56894
|
field: field,
|
|
56816
56895
|
newValue: newRowData[field]
|
|
56817
56896
|
});
|
|
56818
|
-
}, [data, onChange, columns
|
|
56897
|
+
}, [data, onChange, columns]);
|
|
56819
56898
|
|
|
56820
56899
|
/** Get the body renderer for a column based on its type */
|
|
56821
56900
|
var getBodyTemplate = useCallback(function (col) {
|
|
@@ -56947,6 +57026,7 @@ var Table$1 = function Table(_ref13) {
|
|
|
56947
57026
|
rowData: rowData,
|
|
56948
57027
|
col: col,
|
|
56949
57028
|
editable: colEditable,
|
|
57029
|
+
isRowEditing: !!editingRows[rowData.id],
|
|
56950
57030
|
onSave: function onSave(v) {
|
|
56951
57031
|
var _onCellChangeRef$curr2;
|
|
56952
57032
|
var enrichedFields = _defineProperty$g({}, col.field, v);
|
|
@@ -56966,7 +57046,7 @@ var Table$1 = function Table(_ref13) {
|
|
|
56966
57046
|
}
|
|
56967
57047
|
setData(function (prev) {
|
|
56968
57048
|
var updated = prev.map(function (r) {
|
|
56969
|
-
return r.id === rowData.id ? _objectSpread2(_objectSpread2(
|
|
57049
|
+
return r.id === rowData.id ? _objectSpread2(_objectSpread2({}, r), enrichedFields) : r;
|
|
56970
57050
|
});
|
|
56971
57051
|
onChange === null || onChange === void 0 || onChange(updated);
|
|
56972
57052
|
return updated;
|
|
@@ -56977,7 +57057,6 @@ var Table$1 = function Table(_ref13) {
|
|
|
56977
57057
|
newValue: v
|
|
56978
57058
|
});
|
|
56979
57059
|
},
|
|
56980
|
-
isRowEditing: !!editingRows[rowData.id],
|
|
56981
57060
|
renderDisplay: displayFn !== null && displayFn !== void 0 ? displayFn : function (rd) {
|
|
56982
57061
|
var _rd$col$field;
|
|
56983
57062
|
return (_rd$col$field = rd[col.field]) !== null && _rd$col$field !== void 0 ? _rd$col$field : '';
|
|
@@ -57003,7 +57082,7 @@ var Table$1 = function Table(_ref13) {
|
|
|
57003
57082
|
};
|
|
57004
57083
|
}
|
|
57005
57084
|
return displayFn;
|
|
57006
|
-
}, [rowEdit, lockable, effectiveEditable, editingRows, updateRow, onChange, onCellChangeRef, onButtonClick, cellClickEnabled, linkTemplate, dateTemplate, selectTemplate, lienFormulaireTemplate, selectMultipleTemplate, colorTextTemplate, pictoTemplate, textTemplate, numericTemplate, badgesTemplate, calculTemplate, documentTemplate, deviseTemplate, treeSelectTemplate, htmlTemplate, journalTemplate
|
|
57085
|
+
}, [rowEdit, lockable, effectiveEditable, editingRows, updateRow, onChange, onCellChangeRef, onButtonClick, cellClickEnabled, linkTemplate, dateTemplate, selectTemplate, lienFormulaireTemplate, selectMultipleTemplate, colorTextTemplate, pictoTemplate, textTemplate, numericTemplate, badgesTemplate, calculTemplate, documentTemplate, deviseTemplate, treeSelectTemplate, htmlTemplate, journalTemplate]);
|
|
57007
57086
|
var getSortField = useCallback(function (col) {
|
|
57008
57087
|
return col.field;
|
|
57009
57088
|
}, []);
|
|
@@ -58141,12 +58220,7 @@ var columnsTyped = [
|
|
|
58141
58220
|
header: 'Inscription',
|
|
58142
58221
|
type: 'date',
|
|
58143
58222
|
editable: true,
|
|
58144
|
-
dbDateFormat: 'MMMM/y'
|
|
58145
|
-
attributeData: {
|
|
58146
|
-
'data-value': 'bonjour',
|
|
58147
|
-
'data-tata': 'hello',
|
|
58148
|
-
'data-tab': []
|
|
58149
|
-
}
|
|
58223
|
+
dbDateFormat: 'MMMM/y'
|
|
58150
58224
|
}, {
|
|
58151
58225
|
field: 'dateNaissance',
|
|
58152
58226
|
header: 'Naissance',
|