arengibook 2.4.591 → 2.4.592

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.
Files changed (2) hide show
  1. package/dist/index.js +119 -59
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35948,8 +35948,6 @@ var PopupPresets = {
35948
35948
  var Dropdown = function Dropdown(_ref) {
35949
35949
  var _ref$options = _ref.options,
35950
35950
  options = _ref$options === void 0 ? [] : _ref$options,
35951
- _ref$optionLoad = _ref.optionLoad,
35952
- optionLoad = _ref$optionLoad === void 0 ? null : _ref$optionLoad,
35953
35951
  _ref$isGroupedOption = _ref.isGroupedOption,
35954
35952
  isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
35955
35953
  value = _ref.value,
@@ -36000,22 +35998,86 @@ var Dropdown = function Dropdown(_ref) {
36000
35998
  _useState2 = _slicedToArray$8(_useState, 2),
36001
35999
  optionSelected = _useState2[0],
36002
36000
  setOptionSelected = _useState2[1];
36003
- var items = useRef([]);
36001
+ useRef([]);
36004
36002
  var _useState3 = useState(false),
36005
36003
  _useState4 = _slicedToArray$8(_useState3, 2),
36006
36004
  loading = _useState4[0],
36007
36005
  setLoading = _useState4[1];
36008
- var loadedOptionsRef = useRef([]);
36006
+ useRef([]);
36009
36007
  var currentPageRef = useRef(1);
36010
- var isLazy = typeof optionLoad === 'function';
36008
+ var _useState5 = useState([]),
36009
+ _useState6 = _slicedToArray$8(_useState5, 2),
36010
+ loadedOptions = _useState6[0],
36011
+ setLoadedOptions = _useState6[1];
36012
+ var isOptionLoadFunction = typeof options === 'function';
36013
+
36014
+ // useEffect(() => {
36015
+ // if (isOptionLoadFunction) {
36016
+ // const loadOptions = async () => {
36017
+ // setLoading(true);
36018
+ // try {
36019
+ // const result = await options();
36020
+ // setLoadedOptions(result);
36021
+ // } catch (err) {
36022
+ // console.error('Erreur lors du chargement des options:', err);
36023
+ // } finally {
36024
+ // setLoading(false);
36025
+ // }
36026
+ // };
36027
+ //
36028
+ // loadOptions();
36029
+ // } else {
36030
+ // setLoadedOptions(options);
36031
+ // }
36032
+ // }, [options, isOptionLoadFunction]);
36033
+
36034
+ useEffect(function () {
36035
+ var loadOptions = /*#__PURE__*/function () {
36036
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
36037
+ var result, _t;
36038
+ return _regenerator().w(function (_context) {
36039
+ while (1) switch (_context.n) {
36040
+ case 0:
36041
+ if (!isOptionLoadFunction) {
36042
+ _context.n = 6;
36043
+ break;
36044
+ }
36045
+ setLoading(true);
36046
+ _context.p = 1;
36047
+ _context.n = 2;
36048
+ return options();
36049
+ case 2:
36050
+ result = _context.v;
36051
+ setLoadedOptions(Array.isArray(result.options) ? result.options : []);
36052
+ _context.n = 4;
36053
+ break;
36054
+ case 3:
36055
+ _context.p = 3;
36056
+ _t = _context.v;
36057
+ console.error('Erreur lors du chargement des options:', _t);
36058
+ case 4:
36059
+ _context.p = 4;
36060
+ setLoading(false);
36061
+ return _context.f(4);
36062
+ case 5:
36063
+ _context.n = 7;
36064
+ break;
36065
+ case 6:
36066
+ setLoadedOptions(options);
36067
+ case 7:
36068
+ return _context.a(2);
36069
+ }
36070
+ }, _callee, null, [[1, 3, 4, 5]]);
36071
+ }));
36072
+ return function loadOptions() {
36073
+ return _ref2.apply(this, arguments);
36074
+ };
36075
+ }();
36076
+ loadOptions();
36077
+ }, [options, isOptionLoadFunction]);
36011
36078
  useEffect(function () {
36012
36079
  setOptionSelected(value !== null && value !== void 0 ? value : null);
36013
36080
  }, [value]);
36014
- useEffect(function () {
36015
- if (!isLazy) {
36016
- items.current = options;
36017
- }
36018
- }, [options, isLazy]);
36019
36081
  var style = {
36020
36082
  border: invalid ? '1px solid red' : '1px solid #ccc',
36021
36083
  width: '100%'
@@ -36035,9 +36097,9 @@ var Dropdown = function Dropdown(_ref) {
36035
36097
  }, optionStyle)
