allaw-ui 3.3.5 → 3.3.7

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.
@@ -3,6 +3,7 @@ import "./TertiaryButton.css";
3
3
  import "../../../styles/global.css";
4
4
  export interface TertiaryButtonProps {
5
5
  startIcon?: string;
6
+ endIcon?: string;
6
7
  label: string;
7
8
  variant?: boolean;
8
9
  href?: string;
@@ -3,7 +3,7 @@ import Link from "next/link";
3
3
  import "./TertiaryButton.css";
4
4
  import "../../../styles/global.css";
5
5
  var TertiaryButton = function (_a) {
6
- var startIcon = _a.startIcon, label = _a.label, _b = _a.variant, variant = _b === void 0 ? false : _b, href = _a.href, onClick = _a.onClick, _c = _a.color, color = _c === void 0 ? "noir" : _c, _d = _a.isDisabled, isDisabled = _d === void 0 ? false : _d;
6
+ var startIcon = _a.startIcon, endIcon = _a.endIcon, label = _a.label, _b = _a.variant, variant = _b === void 0 ? false : _b, href = _a.href, onClick = _a.onClick, _c = _a.color, color = _c === void 0 ? "noir" : _c, _d = _a.isDisabled, isDisabled = _d === void 0 ? false : _d;
7
7
  var buttonClass = "tertiary-button tertiary-button-".concat(color, " ").concat(variant ? "tertiary-button-variant" : "tertiary-button-default", " ").concat(isDisabled ? "tertiary-button-disabled" : "");
8
8
  var handleClick = function (e) {
9
9
  if (isDisabled) {
@@ -14,8 +14,10 @@ var TertiaryButton = function (_a) {
14
14
  };
15
15
  return href ? (React.createElement(Link, { href: href, className: buttonClass, onClick: handleClick },
16
16
  startIcon && React.createElement("span", { className: "tertiary-button-icon ".concat(startIcon) }),
17
- React.createElement("span", { className: "tertiary-button-label" }, label))) : (React.createElement("button", { type: "button", className: buttonClass, onClick: handleClick, disabled: isDisabled },
17
+ React.createElement("span", { className: "tertiary-button-label" }, label),
18
+ endIcon && React.createElement("span", { className: "tertiary-button-icon ".concat(endIcon) }))) : (React.createElement("button", { type: "button", className: buttonClass, onClick: handleClick, disabled: isDisabled },
18
19
  startIcon && React.createElement("span", { className: "tertiary-button-icon ".concat(startIcon) }),
19
- React.createElement("span", { className: "tertiary-button-label" }, label)));
20
+ React.createElement("span", { className: "tertiary-button-label" }, label),
21
+ endIcon && React.createElement("span", { className: "tertiary-button-icon ".concat(endIcon) })));
20
22
  };
21
23
  export default TertiaryButton;
@@ -13,27 +13,34 @@ declare namespace _default {
13
13
  let type: string;
14
14
  }
15
15
  }
16
- export namespace variant {
16
+ export namespace endIcon {
17
17
  export namespace control_1 {
18
18
  let type_1: string;
19
19
  export { type_1 as type };
20
20
  }
21
21
  export { control_1 as control };
22
22
  }
23
- export namespace color {
23
+ export namespace variant {
24
24
  export namespace control_2 {
25
25
  let type_2: string;
26
26
  export { type_2 as type };
27
27
  }
28
28
  export { control_2 as control };
29
- export let options: string[];
30
29
  }
31
- export namespace isDisabled {
30
+ export namespace color {
32
31
  export namespace control_3 {
33
32
  let type_3: string;
34
33
  export { type_3 as type };
35
34
  }
36
35
  export { control_3 as control };
36
+ export let options: string[];
37
+ }
38
+ export namespace isDisabled {
39
+ export namespace control_4 {
40
+ let type_4: string;
41
+ export { type_4 as type };
42
+ }
43
+ export { control_4 as control };
37
44
  }
38
45
  export namespace onClick_1 {
39
46
  let action: string;
@@ -56,6 +63,8 @@ export const Default: any;
56
63
  export const BlueButton: any;
57
64
  export const ErrorButton: any;
58
65
  export const Variant: any;
66
+ export const WithEndIcon: any;
67
+ export const WithBothIcons: any;
59
68
  export const Disabled: any;
60
69
  export const ColoredButton: any;
61
70
  import TertiaryButton from "./TertiaryButton";
@@ -27,6 +27,11 @@ export default {
27
27
  type: "text",
28
28
  },
29
29
  },
30
+ endIcon: {
31
+ control: {
32
+ type: "text",
33
+ },
34
+ },
30
35
  variant: {
31
36
  control: {
32
37
  type: "boolean",
@@ -94,6 +99,21 @@ Variant.args = {
94
99
  color: "dark-grey",
95
100
  isDisabled: false,
96
101
  };
102
+ export var WithEndIcon = Template.bind({});
103
+ WithEndIcon.args = {
104
+ label: "Ouvrir le lien",
105
+ endIcon: "allaw-icon-external-link",
106
+ variant: false,
107
+ color: "bleu-allaw",
108
+ };
109
+ export var WithBothIcons = Template.bind({});
110
+ WithBothIcons.args = {
111
+ label: "Télécharger",
112
+ startIcon: "allaw-icon-download",
113
+ endIcon: "allaw-icon-chevron-right",
114
+ variant: false,
115
+ color: "noir",
116
+ };
97
117
  export var Disabled = Template.bind({});
98
118
  Disabled.args = {
99
119
  label: "Bouton désactivé",
@@ -1,18 +1,32 @@
1
1
  import React from "react";
2
+ interface ImageConfig {
3
+ url: string;
4
+ alt?: string;
5
+ width?: number | string;
6
+ height?: number | string;
7
+ padding?: string;
8
+ className?: string;
9
+ style?: React.CSSProperties;
10
+ }
2
11
  export interface ModalProps {
3
12
  show: boolean;
4
13
  title: string;
5
14
  description: string;
6
15
  confirmLabel: string;
7
- cancelLabel: string;
16
+ cancelLabel?: string;
8
17
  onConfirm: () => void;
9
18
  onCancel: () => void;
10
19
  isDanger?: boolean;
11
20
  confirmIconName?: string;
21
+ imageConfig?: ImageConfig;
12
22
  verticalOffset?: {
13
23
  top?: number;
14
24
  bottom?: number;
15
25
  };
26
+ horizontalOffset?: {
27
+ left?: number;
28
+ right?: number;
29
+ };
16
30
  }
17
31
  declare const Modal: React.FC<ModalProps>;
18
32
  export default Modal;
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React, { useEffect, useRef, useState } from "react";
2
13
  import ReactDOM from "react-dom";
3
14
  import style from "./Modal.module.css";
@@ -6,8 +17,9 @@ import SecondaryButton from "../../atoms/buttons/SecondaryButton";
6
17
  import Heading from "../../atoms/typography/Heading";
7
18
  import Paragraph from "../../atoms/typography/Paragraph";
8
19
  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, _c = _a.confirmIconName, confirmIconName = _c === void 0 ? "allaw-icon-check" : _c, verticalOffset = _a.verticalOffset;
20
+ 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, imageConfig = _a.imageConfig, verticalOffset = _a.verticalOffset, horizontalOffset = _a.horizontalOffset;
10
21
  var _d = useState(false), isVisible = _d[0], setIsVisible = _d[1];
22
+ var _e = useState(false), imgError = _e[0], setImgError = _e[1];
11
23
  var portalContainerRef = useRef(null);
12
24
  var modalContentRef = useRef(null);
13
25
  var isMouseDownOutsideRef = useRef(false);
@@ -18,6 +30,7 @@ var Modal = function (_a) {
18
30
  portalContainerRef.current = container;
19
31
  document.body.style.overflow = "hidden";
20
32
  setIsVisible(true);
33
+ setImgError(false);
21
34
  }
22
35
  else {
23
36
  setIsVisible(false);
@@ -52,6 +65,9 @@ var Modal = function (_a) {
52
65
  onCancel();
53
66
  }
54
67
  };
68
+ var handleImageError = function () {
69
+ setImgError(true);
70
+ };
55
71
  if (!show || !isVisible || !portalContainerRef.current)
56
72
  return null;
57
73
  var modalContent = (React.createElement("div", { className: "".concat(style.modalOverlay, " ").concat(isVisible ? style.visible : "", " ").concat(show ? style.modal : ""), onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, style: {
@@ -59,14 +75,22 @@ var Modal = function (_a) {
59
75
  paddingBottom: (verticalOffset === null || verticalOffset === void 0 ? void 0 : verticalOffset.bottom)
60
76
  ? "".concat(verticalOffset.bottom, "px")
61
77
  : undefined,
78
+ paddingLeft: (horizontalOffset === null || horizontalOffset === void 0 ? void 0 : horizontalOffset.left)
79
+ ? "".concat(horizontalOffset.left, "px")
80
+ : undefined,
81
+ paddingRight: (horizontalOffset === null || horizontalOffset === void 0 ? void 0 : horizontalOffset.right)
82
+ ? "".concat(horizontalOffset.right, "px")
83
+ : undefined,
62
84
  } },
63
85
  React.createElement("div", { className: "".concat(style.modalContent, " ").concat(show ? style.modal : ""), ref: modalContentRef },
64
86
  React.createElement("div", { className: style.modalHeadingWrapper },
65
87
  React.createElement(Heading, { text: title, variant: "h4", color: "noir", align: "left" })),
66
88
  React.createElement("div", { className: style.modalParagraphWrapper },
67
89
  React.createElement(Paragraph, { text: description, variant: "medium", size: "default", className: style.modalParagraph })),
90
+ imageConfig && !imgError && (React.createElement("div", { className: "".concat(style.modalImageWrapper, " ").concat(imageConfig.className || ""), style: __assign({ padding: imageConfig.padding }, imageConfig.style) },
91
+ React.createElement("img", { src: imageConfig.url, alt: imageConfig.alt || "", width: imageConfig.width, height: imageConfig.height, onError: handleImageError, className: style.modalImage }))),
68
92
  React.createElement("div", { className: style.modalButtons },
69
- React.createElement(SecondaryButton, { label: cancelLabel, onClick: onCancel, startIconName: "allaw-icon-close", startIcon: true }),
93
+ cancelLabel && (React.createElement(SecondaryButton, { label: cancelLabel, onClick: onCancel, startIconName: "allaw-icon-close", startIcon: true })),
70
94
  React.createElement(PrimaryButton, { label: confirmLabel, variant: isDanger ? "warning" : "default", onClick: onConfirm, startIconName: confirmIconName, startIcon: true })))));
71
95
  return ReactDOM.createPortal(modalContent, portalContainerRef.current);
72
96
  };
@@ -275,6 +275,17 @@
275
275
  overflow-y: auto;
276
276
  }
277
277
 
278
+ .modalImageWrapper {
279
+ text-align: center;
280
+ margin: 0 0 2.5rem 0;
281
+ }
282
+
283
+ .modalImage {
284
+ max-width: 100%;
285
+ height: auto;
286
+ border-radius: 8px;
287
+ }
288
+
278
289
  .modalParagraph {
279
290
  text-align: left;
280
291
  }
@@ -290,6 +301,10 @@
290
301
  flex: 1;
291
302
  }
292
303
 
304
+ .modalButtons button:only-child {
305
+ width: 100%;
306
+ }
307
+
293
308
  @media (max-width: 1000px) {
294
309
  .modalContent {
295
310
  z-index: 5001;
@@ -9,44 +9,62 @@ declare namespace _default {
9
9
  }
10
10
  let description: string;
11
11
  }
12
- export namespace show {
13
- let control_1: string;
12
+ export namespace horizontalOffset {
13
+ export namespace control_1 {
14
+ let type_1: string;
15
+ export { type_1 as type };
16
+ }
14
17
  export { control_1 as control };
15
18
  let description_1: string;
16
19
  export { description_1 as description };
17
20
  }
18
- export namespace title_1 {
21
+ export namespace show {
19
22
  let control_2: string;
20
23
  export { control_2 as control };
21
24
  let description_2: string;
22
25
  export { description_2 as description };
23
26
  }
24
- export { title_1 as title };
25
- export namespace description_3 {
27
+ export namespace title_1 {
26
28
  let control_3: string;
27
29
  export { control_3 as control };
28
- let description_4: string;
29
- export { description_4 as description };
30
+ let description_3: string;
31
+ export { description_3 as description };
30
32
  }
31
- export { description_3 as description };
32
- export namespace confirmLabel {
33
+ export { title_1 as title };
34
+ export namespace description_4 {
33
35
  let control_4: string;
34
36
  export { control_4 as control };
35
37
  let description_5: string;
36
38
  export { description_5 as description };
37
39
  }
38
- export namespace cancelLabel {
40
+ export { description_4 as description };
41
+ export namespace confirmLabel {
39
42
  let control_5: string;
40
43
  export { control_5 as control };
41
44
  let description_6: string;
42
45
  export { description_6 as description };
43
46
  }
44
- export namespace isDanger {
47
+ export namespace cancelLabel {
45
48
  let control_6: string;
46
49
  export { control_6 as control };
47
50
  let description_7: string;
48
51
  export { description_7 as description };
49
52
  }
53
+ export namespace imageConfig {
54
+ export namespace control_7 {
55
+ let type_2: string;
56
+ export { type_2 as type };
57
+ }
58
+ export { control_7 as control };
59
+ let description_8: string;
60
+ export { description_8 as description };
61
+ }
62
+ export namespace isDanger {
63
+ let control_8: string;
64
+ export { control_8 as control };
65
+ let description_9: string;
66
+ export { description_9 as description };
67
+ }
50
68
  }
51
69
  export namespace parameters {
52
70
  namespace backgrounds {
@@ -63,4 +81,7 @@ export default _default;
63
81
  export const Default: any;
64
82
  export const DangerModal: any;
65
83
  export const WithLargeOffset: any;
84
+ export const WithImageConfig: any;
85
+ export const WithoutCancel: any;
86
+ export const OffsetBothWays: any;
66
87
  import Modal from "./Modal";
@@ -1,3 +1,4 @@
1
+ // src/components/molecules/modal/Modal.stories.jsx
1
2
  var __assign = (this && this.__assign) || function () {
2
3
  __assign = Object.assign || function(t) {
3
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -19,11 +20,13 @@ export default {
19
20
  tags: ["autodocs"],
20
21
  argTypes: {
21
22
  verticalOffset: {
22
- control: {
23
- type: "object",
24
- },
23
+ control: { type: "object" },
25
24
  description: "Décalage vertical du modal (en px) pour éviter les barres de navigation",
26
25
  },
26
+ horizontalOffset: {
27
+ control: { type: "object" },
28
+ description: "Décalage horizontal du modal (en px) pour éviter les éléments latéraux",
29
+ },
27
30
  show: {
28
31
  control: "boolean",
29
32
  description: "Affiche ou masque la modal",
@@ -42,7 +45,11 @@ export default {
42
45
  },
43
46
  cancelLabel: {
44
47
  control: "text",
45
- description: "Texte du bouton secondaire",
48
+ description: "Texte du bouton secondaire (optionnel)",
49
+ },
50
+ imageConfig: {
51
+ control: { type: "object" },
52
+ description: "Configuration de l'image à afficher (url, alt, dimensions, styles, padding, className)",
46
53
  },
47
54
  isDanger: {
48
55
  control: "boolean",
@@ -81,15 +88,39 @@ Default.args = {
81
88
  confirmLabel: "Confirmer",
82
89
  cancelLabel: "Annuler",
83
90
  isDanger: false,
84
- verticalOffset: {
85
- top: 64,
86
- bottom: 0,
91
+ verticalOffset: { top: 64, bottom: 0 },
92
+ horizontalOffset: { left: 0, right: 0 },
93
+ imageConfig: {
94
+ url: "https://cdn.iconscout.com/icon/free/png-512/free-checkmark-icon-download-in-svg-png-gif-file-formats--done-approved-check-tick-user-interface-pack-icons-1502470.png?f=webp&w=512",
95
+ alt: "Checkmark",
96
+ width: 64,
97
+ height: 64,
98
+ padding: "0px, 0px, 250px, 300px",
99
+ className: "",
100
+ style: {
101
+ backgroundColor: "#ffffff",
102
+ },
87
103
  },
88
104
  };
89
105
  export var DangerModal = Template.bind({});
90
106
  DangerModal.args = __assign(__assign({}, Default.args), { title: "Attention", description: "Cette action est irréversible. Voulez-vous continuer ?", confirmLabel: "Supprimer", isDanger: true });
91
107
  export var WithLargeOffset = Template.bind({});
92
- WithLargeOffset.args = __assign(__assign({}, Default.args), { verticalOffset: {
93
- top: 120,
94
- bottom: 80,
95
- } });
108
+ WithLargeOffset.args = __assign(__assign({}, Default.args), { verticalOffset: { top: 120, bottom: 80 } });
109
+ export var WithImageConfig = Template.bind({});
110
+ WithImageConfig.args = __assign(__assign({}, Default.args), { title: "Image personnalisée", description: "Cette modal affiche une image avec dimensions et styles personnalisés.", imageConfig: {
111
+ url: Default.args.imageConfig.url,
112
+ alt: "Custom checkmark",
113
+ width: 200,
114
+ height: 200,
115
+ padding: "24px",
116
+ className: "border-circle",
117
+ style: {
118
+ border: "4px dashed #007bff",
119
+ borderRadius: "50%",
120
+ backgroundColor: "#e9f5ff",
121
+ },
122
+ }, confirmLabel: "Valider", cancelLabel: "Annuler" });
123
+ export var WithoutCancel = Template.bind({});
124
+ WithoutCancel.args = __assign(__assign({}, Default.args), { title: "Information", description: "Cette action a été effectuée avec succès.", confirmLabel: "OK", cancelLabel: undefined });
125
+ export var OffsetBothWays = Template.bind({});
126
+ OffsetBothWays.args = __assign(__assign({}, Default.args), { title: "Modal avec décalages", description: "Décalages verticaux et horizontaux appliqués.", verticalOffset: { top: 100, bottom: 50 }, horizontalOffset: { left: 80, right: 80 } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "3.3.5",
3
+ "version": "3.3.7",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",