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.
- 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/dist/components/molecules/modal/Modal.d.ts +1 -0
- package/dist/components/molecules/modal/Modal.js +16 -5
- package/dist/components/molecules/stepper/Stepper.css +1 -0
- package/dist/components/molecules/stepper/Stepper.stories.js +14 -6
- 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;
|
|
@@ -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
|
|
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
|
|
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 : ""),
|
|
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,
|
|
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;
|
|
@@ -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
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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(
|
|
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 = {
|