36036
36098
  }, option === null || option === void 0 ? void 0 : option[optionLabel]);
36037
36099
  } else {
36038
- var _ref2 = selectMetaConfig || {},
36039
- labelStyle = _ref2.labelStyle,
36040
- generalIcon = _ref2.generalIcon;
36100
+ var _ref3 = selectMetaConfig || {},
36101
+ labelStyle = _ref3.labelStyle,
36102
+ generalIcon = _ref3.generalIcon;
36041
36103
  var styleLabel = {
36042
36104
  marginLeft: '10px'
36043
36105
  };
@@ -36091,48 +36153,49 @@ var Dropdown = function Dropdown(_ref) {
36091
36153
  }
36092
36154
  };
36093
36155
  var onLazyLoad = /*#__PURE__*/function () {
36094
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
36156
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
36095
36157
  var _event$filter;
36096
- var search, _res$options, _res$additional$page, _res$additional, res, newOptions, _t;
36097
- return _regenerator().w(function (_context) {
36098
- while (1) switch (_context.n) {
36158
+ var search, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
36159
+ return _regenerator().w(function (_context2) {
36160
+ while (1) switch (_context2.n) {
36099
36161
  case 0:
36100
- if (!(!isLazy || !optionLoad)) {
36101
- _context.n = 1;
36162
+ if (isOptionLoadFunction) {
36163
+ _context2.n = 1;
36102
36164
  break;
36103
36165
  }
36104
- return _context.a(2);
36166
+ return _context2.a(2);
36105
36167
  case 1:
36106
36168
  setLoading(true);
36107
36169
  search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : '';
36108
- _context.p = 2;
36109
- _context.n = 3;
36110
- return optionLoad(search, loadedOptionsRef.current, {
36170
+ _context2.p = 2;
36171
+ _context2.n = 3;
36172
+ return options(search, loadedOptions, {
36111
36173
  page: currentPageRef.current
36112
36174
  });
36113
36175
  case 3:
36114
- res = _context.v;
36176
+ res = _context2.v;
36115
36177
  newOptions = (_res$options = res === null || res === void 0 ? void 0 : res.options) !== null && _res$options !== void 0 ? _res$options : [];
36116
- loadedOptionsRef.current = [].concat(_toConsumableArray$6(loadedOptionsRef.current), _toConsumableArray$6(newOptions));
36117
- items.current = loadedOptionsRef.current;
36178
+ setLoadedOptions(function (prevOptions) {
36179
+ return [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
36180
+ });
36118
36181
  currentPageRef.current = (_res$additional$page = res === null || res === void 0 || (_res$additional = res.additional) === null || _res$additional === void 0 ? void 0 : _res$additional.page) !== null && _res$additional$page !== void 0 ? _res$additional$page : currentPageRef.current + 1;
36119
- _context.n = 5;
36182
+ _context2.n = 5;
36120
36183
  break;
36121
36184
  case 4:
36122
- _context.p = 4;
36123
- _t = _context.v;
36124
- console.error('Erreur optionLoad:', _t);
36185
+ _context2.p = 4;
36186
+ _t2 = _context2.v;
36187
+ console.error('Erreur lors du chargement des options:', _t2);
36125
36188
  case 5:
36126
- _context.p = 5;
36189
+ _context2.p = 5;
36127
36190
  setLoading(false);
36128
- return _context.f(5);
36191
+ return _context2.f(5);
36129
36192
  case 6:
36130
- return _context.a(2);
36193
+ return _context2.a(2);
36131
36194
  }
36132
- }, _callee, null, [[2, 4, 5, 6]]);
36195
+ }, _callee2, null, [[2, 4, 5, 6]]);
36133
36196
  }));
36134
36197
  return function onLazyLoad(_x) {
36135
- return _ref3.apply(this, arguments);
36198
+ return _ref4.apply(this, arguments);
36136
36199
  };
36137
36200
  }();
36138
36201
  var handleChange = function handleChange(e) {
@@ -36143,15 +36206,15 @@ var Dropdown = function Dropdown(_ref) {
36143
36206
  }
36144
36207
  };
36145
36208
  var groupedItemTemplate = function groupedItemTemplate(option) {
36146
- var _ref4 = groupedItemTemplateConfig || {},
36147
- showImage = _ref4.showImage,
36148
- imageKey = _ref4.imageKey,
36149
- imageStyle = _ref4.imageStyle,
36150
- showIcon = _ref4.showIcon,
36151
- iconKey = _ref4.iconKey,
36152
- labelStyle = _ref4.labelStyle,
36153
- generalIcon = _ref4.generalIcon,
36154
- generalImage = _ref4.generalImage;
36209
+ var _ref5 = groupedItemTemplateConfig || {},
36210
+ showImage = _ref5.showImage,
36211
+ imageKey = _ref5.imageKey,
36212
+ imageStyle = _ref5.imageStyle,
36213
+ showIcon = _ref5.showIcon,
36214
+ iconKey = _ref5.iconKey,
36215
+ labelStyle = _ref5.labelStyle,
36216
+ generalIcon = _ref5.generalIcon,
36217
+ generalImage = _ref5.generalImage;
36155
36218
  var icon = option.value && option.value[iconKey];
36156
36219
  var styleLabel = generalIcon || showImage && option[imageKey] || showIcon && icon ? {
36157
36220
  marginLeft: '10px'
@@ -36201,7 +36264,7 @@ var Dropdown = function Dropdown(_ref) {
36201
36264
  className: "flex flex-col gap-1"
36202
36265
  }, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
36203
36266
  value: optionSelected,
36204
- options: isLazy ? items.current : options,
36267
+ options: loadedOptions,
36205
36268
  onChange: handleChange,
36206
36269
  placeholder: placeholder,
36207
36270
  disabled: disabled,
@@ -36216,7 +36279,7 @@ var Dropdown = function Dropdown(_ref) {
36216
36279
  }, isGroupedOption && {
36217
36280
  optionGroupLabel: 'label',
36218
36281
  optionGroupChildren: 'items'
36219
- }, (isSelectMeta || isLazy) && {
36282
+ }, (isSelectMeta || isOptionLoadFunction) && {
36220
36283
  virtualScrollerOptions: {
36221
36284
  lazy: true,
36222
36285
  onLazyLoad: onLazyLoad,
@@ -36375,9 +36438,8 @@ var DropdownPresets = {
36375
36438
  },
36376
36439
  AsyncLoad: {
36377
36440
  placeholder: 'Chargement distant simulé',
36378
- options: [],
36379
- optionLoad: function () {
36380
- var _optionLoad = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
36441
+ options: function () {
36442
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
36381
36443
  var page, length, start, data;
36382
36444
  return _regenerator().w(function (_context) {
36383
36445
  while (1) switch (_context.n) {
@@ -36400,7 +36462,6 @@ var DropdownPresets = {
36400
36462
  });
36401
36463
  }),
36402
36464
  hasMore: page * length < 100,
36403
- // Supposons que nous avons 100 options au total
36404
36465
  additional: {
36405
36466
  page: page + 1
36406
36467
  }
@@ -36408,10 +36469,10 @@ var DropdownPresets = {
36408
36469
  }
36409
36470
  }, _callee);
36410
36471
  }));
36411
- function optionLoad(_x, _x2, _x3) {
36412
- return _optionLoad.apply(this, arguments);
36472
+ function options(_x, _x2, _x3) {
36473
+ return _options.apply(this, arguments);
36413
36474
  }
36414
- return optionLoad;
36475
+ return options;
36415
36476
  }(),
36416
36477
  selectMetaConfig: {
36417
36478
  generalIcon: 'pi pi-circle-fill'
@@ -36429,9 +36490,8 @@ var DropdownPresets = {
36429
36490
  AsyncSearch: {
36430
36491
  placeholder: 'Recherchez une option...',
36431
36492
  filter: true,
36432
- options: [],
36433
- optionLoad: function () {
36434
- var _optionLoad2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(search, loadedOptions, _ref2) {
36493
+ options: function () {
36494
+ var _options2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(search, loadedOptions, _ref2) {
36435
36495
  var page, length, allOptions, filteredOptions, start, pageSlice;
36436
36496
  return _regenerator().w(function (_context2) {
36437
36497
  while (1) switch (_context2.n) {
@@ -36464,10 +36524,10 @@ var DropdownPresets = {
36464
36524
  }
36465
36525
  }, _callee2);
36466
36526
  }));
36467
- function optionLoad(_x4, _x5, _x6) {
36468
- return _optionLoad2.apply(this, arguments);
36527
+ function options(_x4, _x5, _x6) {
36528
+ return _options2.apply(this, arguments);
36469
36529
  }
36470
- return optionLoad;
36530
+ return options;
36471
36531
  }(),
36472
36532
  isSelectMeta: true,
36473
36533
  selectMetaConfig: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.591",
4
+ "version": "2.4.592",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {