allaw-ui 3.1.8 → 3.2.0

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.
@@ -5,6 +5,7 @@ export type BillingCountProps = {
5
5
  setIsStarted?: (value: boolean) => void;
6
6
  resetTimer?: boolean;
7
7
  pauseTimer?: boolean;
8
+ responsiveSize?: number;
8
9
  };
9
- declare const BillingCount: ({ onEnd, setIsStarted, resetTimer, pauseTimer, }: BillingCountProps) => React.JSX.Element;
10
+ declare const BillingCount: ({ onEnd, setIsStarted, resetTimer, pauseTimer, responsiveSize, }: BillingCountProps) => React.JSX.Element;
10
11
  export default BillingCount;
@@ -7,10 +7,11 @@ var LOCAL_STORAGE_KEYS = {
7
7
  HAS_STARTED_BEFORE: "hasStartedBefore",
8
8
  };
9
9
  var BillingCount = function (_a) {
10
- var onEnd = _a.onEnd, setIsStarted = _a.setIsStarted, resetTimer = _a.resetTimer, pauseTimer = _a.pauseTimer;
10
+ var onEnd = _a.onEnd, setIsStarted = _a.setIsStarted, resetTimer = _a.resetTimer, pauseTimer = _a.pauseTimer, responsiveSize = _a.responsiveSize;
11
11
  var _b = useState(0), elapsedSeconds = _b[0], setElapsedSeconds = _b[1];
12
12
  var _c = useState(false), isRunning = _c[0], setIsRunning = _c[1];
13
13
  var intervalRef = useRef(null);
14
+ var _d = useState(true), isVisible = _d[0], setIsVisible = _d[1];
14
15
  // --- Au premier render, on relit le localStorage
15
16
  useEffect(function () {
16
17
  var savedAccumulated = getAccumulatedTime();
@@ -69,6 +70,17 @@ var BillingCount = function (_a) {
69
70
  }
70
71
  }
71
72
  }, [resetTimer, pauseTimer]);
73
+ useEffect(function () {
74
+ var handleResize = function () {
75
+ if (responsiveSize !== undefined) {
76
+ var width = window.innerWidth;
77
+ setIsVisible(width >= responsiveSize);
78
+ }
79
+ };
80
+ handleResize();
81
+ window.addEventListener("resize", handleResize);
82
+ return function () { return window.removeEventListener("resize", handleResize); };
83
+ }, [responsiveSize]);
72
84
  // --- Fonctions utilitaires ---
73
85
  // Calcule la différence en s'appuyant sur:
74
86
  // accumulatedTime (secondes) + (Date.now() - startTime) / 1000
@@ -151,7 +163,7 @@ var BillingCount = function (_a) {
151
163
  };
152
164
  return (React.createElement("button", { onClick: handleButtonClick, className: "billing-button-wrapper ".concat(isRunning ? "isRunning" : "") },
153
165
  React.createElement("i", { className: "allaw-icon-clock" }),
154
- React.createElement("span", { className: "billing-time" }, formatTime(elapsedSeconds)),
166
+ isVisible && (React.createElement("span", { className: "billing-time" }, formatTime(elapsedSeconds))),
155
167
  React.createElement("i", { className: isRunning ? "allaw-icon-pause" : "allaw-icon-play", style: { fontSize: "12px", color: "#25BEEB", fontWeight: 800 } })));
156
168
  };
157
169
  export default BillingCount;
@@ -17,5 +17,6 @@ export namespace WithStartedState {
17
17
  }
18
18
  }
19
19
  }
20
+ export const WithResponsiveSize: any;
20
21
  import BillingCount from "./BillingCount";
21
22
  import React from "react";
@@ -42,3 +42,8 @@ WithStartedState.story = {
42
42
  },
43
43
  },
44
44
  };
45
+ export var WithResponsiveSize = Template.bind({});
46
+ WithResponsiveSize.args = {
47
+ onEnd: onEnd,
48
+ responsiveSize: 600,
49
+ };
@@ -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.2.0",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",