allaw-ui 3.1.9 → 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.
- package/dist/components/molecules/billingCount/BillingCount.d.ts +2 -1
- package/dist/components/molecules/billingCount/BillingCount.js +14 -2
- package/dist/components/molecules/billingCount/BillingCount.stories.d.ts +1 -0
- package/dist/components/molecules/billingCount/BillingCount.stories.js +5 -0
- package/package.json +1 -1
|
@@ -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;
|