arengibook 2.4.608 → 2.4.610

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 +34 -129
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment, useMemo } from 'react';
2
+ import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
4
 
5
5
  function _arrayWithHoles$d(r) {
@@ -35963,7 +35963,7 @@ var Dropdown = function Dropdown(_ref) {
35963
35963
  _ref$objValue = _ref.objValue,
35964
35964
  objValue = _ref$objValue === void 0 ? null : _ref$objValue,
35965
35965
  _ref$placeholder = _ref.placeholder,
35966
- placeholder = _ref$placeholder === void 0 ? null : _ref$placeholder,
35966
+ placeholder = _ref$placeholder === void 0 ? 'Sélectionnez une option' : _ref$placeholder,
35967
35967
  _ref$disabled = _ref.disabled,
35968
35968
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
35969
35969
  _ref$filter = _ref.filter,
@@ -35984,8 +35984,6 @@ var Dropdown = function Dropdown(_ref) {
35984
35984
  onChange = _ref.onChange,
35985
35985
  _ref$optionStyle = _ref.optionStyle,
35986
35986
  optionStyle = _ref$optionStyle === void 0 ? {} : _ref$optionStyle,
35987
- _ref$editable = _ref.editable,
35988
- editable = _ref$editable === void 0 ? false : _ref$editable,
35989
35987
  name = _ref.name,
35990
35988
  _ref$showClear = _ref.showClear,
35991
35989
  showClear = _ref$showClear === void 0 ? false : _ref$showClear,
@@ -36020,42 +36018,14 @@ var Dropdown = function Dropdown(_ref) {
36020
36018
  _useState6 = _slicedToArray$8(_useState5, 2),
36021
36019
  loadedOptions = _useState6[0],
36022
36020
  setLoadedOptions = _useState6[1];
36023
- var isOptionLoadFunction = typeof options === 'function'; // (détecte si l'option est une fonction donc fonction asynchrone)
36021
+ var isOptionLoadFunction = typeof options === 'function';
36024
36022
  var filterRef = useRef('');
36025
36023
  var dropdownRef = useRef(null);
36026
36024
  var _useState7 = useState(null),
36027
36025
  _useState8 = _slicedToArray$8(_useState7, 2),
36028
36026
  valueToOptionMap = _useState8[0],
36029
36027
  setValueToOptionMap = _useState8[1];
36030
- var _useState9 = useState(20),
36031
- _useState0 = _slicedToArray$8(_useState9, 2),
36032
- inputWidth = _useState0[0];
36033
- _useState0[1]; // largeur initiale minimale
36034
-
36035
36028
  useEffect(function () {
36036
- // const editableFunction = () => {
36037
- // if (editable) {
36038
- // const hiddenInput= document.getElementsByClassName("p-dropdown-label");
36039
- // hiddenInput[0].setAttribute('type', 'hidden');
36040
- //
36041
- // const editableDiv = document.createElement('div');
36042
- // editableDiv.contentEditable = 'true';
36043
- // editableDiv.textContent = 'Mon texte ici';
36044
- //
36045
- //
36046
- // editableDiv.style.display = 'inline-block';
36047
- // editableDiv.style.width = 'auto';
36048
- // editableDiv.style.padding = '6px 10px';
36049
- // editableDiv.style.color = 'green';
36050
- // editableDiv.style.backgroundColor = 'gray';
36051
- // editableDiv.style.borderRadius = '20px';
36052
- // editableDiv.style.fontSize = '16px';
36053
- // editableDiv.style.outline = 'none';
36054
- // hiddenInput[0].parentNode.insertBefore(editableDiv, hiddenInput[0]);
36055
- // }
36056
- // }
36057
- // editableFunction();
36058
-
36059
36029
  if (isOptionLoadFunction && objValue && isSelectMeta) {
36060
36030
  setValueToOptionMap(objValue);
36061
36031
  }
@@ -36088,9 +36058,7 @@ var Dropdown = function Dropdown(_ref) {
36088
36058
  setLoading(true);
36089
36059
  _context.p = 1;
36090
36060
  _context.n = 2;
36091
- return options('', [], {
36092
- page: 1
36093
- });
36061
+ return options();
36094
36062
  case 2:
36095
36063
  result = _context.v;
36096
36064
  setLoadedOptions(Array.isArray(result.options) ? result.options : []);
@@ -36185,43 +36153,44 @@ var Dropdown = function Dropdown(_ref) {
36185
36153
  };
36186
36154
  var valueTemplate = function valueTemplate(option) {
36187
36155
  if (isSelectMeta) {
36188
- if (objValue === null) {
36189
- var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
36190
- return /*#__PURE__*/React__default.createElement("span", {
36191
- ref: dropdownRef
36192
- }, /*#__PURE__*/React__default.createElement("div", {
36156
+ if (objValue && valueToOptionMap && _typeof$a(objValue) === 'object') {
36157
+ var mappedOption = valueToOptionMap;
36158
+ var iconColor = mappedOption.color ? inverseColor(mappedOption.color) : '#FFFFFF';
36159
+ return /*#__PURE__*/React__default.createElement("div", {
36193
36160
  className: 'badge select-badge',
36194
36161
  style: _objectSpread2({
36195
- backgroundColor: option === null || option === void 0 ? void 0 : option.color,
36162
+ backgroundColor: mappedOption.color,
36196
36163
  color: iconColor,
36197
36164
  padding: '0.5rem',
36198
36165
  display: 'inline-block'
36199
36166
  }, valueStyle)
36200
- }, option !== null && option !== void 0 && option[optionLabel] ? /*#__PURE__*/React__default.createElement("span", {
36167
+ }, /*#__PURE__*/React__default.createElement("span", {
36201
36168
  style: {
36202
36169
  color: iconColor
36203
36170
  }
36204
- }, option === null || option === void 0 ? void 0 : option[optionLabel]) : /*#__PURE__*/React__default.createElement("span", {
36205
- style: {
36206
- color: '#000000'
36207
- }
36208
- }, placeholder)));
36209
- } else if (objValue && valueToOptionMap && _typeof$a(objValue) === 'object') {
36210
- var mappedOption = valueToOptionMap;
36211
- var _iconColor = mappedOption.color ? inverseColor(mappedOption.color) : '#FFFFFF';
36212
- return /*#__PURE__*/React__default.createElement("div", {
36171
+ }, mappedOption.label));
36172
+ }
36173
+ if (objValue === null) {
36174
+ var _iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
36175
+ return /*#__PURE__*/React__default.createElement("span", {
36176
+ ref: dropdownRef
36177
+ }, /*#__PURE__*/React__default.createElement("div", {
36213
36178
  className: 'badge select-badge',
36214
36179
  style: _objectSpread2({
36215
- backgroundColor: mappedOption.color,
36180
+ backgroundColor: option === null || option === void 0 ? void 0 : option.color,
36216
36181
  color: _iconColor,
36217
36182
  padding: '0.5rem',
36218
36183
  display: 'inline-block'
36219
36184
  }, valueStyle)
36220
- }, /*#__PURE__*/React__default.createElement("span", {
36185
+ }, option !== null && option !== void 0 && option[optionLabel] ? /*#__PURE__*/React__default.createElement("span", {
36221
36186
  style: {
36222
36187
  color: _iconColor
36223
36188
  }
36224
- }, mappedOption.label));
36189
+ }, option === null || option === void 0 ? void 0 : option[optionLabel]) : /*#__PURE__*/React__default.createElement("span", {
36190
+ style: {
36191
+ color: '#000000'
36192
+ }
36193
+ }, placeholder)));
36225
36194
  }
36226
36195
  } else {
36227
36196
  return /*#__PURE__*/React__default.createElement("span", {
@@ -36239,7 +36208,7 @@ var Dropdown = function Dropdown(_ref) {
36239
36208
  return _regenerator().w(function (_context2) {
36240
36209
  while (1) switch (_context2.n) {
36241
36210
  case 0:
36242
- if (!(!isOptionLoadFunction || loading)) {
36211
+ if (isOptionLoadFunction) {
36243
36212
  _context2.n = 1;
36244
36213
  break;
36245
36214
  }
@@ -36355,54 +36324,10 @@ var Dropdown = function Dropdown(_ref) {
36355
36324
  }, option.label)));
36356
36325
  }
36357
36326
  };
36358
-
36359
- // 🔍 Trouver l’option actuelle (comme valueTemplate)
36360
- var currentOption = useMemo(function () {
36361
- var allOptions = Array.isArray(loadedOptions) ? loadedOptions : [];
36362
- return allOptions.find(function (opt) {
36363
- return opt[optionValue] === optionSelected;
36364
- }) || null;
36365
- }, [loadedOptions, optionSelected, optionValue]);
36366
- var getTextWidth = function getTextWidth(text, font) {
36367
- var span = document.createElement('span');
36368
- span.style.visibility = 'hidden';
36369
- span.style.whiteSpace = 'pre';
36370
- span.style.position = 'absolute';
36371
- span.style.font = font;
36372
- span.textContent = text || '';
36373
- document.body.appendChild(span);
36374
- var width = span.offsetWidth;
36375
- document.body.removeChild(span);
36376
- return width + 16;
36377
- };
36378
- var editableInputStyle = useMemo(function () {
36379
- if (!editable) return {};
36380
- var bg = (currentOption === null || currentOption === void 0 ? void 0 : currentOption.color) || '#FFFFFF';
36381
- var iconColor = currentOption !== null && currentOption !== void 0 && currentOption.color ? inverseColor(currentOption.color) : '#000000';
36382
- return _objectSpread2({
36383
- backgroundColor: bg,
36384
- color: iconColor,
36385
- padding: '0.5rem',
36386
- borderRadius: '1rem',
36387
- width: getTextWidth(currentOption === null || currentOption === void 0 ? void 0 : currentOption.label),
36388
- marginRight: '16px'
36389
- }, valueStyle);
36390
- }, [editable, currentOption, inputWidth, valueStyle]);
36391
- var handleEditableChange = function handleEditableChange(e) {
36392
- var text = e.target.value;
36393
- if (!text || text.trim() === "") {
36394
- setOptionSelected(null);
36395
- if (onChange) onChange(null);
36396
- } else {
36397
- setOptionSelected(text);
36398
- if (onChange) onChange(text);
36399
- }
36400
- };
36401
36327
  return /*#__PURE__*/React__default.createElement("div", {
36402
36328
  className: "flex flex-col gap-1"
36403
36329
  }, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
36404
36330
  value: optionSelected,
36405
- valueTemplate: valueTemplate,
36406
36331
  options: loadedOptions,
36407
36332
  onChange: handleChange,
36408
36333
  placeholder: placeholder,
@@ -36417,39 +36342,20 @@ var Dropdown = function Dropdown(_ref) {
36417
36342
  overflowY: 'auto'
36418
36343
  },
36419
36344
  itemTemplate: optionTemplate,
36345
+ valueTemplate: valueTemplate,
36420
36346
  showClear: showClear,
36421
- optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null,
36422
- editable: editable
36423
- }, editable && {
36424
- editable: editable,
36425
- pt: {
36426
- input: {
36427
- className: 'badge select-badge',
36428
- style: editableInputStyle
36429
- },
36430
- root: {
36431
- style: {
36432
- border: '1px solid #ccc',
36433
- width: '100%',
36434
- display: 'inline-flex',
36435
- alignItems: 'center',
36436
- justifyContent: 'flex-start',
36437
- padding: '0.25rem 0.5rem'
36438
- }
36439
- }
36440
- },
36441
- onInput: handleEditableChange
36347
+ optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null
36442
36348
  }, isGroupedOption && {
36443
36349
  optionGroupLabel: 'label',
36444
36350
  optionGroupChildren: 'items'
36445
36351
  }, (isSelectMeta || isOptionLoadFunction) && {
36446
36352
  virtualScrollerOptions: {
36447
- showLoader: true,
36353
+ lazy: true,
36448
36354
  onLazyLoad: onLazyLoad,
36449
36355
  itemSize: 38,
36450
- totalrecords: loadedOptions.length + 50,
36356
+ showLoader: true,
36451
36357
  loading: loading,
36452
- lazy: true
36358
+ delay: 250
36453
36359
  }
36454
36360
  })), name && /*#__PURE__*/React__default.createElement("input", {
36455
36361
  type: "hidden",
@@ -36587,7 +36493,6 @@ var DropdownPresets = {
36587
36493
  placeholder: 'Sélectionnez une couleur',
36588
36494
  options: optionsWithColors,
36589
36495
  isSelectMeta: true,
36590
- editable: false,
36591
36496
  selectMetaConfig: {
36592
36497
  generalIcon: 'pi pi-circle-fill'
36593
36498
  },
@@ -36602,9 +36507,9 @@ var DropdownPresets = {
36602
36507
  }
36603
36508
  },
36604
36509
  SelectMetaAsyncLoad: {
36605
- editable: false,
36606
- value: 3,
36607
- // objValue: { label: 'Option 3', value: 3, color: '#000000' }, // simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
36510
+ placeholder: 'Chargement distant simulé',
36511
+ value: 20,
36512
+ // objValue: { label: 'Option 2', value: 2, color: 'green' }, // simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
36608
36513
  options: function () {
36609
36514
  var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
36610
36515
  var page, length, start, data;
@@ -36612,7 +36517,7 @@ var DropdownPresets = {
36612
36517
  while (1) switch (_context.n) {
36613
36518
  case 0:
36614
36519
  page = _ref.page;
36615
- length = 20;
36520
+ length = 2;
36616
36521
  start = (page - 1) * length; // Simule un délai réseau
36617
36522
  _context.n = 1;
36618
36523
  return new Promise(function (res) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.608",
4
+ "version": "2.4.610",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {