arengibook 2.5.509 → 2.5.510
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 +93 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42773,39 +42773,55 @@ var Toast = function Toast(_ref) {
|
|
|
42773
42773
|
|
|
42774
42774
|
// Singleton pour l'empilement des toasts
|
|
42775
42775
|
var toastRefs = {
|
|
42776
|
-
|
|
42777
|
-
hasShownRef: {
|
|
42778
|
-
current: false
|
|
42779
|
-
},
|
|
42780
|
-
container: null,
|
|
42776
|
+
containers: {},
|
|
42781
42777
|
sizeStates: new Map()
|
|
42782
42778
|
};
|
|
42783
|
-
|
|
42779
|
+
|
|
42780
|
+
// const ToastContainer = () => {
|
|
42781
|
+
// const ref = useRef(null);
|
|
42782
|
+
// useEffect(() => {
|
|
42783
|
+
// toastRefs.toastRef = ref;
|
|
42784
|
+
// }, []);
|
|
42785
|
+
//
|
|
42786
|
+
// return <PrimeToast ref={ref} position="top-right" />;
|
|
42787
|
+
// };
|
|
42788
|
+
|
|
42789
|
+
var ToastContainer = function ToastContainer(_ref2) {
|
|
42790
|
+
var _ref2$position = _ref2.position,
|
|
42791
|
+
position = _ref2$position === void 0 ? "top-right" : _ref2$position;
|
|
42784
42792
|
var ref = useRef(null);
|
|
42785
42793
|
useEffect(function () {
|
|
42786
|
-
toastRefs.
|
|
42787
|
-
|
|
42794
|
+
if (!toastRefs.containers[position]) {
|
|
42795
|
+
toastRefs.containers[position] = ref;
|
|
42796
|
+
}
|
|
42797
|
+
}, [position]);
|
|
42788
42798
|
return /*#__PURE__*/React__default.createElement(Toast$1, {
|
|
42789
42799
|
ref: ref,
|
|
42790
|
-
position:
|
|
42800
|
+
position: position
|
|
42791
42801
|
});
|
|
42792
42802
|
};
|
|
42793
42803
|
var showToast = function showToast(props) {
|
|
42794
|
-
|
|
42795
|
-
|
|
42796
|
-
document.
|
|
42797
|
-
|
|
42804
|
+
var position = props.position || "top-right";
|
|
42805
|
+
if (!toastRefs.containers[position]) {
|
|
42806
|
+
var containerDiv = document.createElement('div');
|
|
42807
|
+
containerDiv.id = "toast-container-".concat(position);
|
|
42808
|
+
document.body.appendChild(containerDiv);
|
|
42809
|
+
ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, {
|
|
42810
|
+
position: position
|
|
42811
|
+
}), containerDiv);
|
|
42798
42812
|
}
|
|
42799
42813
|
setTimeout(function () {
|
|
42800
|
-
|
|
42814
|
+
var toastRef = toastRefs.containers[position];
|
|
42815
|
+
if (toastRef !== null && toastRef !== void 0 && toastRef.current) {
|
|
42801
42816
|
// Générer un ID unique pour ce toast
|
|
42802
42817
|
var toastId = "toast-".concat(Date.now(), "-").concat(Math.random());
|
|
42803
42818
|
|
|
42804
|
-
// Initialiser l'état de taille
|
|
42819
|
+
// Initialiser l'état de taille ET position
|
|
42805
42820
|
var initialSize = props.size || 'M';
|
|
42806
42821
|
toastRefs.sizeStates.set(toastId, {
|
|
42807
42822
|
currentSize: initialSize,
|
|
42808
|
-
isExpanded: initialSize === 'L'
|
|
42823
|
+
isExpanded: initialSize === 'L',
|
|
42824
|
+
currentPosition: position
|
|
42809
42825
|
});
|
|
42810
42826
|
var progressBarRef = {
|
|
42811
42827
|
current: null
|
|
@@ -42822,11 +42838,41 @@ var showToast = function showToast(props) {
|
|
|
42822
42838
|
state.isExpanded = newSize === 'L';
|
|
42823
42839
|
|
|
42824
42840
|
// Re-afficher le toast avec la nouvelle taille
|
|
42825
|
-
|
|
42841
|
+
toastRef.current.clear();
|
|
42826
42842
|
showToastWithState(toastId, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
42827
42843
|
size: newSize
|
|
42828
42844
|
}));
|
|
42829
42845
|
};
|
|
42846
|
+
|
|
42847
|
+
// Nouvelle fonction pour changer la position
|
|
42848
|
+
var handlePositionChange = function handlePositionChange(newPosition) {
|
|
42849
|
+
var state = toastRefs.sizeStates.get(toastId);
|
|
42850
|
+
if (!state) return;
|
|
42851
|
+
|
|
42852
|
+
// Effacer le toast de l'ancienne position
|
|
42853
|
+
var oldToastRef = toastRefs.containers[state.currentPosition];
|
|
42854
|
+
if (oldToastRef !== null && oldToastRef !== void 0 && oldToastRef.current) {
|
|
42855
|
+
oldToastRef.current.clear();
|
|
42856
|
+
}
|
|
42857
|
+
state.currentPosition = newPosition;
|
|
42858
|
+
|
|
42859
|
+
// Créer le conteneur pour la nouvelle position si nécessaire
|
|
42860
|
+
if (!toastRefs.containers[newPosition]) {
|
|
42861
|
+
var _containerDiv = document.createElement('div');
|
|
42862
|
+
_containerDiv.id = "toast-container-".concat(newPosition);
|
|
42863
|
+
document.body.appendChild(_containerDiv);
|
|
42864
|
+
ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, {
|
|
42865
|
+
position: newPosition
|
|
42866
|
+
}), _containerDiv);
|
|
42867
|
+
}
|
|
42868
|
+
|
|
42869
|
+
// Attendre que le nouveau conteneur soit prêt
|
|
42870
|
+
setTimeout(function () {
|
|
42871
|
+
showToastWithState(toastId, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
42872
|
+
position: newPosition
|
|
42873
|
+
}));
|
|
42874
|
+
}, 50);
|
|
42875
|
+
};
|
|
42830
42876
|
var handleToggleSize = function handleToggleSize() {
|
|
42831
42877
|
var state = toastRefs.sizeStates.get(toastId);
|
|
42832
42878
|
if (!state || !props.sizeSModulable) return;
|
|
@@ -42850,7 +42896,9 @@ var showToast = function showToast(props) {
|
|
|
42850
42896
|
var showToastWithState = function showToastWithState(id, currentProps) {
|
|
42851
42897
|
var state = toastRefs.sizeStates.get(id);
|
|
42852
42898
|
if (!state) return;
|
|
42853
|
-
toastRefs.
|
|
42899
|
+
var currentToastRef = toastRefs.containers[state.currentPosition];
|
|
42900
|
+
if (!(currentToastRef !== null && currentToastRef !== void 0 && currentToastRef.current)) return;
|
|
42901
|
+
currentToastRef.current.show({
|
|
42854
42902
|
severity: currentProps.type || 'info',
|
|
42855
42903
|
life: currentProps.duration || 3000,
|
|
42856
42904
|
sticky: currentProps.sticky,
|
|
@@ -42872,9 +42920,10 @@ var showToast = function showToast(props) {
|
|
|
42872
42920
|
enablePercentage: currentProps.enablePercentage,
|
|
42873
42921
|
sizeSModulable: currentProps.sizeSModulable,
|
|
42874
42922
|
isExpanded: state.isExpanded,
|
|
42923
|
+
currentPosition: state.currentPosition,
|
|
42875
42924
|
onSizeChange: handleSizeChange,
|
|
42876
|
-
|
|
42877
|
-
|
|
42925
|
+
onPositionChange: handlePositionChange,
|
|
42926
|
+
toastRef: currentToastRef,
|
|
42878
42927
|
progressBarRef: progressBarRef,
|
|
42879
42928
|
percentageTextRef: percentageTextRef,
|
|
42880
42929
|
handleToggleSize: handleToggleSize
|
|
@@ -42893,30 +42942,30 @@ var showToast = function showToast(props) {
|
|
|
42893
42942
|
if (typeof window !== 'undefined') {
|
|
42894
42943
|
window.showArengibookToast = showToast;
|
|
42895
42944
|
}
|
|
42896
|
-
var RichMessage = function RichMessage(
|
|
42897
|
-
var icon =
|
|
42898
|
-
|
|
42899
|
-
type =
|
|
42900
|
-
|
|
42901
|
-
size =
|
|
42902
|
-
title =
|
|
42903
|
-
message =
|
|
42904
|
-
|
|
42905
|
-
enableHtmlContent =
|
|
42906
|
-
link =
|
|
42907
|
-
|
|
42908
|
-
links =
|
|
42909
|
-
|
|
42910
|
-
attachedFiles =
|
|
42911
|
-
|
|
42912
|
-
enablePercentage =
|
|
42913
|
-
currentPercentage =
|
|
42914
|
-
sizeSModulable =
|
|
42915
|
-
|
|
42916
|
-
isExpanded =
|
|
42917
|
-
progressBarRef =
|
|
42918
|
-
percentageTextRef =
|
|
42919
|
-
handleToggleSize =
|
|
42945
|
+
var RichMessage = function RichMessage(_ref3) {
|
|
42946
|
+
var icon = _ref3.icon,
|
|
42947
|
+
_ref3$type = _ref3.type,
|
|
42948
|
+
type = _ref3$type === void 0 ? "info" : _ref3$type,
|
|
42949
|
+
_ref3$size = _ref3.size,
|
|
42950
|
+
size = _ref3$size === void 0 ? "M" : _ref3$size,
|
|
42951
|
+
title = _ref3.title,
|
|
42952
|
+
message = _ref3.message,
|
|
42953
|
+
_ref3$enableHtmlConte = _ref3.enableHtmlContent,
|
|
42954
|
+
enableHtmlContent = _ref3$enableHtmlConte === void 0 ? false : _ref3$enableHtmlConte,
|
|
42955
|
+
link = _ref3.link,
|
|
42956
|
+
_ref3$links = _ref3.links,
|
|
42957
|
+
links = _ref3$links === void 0 ? [] : _ref3$links,
|
|
42958
|
+
_ref3$attachedFiles = _ref3.attachedFiles,
|
|
42959
|
+
attachedFiles = _ref3$attachedFiles === void 0 ? [] : _ref3$attachedFiles,
|
|
42960
|
+
_ref3$enablePercentag = _ref3.enablePercentage,
|
|
42961
|
+
enablePercentage = _ref3$enablePercentag === void 0 ? false : _ref3$enablePercentag,
|
|
42962
|
+
currentPercentage = _ref3.currentPercentage,
|
|
42963
|
+
sizeSModulable = _ref3.sizeSModulable,
|
|
42964
|
+
_ref3$isExpanded = _ref3.isExpanded,
|
|
42965
|
+
isExpanded = _ref3$isExpanded === void 0 ? false : _ref3$isExpanded,
|
|
42966
|
+
progressBarRef = _ref3.progressBarRef,
|
|
42967
|
+
percentageTextRef = _ref3.percentageTextRef,
|
|
42968
|
+
handleToggleSize = _ref3.handleToggleSize;
|
|
42920
42969
|
var getIconByType = function getIconByType() {
|
|
42921
42970
|
switch (type) {
|
|
42922
42971
|
case "success":
|