@teamturing/react-kit 2.46.6 → 2.47.1

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.
@@ -7,24 +7,27 @@ import Image from '../Image/index.js';
7
7
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
8
8
  import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
9
9
 
10
- const Avatar = ({
11
- src,
10
+ const DEFAULT_AVATAR_URL = 'https://cdn.teamturing.com/cms/uploads/2024-02-21/1708481300_empty-profile.png';
11
+ const Avatar = /*#__PURE__*/forwardRef(({
12
+ src = DEFAULT_AVATAR_URL,
12
13
  alt = '',
13
14
  size = 'm',
14
15
  sx,
15
16
  ...props
16
17
  }, ref) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseAvatar, {
17
18
  ref: ref,
19
+ role: 'presentation',
18
20
  src: src,
19
21
  alt: alt,
20
22
  sx: sx,
21
23
  size: size,
22
24
  ...props
23
- });
25
+ }));
24
26
  const BaseAvatar = styled(Image)`
25
27
  border-radius: ${({
26
28
  theme
27
29
  }) => forcePixelValue(theme.radii.full)};
30
+ object-fit: cover;
28
31
 
29
32
  ${variant({
30
33
  prop: 'size',
@@ -66,6 +69,5 @@ const BaseAvatar = styled(Image)`
66
69
 
67
70
  ${sx}
