allaw-ui 3.1.8 → 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,10 +6,11 @@ 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");
@@ -35,15 +36,25 @@ var Modal = function (_a) {
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;
@@ -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.8",
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",