arengibook 2.4.637 → 2.4.638

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 +144 -57
  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$1 = 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$1 = 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$1();
36858
36858
  case 1:
36859
- allOptions = createFakeOptions(0, 100);
36859
+ allOptions = createFakeOptions$1(0, 100);
36860
36860
  filtered = allOptions.filter(function (opt) {
36861
36861
  return opt.label.toLowerCase().includes(search.toLowerCase());
36862
36862
  });
@@ -39133,14 +39133,12 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39133
39133
  _ref3,
39134
39134
  _ref3$page,
39135
39135
  page,
39136
+ length,
39137
+ start,
39136
39138
  queryParams,
39137
39139
  response,
39138
- data,
39139
- items,
39140
- filteredItems,
39141
- pageSize,
39142
- start,
39143
- paginatedItems,
39140
+ responseJSON,
39141
+ dataAjax,
39144
39142
  mappedOptions,
39145
39143
  _args = arguments,
39146
39144
  _t;
@@ -39150,11 +39148,12 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39150
39148
  search = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
39151
39149
  _ref3 = _args.length > 2 ? _args[2] : undefined, _ref3$page = _ref3.page, page = _ref3$page === void 0 ? 1 : _ref3$page;
39152
39150
  _context.p = 1;
39153
- // Construction de l'URL avec les paramètres de pagination et de recherche
39151
+ length = 25; // Même valeur que dans loadOptions
39152
+ start = (page - 1) * length;
39154
39153
  queryParams = new URLSearchParams();
39155
- if (search) queryParams.append('search', search);
39156
- queryParams.append('page', page);
39157
- queryParams.append('pageSize', 30);
39154
+ if (search) queryParams.append('search[value]', search);
39155
+ queryParams.append('start', start);
39156
+ queryParams.append('length', length);
39158
39157
  _context.n = 2;
39159
39158
  return fetch("".concat(optionsUrl, "?").concat(queryParams.toString()));
39160
39159
  case 2:
@@ -39168,26 +39167,24 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39168
39167
  _context.n = 4;
39169
39168
  return response.json();
39170
39169
  case 4:
39171
- data = _context.v;
39172
- // Récupération des données paginées ou filtrées
39173
- // (adaptez cette partie si votre API retourne les données dans un champ spécifique, comme `data.results`)
39174
- items = Array.isArray(data) ? data : data.results || data.items || []; // Filtrage côté client si nécessaire
39175
- filteredItems = search ? items.filter(function (item) {
39176
- return String(item[optionLabel]).toLowerCase().includes(search.toLowerCase());
39177
- }) : items; // Pagination côté client
39178
- pageSize = 30;
39179
- start = (page - 1) * pageSize;
39180
- paginatedItems = filteredItems.slice(start, start + pageSize); // Mapping dynamique des champs
39181
- mappedOptions = paginatedItems.map(function (item) {
39182
- var option = _objectSpread2({}, item);
39183
- // Si optionLabel et optionValue sont différents des clés par défaut
39184
- option.label = item[optionLabel];
39185
- option.value = item[optionValue];
39186
- return option;
39170
+ responseJSON = _context.v;
39171
+ // Simule le filtrage et le mapping comme dans loadOptions
39172
+ dataAjax = responseJSON.data.filter(function (data) {
39173
+ // Logique de filtrage si nécessaire adapter selon vos besoins)
39174
+ return true;
39175
+ });
39176
+ mappedOptions = dataAjax.map(function (opt) {
39177
+ if (!opt.hasOwnProperty('color') || opt.color === null || opt.color.length === 0) {
39178
+ opt.color = '#ccc';
39179
+ }
39180
+ opt.color = opt.color.toLowerCase();
39181
+ opt.label = opt.nom;
39182
+ opt.value = opt.id;
39183
+ return opt;
39187
39184
  });
39188
39185
  return _context.a(2, {
39189
39186
  options: mappedOptions,
39190
- hasMore: start + pageSize < filteredItems.length,
39187
+ hasMore: start + responseJSON.data.length < responseJSON.recordsTotal,
39191
39188
  additional: {
39192
39189
  page: page + 1
39193
39190
  }
@@ -39321,7 +39318,6 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39321
39318
  };
39322
39319
  var optionTemplate = function optionTemplate(option) {
39323
39320
  if (!option) return null;
39324
- console.log(option);
39325
39321
  var _ref5 = selectMetaConfig || {};
39326
39322
  _ref5.labelStyle;
39327
39323
  var generalIcon = _ref5.generalIcon;
@@ -39808,6 +39804,11 @@ var MultiSelect = function MultiSelect(props) {
39808
39804
  }, errorMessage || 'Sélection invalide')));
39809
39805
  };
