allaw-ui 3.1.7 → 3.1.9

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.
@@ -8,6 +8,7 @@ export interface ModalProps {
8
8
  onConfirm: () => void;
9
9
  onCancel: () => void;
10
10
  isDanger?: boolean;
11
+ confirmIconName?: string;
11
12
  verticalOffset?: {
12
13
  top?: number;
13
14
  bottom?: number;
@@ -6,16 +6,17 @@ import SecondaryButton from "../../atoms/buttons/SecondaryButton";
6
6
  import Heading from "../../atoms/typography/Heading";
7
7
  import Paragraph from "../../atoms/typography/Paragraph";
8
8
  var Modal = function (_a) {
9
- var show = _a.show, title = _a.title, description = _a.description, confirmLabel = _a.confirmLabel, cancelLabel = _a.cancelLabel, onConfirm = _a.onConfirm, onCancel = _a.onCancel, _b = _a.isDanger, isDanger = _b === void 0 ? false : _b, verticalOffset = _a.verticalOffset;
10
- var _c = useState(false), isVisible = _c[0], setIsVisible = _c[1];
9
+ var show = _a.show, title = _a.title, description = _a.description, confirmLabel = _a.confirmLabel, cancelLabel = _a.cancelLabel, onConfirm = _a.onConfirm, onCancel = _a.onCancel, _b = _a.isDanger, isDanger = _b === void 0 ? false : _b, _c = _a.confirmIconName, confirmIconName = _c === void 0 ? "allaw-icon-check" : _c, verticalOffset = _a.verticalOffset;
10
+ var _d = useState(false), isVisible = _d[0], setIsVisible = _d[1];
11
11
  var portalContainerRef = useRef(null);
12
12
  var modalContentRef = useRef(null);
13
+ var isMouseDownOutsideRef = useRef(false);
13
14
  useEffect(function () {
14
15
  if (show) {
15
16
  var container = document.createElement("div");
16
17
  document.body.appendChild(container);
17
18
  portalContainerRef.current = container;
18
- document.body.classList.add("modal-open");
19
+ document.body.style.overflow = "hidden";
19
20
  setIsVisible(true);
20
21
  }
21
22
  else {
@@ -23,7 +24,7 @@ var Modal = function (_a) {
23
24
  if (portalContainerRef.current &&
24
25
  document.body.contains(portalContainerRef.current)) {
25
26
  document.body.removeChild(portalContainerRef.current);
26
- document.body.classList.remove("modal-open");
27
+ document.body.style.overflow = "";
27
28
  }
28
29
  }
29
30
  return function () {
@@ -31,19 +32,29 @@ var Modal = function (_a) {
31
32
  if (portalContainerRef.current &&
32
33
  document.body.contains(portalContainerRef.current)) {
33
34
  document.body.removeChild(portalContainerRef.current);
34
- document.body.classList.remove("modal-open");
35
+ document.body.style.overflow = "";
35
36
  }
36
37
  };
37
38
  }, [show]);
38
- var handleOutsideClick = function (e) {
39
+ var handleMouseDown = function (e) {
39
40
  if (modalContentRef.current &&
41
+ !modalContentRef.current.contains(e.target)) {
42
+ isMouseDownOutsideRef.current = true;
43
+ }
44
+ else {
45
+ isMouseDownOutsideRef.current = false;
46
+ }
47
+ };
48
+ var handleMouseUp = function (e) {
49
+ if (isMouseDownOutsideRef.current &&
50
+ modalContentRef.current &&
40
51
  !modalContentRef.current.contains(e.target)) {
41
52
  onCancel();
42
53
  }
43
54
  };
44
55
  if (!show || !isVisible || !portalContainerRef.current)
45
56
  return null;
46
- var modalContent = (React.createElement("div", { className: "".concat(style.modalOverlay, " ").concat(isVisible ? style.visible : "", " ").concat(show ? style.modal : ""), onClick: handleOutsideClick, style: {
57
+ var modalContent = (React.createElement("div", { className: "".concat(style.modalOverlay, " ").concat(isVisible ? style.visible : "", " ").concat(show ? style.modal : ""), onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, style: {
47
58
  paddingTop: (verticalOffset === null || verticalOffset === void 0 ? void 0 : verticalOffset.top) ? "".concat(verticalOffset.top, "px") : undefined,
48
59
  paddingBottom: (verticalOffset === null || verticalOffset === void 0 ? void 0 : verticalOffset.bottom)
49
60
  ? "".concat(verticalOffset.bottom, "px")
@@ -56,7 +67,7 @@ var Modal = function (_a) {
56
67
  React.createElement(Paragraph, { text: description, variant: "medium", size: "default", className: style.modalParagraph })),
57
68
  React.createElement("div", { className: style.modalButtons },
58
69
  React.createElement(SecondaryButton, { label: cancelLabel, onClick: onCancel, startIconName: "allaw-icon-close", startIcon: true }),
59
- React.createElement(PrimaryButton, { label: confirmLabel, variant: isDanger ? "warning" : "default", onClick: onConfirm, endIconName: "allaw-icon-check", endIcon: true })))));
70
+ React.createElement(PrimaryButton, { label: confirmLabel, variant: isDanger ? "warning" : "default", onClick: onConfirm, startIconName: confirmIconName, startIcon: true })))));
60
71
  return ReactDOM.createPortal(modalContent, portalContainerRef.current);
61
72
  };
62
73
  export default Modal;
@@ -110,7 +110,7 @@
110
110
  }
111
111
 
112
112
  /* Classe pour bloquer le scroll du body */
113
- body.stepper-open {
113
+ .modal-open {
114
114
  overflow: hidden;
115
115
  position: fixed;
116
116
  width: 100%;
@@ -290,25 +290,6 @@ body.stepper-open {
290
290
  flex: 1;
291
291
  }
292
292
 
293
- /* Classe pour bloquer le scroll du body */
294
- :global(.modal-open) {
295
- overflow: hidden;
296
- position: fixed;
297
- width: 100%;
298
- height: 100%;
299
- }
300
-
301
- @keyframes fadeIn {
302
- from {
303
- opacity: 0;
304
- transform: scale(0.9);
305
- }
306
- to {
307
- opacity: 1;
308
- transform: scale(1);
309
- }
310
- }
311
-
312
293
  @media (max-width: 1000px) {
313
294
  .modalContent {
314
295
  z-index: 5001;
@@ -14,6 +14,7 @@
14
14
  z-index: 1001;
15
15
  max-height: 90vh;
16
16
  overflow: hidden;
17
+ animation: fadeIn 0.2s ease-out;
17
18
  }
18
19
 
19
20
  .stepper-content {
@@ -92,14 +92,20 @@ export default {
92
92
  };
93
93
  var Template = function (args) {
94
94
  var _a = useState(args.currentStep), step = _a[0], setStep = _a[1];
95
+ var _b = useState(false), showStepper = _b[0], setShowStepper = _b[1];
95
96
  useEffect(function () {
96
97
  setStep(args.currentStep);
97
98
  }, [args.currentStep]);
98
- var updatedArgs = __assign(__assign({}, args), { currentStep: step, onClose: function () {
99
- action("Stepper closed")();
100
- if (args.onClose)
101
- args.onClose();
102
- }, primaryButton: args.primaryButton.map(function (button) { return (__assign(__assign({}, button), { onPrimaryButtonClick: function (currentStep) {
99
+ var handleOpenStepper = function () {
100
+ setShowStepper(true);
101
+ };
102
+ var handleCloseStepper = function () {
103
+ setShowStepper(false);
104
+ action("Stepper closed")();
105
+ if (args.onClose)
106
+ args.onClose();
107
+ };
108
+ var updatedArgs = __assign(__assign({}, args), { currentStep: step, onClose: handleCloseStepper, primaryButton: args.primaryButton.map(function (button) { return (__assign(__assign({}, button), { onPrimaryButtonClick: function (currentStep) {
103
109
  action("Primary button clicked on step ".concat(currentStep))();
104
110
  if (currentStep < args.steps) {
105
111
  setStep(currentStep + 1);
@@ -110,7 +116,9 @@ var Template = function (args) {
110
116
  setStep(currentStep - 1);
111
117
  }
112
118
  } })); }) });
113
- return React.createElement(Stepper, __assign({}, updatedArgs));
119
+ return (React.createElement("div", null,
120
+ React.createElement("button", { onClick: handleOpenStepper, style: { margin: "20px" } }, "Ouvrir le stepper"),
121
+ showStepper && React.createElement(Stepper, __assign({}, updatedArgs))));
114
122
  };
115
123
  export var Default = Template.bind({});
116
124
  Default.args = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",