arengibook 2.4.626 → 2.4.628

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 +177 -154
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -36820,12 +36820,12 @@ var DropdownPresets = {
36820
36820
  }
36821
36821
  };
36822
36822
 
36823
- var simulateNetworkDelay = function simulateNetworkDelay() {
36823
+ var simulateNetworkDelay$2 = function simulateNetworkDelay() {
36824
36824
  return new Promise(function (res) {
36825
36825
  return setTimeout(res, 400);
36826
36826
  });
36827
36827
  };
36828
- var createFakeOptions = function createFakeOptions(start, length) {
36828
+ var createFakeOptions$2 = function createFakeOptions(start, length) {
36829
36829
  var options = [];
36830
36830
  for (var i = start; i < start + length; i++) {
36831
36831
  options.push({
@@ -36854,9 +36854,9 @@ var DropdownSelectMetaAsyncPresets = {
36854
36854
  search = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
36855
36855
  _ref = _args.length > 2 ? _args[2] : undefined, page = _ref.page;
36856
36856
  _context.n = 1;
36857
- return simulateNetworkDelay();
36857
+ return simulateNetworkDelay$2();
36858
36858
  case 1:
36859
- allOptions = createFakeOptions(0, 100);
36859
+ allOptions = createFakeOptions$2(0, 100);
36860
36860
  filtered = allOptions.filter(function (opt) {
36861
36861
  return opt.label.toLowerCase().includes(search.toLowerCase());
36862
36862
  });
@@ -39091,7 +39091,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39091
39091
  _ref$valueStyle = _ref.valueStyle,
39092
39092
  valueStyle = _ref$valueStyle === void 0 ? {} : _ref$valueStyle,
39093
39093
  _ref$filter = _ref.filter,
39094
- filter = _ref$filter === void 0 ? true : _ref$filter,
39094
+ filter = _ref$filter === void 0 ? false : _ref$filter,
39095
39095
  _ref$invalid = _ref.invalid,
39096
39096
  invalid = _ref$invalid === void 0 ? false : _ref$invalid,
39097
39097
  _ref$errorMessage = _ref.errorMessage,
@@ -39109,36 +39109,43 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39109
39109
  useCheckbox = _ref$useCheckbox === void 0 ? false : _ref$useCheckbox,
39110
39110
  _ref$showSelectAll = _ref.showSelectAll,
39111
39111
  showSelectAll = _ref$showSelectAll === void 0 ? true : _ref$showSelectAll;
39112
- // const [selectedOptions, setSelectedOptions] = useState(value ?? []);
39113
- var _useState = useState(objValue ? _toConsumableArray$7(objValue.map(function (opt) {
39114
- return opt[optionValue];
39115
- })) : value !== null && value !== void 0 ? value : []),
39112
+ var _useState = useState(null),
39116
39113
  _useState2 = _slicedToArray$9(_useState, 2),
39117
39114
  selectedOptions = _useState2[0],
39118
39115
  setSelectedOptions = _useState2[1];
39119
- var _useState3 = useState([]),
39120
- _useState4 = _slicedToArray$9(_useState3, 2),
39121
- loadedOptions = _useState4[0],
39122
- setLoadedOptions = _useState4[1];
39123
- var _useState5 = useState(''),
39116
+ var _useState3 = useState(null),
39117
+ _useState4 = _slicedToArray$9(_useState3, 2);
39118
+ _useState4[0];
39119
+ _useState4[1];
39120
+ var _useState5 = useState([]),
39124
39121
  _useState6 = _slicedToArray$9(_useState5, 2),
39125
- inputValue = _useState6[0];
39126
- _useState6[1];
39127
- var multiSelectRef = useRef(null);
39128
- var _useState7 = useState(false),
39122
+ loadedOptions = _useState6[0],
39123
+ setLoadedOptions = _useState6[1];
39124
+ var _useState7 = useState(''),
39129
39125
  _useState8 = _slicedToArray$9(_useState7, 2),
39130
- loading = _useState8[0],
39131
- setLoading = _useState8[1];
39126
+ inputValue = _useState8[0];
39127
+ _useState8[1];
39128
+ var multiSelectRef = useRef(null);
39129
+ var _useState9 = useState(false),
39130
+ _useState0 = _slicedToArray$9(_useState9, 2),
39131
+ loading = _useState0[0],
39132
+ setLoading = _useState0[1];
39132
39133
  var loadLazyTimeout = useRef();
39133
39134
  var currentPageRef = useRef(1);
39134
39135
  var isOptionsArray = Array.isArray(options);
39136
+ var numericValue = Array.isArray(value) ? value.map(function (v) {
39137
+ return typeof v === 'string' ? parseInt(v, 10) : v;
39138
+ }) : [];
39139
+ var numericObjValue = Array.isArray(objValue) ? objValue.map(function (opt) {
39140
+ return _objectSpread2(_objectSpread2({}, opt), {}, _defineProperty$b({}, optionValue, typeof opt[optionValue] === 'string' ? parseInt(opt[optionValue], 10) : opt[optionValue]));
39141
+ }) : null;
39135
39142
  useEffect(function () {
39136
39143
  if (isOptionsArray) {
39137
39144
  setLoadedOptions(options);
39138
39145
  } else {
39139
39146
  var loadInitialOptions = /*#__PURE__*/function () {
39140
39147
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
39141
- var result;
39148
+ var result, initialValues;
39142
39149
  return _regenerator().w(function (_context) {
39143
39150
  while (1) switch (_context.n) {
39144
39151
  case 0:
@@ -39149,6 +39156,10 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39149
39156
  case 1:
39150
39157
  result = _context.v;
39151
39158
  setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
39159
+ initialValues = numericObjValue ? numericObjValue.map(function (opt) {
39160
+ return opt[optionValue];
39161
+ }) : numericValue;
39162
+ setSelectedOptions(initialValues);
39152
39163
  case 2:
39153
39164
  return _context.a(2);
39154
39165
  }
@@ -39160,7 +39171,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39160
39171
  }();
39161
39172
  loadInitialOptions();
39162
39173
  }
39163
- }, [options]);
39174
+ }, [options, numericObjValue, numericValue]);
39164
39175
  useEffect(function () {
39165
39176
  var observer = new MutationObserver(function () {
39166
39177
  var panel = document.querySelector('.p-multiselect-panel.p-component');
@@ -39179,10 +39190,10 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39179
39190
 
39180
39191
  // Gestion du changement de sélection
39181
39192
  var handleChange = function handleChange(e) {
39193
+ console.log(selectedOptions);
39182
39194
  setSelectedOptions(e.value);
39183
39195
  if (onChange) onChange(e.value);
39184
39196
  };
39185
-
39186
39197
  // Inversion de couleur pour le texte des badges
39187
39198
  var inverseColor = function inverseColor(hexColor) {
39188
39199
  var r = parseInt(hexColor.substr(1, 2), 16);
@@ -39309,7 +39320,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39309
39320
  style: style,
39310
39321
  showSelectAll: showSelectAll,
39311
39322
  disabled: disabled,
39312
- filter: true,
39323
+ filter: filter,
39313
39324
  placeholder: placeholder,
39314
39325
  optionLabel: optionLabel,
39315
39326
  optionValue: optionValue,
@@ -39656,6 +39667,11 @@ var MultiSelect = function MultiSelect(props) {
39656
39667
  }, errorMessage || 'Sélection invalide')));
39657
39668
  };
39658
39669
 
39670
+ var simulateNetworkDelay$1 = function simulateNetworkDelay() {
39671
+ return new Promise(function (res) {
39672
+ return setTimeout(res, 400);
39673
+ });
39674
+ };
39659
39675
  var optionsExample = [{
39660
39676
  label: 'New York',
39661
39677
  value: 'NY'
@@ -39742,68 +39758,17 @@ var syncOptions$1 = [{
39742
39758
  value: '5',
39743
39759
  color: '#ec4899'
39744
39760
  }];
39745
- var asyncOptions$1 = /*#__PURE__*/function () {
39746
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, _, _ref) {
39747
- var page, mockOptions, startIndex, paginatedOptions;
39748
- return _regenerator().w(function (_context) {
39749
- while (1) switch (_context.n) {
39750
- case 0:
39751
- page = _ref.page;
39752
- mockOptions = [{
39753
- label: 'Option 1',
39754
- value: '1',
39755
- color: '#ff9900'
39756
- }, {
39757
- label: 'Option 2',
39758
- value: '2',
39759
- color: '#3b82f6'
39760
- }, {
39761
- label: 'Option 3',
39762
- value: '3',
39763
- color: '#10b981'
39764
- }, {
39765
- label: 'Option 4',
39766
- value: '4',
39767
- color: '#8b5cf6'
39768
- }, {
39769
- label: 'Option 5',
39770
- value: '5',
39771
- color: '#ec4899'
39772
- }, {
39773
- label: 'Option 6',
39774
- value: '6',
39775
- color: '#f59e0b'
39776
- }, {
39777
- label: 'Option 7',
39778
- value: '7',
39779
- color: '#ef4444'
39780
- }, {
39781
- label: 'Option 8',
39782
- value: '8',
39783
- color: '#10b981'
39784
- }, {
39785
- label: 'Option 9',
39786
- value: '9',
39787
- color: '#3b82f6'
39788
- }, {
39789
- label: 'Option 10',
39790
- value: '10',
39791
- color: '#8b5cf6'
39792
- }]; // Simulation de pagination
39793
- startIndex = (page - 1) * 5;
39794
- paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39795
- return _context.a(2, {
39796
- options: search ? mockOptions.filter(function (opt) {
39797
- return opt.label.toLowerCase().includes(search.toLowerCase());
39798
- }) : paginatedOptions
39799
- });
39800
- }
39801
- }, _callee);
39802
- }));
39803
- return function asyncOptions(_x, _x2, _x3) {
39804
- return _ref2.apply(this, arguments);
39805
- };
39806
- }();
39761
+ var createFakeOptions$1 = function createFakeOptions(start, length) {
39762
+ var options = [];
39763
+ for (var i = start; i < start + length; i++) {
39764
+ options.push({
39765
+ value: i,
39766
+ label: "Option ".concat(i),
39767
+ color: 'black'
39768
+ });
39769
+ }
39770
+ return options;
39771
+ };
39807
39772
  var MultiSelectPresets = {
39808
39773
  Default: {
39809
39774
  placeholder: 'Sélectionnez des options',
@@ -39888,17 +39853,55 @@ var MultiSelectPresets = {
39888
39853
  // Configuration pour les options asynchrones
39889
39854
  SelectMetaAsync: {
39890
39855
  isSelectMeta: true,
39891
- // value: ['3', '4', '5'],
39892
39856
  objValue: [{
39893
- label: 'Option 2',
39894
- value: '2',
39857
+ label: 'Option 9',
39858
+ value: '9',
39895
39859
  color: '#ff9900'
39896
39860
  }, {
39897
39861
  label: 'Option 4',
39898
39862
  value: '4',
39899
39863
  color: 'black'
39900
39864
  }],
39901
- options: asyncOptions$1,
39865
+ // value: ['3', '4'],
39866
+ options: function () {
39867
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
39868
+ var search,
39869
+ _ref3,
39870
+ page,
39871
+ allOptions,
39872
+ filtered,
39873
+ pageSize,
39874
+ start,
39875
+ _args2 = arguments;
39876
+ return _regenerator().w(function (_context2) {
39877
+ while (1) switch (_context2.n) {
39878
+ case 0:
39879
+ search = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
39880
+ _ref3 = _args2.length > 2 ? _args2[2] : undefined, page = _ref3.page;
39881
+ _context2.n = 1;
39882
+ return simulateNetworkDelay$1();
39883
+ case 1:
39884
+ allOptions = createFakeOptions$1(0, 100);
39885
+ filtered = allOptions.filter(function (opt) {
39886
+ return opt.label.toLowerCase().includes(search.toLowerCase());
39887
+ });
39888
+ pageSize = 30;
39889
+ start = (page - 1) * pageSize;
39890
+ return _context2.a(2, {
39891
+ options: filtered.slice(start, start + pageSize),
39892
+ hasMore: start + pageSize < filtered.length,
39893
+ additional: {
39894
+ page: page + 1
39895
+ }
39896
+ });
39897
+ }
39898
+ }, _callee2);
39899
+ }));
39900
+ function options() {
39901
+ return _options.apply(this, arguments);
39902
+ }
39903
+ return options;
39904
+ }(),
39902
39905
  placeholder: 'Sélectionnez une ou plusieurs options',
39903
39906
  optionLabel: 'label',
39904
39907
  optionValue: 'value',
@@ -39919,6 +39922,12 @@ var MultiSelectPresets = {
39919
39922
  }
39920
39923
  };
39921
39924
 
39925
+ var simulateNetworkDelay = function simulateNetworkDelay() {
39926
+ return new Promise(function (res) {
39927
+ return setTimeout(res, 400);
39928
+ });
39929
+ };
39930
+
39922
39931
  // Options synchrones (tableau)
39923
39932
  var syncOptions = [{
39924
39933
  label: 'Option 1',
@@ -39943,68 +39952,44 @@ var syncOptions = [{
39943
39952
  }];
39944
39953
 
39945
39954
  // Fonction pour simuler des options asynchrones
39946
- var asyncOptions = /*#__PURE__*/function () {
39947
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, _, _ref) {
39948
- var page, mockOptions, startIndex, paginatedOptions;
39949
- return _regenerator().w(function (_context) {
39950
- while (1) switch (_context.n) {
39951
- case 0:
39952
- page = _ref.page;
39953
- mockOptions = [{
39954
- label: 'Option 1',
39955
- value: '1',
39956
- color: '#ff9900'
39957
- }, {
39958
- label: 'Option 2',
39959
- value: '2',
39960
- color: '#3b82f6'
39961
- }, {
39962
- label: 'Option 3',
39963
- value: '3',
39964
- color: '#10b981'
39965
- }, {
39966
- label: 'Option 4',
39967
- value: '4',
39968
- color: '#8b5cf6'
39969
- }, {
39970
- label: 'Option 5',
39971
- value: '5',
39972
- color: '#ec4899'
39973
- }, {
39974
- label: 'Option 6',
39975
- value: '6',
39976
- color: '#f59e0b'
39977
- }, {
39978
- label: 'Option 7',
39979
- value: '7',
39980
- color: '#ef4444'
39981
- }, {
39982
- label: 'Option 8',
39983
- value: '8',
39984
- color: '#10b981'
39985
- }, {
39986
- label: 'Option 9',
39987
- value: '9',
39988
- color: '#3b82f6'
39989
- }, {
39990
- label: 'Option 10',
39991
- value: '10',
39992
- color: '#8b5cf6'
39993
- }]; // Simulation de pagination
39994
- startIndex = (page - 1) * 5;
39995
- paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39996
- return _context.a(2, {
39997
- options: search ? mockOptions.filter(function (opt) {
39998
- return opt.label.toLowerCase().includes(search.toLowerCase());
39999
- }) : paginatedOptions
40000
- });
40001
- }
40002
- }, _callee);
40003
- }));
40004
- return function asyncOptions(_x, _x2, _x3) {
40005
- return _ref2.apply(this, arguments);
40006
- };
40007
- }();
39955
+ // const asyncOptions = async (search, _, { page }) => {
39956
+ // const mockOptions = [
39957
+ // { label: 'Option 1', value: '1', color: '#ff9900' },
39958
+ // { label: 'Option 2', value: '2', color: '#3b82f6' },
39959
+ // { label: 'Option 3', value: '3', color: '#10b981' },
39960
+ // { label: 'Option 4', value: '4', color: '#8b5cf6' },
39961
+ // { label: 'Option 5', value: '5', color: '#ec4899' },
39962
+ // { label: 'Option 6', value: '6', color: '#f59e0b' },
39963
+ // { label: 'Option 7', value: '7', color: '#ef4444' },
39964
+ // { label: 'Option 8', value: '8', color: '#10b981' },
39965
+ // { label: 'Option 9', value: '9', color: '#3b82f6' },
39966
+ // { label: 'Option 10', value: '10', color: '#8b5cf6' },
39967
+ // ];
39968
+ //
39969
+ // // Simulation de pagination
39970
+ // const startIndex = (page - 1) * 5;
39971
+ // const paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39972
+ //
39973
+ // return {
39974
+ // options: search
39975
+ // ? mockOptions.filter(opt =>
39976
+ // opt.label.toLowerCase().includes(search.toLowerCase())
39977
+ // )
39978
+ // : paginatedOptions,
39979
+ // };
39980
+ // };
39981
+
39982
+ var createFakeOptions = function createFakeOptions(start, length) {
39983
+ var options = [];
39984
+ for (var i = start; i < start + length; i++) {
39985
+ options.push({
39986
+ value: i,
39987
+ label: "Option ".concat(i),
39988
+ color: 'black'
39989
+ });
39990
+ }
39991
+ return options;
39992
+ };
40008
39993
  var MultiSelectMetaAsyncPresets = {
40009
39994
  // Configuration pour les options synchrones
40010
39995
  SyncOptions: {
@@ -40030,8 +40015,46 @@ var MultiSelectMetaAsyncPresets = {
40030
40015
  },
40031
40016
  // Configuration pour les options asynchrones
40032
40017
  AsyncOptions: {
40033
- value: ['1', '2'],
40034
- options: asyncOptions,
40018
+ value: ['3', '4'],
40019
+ options: function () {
40020
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
40021
+ var search,
40022
+ _ref,
40023
+ page,
40024
+ allOptions,
40025
+ filtered,
40026
+ pageSize,
40027
+ start,
40028
+ _args = arguments;
40029
+ return _regenerator().w(function (_context) {
40030
+ while (1) switch (_context.n) {
40031
+ case 0:
40032
+ search = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
40033
+ _ref = _args.length > 2 ? _args[2] : undefined, page = _ref.page;
40034
+ _context.n = 1;
40035
+ return simulateNetworkDelay();
40036
+ case 1:
40037
+ allOptions = createFakeOptions(0, 100);
40038
+ filtered = allOptions.filter(function (opt) {
40039
+ return opt.label.toLowerCase().includes(search.toLowerCase());
40040
+ });
40041
+ pageSize = 30;
40042
+ start = (page - 1) * pageSize;
40043
+ return _context.a(2, {
40044
+ options: filtered.slice(start, start + pageSize),
40045
+ hasMore: start + pageSize < filtered.length,
40046
+ additional: {
40047
+ page: page + 1
40048
+ }
40049
+ });
40050
+ }
40051
+ }, _callee);
40052
+ }));
40053
+ function options() {
40054
+ return _options.apply(this, arguments);
40055
+ }
40056
+ return options;
40057
+ }(),
40035
40058
  placeholder: 'Sélectionnez une ou plusieurs options',
40036
40059
  optionLabel: 'label',
40037
40060
  optionValue: 'value',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.626",
4
+ "version": "2.4.628",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {