arengibook 2.5.2 → 2.5.4

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 +32 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42835,21 +42835,40 @@ var Toast = function Toast(_ref) {
42835
42835
  });
42836
42836
  };
42837
42837
 
42838
- // Fonction globale pour afficher un toast simplement
42839
- var showToast = function showToast(props) {
42840
- var container = document.createElement('div');
42841
- document.body.appendChild(container);
42842
- var cleanup = function cleanup() {
42843
- ReactDOM.unmountComponentAtNode(container);
42844
- container.remove();
42845
- };
42846
- ReactDOM.render(/*#__PURE__*/React__default.createElement(Toast, props), container);
42847
-
42848
- // Supprime le conteneur après la durée du toast
42849
- setTimeout(cleanup, (props.duration || 3000) + 500);
42838
+ // Singleton pour l'empilement des toasts
42839
+ var toastRef = null;
42840
+ var container = null;
42841
+ var ToastContainer = function ToastContainer() {
42842
+ var ref = useRef(null);
42843
+ useEffect(function () {
42844
+ toastRef = ref.current;
42845
+ }, []);
42846
+ return /*#__PURE__*/React__default.createElement(Toast$1, {
42847
+ ref: ref,
42848
+ position: "top-right"
42849
+ });
42850
42850
  };
42851
42851
 
42852
- // Expose globalement
42852
+ // Fonction globale simple
42853
+ var showToast = function showToast(props) {
42854
+ if (!container) {
42855
+ container = document.createElement('div');
42856
+ document.body.appendChild(container);
42857
+ ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, null), container);
42858
+ }
42859
+ setTimeout(function () {
42860
+ if (toastRef) {
42861
+ toastRef.show({
42862
+ severity: props.type || 'info',
42863
+ summary: props.title || '',
42864
+ detail: props.message,
42865
+ life: props.duration || 3000,
42866
+ sticky: props.sticky,
42867
+ closable: props.closable !== false
42868
+ });
42869
+ }
42870
+ }, 0);
42871
+ };
42853
42872
  if (typeof window !== 'undefined') {
42854
42873
  window.showArengibookToast = showToast;
42855
42874
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.5.02",
4
+ "version": "2.5.04",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {