arengibook 2.4.606 → 2.4.608
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.
- package/dist/index.js +123 -53
- 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 } from 'react';
|
|
2
|
+
import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment, useMemo } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
|
|
5
5
|
function _arrayWithHoles$d(r) {
|
|
@@ -36027,9 +36027,36 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36027
36027
|
_useState8 = _slicedToArray$8(_useState7, 2),
|
|
36028
36028
|
valueToOptionMap = _useState8[0],
|
|
36029
36029
|
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
|
+
|
|
36030
36035
|
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
|
+
|
|
36031
36059
|
if (isOptionLoadFunction && objValue && isSelectMeta) {
|
|
36032
|
-
console.log("objValue");
|
|
36033
36060
|
setValueToOptionMap(objValue);
|
|
36034
36061
|
}
|
|
36035
36062
|
var handleScroll = function handleScroll(e) {
|
|
@@ -36067,8 +36094,6 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36067
36094
|
case 2:
|
|
36068
36095
|
result = _context.v;
|
|
36069
36096
|
setLoadedOptions(Array.isArray(result.options) ? result.options : []);
|
|
36070
|
-
console.log(loadedOptions);
|
|
36071
|
-
console.log(loadedOptions.length);
|
|
36072
36097
|
_context.n = 4;
|
|
36073
36098
|
break;
|
|
36074
36099
|
case 3:
|
|
@@ -36160,44 +36185,43 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36160
36185
|
};
|
|
36161
36186
|
var valueTemplate = function valueTemplate(option) {
|
|
36162
36187
|
if (isSelectMeta) {
|
|
36163
|
-
if (objValue && valueToOptionMap && _typeof$a(objValue) === 'object') {
|
|
36164
|
-
var mappedOption = valueToOptionMap;
|
|
36165
|
-
var iconColor = mappedOption.color ? inverseColor(mappedOption.color) : '#FFFFFF';
|
|
36166
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
36167
|
-
className: 'badge select-badge',
|
|
36168
|
-
style: _objectSpread2({
|
|
36169
|
-
backgroundColor: mappedOption.color,
|
|
36170
|
-
color: iconColor,
|
|
36171
|
-
padding: '0.5rem',
|
|
36172
|
-
display: 'inline-block'
|
|
36173
|
-
}, valueStyle)
|
|
36174
|
-
}, /*#__PURE__*/React__default.createElement("span", {
|
|
36175
|
-
style: {
|
|
36176
|
-
color: iconColor
|
|
36177
|
-
}
|
|
36178
|
-
}, mappedOption.label));
|
|
36179
|
-
}
|
|
36180
36188
|
if (objValue === null) {
|
|
36181
|
-
var
|
|
36189
|
+
var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
|
|
36182
36190
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
36183
36191
|
ref: dropdownRef
|
|
36184
36192
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
36185
36193
|
className: 'badge select-badge',
|
|
36186
36194
|
style: _objectSpread2({
|
|
36187
36195
|
backgroundColor: option === null || option === void 0 ? void 0 : option.color,
|
|
36188
|
-
color:
|
|
36196
|
+
color: iconColor,
|
|
36189
36197
|
padding: '0.5rem',
|
|
36190
36198
|
display: 'inline-block'
|
|
36191
36199
|
}, valueStyle)
|
|
36192
36200
|
}, option !== null && option !== void 0 && option[optionLabel] ? /*#__PURE__*/React__default.createElement("span", {
|
|
36193
36201
|
style: {
|
|
36194
|
-
color:
|
|
36202
|
+
color: iconColor
|
|
36195
36203
|
}
|
|
36196
36204
|
}, option === null || option === void 0 ? void 0 : option[optionLabel]) : /*#__PURE__*/React__default.createElement("span", {
|
|
36197
36205
|
style: {
|
|
36198
36206
|
color: '#000000'
|
|
36199
36207
|
}
|
|
36200
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", {
|
|
36213
|
+
className: 'badge select-badge',
|
|
36214
|
+
style: _objectSpread2({
|
|
36215
|
+
backgroundColor: mappedOption.color,
|
|
36216
|
+
color: _iconColor,
|
|
36217
|
+
padding: '0.5rem',
|
|
36218
|
+
display: 'inline-block'
|
|
36219
|
+
}, valueStyle)
|
|
36220
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
36221
|
+
style: {
|
|
36222
|
+
color: _iconColor
|
|
36223
|
+
}
|
|
36224
|
+
}, mappedOption.label));
|
|
36201
36225
|
}
|
|
36202
36226
|
} else {
|
|
36203
36227
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -36215,7 +36239,6 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36215
36239
|
return _regenerator().w(function (_context2) {
|
|
36216
36240
|
while (1) switch (_context2.n) {
|
|
36217
36241
|
case 0:
|
|
36218
|
-
console.log('onLazyLoad appelé avec :', event);
|
|
36219
36242
|
if (!(!isOptionLoadFunction || loading)) {
|
|
36220
36243
|
_context2.n = 1;
|
|
36221
36244
|
break;
|
|
@@ -36332,10 +36355,54 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36332
36355
|
}, option.label)));
|
|
36333
36356
|
}
|
|
36334
36357
|
};
|
|
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
|
+
};
|
|
36335
36401
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36336
36402
|
className: "flex flex-col gap-1"
|
|
36337
36403
|
}, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
|
|
36338
36404
|
value: optionSelected,
|
|
36405
|
+
valueTemplate: valueTemplate,
|
|
36339
36406
|
options: loadedOptions,
|
|
36340
36407
|
onChange: handleChange,
|
|
36341
36408
|
placeholder: placeholder,
|
|
@@ -36350,32 +36417,40 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36350
36417
|
overflowY: 'auto'
|
|
36351
36418
|
},
|
|
36352
36419
|
itemTemplate: optionTemplate,
|
|
36353
|
-
valueTemplate: valueTemplate,
|
|
36354
36420
|
showClear: showClear,
|
|
36355
36421
|
optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null,
|
|
36356
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
|
|
36357
36442
|
}, isGroupedOption && {
|
|
36358
36443
|
optionGroupLabel: 'label',
|
|
36359
36444
|
optionGroupChildren: 'items'
|
|
36360
36445
|
}, (isSelectMeta || isOptionLoadFunction) && {
|
|
36361
|
-
|
|
36362
|
-
|
|
36363
|
-
|
|
36364
|
-
|
|
36365
|
-
|
|
36366
|
-
|
|
36367
|
-
|
|
36368
|
-
}
|
|
36369
|
-
|
|
36370
|
-
/* virtualScrollerOptions: {
|
|
36371
|
-
lazy: true,
|
|
36372
|
-
onLazyLoad: onLazyLoad,
|
|
36373
|
-
itemSize: 0,
|
|
36374
|
-
showLoader: true,
|
|
36375
|
-
loading: false,
|
|
36376
|
-
delay: 0,
|
|
36377
|
-
totalrecords: 0,
|
|
36378
|
-
}, */
|
|
36446
|
+
virtualScrollerOptions: {
|
|
36447
|
+
showLoader: true,
|
|
36448
|
+
onLazyLoad: onLazyLoad,
|
|
36449
|
+
itemSize: 38,
|
|
36450
|
+
totalrecords: loadedOptions.length + 50,
|
|
36451
|
+
loading: loading,
|
|
36452
|
+
lazy: true
|
|
36453
|
+
}
|
|
36379
36454
|
})), name && /*#__PURE__*/React__default.createElement("input", {
|
|
36380
36455
|
type: "hidden",
|
|
36381
36456
|
name: name,
|
|
@@ -36512,7 +36587,7 @@ var DropdownPresets = {
|
|
|
36512
36587
|
placeholder: 'Sélectionnez une couleur',
|
|
36513
36588
|
options: optionsWithColors,
|
|
36514
36589
|
isSelectMeta: true,
|
|
36515
|
-
editable:
|
|
36590
|
+
editable: false,
|
|
36516
36591
|
selectMetaConfig: {
|
|
36517
36592
|
generalIcon: 'pi pi-circle-fill'
|
|
36518
36593
|
},
|
|
@@ -36527,14 +36602,9 @@ var DropdownPresets = {
|
|
|
36527
36602
|
}
|
|
36528
36603
|
},
|
|
36529
36604
|
SelectMetaAsyncLoad: {
|
|
36530
|
-
editable:
|
|
36531
|
-
|
|
36532
|
-
objValue: {
|
|
36533
|
-
label: 'Option 2',
|
|
36534
|
-
value: 2,
|
|
36535
|
-
color: '#000000'
|
|
36536
|
-
},
|
|
36537
|
-
// simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
|
|
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
|
|
36538
36608
|
options: function () {
|
|
36539
36609
|
var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
|
|
36540
36610
|
var page, length, start, data;
|