arengibook 2.5.510 → 2.5.511

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 +271 -327
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42653,348 +42653,70 @@ Toast$1.displayName = 'Toast';
42653
42653
  var css_248z = ".p-toast-message {\n height:auto;\n}\n.p-toast-message.heightoastlarge {\n min-height:50px;\n}\n.p-toast-message.heightoastmedium {\n max-height:100px;\n overflow: hidden;\n}\n\n.p-toast-message.toast_s--compact {\n width: 116px;\n min-width: 56px;\n padding-right: 0;\n position: relative;\n}\n\n.p-toast-message.toast_s--compact .p-toast-message-content {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0.5rem;\n}\n\n.p-toast-message.toast_s--compact .maximize-button {\n margin-right: 20px;\n}\n\n.p-toast-message.toast_s--compact .p-toast-icon-close {\n position: absolute;\n top: 4px;\n right: 4px;\n}\n\n\n.p-toast-message.toast_s--large {\n width: auto;\n min-width: auto;\n padding-right: inherit;\n}\n\n.p-toast-message.toast_s--large .p-toast-message-content {\n display: flex;\n align-items: center;\n padding: 1rem;\n gap: 0.75rem;\n}\n\n.p-toast-message .maximize-button-container {\n margin-left: auto;\n display: flex;\n align-items: center;\n}\n\n.p-toast-message.toast_s--large .p-toast-icon-close {\n position: static;\n margin-left: 0.5rem;\n}\n\n/* Title */\n\n.toast-title {\n font-weight: 600;\n font-size: 0.95rem;\n line-height: 1.3;\n color: #111827; /* gris très foncé / quasi noir */\n margin-bottom: 0.25rem;\n}\n\n\n.toast-root {\n display: flex;\n align-items: flex-start;\n width: 100%;\n gap: 0.75rem;\n}\n.toast-left {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n flex-shrink: 0;\n}\n.toast-body {\n line-height: 1.4;\n}\n.toast-action-btn {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 0;\n}\n.p-toast-message-content {\n position: relative;\n}\n.p-toast-icon-close {\n position: static;\n}\n.toast-left .p-toast-icon-close {\n order: 3;\n}\n/* Toast - Percentage */\n.toast-percentage {\n margin-top: 0.5rem;\n width: 100%;\n}\n\n.toast-percentage-label {\n font-size: 0.875rem;\n color: #6b7280;\n margin-bottom: 0.25rem;\n text-align: right;\n width: 100%;\n}\n\n.toast-percentage-bar {\n height: 6px;\n background-color: #e5e7eb;\n border-radius: 999px;\n overflow: hidden;\n width: 100%;\n}\n\n.toast-percentage-bar-fill {\n height: 100%;\n background-color: #3b82f6;\n transition: width 0.3s ease;\n}\n\n/* Link */\n\n.toast-link {\n margin-top: 0.5rem;\n}\n\n.toast-link a {\n font-size: 0.85rem;\n font-weight: 500;\n color: #2563eb;\n text-decoration: underline;\n}\n\n.toast-link a:hover {\n text-decoration: none;\n}\n\n/* Links */\n\n.toast-links {\n margin-top: 0.5rem;\n padding-left: 1rem;\n}\n\n.toast-links li {\n margin-bottom: 0.25rem;\n}\n\n.toast-links a {\n font-size: 0.85rem;\n color: #2563eb;\n text-decoration: underline;\n}\n\n.toast-links a:hover {\n text-decoration: none;\n}\n\n.toast-message {\n padding-right: 20px;\n}\n.p-toast-message {\n position: relative;\n}\n.p-toast-message .p-toast-icon-close {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n}\n.p-toast-message .toast-action-btn {\n position: absolute;\n top: 0.5rem;\n right: 2.5rem;\n}\n\n/* AttachedFiles */\n\n.toast-attached-files {\n margin-top: 0.75rem;\n}\n\n.toast-attached-files-title {\n font-size: 0.75rem;\n font-weight: 600;\n color: #6b7280;\n margin-bottom: 0.25rem;\n}\n\n.toast-attached-files-list {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n\n.toast-attached-files-list li {\n margin-bottom: 0.25rem;\n}\n\n.toast-attached-files-list a {\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n font-size: 0.85rem;\n color: #2563eb;\n text-decoration: underline;\n}\n\n.toast-attached-files-list a:hover {\n text-decoration: none;\n}\n\n";
42654
42654
  styleInject(css_248z);
42655
42655
 
42656
- var Toast = function Toast(_ref) {
42656
+ // Fonction utilitaire pour obtenir l'icône en fonction du type
42657
+ var getIconByType = function getIconByType(type) {
42658
+ switch (type) {
42659
+ case "success":
42660
+ return "pi pi-check-circle";
42661
+ case "error":
42662
+ return "pi pi-times-circle";
42663
+ case "settingError":
42664
+ return "pi pi-cog pi-times-circle";
42665
+ case "warning":
42666
+ return "pi pi-exclamation-triangle";
42667
+ case "processing":
42668
+ return "pi pi-spinner pi-spin";
42669
+ case "info":
42670
+ default:
42671
+ return "pi pi-info-circle";
42672
+ }
42673
+ };
42674
+
42675
+ // Fonction utilitaire pour obtenir la classe CSS en fonction de la taille
42676
+ var getSizeClassName = function getSizeClassName(size, sizeSModulable) {
42677
+ switch (size) {
42678
+ case 'S':
42679
+ return "toast_s--compact";
42680
+ case 'L':
42681
+ return sizeSModulable ? "toast_s--large" : "";
42682
+ default:
42683
+ return '';
42684
+ }
42685
+ };
42686
+ var RichMessage = function RichMessage(_ref) {
42657
42687
  var icon = _ref.icon,
42658
- message = _ref.message,
42659
- _ref$enableHtmlConten = _ref.enableHtmlContent,
42660
- enableHtmlContent = _ref$enableHtmlConten === void 0 ? false : _ref$enableHtmlConten,
42661
42688
  _ref$type = _ref.type,
42662
42689
  type = _ref$type === void 0 ? "info" : _ref$type,
42663
42690
  _ref$size = _ref.size,
42664
42691
  size = _ref$size === void 0 ? "M" : _ref$size,
42665
- _ref$closable = _ref.closable,
42666
- closable = _ref$closable === void 0 ? true : _ref$closable,
42667
- _ref$position = _ref.position,
42668
- position = _ref$position === void 0 ? "top-right" : _ref$position,
42669
- _ref$duration = _ref.duration,
42670
- duration = _ref$duration === void 0 ? 3000 : _ref$duration,
42671
- _ref$autoShow = _ref.autoShow,
42672
- autoShow = _ref$autoShow === void 0 ? true : _ref$autoShow,
42673
- onSizeChange = _ref.onSizeChange,
42674
42692
  title = _ref.title,
42675
- sticky = _ref.sticky,
42693
+ message = _ref.message,
42694
+ _ref$enableHtmlConten = _ref.enableHtmlContent,
42695
+ enableHtmlContent = _ref$enableHtmlConten === void 0 ? false : _ref$enableHtmlConten,
42696
+ link = _ref.link,
42697
+ _ref$links = _ref.links,
42698
+ links = _ref$links === void 0 ? [] : _ref$links,
42699
+ _ref$attachedFiles = _ref.attachedFiles,
42700
+ attachedFiles = _ref$attachedFiles === void 0 ? [] : _ref$attachedFiles,
42676
42701
  _ref$enablePercentage = _ref.enablePercentage,
42677
42702
  enablePercentage = _ref$enablePercentage === void 0 ? false : _ref$enablePercentage,
42678
- percentage = _ref.percentage,
42679
- link = _ref.link,
42680
- links = _ref.links;
42681
- _ref.datetimecreation;
42682
- var sizeSModulable = _ref.sizeSModulable,
42683
- isExpanded = _ref.isExpanded,
42684
- attachedFiles = _ref.attachedFiles;
42685
- var toastRef = useRef(null);
42686
- var hasShownRef = useRef(false);
42687
- var progressBarRef = useRef(null);
42688
- var percentageTextRef = useRef(null);
42689
- var handleToggleSize = function handleToggleSize() {
42690
- if (!onSizeChange) return;
42691
- if (size === "S") {
42692
- onSizeChange("L");
42693
- toastRef.current.clear();
42694
- hasShownRef.current = false;
42695
- } else if (size === "L") {
42696
- onSizeChange("S");
42697
- toastRef.current.clear();
42698
- hasShownRef.current = false;
42699
- }
42700
- };
42701
- var classNameSizeS = function classNameSizeS() {
42702
- switch (size) {
42703
- case 'S':
42704
- return "toast_s--compact";
42705
- case 'L':
42706
- if (sizeSModulable === true) {
42707
- return "toast_s--large";
42708
- } else {
42709
- return "";
42710
- }
42711
- default:
42712
- return '';
42713
- }
42714
- };
42715
- var memoizedRichMessage = useMemo(function () {
42716
- return /*#__PURE__*/React__default.createElement(RichMessage, {
42717
- icon: icon,
42718
- type: type,
42719
- size: size,
42720
- title: title,
42721
- message: message,
42722
- enableHtmlContent: enableHtmlContent,
42723
- link: link,
42724
- links: links,
42725
- attachedFiles: attachedFiles,
42726
- enablePercentage: enablePercentage,
42727
- sizeSModulable: sizeSModulable,
42728
- isExpanded: isExpanded,
42729
- onSizeChange: onSizeChange,
42730
- toastRef: toastRef,
42731
- progressBarRef: progressBarRef,
42732
- percentageTextRef: percentageTextRef,
42733
- handleToggleSize: handleToggleSize
42734
- });
42735
- }, [icon, type, size, title, message, enableHtmlContent, link, links, attachedFiles, enablePercentage, sizeSModulable, isExpanded, onSizeChange, handleToggleSize]);
42736
- useEffect(function () {
42737
- if (!toastRef.current || !autoShow) return;
42738
- if (!hasShownRef.current) {
42739
- toastRef.current.show({
42740
- severity: type,
42741
- closable: closable,
42742
- life: duration,
42743
- sticky: sticky,
42744
- className: "".concat(classNameSizeS(), " ").concat(type === "processing" ? "toast--processing" : ""),
42745
- content: function content() {
42746
- return memoizedRichMessage;
42747
- }
42748
- });
42749
- hasShownRef.current = true;
42750
- }
42751
- }, [autoShow, toastRef, memoizedRichMessage]);
42752
- useEffect(function () {
42753
- return function () {
42754
- if (toastRef.current) {
42755
- toastRef.current.clear();
42756
- hasShownRef.current = false;
42757
- }
42758
- };
42759
- }, []);
42760
- useEffect(function () {
42761
- if (progressBarRef.current) {
42762
- progressBarRef.current.style.width = "".concat(percentage, "%");
42763
- }
42764
- if (percentageTextRef.current) {
42765
- percentageTextRef.current.textContent = "".concat(percentage, "%");
42766
- }
42767
- }, [percentage]);
42768
- return /*#__PURE__*/React__default.createElement(Toast$1, {
42769
- ref: toastRef,
42770
- position: position
42771
- });
42772
- };
42773
-
42774
- // Singleton pour l'empilement des toasts
42775
- var toastRefs = {
42776
- containers: {},
42777
- sizeStates: new Map()
42778
- };
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;
42792
- var ref = useRef(null);
42793
- useEffect(function () {
42794
- if (!toastRefs.containers[position]) {
42795
- toastRefs.containers[position] = ref;
42796
- }
42797
- }, [position]);
42798
- return /*#__PURE__*/React__default.createElement(Toast$1, {
42799
- ref: ref,
42800
- position: position
42801
- });
42802
- };
42803
- var showToast = function showToast(props) {
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);
42812
- }
42813
- setTimeout(function () {
42814
- var toastRef = toastRefs.containers[position];
42815
- if (toastRef !== null && toastRef !== void 0 && toastRef.current) {
42816
- // Générer un ID unique pour ce toast
42817
- var toastId = "toast-".concat(Date.now(), "-").concat(Math.random());
42818
-
42819
- // Initialiser l'état de taille ET position
42820
- var initialSize = props.size || 'M';
42821
- toastRefs.sizeStates.set(toastId, {
42822
- currentSize: initialSize,
42823
- isExpanded: initialSize === 'L',
42824
- currentPosition: position
42825
- });
42826
- var progressBarRef = {
42827
- current: null
42828
- };
42829
- var percentageTextRef = {
42830
- current: null
42831
- };
42832
-
42833
- // Fonction pour changer la taille
42834
- var handleSizeChange = function handleSizeChange(newSize) {
42835
- var state = toastRefs.sizeStates.get(toastId);
42836
- if (!state) return;
42837
- state.currentSize = newSize;
42838
- state.isExpanded = newSize === 'L';
42839
-
42840
- // Re-afficher le toast avec la nouvelle taille
42841
- toastRef.current.clear();
42842
- showToastWithState(toastId, _objectSpread2(_objectSpread2({}, props), {}, {
42843
- size: newSize
42844
- }));
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
- };
42876
- var handleToggleSize = function handleToggleSize() {
42877
- var state = toastRefs.sizeStates.get(toastId);
42878
- if (!state || !props.sizeSModulable) return;
42879
- var newSize = state.currentSize === "S" ? "L" : "S";
42880
- handleSizeChange(newSize);
42881
- };
42882
- var classNameSizeS = function classNameSizeS(currentSize) {
42883
- switch (currentSize) {
42884
- case 'S':
42885
- return "toast_s--compact";
42886
- case 'L':
42887
- if (props.sizeSModulable === true) {
42888
- return "toast_s--large";
42889
- } else {
42890
- return "";
42891
- }
42892
- default:
42893
- return '';
42894
- }
42895
- };
42896
- var showToastWithState = function showToastWithState(id, currentProps) {
42897
- var state = toastRefs.sizeStates.get(id);
42898
- if (!state) return;
42899
- var currentToastRef = toastRefs.containers[state.currentPosition];
42900
- if (!(currentToastRef !== null && currentToastRef !== void 0 && currentToastRef.current)) return;
42901
- currentToastRef.current.show({
42902
- severity: currentProps.type || 'info',
42903
- life: currentProps.duration || 3000,
42904
- sticky: currentProps.sticky,
42905
- closable: currentProps.closable !== false,
42906
- summary: currentProps.title || '',
42907
- className: "".concat(classNameSizeS(state.currentSize), " ").concat(currentProps.type === "processing" ? "toast--processing" : ""),
42908
- content: function content() {
42909
- return /*#__PURE__*/React__default.createElement(RichMessage, {
42910
- icon: currentProps.icon,
42911
- type: currentProps.type,
42912
- size: state.currentSize,
42913
- title: currentProps.title,
42914
- message: currentProps.message,
42915
- enableHtmlContent: currentProps.enableHtmlContent,
42916
- currentPercentage: currentProps.percentage || 0,
42917
- link: currentProps.link,
42918
- links: currentProps.links,
42919
- attachedFiles: currentProps.attachedFiles,
42920
- enablePercentage: currentProps.enablePercentage,
42921
- sizeSModulable: currentProps.sizeSModulable,
42922
- isExpanded: state.isExpanded,
42923
- currentPosition: state.currentPosition,
42924
- onSizeChange: handleSizeChange,
42925
- onPositionChange: handlePositionChange,
42926
- toastRef: currentToastRef,
42927
- progressBarRef: progressBarRef,
42928
- percentageTextRef: percentageTextRef,
42929
- handleToggleSize: handleToggleSize
42930
- });
42931
- },
42932
- onRemove: function onRemove() {
42933
- // Nettoyer l'état quand le toast est supprimé
42934
- toastRefs.sizeStates["delete"](id);
42935
- }
42936
- });
42937
- };
42938
- showToastWithState(toastId, props);
42939
- }
42940
- }, 0);
42941
- };
42942
- if (typeof window !== 'undefined') {
42943
- window.showArengibookToast = showToast;
42944
- }
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;
42969
- var getIconByType = function getIconByType() {
42970
- switch (type) {
42971
- case "success":
42972
- return "pi pi-check-circle";
42973
- case "error":
42974
- return "pi pi-times-circle";
42975
- case "settingError":
42976
- return "pi pi-cog pi-times-circle";
42977
- case "warning":
42978
- return "pi pi-exclamation-triangle";
42979
- case "processing":
42980
- return "pi pi-spinner pi-spin";
42981
- case "info":
42982
- default:
42983
- return "pi pi-info-circle";
42984
- }
42985
- };
42703
+ currentPercentage = _ref.currentPercentage,
42704
+ sizeSModulable = _ref.sizeSModulable,
42705
+ _ref$isExpanded = _ref.isExpanded,
42706
+ isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
42707
+ progressBarRef = _ref.progressBarRef,
42708
+ percentageTextRef = _ref.percentageTextRef,
42709
+ handleToggleSize = _ref.handleToggleSize;
42986
42710
  return /*#__PURE__*/React__default.createElement("div", {
42987
42711
  className: "toast-root"
42988
42712
  }, /*#__PURE__*/React__default.createElement("div", {
42989
42713
  className: "toast-left"
42990
42714
  }, /*#__PURE__*/React__default.createElement("i", {
42991
- className: icon !== null && icon !== void 0 ? icon : getIconByType(),
42715
+ className: icon !== null && icon !== void 0 ? icon : getIconByType(type),
42992
42716
  "aria-hidden": "true"
42993
- }), (size === "S" || size === "L" && sizeSModulable === true) && /*#__PURE__*/React__default.createElement("button", {
42717
+ }), (size === "S" || size === "L" && sizeSModulable) && /*#__PURE__*/React__default.createElement("button", {
42994
42718
  type: "button",
42995
- onClick: function onClick() {
42996
- return handleToggleSize();
42997
- },
42719
+ onClick: handleToggleSize,
42998
42720
  "aria-label": isExpanded ? "Réduire" : "Agrandir",
42999
42721
  className: "toast-action-btn"
43000
42722
  }, /*#__PURE__*/React__default.createElement("i", {
@@ -43060,6 +42782,228 @@ var RichMessage = function RichMessage(_ref3) {
43060
42782
  })))));
43061
42783
  };
43062
42784
 
42785
+ // Singleton pour l'empilement des toasts
42786
+ var toastRefs = {
42787
+ containers: {},
42788
+ sizeStates: {}};
42789
+ var ToastContainer = function ToastContainer(_ref2) {
42790
+ var _ref2$position = _ref2.position,
42791
+ position = _ref2$position === void 0 ? "top-right" : _ref2$position;
42792
+ var ref = useRef(null);
42793
+ useEffect(function () {
42794
+ if (!toastRefs.containers[position]) {
42795
+ toastRefs.containers[position] = ref;
42796
+ }
42797
+ }, [position]);
42798
+ return /*#__PURE__*/React__default.createElement(Toast$1, {
42799
+ ref: ref,
42800
+ position: position
42801
+ });
42802
+ };
42803
+ var Toast = function Toast(_ref3) {
42804
+ var icon = _ref3.icon,
42805
+ message = _ref3.message,
42806
+ _ref3$enableHtmlConte = _ref3.enableHtmlContent,
42807
+ enableHtmlContent = _ref3$enableHtmlConte === void 0 ? false : _ref3$enableHtmlConte,
42808
+ _ref3$type = _ref3.type,
42809
+ type = _ref3$type === void 0 ? "info" : _ref3$type,
42810
+ _ref3$size = _ref3.size,
42811
+ size = _ref3$size === void 0 ? "M" : _ref3$size,
42812
+ _ref3$closable = _ref3.closable,
42813
+ closable = _ref3$closable === void 0 ? true : _ref3$closable,
42814
+ _ref3$position = _ref3.position,
42815
+ position = _ref3$position === void 0 ? "top-right" : _ref3$position,
42816
+ _ref3$duration = _ref3.duration,
42817
+ duration = _ref3$duration === void 0 ? 3000 : _ref3$duration,
42818
+ _ref3$autoShow = _ref3.autoShow,
42819
+ autoShow = _ref3$autoShow === void 0 ? true : _ref3$autoShow,
42820
+ onSizeChange = _ref3.onSizeChange,
42821
+ title = _ref3.title,
42822
+ sticky = _ref3.sticky,
42823
+ _ref3$enablePercentag = _ref3.enablePercentage,
42824
+ enablePercentage = _ref3$enablePercentag === void 0 ? false : _ref3$enablePercentag,
42825
+ percentage = _ref3.percentage,
42826
+ link = _ref3.link,
42827
+ links = _ref3.links;
42828
+ _ref3.datetimecreation;
42829
+ var sizeSModulable = _ref3.sizeSModulable,
42830
+ isExpanded = _ref3.isExpanded,
42831
+ attachedFiles = _ref3.attachedFiles;
42832
+ var toastRef = useRef(null);
42833
+ var hasShownRef = useRef(false);
42834
+ var progressBarRef = useRef(null);
42835
+ var percentageTextRef = useRef(null);
42836
+ var handleToggleSize = function handleToggleSize() {
42837
+ if (!onSizeChange) return;
42838
+ var newSize = size === "S" ? "L" : "S";
42839
+ onSizeChange(newSize);
42840
+ toastRef.current.clear();
42841
+ hasShownRef.current = false;
42842
+ };
42843
+ var memoizedRichMessage = useMemo(function () {
42844
+ return /*#__PURE__*/React__default.createElement(RichMessage, {
42845
+ icon: icon,
42846
+ type: type,
42847
+ size: size,
42848
+ title: title,
42849
+ message: message,
42850
+ enableHtmlContent: enableHtmlContent,
42851
+ link: link,
42852
+ links: links,
42853
+ attachedFiles: attachedFiles,
42854
+ enablePercentage: enablePercentage,
42855
+ currentPercentage: percentage,
42856
+ sizeSModulable: sizeSModulable,
42857
+ isExpanded: isExpanded,
42858
+ progressBarRef: progressBarRef,
42859
+ percentageTextRef: percentageTextRef,
42860
+ handleToggleSize: handleToggleSize
42861
+ });
42862
+ }, [icon, type, size, title, message, enableHtmlContent, link, links, attachedFiles, enablePercentage, percentage, sizeSModulable, isExpanded, handleToggleSize]);
42863
+ useEffect(function () {
42864
+ if (!toastRef.current || !autoShow || hasShownRef.current) return;
42865
+ toastRef.current.show({
42866
+ severity: type,
42867
+ closable: closable,
42868
+ life: duration,
42869
+ sticky: sticky,
42870
+ className: "".concat(getSizeClassName(size, sizeSModulable), " ").concat(type === "processing" ? "toast--processing" : ""),
42871
+ content: function content() {
42872
+ return memoizedRichMessage;
42873
+ }
42874
+ });
42875
+ hasShownRef.current = true;
42876
+ }, [autoShow, toastRef, memoizedRichMessage, type, closable, duration, sticky, size, sizeSModulable]);
42877
+ useEffect(function () {
42878
+ if (progressBarRef.current) {
42879
+ progressBarRef.current.style.width = "".concat(percentage, "%");
42880
+ }
42881
+ if (percentageTextRef.current) {
42882
+ percentageTextRef.current.textContent = "".concat(percentage, "%");
42883
+ }
42884
+ }, [percentage]);
42885
+ useEffect(function () {
42886
+ return function () {
42887
+ if (toastRef.current) {
42888
+ toastRef.current.clear();
42889
+ hasShownRef.current = false;
42890
+ }
42891
+ };
42892
+ }, []);
42893
+ return /*#__PURE__*/React__default.createElement(Toast$1, {
42894
+ ref: toastRef,
42895
+ position: position
42896
+ });
42897
+ };
42898
+ var showToast = function showToast(props) {
42899
+ var position = props.position || "top-right";
42900
+ if (!toastRefs.containers[position]) {
42901
+ var containerDiv = document.createElement('div');
42902
+ containerDiv.id = "toast-container-".concat(position);
42903
+ document.body.appendChild(containerDiv);
42904
+ ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, {
42905
+ position: position
42906
+ }), containerDiv);
42907
+ }
42908
+ setTimeout(function () {
42909
+ var toastRef = toastRefs.containers[position];
42910
+ if (!(toastRef !== null && toastRef !== void 0 && toastRef.current)) return;
42911
+ var toastId = "toast-".concat(Date.now(), "-").concat(Math.random());
42912
+ var initialSize = props.size || 'M';
42913
+ toastRefs.sizeStates[toastId] = {
42914
+ currentSize: initialSize,
42915
+ isExpanded: initialSize === 'L',
42916
+ currentPosition: position
42917
+ };
42918
+ var progressBarRef = {
42919
+ current: null
42920
+ };
42921
+ var percentageTextRef = {
42922
+ current: null
42923
+ };
42924
+ var handleSizeChange = function handleSizeChange(newSize) {
42925
+ var state = toastRefs.sizeStates[toastId];
42926
+ if (!state) return;
42927
+ state.currentSize = newSize;
42928
+ state.isExpanded = newSize === 'L';
42929
+ toastRef.current.clear();
42930
+ showToastWithState(toastId, _objectSpread2(_objectSpread2({}, props), {}, {
42931
+ size: newSize
42932
+ }));
42933
+ };
42934
+ var handlePositionChange = function handlePositionChange(newPosition) {
42935
+ var state = toastRefs.sizeStates[toastId];
42936
+ if (!state) return;
42937
+ var oldToastRef = toastRefs.containers[state.currentPosition];
42938
+ if (oldToastRef !== null && oldToastRef !== void 0 && oldToastRef.current) {
42939
+ oldToastRef.current.clear();
42940
+ }
42941
+ state.currentPosition = newPosition;
42942
+ if (!toastRefs.containers[newPosition]) {
42943
+ var _containerDiv = document.createElement('div');
42944
+ _containerDiv.id = "toast-container-".concat(newPosition);
42945
+ document.body.appendChild(_containerDiv);
42946
+ ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, {
42947
+ position: newPosition
42948
+ }), _containerDiv);
42949
+ }
42950
+ setTimeout(function () {
42951
+ showToastWithState(toastId, _objectSpread2(_objectSpread2({}, props), {}, {
42952
+ position: newPosition
42953
+ }));
42954
+ }, 50);
42955
+ };
42956
+ var handleToggleSize = function handleToggleSize() {
42957
+ var state = toastRefs.sizeStates[toastId];
42958
+ if (!state || !props.sizeSModulable) return;
42959
+ var newSize = state.currentSize === "S" ? "L" : "S";
42960
+ handleSizeChange(newSize);
42961
+ };
42962
+ var showToastWithState = function showToastWithState(id, currentProps) {
42963
+ var state = toastRefs.sizeStates[id];
42964
+ if (!state) return;
42965
+ var currentToastRef = toastRefs.containers[state.currentPosition];
42966
+ if (!(currentToastRef !== null && currentToastRef !== void 0 && currentToastRef.current)) return;
42967
+ currentToastRef.current.show({
42968
+ severity: currentProps.type || 'info',
42969
+ life: currentProps.duration || 3000,
42970
+ sticky: currentProps.sticky,
42971
+ closable: currentProps.closable !== false,
42972
+ summary: currentProps.title || '',
42973
+ className: "".concat(getSizeClassName(state.currentSize, currentProps.sizeSModulable), " ").concat(currentProps.type === "processing" ? "toast--processing" : ""),
42974
+ content: function content() {
42975
+ return /*#__PURE__*/React__default.createElement(RichMessage, {
42976
+ icon: currentProps.icon,
42977
+ type: currentProps.type,
42978
+ size: state.currentSize,
42979
+ title: currentProps.title,
42980
+ message: currentProps.message,
42981
+ enableHtmlContent: currentProps.enableHtmlContent,
42982
+ currentPercentage: currentProps.percentage || 0,
42983
+ link: currentProps.link,
42984
+ links: currentProps.links,
42985
+ attachedFiles: currentProps.attachedFiles,
42986
+ enablePercentage: currentProps.enablePercentage,
42987
+ sizeSModulable: currentProps.sizeSModulable,
42988
+ isExpanded: state.isExpanded,
42989
+ currentPosition: state.currentPosition,
42990
+ onSizeChange: handleSizeChange,
42991
+ onPositionChange: handlePositionChange,
42992
+ toastRef: currentToastRef,
42993
+ progressBarRef: progressBarRef,
42994
+ percentageTextRef: percentageTextRef,
42995
+ handleToggleSize: handleToggleSize
42996
+ });
42997
+ }
42998
+ });
42999
+ };
43000
+ showToastWithState(toastId, props);
43001
+ }, 0);
43002
+ };
43003
+ if (typeof window !== 'undefined') {
43004
+ window.showArengibookToast = showToast;
43005
+ }
43006
+
43063
43007
  var ToastPresets = {
43064
43008
  Picto: {
43065
43009
  presetType: "base",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.5.510",
4
+ "version": "2.5.511",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {