arengibook 2.4.625 → 2.4.627

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 +186 -155
  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,29 +39109,36 @@ 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 = value.map(function (v) {
39137
+ return typeof v === 'string' ? parseInt(v, 10) : v;
39138
+ });
39139
+ var numericObjValue = 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);
@@ -39149,6 +39156,9 @@ 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
+ setSelectedOptions(objValue ? _toConsumableArray$7(numericObjValue.map(function (opt) {
39160
+ return opt[optionValue];
39161
+ })) : numericValue !== null && numericValue !== void 0 ? numericValue : []);
39152
39162
  case 2:
39153
39163
  return _context.a(2);
39154
39164
  }
@@ -39160,7 +39170,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39160
39170
  }();
39161
39171
  loadInitialOptions();
39162
39172
  }
39163
- }, [options]);
39173
+ }, [options, objValue, value]);
39164
39174
  useEffect(function () {
39165
39175
  var observer = new MutationObserver(function () {
39166
39176
  var panel = document.querySelector('.p-multiselect-panel.p-component');
@@ -39179,10 +39189,10 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39179
39189
 
39180
39190
  // Gestion du changement de sélection
39181
39191
  var handleChange = function handleChange(e) {
39192
+ console.log(selectedOptions);
39182
39193
  setSelectedOptions(e.value);
39183
39194
  if (onChange) onChange(e.value);
39184
39195
  };
39185
-
39186
39196
  // Inversion de couleur pour le texte des badges
39187
39197
  var inverseColor = function inverseColor(hexColor) {
39188
39198
  var r = parseInt(hexColor.substr(1, 2), 16);
@@ -39299,14 +39309,17 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39299
39309
  };
39300
39310
  return /*#__PURE__*/React__default.createElement("div", {
39301
39311
  ref: multiSelectRef,
39302
- className: "flex flex-col gap-1"
39312
+ className: "flex flex-col gap-1",
39313
+ style: {
39314
+ width: '100%'
39315
+ }
39303
39316
  }, /*#__PURE__*/React__default.createElement(MultiSelect$1, {
39304
39317
  options: loadedOptions,
39305
39318
  onChange: handleChange,
39306
39319
  style: style,
39307
39320
  showSelectAll: showSelectAll,
39308
39321
  disabled: disabled,
39309
- filter: true,
39322
+ filter: filter,
39310
39323
  placeholder: placeholder,
39311
39324
  optionLabel: optionLabel,
39312
39325
  optionValue: optionValue,
@@ -39582,9 +39595,15 @@ var MultiSelect = function MultiSelect(props) {
39582
39595
  }
39583
39596
  };
39584
39597
  return /*#__PURE__*/React__default.createElement("div", {
39585
- className: "flex flex-col gap-1"
39598
+ className: "flex flex-col gap-1",
39599
+ style: {
39600
+ width: '100%'
39601
+ }
39586
39602
  }, /*#__PURE__*/React__default.createElement("div", {
39587
39603
  className: "multiselect-container",
39604
+ style: {
39605
+ width: '100%'
39606
+ },
39588
39607
  onMouseEnter: function onMouseEnter() {
39589
39608
  return setHovered(true);
39590
39609
  },
@@ -39647,6 +39666,11 @@ var MultiSelect = function MultiSelect(props) {
39647
39666
  }, errorMessage || 'Sélection invalide')));
39648
39667
  };
39649
39668
 
39669
+ var simulateNetworkDelay$1 = function simulateNetworkDelay() {
39670
+ return new Promise(function (res) {
39671
+ return setTimeout(res, 400);
39672
+ });
39673
+ };
39650
39674
  var optionsExample = [{
39651
39675
  label: 'New York',
39652
39676
  value: 'NY'
@@ -39733,68 +39757,17 @@ var syncOptions$1 = [{
39733
39757
  value: '5',
39734
39758
  color: '#ec4899'
39735
39759
  }];
39736
- var asyncOptions$1 = /*#__PURE__*/function () {
39737
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, _, _ref) {
39738
- var page, mockOptions, startIndex, paginatedOptions;
39739
- return _regenerator().w(function (_context) {
39740
- while (1) switch (_context.n) {
39741
- case 0:
39742
- page = _ref.page;
39743
- mockOptions = [{
39744
- label: 'Option 1',
39745
- value: '1',
39746
- color: '#ff9900'
39747
- }, {
39748
- label: 'Option 2',
39749
- value: '2',
39750
- color: '#3b82f6'
39751
- }, {
39752
- label: 'Option 3',
39753
- value: '3',
39754
- color: '#10b981'
39755
- }, {
39756
- label: 'Option 4',
39757
- value: '4',
39758
- color: '#8b5cf6'
39759
- }, {
39760
- label: 'Option 5',
39761
- value: '5',
39762
- color: '#ec4899'
39763
- }, {
39764
- label: 'Option 6',
39765
- value: '6',
39766
- color: '#f59e0b'
39767
- }, {
39768
- label: 'Option 7',
39769
- value: '7',
39770
- color: '#ef4444'
39771
- }, {
39772
- label: 'Option 8',
39773
- value: '8',
39774
- color: '#10b981'
39775
- }, {
39776
- label: 'Option 9',
39777
- value: '9',
39778
- color: '#3b82f6'
39779
- }, {
39780
- label: 'Option 10',
39781
- value: '10',
39782
- color: '#8b5cf6'
39783
- }]; // Simulation de pagination
39784
- startIndex = (page - 1) * 5;
39785
- paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39786
- return _context.a(2, {
39787
- options: search ? mockOptions.filter(function (opt) {
39788
- return opt.label.toLowerCase().includes(search.toLowerCase());
39789
- }) : paginatedOptions
39790
- });
39791
- }
39792
- }, _callee);
39793
- }));
39794
- return function asyncOptions(_x, _x2, _x3) {
39795
- return _ref2.apply(this, arguments);
39796
- };
39797
- }();
39760
+ var createFakeOptions$1 = function createFakeOptions(start, length) {
39761
+ var options = [];
39762
+ for (var i = start; i < start + length; i++) {
39763
+ options.push({
39764
+ value: i,
39765
+ label: "Option ".concat(i),
39766
+ color: 'black'
39767
+ });
39768
+ }
39769
+ return options;
39770
+ };
39798
39771
  var MultiSelectPresets = {
39799
39772
  Default: {
39800
39773
  placeholder: 'Sélectionnez des options',
@@ -39879,17 +39852,55 @@ var MultiSelectPresets = {
39879
39852
  // Configuration pour les options asynchrones
39880
39853
  SelectMetaAsync: {
39881
39854
  isSelectMeta: true,
39882
- // value: ['3', '4', '5'],
39883
39855
  objValue: [{
39884
- label: 'Option 2',
39885
- value: '2',
39856
+ label: 'Option 9',
39857
+ value: '9',
39886
39858
  color: '#ff9900'
39887
39859
  }, {
39888
39860
  label: 'Option 4',
39889
39861
  value: '4',
39890
39862
  color: 'black'
39891
39863
  }],
39892
- options: asyncOptions$1,
39864
+ // value: ['3', '4'],
39865
+ options: function () {
39866
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
39867
+ var search,
39868
+ _ref3,
39869
+ page,
39870
+ allOptions,
39871
+ filtered,
39872
+ pageSize,
39873
+ start,
39874
+ _args2 = arguments;
39875
+ return _regenerator().w(function (_context2) {
39876
+ while (1) switch (_context2.n) {
39877
+ case 0:
39878
+ search = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
39879
+ _ref3 = _args2.length > 2 ? _args2[2] : undefined, page = _ref3.page;
39880
+ _context2.n = 1;
39881
+ return simulateNetworkDelay$1();
39882
+ case 1:
39883
+ allOptions = createFakeOptions$1(0, 100);
39884
+ filtered = allOptions.filter(function (opt) {
39885
+ return opt.label.toLowerCase().includes(search.toLowerCase());
39886
+ });
39887
+ pageSize = 30;
39888
+ start = (page - 1) * pageSize;
39889
+ return _context2.a(2, {
39890
+ options: filtered.slice(start, start + pageSize),
39891
+ hasMore: start + pageSize < filtered.length,
39892
+ additional: {
39893
+ page: page + 1
39894
+ }
39895
+ });
39896
+ }
39897
+ }, _callee2);
39898
+ }));
39899
+ function options() {
39900
+ return _options.apply(this, arguments);
39901
+ }
39902
+ return options;
39903
+ }(),
39893
39904
  placeholder: 'Sélectionnez une ou plusieurs options',
39894
39905
  optionLabel: 'label',
39895
39906
  optionValue: 'value',
@@ -39910,6 +39921,12 @@ var MultiSelectPresets = {
39910
39921
  }
39911
39922
  };
39912
39923
 
39924
+ var simulateNetworkDelay = function simulateNetworkDelay() {
39925
+ return new Promise(function (res) {
39926
+ return setTimeout(res, 400);
39927
+ });
39928
+ };
39929
+
39913
39930
  // Options synchrones (tableau)
39914
39931
  var syncOptions = [{
39915
39932
  label: 'Option 1',
@@ -39934,68 +39951,44 @@ var syncOptions = [{
39934
39951
  }];
39935
39952
 
39936
39953
  // Fonction pour simuler des options asynchrones
39937
- var asyncOptions = /*#__PURE__*/function () {
39938
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, _, _ref) {
39939
- var page, mockOptions, startIndex, paginatedOptions;
39940
- return _regenerator().w(function (_context) {
39941
- while (1) switch (_context.n) {
39942
- case 0:
39943
- page = _ref.page;
39944
- mockOptions = [{
39945
- label: 'Option 1',
39946
- value: '1',
39947
- color: '#ff9900'
39948
- }, {
39949
- label: 'Option 2',
39950
- value: '2',
39951
- color: '#3b82f6'
39952
- }, {
39953
- label: 'Option 3',
39954
- value: '3',
39955
- color: '#10b981'
39956
- }, {
39957
- label: 'Option 4',
39958
- value: '4',
39959
- color: '#8b5cf6'
39960
- }, {
39961
- label: 'Option 5',
39962
- value: '5',
39963
- color: '#ec4899'
39964
- }, {
39965
- label: 'Option 6',
39966
- value: '6',
39967
- color: '#f59e0b'
39968
- }, {
39969
- label: 'Option 7',
39970
- value: '7',
39971
- color: '#ef4444'
39972
- }, {
39973
- label: 'Option 8',
39974
- value: '8',
39975
- color: '#10b981'
39976
- }, {
39977
- label: 'Option 9',
39978
- value: '9',
39979
- color: '#3b82f6'
39980
- }, {
39981
- label: 'Option 10',
39982
- value: '10',
39983
- color: '#8b5cf6'
39984
- }]; // Simulation de pagination
39985
- startIndex = (page - 1) * 5;
39986
- paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39987
- return _context.a(2, {
39988
- options: search ? mockOptions.filter(function (opt) {
39989
- return opt.label.toLowerCase().includes(search.toLowerCase());
39990
- }) : paginatedOptions
39991
- });
39992
- }
39993
- }, _callee);
39994
- }));
39995
- return function asyncOptions(_x, _x2, _x3) {
39996
- return _ref2.apply(this, arguments);
39997
- };
39998
- }();
39954
+ // const asyncOptions = async (search, _, { page }) => {
39955
+ // const mockOptions = [
39956
+ // { label: 'Option 1', value: '1', color: '#ff9900' },
39957
+ // { label: 'Option 2', value: '2', color: '#3b82f6' },
39958
+ // { label: 'Option 3', value: '3', color: '#10b981' },
39959
+ // { label: 'Option 4', value: '4', color: '#8b5cf6' },
39960
+ // { label: 'Option 5', value: '5', color: '#ec4899' },
39961
+ // { label: 'Option 6', value: '6', color: '#f59e0b' },
39962
+ // { label: 'Option 7', value: '7', color: '#ef4444' },
39963
+ // { label: 'Option 8', value: '8', color: '#10b981' },
39964
+ // { label: 'Option 9', value: '9', color: '#3b82f6' },
39965
+ // { label: 'Option 10', value: '10', color: '#8b5cf6' },
39966
+ // ];
39967
+ //
39968
+ // // Simulation de pagination
39969
+ // const startIndex = (page - 1) * 5;
39970
+ // const paginatedOptions = mockOptions.slice(startIndex, startIndex + 5);
39971
+ //
39972
+ // return {
39973
+ // options: search
39974
+ // ? mockOptions.filter(opt =>
39975
+ // opt.label.toLowerCase().includes(search.toLowerCase())
39976
+ // )
39977
+ // : paginatedOptions,
39978
+ // };
39979
+ // };
39980
+
39981
+ var createFakeOptions = function createFakeOptions(start, length) {
39982
+ var options = [];
39983
+ for (var i = start; i < start + length; i++) {
39984
+ options.push({
39985
+ value: i,
39986
+ label: "Option ".concat(i),
39987
+ color: 'black'
39988
+ });
39989
+ }
39990
+ return options;
39991
+ };
39999
39992
  var MultiSelectMetaAsyncPresets = {
40000
39993
  // Configuration pour les options synchrones
40001
39994
  SyncOptions: {
@@ -40021,8 +40014,46 @@ var MultiSelectMetaAsyncPresets = {
40021
40014
  },
40022
40015
  // Configuration pour les options asynchrones
40023
40016
  AsyncOptions: {
40024
- value: ['1', '2'],
40025
- options: asyncOptions,
40017
+ value: ['3', '4'],
40018
+ options: function () {
40019
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
40020
+ var search,
40021
+ _ref,
40022
+ page,
40023
+ allOptions,
40024
+ filtered,
40025
+ pageSize,
40026
+ start,
40027
+ _args = arguments;
40028
+ return _regenerator().w(function (_context) {
40029
+ while (1) switch (_context.n) {
40030
+ case 0:
40031
+ search = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
40032
+ _ref = _args.length > 2 ? _args[2] : undefined, page = _ref.page;
40033
+ _context.n = 1;
40034
+ return simulateNetworkDelay();
40035
+ case 1:
40036
+ allOptions = createFakeOptions(0, 100);
40037
+ filtered = allOptions.filter(function (opt) {
40038
+ return opt.label.toLowerCase().includes(search.toLowerCase());
40039
+ });
40040
+ pageSize = 30;
40041
+ start = (page - 1) * pageSize;
40042
+ return _context.a(2, {
40043
+ options: filtered.slice(start, start + pageSize),
40044
+ hasMore: start + pageSize < filtered.length,
40045
+ additional: {
40046
+ page: page + 1
40047
+ }
40048
+ });
40049
+ }
40050
+ }, _callee);
40051
+ }));
40052
+ function options() {
40053
+ return _options.apply(this, arguments);
40054
+ }
40055
+ return options;
40056
+ }(),
40026
40057
  placeholder: 'Sélectionnez une ou plusieurs options',
40027
40058
  optionLabel: 'label',
40028
40059
  optionValue: 'value',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.625",
4
+ "version": "2.4.627",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {