arengibook 2.4.607 → 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 +115 -32
- 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) {
|
|
@@ -36158,44 +36185,43 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36158
36185
|
};
|
|
36159
36186
|
var valueTemplate = function valueTemplate(option) {
|
|
36160
36187
|
if (isSelectMeta) {
|
|
36161
|
-
if (objValue && valueToOptionMap && _typeof$a(objValue) === 'object') {
|
|
36162
|
-
var mappedOption = valueToOptionMap;
|
|
36163
|
-
var iconColor = mappedOption.color ? inverseColor(mappedOption.color) : '#FFFFFF';
|
|
36164
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
36165
|
-
className: 'badge select-badge',
|
|
36166
|
-
style: _objectSpread2({
|
|
36167
|
-
backgroundColor: mappedOption.color,
|
|
36168
|
-
color: iconColor,
|
|
36169
|
-
padding: '0.5rem',
|
|
36170
|
-
display: 'inline-block'
|
|
36171
|
-
}, valueStyle)
|
|
36172
|
-
}, /*#__PURE__*/React__default.createElement("span", {
|
|
36173
|
-
style: {
|
|
36174
|
-
color: iconColor
|
|
36175
|
-
}
|
|
36176
|
-
}, mappedOption.label));
|
|
36177
|
-
}
|
|
36178
36188
|
if (objValue === null) {
|
|
36179
|
-
var
|
|
36189
|
+
var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
|
|
36180
36190
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
36181
36191
|
ref: dropdownRef
|
|
36182
36192
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
36183
36193
|
className: 'badge select-badge',
|
|
36184
36194
|
style: _objectSpread2({
|
|
36185
36195
|
backgroundColor: option === null || option === void 0 ? void 0 : option.color,
|
|
36186
|
-
color:
|
|
36196
|
+
color: iconColor,
|
|
36187
36197
|
padding: '0.5rem',
|
|
36188
36198
|
display: 'inline-block'
|
|
36189
36199
|
}, valueStyle)
|
|
36190
36200
|
}, option !== null && option !== void 0 && option[optionLabel] ? /*#__PURE__*/React__default.createElement("span", {
|
|
36191
36201
|
style: {
|
|
36192
|
-
color:
|
|
36202
|
+
color: iconColor
|
|
36193
36203
|
}
|
|
36194
36204
|
}, option === null || option === void 0 ? void 0 : option[optionLabel]) : /*#__PURE__*/React__default.createElement("span", {
|
|
36195
36205
|
style: {
|
|
36196
36206
|
color: '#000000'
|
|
36197
36207
|
}
|
|
36198
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));
|
|
36199
36225
|
}
|
|
36200
36226
|
} else {
|
|
36201
36227
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -36329,10 +36355,54 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36329
36355
|
}, option.label)));
|
|
36330
36356
|
}
|
|
36331
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
|
+
};
|
|
36332
36401
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36333
36402
|
className: "flex flex-col gap-1"
|
|
36334
36403
|
}, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
|
|
36335
36404
|
value: optionSelected,
|
|
36405
|
+
valueTemplate: valueTemplate,
|
|
36336
36406
|
options: loadedOptions,
|
|
36337
36407
|
onChange: handleChange,
|
|
36338
36408
|
placeholder: placeholder,
|
|
@@ -36347,10 +36417,28 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36347
36417
|
overflowY: 'auto'
|
|
36348
36418
|
},
|
|
36349
36419
|
itemTemplate: optionTemplate,
|
|
36350
|
-
valueTemplate: valueTemplate,
|
|
36351
36420
|
showClear: showClear,
|
|
36352
36421
|
optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null,
|
|
36353
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
|
|
36354
36442
|
}, isGroupedOption && {
|
|
36355
36443
|
optionGroupLabel: 'label',
|
|
36356
36444
|
optionGroupChildren: 'items'
|
|
@@ -36499,7 +36587,7 @@ var DropdownPresets = {
|
|
|
36499
36587
|
placeholder: 'Sélectionnez une couleur',
|
|
36500
36588
|
options: optionsWithColors,
|
|
36501
36589
|
isSelectMeta: true,
|
|
36502
|
-
editable:
|
|
36590
|
+
editable: false,
|
|
36503
36591
|
selectMetaConfig: {
|
|
36504
36592
|
generalIcon: 'pi pi-circle-fill'
|
|
36505
36593
|
},
|
|
@@ -36514,14 +36602,9 @@ var DropdownPresets = {
|
|
|
36514
36602
|
}
|
|
36515
36603
|
},
|
|
36516
36604
|
SelectMetaAsyncLoad: {
|
|
36517
|
-
editable:
|
|
36518
|
-
|
|
36519
|
-
objValue: {
|
|
36520
|
-
label: 'Option 2',
|
|
36521
|
-
value: 2,
|
|
36522
|
-
color: '#000000'
|
|
36523
|
-
},
|
|
36524
|
-
// 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
|
|
36525
36608
|
options: function () {
|
|
36526
36609
|
var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
|
|
36527
36610
|
var page, length, start, data;
|