allaw-ui 4.2.3 → 4.2.5

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.
@@ -13,6 +13,7 @@ export interface AvatarBubbleProps {
13
13
  borderThick?: boolean;
14
14
  showTooltip?: boolean;
15
15
  tooltipId?: string;
16
+ clickable?: boolean;
16
17
  }
17
18
  declare const AvatarBubble: React.FC<AvatarBubbleProps>;
18
19
  export default AvatarBubble;
@@ -36,8 +36,8 @@ var generateInitials = function (firstName, name) {
36
36
  return "".concat(firstInitial).concat(lastInitial);
37
37
  };
38
38
  var AvatarBubble = function (_a) {
39
- var firstName = _a.firstName, name = _a.name, src = _a.src, _b = _a.size, size = _b === void 0 ? 42.5 : _b, _c = _a.isSelected, isSelected = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.disableHoverAnimation, disableHoverAnimation = _e === void 0 ? false : _e, onClick = _a.onClick, alt = _a.alt, _f = _a.className, className = _f === void 0 ? "" : _f, _g = _a.borderThick, borderThick = _g === void 0 ? false : _g, _h = _a.showTooltip, showTooltip = _h === void 0 ? false : _h, _j = _a.tooltipId, tooltipId = _j === void 0 ? "avatar-tooltip" : _j;
40
- var _k = useState(false), imageError = _k[0], setImageError = _k[1];
39
+ var firstName = _a.firstName, name = _a.name, src = _a.src, _b = _a.size, size = _b === void 0 ? 42.5 : _b, _c = _a.isSelected, isSelected = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.disableHoverAnimation, disableHoverAnimation = _e === void 0 ? false : _e, onClick = _a.onClick, alt = _a.alt, _f = _a.className, className = _f === void 0 ? "" : _f, _g = _a.borderThick, borderThick = _g === void 0 ? false : _g, _h = _a.showTooltip, showTooltip = _h === void 0 ? false : _h, _j = _a.tooltipId, tooltipId = _j === void 0 ? "avatar-tooltip" : _j, _k = _a.clickable, clickable = _k === void 0 ? true : _k;
40
+ var _l = useState(false), imageError = _l[0], setImageError = _l[1];
41
41
  var hasValidSrc = src && src.trim() !== "";
42
42
  var shouldShowInitials = !hasValidSrc || imageError;
43
43
  var backgroundColor = generateBackgroundColor(firstName, name);
@@ -49,19 +49,22 @@ var AvatarBubble = function (_a) {
49
49
  setImageError(true);
50
50
  }, []);
51
51
  var handleClick = useCallback(function () {
52
- if (!disabled && onClick) {
52
+ if (!disabled && clickable && onClick) {
53
53
  onClick();
54
54
  }
55
- }, [disabled, onClick]);
55
+ }, [disabled, clickable, onClick]);
56
56
  var handleKeyDown = useCallback(function (event) {
57
+ if (!clickable)
58
+ return;
57
59
  if (event.key === "Enter" || event.key === " ") {
58
60
  event.preventDefault();
59
61
  handleClick();
60
62
  }
61
- }, [handleClick]);
63
+ }, [handleClick, clickable]);
62
64
  var containerStyle = {
63
65
  width: "".concat(size, "px"),
64
66
  height: "".concat(size, "px"),
67
+ cursor: clickable && !disabled ? "pointer" : "default",
65
68
  };
66
69
  var initialsStyle = {
67
70
  backgroundColor: backgroundColor,
@@ -75,7 +78,18 @@ var AvatarBubble = function (_a) {
75
78
  : styles.thick
76
79
  : isSelected
77
80
  ? styles.selectedThin
78
- : styles.thin), style: containerStyle, role: "button", "aria-label": ariaLabel, tabIndex: disabled ? -1 : 0, onClick: handleClick, onKeyDown: handleKeyDown, "data-selected": isSelected, "data-disabled": disabled, "data-disable-hover-animation": disableHoverAnimation }, (showTooltip && {
81
+ : styles.thin), style: containerStyle }, (clickable
82
+ ? {
83
+ role: "button",
84
+ tabIndex: disabled ? -1 : 0,
85
+ onClick: handleClick,
86
+ onKeyDown: handleKeyDown,
87
+ "aria-label": ariaLabel,
88
+ }
89
+ : {
90
+ tabIndex: -1,
91
+ "aria-label": ariaLabel,
92
+ }), { "data-selected": isSelected, "data-disabled": disabled, "data-disable-hover-animation": disableHoverAnimation }, (showTooltip && {
79
93
  "data-tooltip-id": tooltipId,
80
94
  "data-tooltip-content": fullName,
81
95
  })), shouldShowInitials ? (React.createElement("div", { className: styles.initials, style: initialsStyle, "aria-label": displayAlt }, initials)) : (React.createElement("div", { className: styles.imageContainer },
@@ -77,6 +77,12 @@ declare namespace _default {
77
77
  let description_11: string;
78
78
  export { description_11 as description };
79
79
  }
80
+ namespace clickable {
81
+ let control_11: string;
82
+ export { control_11 as control };
83
+ let description_12: string;
84
+ export { description_12 as description };
85
+ }
80
86
  }
81
87
  export namespace parameters {
82
88
  namespace backgrounds {
@@ -101,5 +107,6 @@ export const SelectedWithoutHoverAnimation: any;
101
107
  export function MultipleSizes(): React.JSX.Element;
102
108
  export function ColorVariations(): React.JSX.Element;
103
109
  export function HoverAnimationComparison(): React.JSX.Element;
110
+ export const NotClickable: any;
104
111
  import AvatarBubble from "./AvatarBubble";
105
112
  import React from "react";
@@ -66,6 +66,10 @@ export default {
66
66
  control: "text",
67
67
  description: "Texte alternatif pour l'accessibilité",
68
68
  },
69
+ clickable: {
70
+ control: "boolean",
71
+ description: "État cliquable de l'avatar",
72
+ },
69
73
  },
70
74
  parameters: {
71
75
  backgrounds: {
@@ -237,3 +241,15 @@ export var HoverAnimationComparison = function () {
237
241
  React.createElement("h4", { style: { marginBottom: "10px" } }, "Sans animation"),
238
242
  React.createElement(AvatarBubble, { firstName: "Marie", name: "Martin", src: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=150&h=150&fit=crop&crop=face", size: 42.5, isSelected: selectedIndex === 1, onClick: function () { return setSelectedIndex(1); }, disableHoverAnimation: true, showTooltip: true, tooltipId: "hover-comparison-tooltip" }))));
239
243
  };
244
+ export var NotClickable = Template.bind({});
245
+ NotClickable.args = {
246
+ firstName: "Non",
247
+ name: "Cliquable",
248
+ src: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=150&h=150&fit=crop&crop=face",
249
+ size: 42.5,
250
+ isSelected: false,
251
+ disabled: false,
252
+ clickable: false,
253
+ showTooltip: true,
254
+ tooltipId: "avatar-not-clickable",
255
+ };
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Pro } from "./AvatarToggleGroup";
3
- interface ProSwitchProps {
3
+ export interface ProSwitchProps {
4
4
  pros: Pro[];
5
5
  selected: string[];
6
6
  mode: "single" | "multiple";
@@ -114,3 +114,10 @@
114
114
  box-shadow: 0px 0px 4px rgba(37, 190, 235, 0.5);
115
115
  z-index: 5;
116
116
  }
117
+
118
+ .avatarBubble[data-clickable="false"] {
119
+ cursor: default !important;
120
+ }
121
+ .avatarBubble[data-clickable="false"]:hover {
122
+ transform: none;
123
+ }
@@ -0,0 +1,6 @@
1
+ export { default as ProSwitch } from "./ProSwitch";
2
+ export type { ProSwitchProps } from "./ProSwitch";
3
+ export { default as AvatarBubble } from "./AvatarBubble";
4
+ export type { AvatarBubbleProps } from "./AvatarBubble";
5
+ export { default as AvatarToggleGroup } from "./AvatarToggleGroup";
6
+ export type { AvatarToggleGroupProps } from "./AvatarToggleGroup";
@@ -0,0 +1,3 @@
1
+ export { default as ProSwitch } from "./ProSwitch";
2
+ export { default as AvatarBubble } from "./AvatarBubble";
3
+ export { default as AvatarToggleGroup } from "./AvatarToggleGroup";
package/dist/index.d.ts CHANGED
@@ -120,3 +120,4 @@ export { default as blogTextImageBlock } from "./components/molecules/blogTextIm
120
120
  export type { BlogTextImageBlockProps } from "./components/molecules/blogTextImageBlock/BlogTextImageBlock";
121
121
  export { default as FileUploader } from "./components/molecules/fileUploader/FileUploader";
122
122
  export type { FileUploaderProps } from "./components/molecules/fileUploader/FileUploader";
123
+ export { default as AvatarBubble } from "./components/molecules/proSwitch/AvatarBubble";
package/dist/index.js CHANGED
@@ -115,3 +115,4 @@ export { default as BlogText } from "./components/molecules/blogText/BlogText";
115
115
  export { default as blogTextImageBlock } from "./components/molecules/blogTextImageBlock/BlogTextImageBlock";
116
116
  // File Uploader
117
117
  export { default as FileUploader } from "./components/molecules/fileUploader/FileUploader";
118
+ export { default as AvatarBubble } from "./components/molecules/proSwitch/AvatarBubble";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "4.2.3",
3
+ "version": "4.2.5",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",