@bitrise/bitkit-v2 0.3.110 → 0.3.112

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.
@@ -0,0 +1,44 @@
1
+ import { AvatarRootProps } from '@chakra-ui/react/avatar';
2
+ import { ColorPalette, SystemStyleObject } from '@chakra-ui/react/styled-system';
3
+ import { ReactElement, SVGProps } from 'react';
4
+ type IconElement = ReactElement<SVGProps<SVGSVGElement> & {
5
+ css?: SystemStyleObject;
6
+ }>;
7
+ export type BitkitAvatarProps = Omit<AvatarRootProps, 'variant' | 'backgroundColor' | 'background' | 'bg'> & ({
8
+ variant: 'image';
9
+ src: string;
10
+ name: string;
11
+ icon?: never;
12
+ iconColor?: never;
13
+ backgroundColor?: never;
14
+ } | {
15
+ variant: 'image+icon';
16
+ src: string;
17
+ name: string;
18
+ icon: IconElement;
19
+ iconColor?: never;
20
+ backgroundColor?: never;
21
+ } | {
22
+ variant: 'icon';
23
+ src?: never;
24
+ name?: never;
25
+ icon: IconElement;
26
+ iconColor?: ColorPalette;
27
+ backgroundColor?: ColorPalette;
28
+ } | {
29
+ variant: 'letters';
30
+ src?: never;
31
+ name: string;
32
+ icon?: never;
33
+ iconColor?: never;
34
+ backgroundColor?: never;
35
+ } | {
36
+ variant: 'user';
37
+ src: string;
38
+ name: string;
39
+ icon?: never;
40
+ iconColor?: never;
41
+ backgroundColor?: never;
42
+ });
43
+ declare const BitkitAvatar: import('react').ForwardRefExoticComponent<BitkitAvatarProps & import('react').RefAttributes<HTMLDivElement>>;
44
+ export default BitkitAvatar;
@@ -0,0 +1,47 @@
1
+ import { jsxs as v, jsx as c } from "react/jsx-runtime";
2
+ import { Avatar as s } from "@chakra-ui/react/avatar";
3
+ import { Box as C } from "@chakra-ui/react/box";
4
+ import { useSlotRecipe as A } from "@chakra-ui/react/styled-system";
5
+ import { forwardRef as y, cloneElement as u } from "react";
6
+ import { COLOR_PALETTES as O } from "../../theme/tokens/colors.js";
7
+ const p = Object.keys(O).reduce((r, t) => ["white"].includes(t) ? r : [...r, t], []), R = (r) => {
8
+ if (!r || r.length === 0) return "neutral";
9
+ const t = r.trim();
10
+ return p[(t.charCodeAt(0) + t.charCodeAt(t.length - 1)) % p.length];
11
+ }, x = (r) => {
12
+ const t = r?.trim() || "";
13
+ return t && t.length >= 2 ? `${t[0]} ${t[t.length - 1]}` : t;
14
+ }, j = y((r, t) => {
15
+ const {
16
+ size: o,
17
+ variant: n,
18
+ src: i,
19
+ name: l,
20
+ icon: e,
21
+ colorPalette: f = R(l),
22
+ iconColor: g,
23
+ backgroundColor: h,
24
+ ...k
25
+ } = r, b = A({ key: "avatar" }), m = n === "user" && ["24", "32", "40", "48"].includes(o) ? "circle" : "rounded", a = b({ size: o, variant: m }), d = x(l);
26
+ return /* @__PURE__ */ v(
27
+ s.Root,
28
+ {
29
+ ref: t,
30
+ size: o,
31
+ variant: m,
32
+ colorPalette: f,
33
+ backgroundColor: h,
34
+ ...k,
35
+ children: [
36
+ !!d && /* @__PURE__ */ c(s.Fallback, { name: d }),
37
+ !!i && /* @__PURE__ */ c(s.Image, { src: i }),
38
+ !!e && n === "icon" && u(e, { css: a.icon, color: g }),
39
+ !!e && n === "image+icon" && /* @__PURE__ */ c(C, { css: a.badgeContainer, children: u(e, { css: a.badge }) })
40
+ ]
41
+ }
42
+ );
43
+ });
44
+ j.displayName = "BitkitAvatar";
45
+ export {
46
+ j as default
47
+ };
@@ -1,4 +1,5 @@
1
1
  export { default as BitkitActionBar, type BitkitActionBarProps } from './BitkitActionBar/BitkitActionBar';
2
+ export { default as BitkitAvatar, type BitkitAvatarProps } from './BitkitAvatar/BitkitAvatar';
2
3
  export { default as BitkitBadge, type BitkitBadgeProps } from './BitkitBadge/BitkitBadge';
3
4
  export { default as BitkitButton, type BitkitButtonProps } from './BitkitButton/BitkitButton';
4
5
  export { default as BitkitCard } from './BitkitCard/BitkitCard';