@allxsmith/bestax-bulma 5.4.2 → 5.5.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/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs.js +22 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Avatars.d.ts +1 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/components/_avatars.scss +7 -0
- package/src/scss/components/_badge.scss +10 -0
package/dist/index.esm.js
CHANGED
|
@@ -794,16 +794,26 @@ const Avatar = ({ className, src, alt, name, initials, icon, size, shape = 'circ
|
|
|
794
794
|
const combinedClasses = classNames(avatarClasses, bulmaHelperClasses, className);
|
|
795
795
|
const initialsClass = usePrefixedClassNames('avatar-initials');
|
|
796
796
|
const Tag = as ?? (href ? 'a' : 'figure');
|
|
797
|
-
const isInteractive = Tag === 'a' ||
|
|
797
|
+
const isInteractive = Tag === 'a' ||
|
|
798
|
+
Tag === 'button' ||
|
|
799
|
+
(typeof Tag !== 'string' && href != null);
|
|
798
800
|
const isLinkLike = Tag === 'a' || typeof Tag !== 'string';
|
|
799
801
|
const linkProps = isLinkLike ? { href, target, rel } : {};
|
|
802
|
+
const accessibleName = alt ?? name;
|
|
803
|
+
const isDecorative = alt === '' && !isInteractive;
|
|
800
804
|
const a11yProps = showImage
|
|
801
|
-
?
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
805
|
+
? isInteractive && !accessibleName
|
|
806
|
+
?
|
|
807
|
+
{ 'aria-label': name || 'Avatar' }
|
|
808
|
+
: {}
|
|
809
|
+
: isDecorative
|
|
810
|
+
? { 'aria-hidden': true }
|
|
811
|
+
: {
|
|
812
|
+
...(isInteractive ? {} : { role: 'img' }),
|
|
813
|
+
'aria-label': accessibleName || name || 'Avatar',
|
|
814
|
+
};
|
|
815
|
+
const buttonTypeProps = Tag === 'button' ? { type: 'button' } : {};
|
|
816
|
+
return (jsxs(Tag, { className: combinedClasses, style: { ...sizeStyle, ...style }, ...buttonTypeProps, ...linkProps, ...a11yProps, ...rest, children: [showImage && (jsx("img", { ...imageProps, ref: imgRef, src: src, alt: accessibleName ?? '', onError: e => {
|
|
807
817
|
imageProps?.onError?.(e);
|
|
808
818
|
setErroredSrc(src);
|
|
809
819
|
} }, src)), showInitials && (jsx("span", { className: initialsClass, children: resolvedInitials })), showIcon && icon, showDefaultIcon && jsx(DefaultAvatarIcon, {})] }));
|
|
@@ -823,7 +833,7 @@ function flattenChildren(children, keyPrefix = '') {
|
|
|
823
833
|
];
|
|
824
834
|
});
|
|
825
835
|
}
|
|
826
|
-
const Avatars = ({ className, max, size, shape, spacing = 'md', spaced = false, style, children, ...props }) => {
|
|
836
|
+
const Avatars = ({ className, max, size, shape, spacing = 'md', spaced = false, surplusLabel, style, children, ...props }) => {
|
|
827
837
|
const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });
|
|
828
838
|
const isPresetSpacing = typeof spacing === 'string';
|
|
829
839
|
const avatarsClasses = usePrefixedClassNames('avatars', {
|
|
@@ -846,7 +856,7 @@ const Avatars = ({ className, max, size, shape, spacing = 'md', spaced = false,
|
|
|
846
856
|
return (jsxs("div", { className: combinedClasses, style: { ...spacingStyle, ...style }, ...rest, children: [visibleChildren.map(child => React.cloneElement(child, {
|
|
847
857
|
...(size !== undefined ? { size } : {}),
|
|
848
858
|
...(shape !== undefined ? { shape } : {}),
|
|
849
|
-
})), overflowCount > 0 && (jsx(Avatar, { initials: `+${overflowCount}`, alt: `${overflowCount} more`, size: size, shape: shape, className: surplusClass }))] }));
|
|
859
|
+
})), overflowCount > 0 && (jsx(Avatar, { initials: `+${overflowCount}`, alt: surplusLabel?.(overflowCount) || `${overflowCount} more`, size: size, shape: shape, className: surplusClass }))] }));
|
|
850
860
|
};
|
|
851
861
|
Avatars.displayName = 'Avatars';
|
|
852
862
|
Avatars.Avatar = Avatar;
|
|
@@ -872,7 +882,8 @@ const Badge = ({ className, badgeClassName, content, max = 99, dot = false, show
|
|
|
872
882
|
content !== true &&
|
|
873
883
|
content !== '' &&
|
|
874
884
|
(!isZero || showZero);
|
|
875
|
-
const
|
|
885
|
+
const zeroPlaceholder = isZero && !showZero && !dot && !invisible;
|
|
886
|
+
const shouldRender = dot || hasContent || invisible || zeroPlaceholder;
|
|
876
887
|
const sanitizedMax = Number.isInteger(max) && max >= 0 ? max : 99;
|
|
877
888
|
const displayValue = useMemo(() => {
|
|
878
889
|
if (dot || !hasContent)
|
|
@@ -894,6 +905,7 @@ const Badge = ({ className, badgeClassName, content, max = 99, dot = false, show
|
|
|
894
905
|
'is-dot': dot,
|
|
895
906
|
'is-pulse': pulse,
|
|
896
907
|
'is-invisible': invisible,
|
|
908
|
+
'is-zero': zeroPlaceholder,
|
|
897
909
|
});
|
|
898
910
|
const pillClass = hasChildren
|
|
899
911
|
? classNames(badgeClasses, badgeClassName)
|