68
71
  `;
69
- var index = /*#__PURE__*/forwardRef(Avatar);
70
72
 
71
- export { index as default };
73
+ export { Avatar as default };
@@ -0,0 +1,29 @@
1
+ import { forwardRef } from 'react';
2
+ import styled from 'styled-components';
3
+ import Avatar from '../Avatar/index.js';
4
+ import Tooltip from '../Tooltip/index.js';
5
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
6
+
7
+ const AvatarGroupItem = ({
8
+ onClick,
9
+ ...props
10
+ }, ref) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseAvatarGroupItem, {
11
+ onClick: onClick,
12
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(Tooltip, {
13
+ text: props.alt,
14
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(Avatar, {
15
+ ref: ref,
16
+ size: 's',
17
+ ...props
18
+ })
19
+ })
20
+ });
21
+ const BaseAvatarGroupItem = styled.li`
22
+ display: inline-flex;
23
+ list-style: none;
24
+ padding: 0;
25
+ margin: 0;
26
+ `;
27
+ var AvatarGroupItem$1 = /*#__PURE__*/forwardRef(AvatarGroupItem);
28
+
29
+ export { AvatarGroupItem$1 as default };
@@ -0,0 +1,126 @@
1
+ import { forcePixelValue } from '../../packages/utils/esm/forcePixelValue.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import styled from 'styled-components';
4
+ import { sx } from '../../utils/styled-system/index.js';
5
+ import Avatar from '../Avatar/index.js';
6
+ import Overlay from '../Overlay/index.js';
7
+ import OverlayPopper from '../OverlayPopper/index.js';
8
+ import Space from '../Space/index.js';
9
+ import Text from '../Text/index.js';
10
+ import View from '../View/index.js';
11
+ import UnstyledButton from '../_UnstyledButton.js';
12
+ import AvatarGroupItem from './AvatarGroupItem.js';
13
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
14
+
15
+ const AvatarGroup = ({
16
+ children: propChildren,
17
+ maxItemCount = 5,
18
+ ...props
19
+ }, ref) => {
20
+ const childrenArray = React__default.Children.toArray(propChildren);
21
+ const isOverflown = childrenArray.length > maxItemCount;
22
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(AvatarGroupWrapper, {
23
+ ref: ref,
24
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(BaseAvatarGroup, {
25
+ ...props,
26
+ children: [...childrenArray.slice(0, maxItemCount)].reverse()
27
+ }), isOverflown ? /*#__PURE__*/jsxRuntimeExports.jsx(OverlayPopper, {
28
+ placement: 'bottom',
29
+ renderOverlay: overlayProps => /*#__PURE__*/jsxRuntimeExports.jsx(Overlay, {
30
+ size: 's',
31
+ maxHeight: 300,
32
+ sx: {
33
+ overflow: 'auto'
34
+ },
35
+ onClick: e => e.stopPropagation(),
36
+ ...overlayProps,
37
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(Space, {
38
+ px: 1,
39
+ py: 2,
40
+ children: childrenArray.slice(maxItemCount).map(({
41
+ key,
42
+ props
43
+ }) => /*#__PURE__*/jsxRuntimeExports.jsxs(View, {
44
+ sx: {
45
+ p: 3,
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ columnGap: 2
49
+ },
50
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(Avatar, {
51
+ size: 'xs',
52
+ src: props.src,
53
+ alt: props.alt
54
+ }), /*#__PURE__*/jsxRuntimeExports.jsx(Text, {
55
+ typography: 'xs',
56
+ color: 'text/neutral',
57
+ children: props.alt
58
+ })]
59
+ }, key))
60
+ })
61
+ }),
62
+ children: popperProps => /*#__PURE__*/jsxRuntimeExports.jsxs(UnstyledButton, {
63
+ ...popperProps,
64
+ onClick: e => {
65
+ e.stopPropagation();
66
+ popperProps.onClick?.(e);
67
+ },
68
+ sx: {
69
+ 'p': 0.5,
70
+ 'fontSize': 'xxs',
71
+ 'fontWeight': 'medium',
72
+ 'color': 'text/neutral/subtle',
73
+ 'borderRadius': 'xxs',
74
+ '&:hover': {
75
+ backgroundColor: 'bg/neutral/subtlest/hovered'
76
+ }
77
+ },
78
+ children: ["+", childrenArray.length - maxItemCount]
79
+ })
80
+ }) : null]
81
+ });
82
+ };
83
+ const AvatarGroupWrapper = styled.div`
84
+ display: inline-flex;
85
+ align-items: center;
86
+ column-gap: ${({
87
+ theme
88
+ }) => forcePixelValue(theme.space[1])};
89
+ `;
90
+ const BaseAvatarGroup = styled.ol`
91
+ list-style: none;
92
+ padding: 0;
93
+ margin: 0;
94
+
95
+ display: inline-flex;
96
+ flex-direction: row-reverse;
97
+ align-items: center;
98
+
99
+ & > * {
100
+ position: relative;
101
+ background-color: ${({
102
+ theme
103
+ }) => theme.colors['border/neutral/subtle']};
104
+ padding: ${({
105
+ theme
106
+ }) => forcePixelValue(theme.space['0.25'])};
107
+ border-radius: ${({
108
+ theme
109
+ }) => forcePixelValue(theme.radii.full)};
110
+
111
+ margin-left: ${({
112
+ theme
113
+ }) => forcePixelValue(theme.space[-1])};
114
+
115
+ &:last-child {
116
+ margin-left: 0;
117
+ }
118
+ }
119
+
120
+ ${sx}
121
+ `;
122
+ var index = Object.assign( /*#__PURE__*/forwardRef(AvatarGroup), {
123
+ Item: AvatarGroupItem
124
+ });
125
+
126
+ export { index as default };
package/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as UnstyledTable } from './core/_UnstyledTable/index.js';
2
2
  export { default as ActionList } from './core/ActionList/index.js';
3
3
  export { default as Avatar } from './core/Avatar/index.js';
4
+ export { default as AvatarGroup } from './core/AvatarGroup/index.js';
4
5
  export { default as BadgeAttacher } from './core/BadgeAttacher/index.js';
5
6
  export { default as Breadcrumbs } from './core/Breadcrumbs/index.js';
6
7
  export { default as Button } from './core/Button/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.46.6",
3
+ "version": "2.47.1",
4
4
  "description": "React components, hooks for create teamturing web application",
5
5
  "author": "Sungchang Park <psch300@gmail.com> (https://github.com/psch300)",
6
6
  "homepage": "https://github.com/weareteamturing/bombe#readme",
@@ -66,5 +66,5 @@
66
66
  "react-textarea-autosize": "^8.5.3",
67
67
  "styled-system": "^5.1.5"
68
68
  },
69
- "gitHead": "64d56dcc9ac1e605b739c05032e36050108784c8"
69
+ "gitHead": "d4def05b872fd881706a5a6a1598cae05aadba49"
70
70
  }