arengibook 2.5.508 → 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.
Files changed (2) hide show
  1. package/dist/index.js +157 -83
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42653,7 +42653,6 @@ 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
- // Toast.jsx
42657
42656
  var Toast = function Toast(_ref) {
42658
42657
  var icon = _ref.icon,
42659
42658
  message = _ref.message,
@@ -42774,51 +42773,114 @@ var Toast = function Toast(_ref) {
42774
42773
 
42775
42774
  // Singleton pour l'empilement des toasts
42776
42775
  var toastRefs = {
42777
- toastRef: null,
42778
- hasShownRef: {
42779
- current: false
42780
- },
42781
- container: null
42776
+ containers: {},
42777
+ sizeStates: new Map()
42782
42778
  };
42783
- var ToastContainer = function ToastContainer() {
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.toastRef = ref;
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: "top-right"
42800
+ position: position
42791
42801
  });
42792
42802
  };
42793
42803
  var showToast = function showToast(props) {
42794
- if (!toastRefs.container) {
42795
- toastRefs.container = document.createElement('div');
42796
- document.body.appendChild(toastRefs.container);
42797
- ReactDOM.render(/*#__PURE__*/React__default.createElement(ToastContainer, null), toastRefs.container);
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
- if (toastRefs.toastRef) {
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
+ });
42801
42826
  var progressBarRef = {
42802
42827
  current: null
42803
42828
  };
42804
42829
  var percentageTextRef = {
42805
42830
  current: null
42806
42831
  };
42807
- var handleToggleSize = function handleToggleSize() {
42808
- console.log(props);
42809
- if (!props.onSizeChange) return;
42810
- if (props.size === "S") {
42811
- props.onSizeChange("L");
42812
- toastRefs.toastRef.current.clear();
42813
- toastRefs.hasShownRef.current = false;
42814
- } else if (props.size === "L") {
42815
- props.onSizeChange("S");
42816
- toastRefs.toastRef.current.clear();
42817
- toastRefs.hasShownRef.current = false;
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);
42818
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);
42819
42875
  };
42820
- var classNameSizeS = function classNameSizeS() {
42821
- switch (props.size) {
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) {
42822
42884
  case 'S':
42823
42885
  return "toast_s--compact";
42824
42886
  case 'L':
@@ -42831,67 +42893,79 @@ var showToast = function showToast(props) {
42831
42893
  return '';
42832
42894
  }
42833
42895
  };
42834
- toastRefs.toastRef.current.show({
42835
- severity: props.type || 'info',
42836
- life: props.duration || 3000,
42837
- sticky: props.sticky,
42838
- closable: props.closable !== false,
42839
- summary: props.title || '',
42840
- className: "".concat(classNameSizeS(), " ").concat(props.type === "processing" ? "toast--processing" : ""),
42841
- content: function content() {
42842
- return /*#__PURE__*/React__default.createElement(RichMessage, {
42843
- icon: props.icon,
42844
- type: props.type,
42845
- size: props.size,
42846
- title: props.title,
42847
- message: props.message,
42848
- enableHtmlContent: props.enableHtmlContent,
42849
- currentPercentage: props.percentage || 0,
42850
- link: props.link,
42851
- links: props.links,
42852
- attachedFiles: props.attachedFiles,
42853
- enablePercentage: props.enablePercentage,
42854
- sizeSModulable: props.sizeSModulable,
42855
- isExpanded: props.isExpanded,
42856
- onSizeChange: props.onSizeChange,
42857
- toastRef: toastRefs.toastRef,
42858
- hasShownRef: toastRefs.hasShownRef,
42859
- progressBarRef: progressBarRef,
42860
- percentageTextRef: percentageTextRef,
42861
- handleToggleSize: handleToggleSize
42862
- });
42863
- }
42864
- });
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);
42865
42939
  }
42866
42940
  }, 0);
42867
42941
  };
42868
42942
  if (typeof window !== 'undefined') {
42869
42943
  window.showArengibookToast = showToast;
42870
42944
  }
42871
- var RichMessage = function RichMessage(_ref2) {
42872
- var icon = _ref2.icon,
42873
- _ref2$type = _ref2.type,
42874
- type = _ref2$type === void 0 ? "info" : _ref2$type,
42875
- _ref2$size = _ref2.size,
42876
- size = _ref2$size === void 0 ? "M" : _ref2$size,
42877
- title = _ref2.title,
42878
- message = _ref2.message,
42879
- _ref2$enableHtmlConte = _ref2.enableHtmlContent,
42880
- enableHtmlContent = _ref2$enableHtmlConte === void 0 ? false : _ref2$enableHtmlConte,
42881
- link = _ref2.link,
42882
- _ref2$links = _ref2.links,
42883
- links = _ref2$links === void 0 ? [] : _ref2$links,
42884
- _ref2$attachedFiles = _ref2.attachedFiles,
42885
- attachedFiles = _ref2$attachedFiles === void 0 ? [] : _ref2$attachedFiles,
42886
- _ref2$enablePercentag = _ref2.enablePercentage,
42887
- enablePercentage = _ref2$enablePercentag === void 0 ? false : _ref2$enablePercentag,
42888
- currentPercentage = _ref2.currentPercentage,
42889
- sizeSModulable = _ref2.sizeSModulable,
42890
- _ref2$isExpanded = _ref2.isExpanded,
42891
- isExpanded = _ref2$isExpanded === void 0 ? false : _ref2$isExpanded,
42892
- progressBarRef = _ref2.progressBarRef,
42893
- percentageTextRef = _ref2.percentageTextRef,
42894
- handleToggleSize = _ref2.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;
42895
42969
  var getIconByType = function getIconByType() {
42896
42970
  switch (type) {
42897
42971
  case "success":
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.5.508",
4
+ "version": "2.5.510",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {