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.
- package/dist/components/molecules/proSwitch/AvatarBubble.d.ts +1 -0
- package/dist/components/molecules/proSwitch/AvatarBubble.js +20 -6
- package/dist/components/molecules/proSwitch/AvatarBubble.stories.d.ts +7 -0
- package/dist/components/molecules/proSwitch/AvatarBubble.stories.js +16 -0
- package/dist/components/molecules/proSwitch/ProSwitch.d.ts +1 -1
- package/dist/components/molecules/proSwitch/avatarBubble.module.css +7 -0
- package/dist/components/molecules/proSwitch/index.d.ts +6 -0
- package/dist/components/molecules/proSwitch/index.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
+
};
|
|
@@ -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";
|
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";
|