39810
39806
 
39807
+ var simulateNetworkDelay = function simulateNetworkDelay() {
39808
+ return new Promise(function (res) {
39809
+ return setTimeout(res, 400);
39810
+ });
39811
+ };
39811
39812
  var optionsExample = [{
39812
39813
  label: 'New York',
39813
39814
  value: 'NY'
@@ -39894,6 +39895,17 @@ var syncOptions$1 = [{
39894
39895
  value: '5',
39895
39896
  color: '#ec4899'
39896
39897
  }];
39898
+ var createFakeOptions = function createFakeOptions(start, length) {
39899
+ var options = [];
39900
+ for (var i = start; i < start + length; i++) {
39901
+ options.push({
39902
+ value: i,
39903
+ label: "Option ".concat(i),
39904
+ color: 'black'
39905
+ });
39906
+ }
39907
+ return options;
39908
+ };
39897
39909
  var MultiSelectPresets = {
39898
39910
  Default: {
39899
39911
  placeholder: 'Sélectionnez des options',
@@ -39976,37 +39988,112 @@ var MultiSelectPresets = {
39976
39988
  showSelectAll: false
39977
39989
  },
39978
39990
  // Configuration pour les options asynchrones
39991
+ // SelectMetaAsync: {
39992
+ // isSelectMeta: true,
39993
+ // value: [9, 4],
39994
+ // objValue: [{ label: 'Option 9', value: 9, color: "#67688C" }, { label: 'Option 4', value: 4, color: "#39C9BF" }],
39995
+ // options: async (search = '', _, { page }) => {
39996
+ // await simulateNetworkDelay();
39997
+ // const allOptions = createFakeOptions(0, 100);
39998
+ // const filtered = allOptions.filter(opt =>
39999
+ // opt.label.toLowerCase().includes(search.toLowerCase())
40000
+ // );
40001
+ // const pageSize = 30;
40002
+ // const start = (page - 1) * pageSize;
40003
+ // return {
40004
+ // options: filtered.slice(start, start + pageSize),
40005
+ // hasMore: start + pageSize < filtered.length,
40006
+ // additional: { page: page + 1 },
40007
+ // };
40008
+ // },
40009
+ // optionLabel: 'label',
40010
+ // optionValue: 'value',
40011
+ //
40012
+ // // value: [3,4],
40013
+ // // objValue: [{ name: 'Clementine Bauch', id: 3 }, { name: 'Patricia Lebsack', id: 4 }],
40014
+ // // optionsUrl: "https://jsonplaceholder.typicode.com/users",
40015
+ // // optionLabel: 'name',
40016
+ // // optionValue: 'id',
40017
+ //
40018
+ // placeholder: 'Sélectionnez une ou plusieurs options',
40019
+ // valueStyle: { marginRight: '15px', marginBottom: '5px' },
40020
+ // selectMetaConfig: {
40021
+ // labelStyle: { fontWeight: 'bold' },
40022
+ // generalIcon: 'pi pi-tag',
40023
+ // },
40024
+ // filter: false,
40025
+ // showClear: false,
40026
+ // useCheckbox: false,
40027
+ // showSelectAll: false,
40028
+ // },
40029
+
39979
40030
  SelectMetaAsync: {
39980
40031
  isSelectMeta: true,
39981
- // value: [9, 4],
39982
- // objValue: [{ label: 'Option 9', value: 9, color: "#67688C" }, { label: 'Option 4', value: 4, color: "#39C9BF" }],
39983
- // options: async (search = '', _, { page }) => {
39984
- // await simulateNetworkDelay();
39985
- // const allOptions = createFakeOptions(0, 100);
39986
- // const filtered = allOptions.filter(opt =>
39987
- // opt.label.toLowerCase().includes(search.toLowerCase())
39988
- // );
39989
- // const pageSize = 30;
39990
- // const start = (page - 1) * pageSize;
39991
- // return {
39992
- // options: filtered.slice(start, start + pageSize),
39993
- // hasMore: start + pageSize < filtered.length,
39994
- // additional: { page: page + 1 },
39995
- // };
39996
- // },
39997
- // optionLabel: 'label',
39998
- // optionValue: 'value',
39999
-
40000
- value: [3, 4],
40032
+ value: [9, 4],
40001
40033
  objValue: [{
40002
- name: 'Clementine Bauch',
40003
- id: 3
40034
+ label: 'Option 9',
40035
+ value: 9,
40036
+ color: "#67688C",
40037
+ nom: 'Option 9',
40038
+ id: 9
40004
40039
  }, {
40005
- name: 'Patricia Lebsack',
40040
+ label: 'Option 4',
40041
+ value: 4,
40042
+ color: "#39C9BF",
40043
+ nom: 'Option 4',
40006
40044
  id: 4
40007
40045
  }],
40008
- optionsUrl: "https://jsonplaceholder.typicode.com/users",
40009
- optionLabel: 'name',
40046
+ options: function () {
40047
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
40048
+ var search,
40049
+ _ref3,
40050
+ _ref3$page,
40051
+ page,
40052
+ allOptions,
40053
+ filtered,
40054
+ length,
40055
+ start,
40056
+ paginatedOptions,
40057
+ _args2 = arguments;
40058
+ return _regenerator().w(function (_context2) {
40059
+ while (1) switch (_context2.n) {
40060
+ case 0:
40061
+ search = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
40062
+ _ref3 = _args2.length > 2 ? _args2[2] : undefined, _ref3$page = _ref3.page, page = _ref3$page === void 0 ? 1 : _ref3$page;
40063
+ _context2.n = 1;
40064
+ return simulateNetworkDelay();
40065
+ case 1:
40066
+ allOptions = createFakeOptions(0, 100).map(function (opt) {
40067
+ return _objectSpread2(_objectSpread2({}, opt), {}, {
40068
+ nom: opt.label,
40069
+ id: opt.value,
40070
+ color: opt.color || '#ccc'
40071
+ });
40072
+ });
40073
+ filtered = allOptions.filter(function (opt) {
40074
+ return opt.nom.toLowerCase().includes(search.toLowerCase());
40075
+ });
40076
+ length = 25;
40077
+ start = (page - 1) * length; // Simule la réponse de votre API Symfony
40078
+ paginatedOptions = filtered.slice(start, start + length);
40079
+ return _context2.a(2, {
40080
+ options: paginatedOptions,
40081
+ hasMore: start + length < filtered.length,
40082
+ additional: {
40083
+ page: page + 1
40084
+ },
40085
+ data: paginatedOptions,
40086
+ recordsTotal: filtered.length
40087
+ });
40088
+ }
40089
+ }, _callee2);
40090
+ }));
40091
+ function options() {
40092
+ return _options.apply(this, arguments);
40093
+ }
40094
+ return options;
40095
+ }(),
40096
+ optionLabel: 'nom',
40010
40097
  optionValue: 'id',
40011
40098
  placeholder: 'Sélectionnez une ou plusieurs options',
40012
40099
  valueStyle: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.637",
4
+ "version": "2.4.638",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {