@soul-refiner/design-system 0.2.97 → 0.2.99
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.
|
@@ -19,9 +19,10 @@ export interface DropdownProps extends NativeProps, React.PropsWithChildren {
|
|
|
19
19
|
additionalOptions?: Omit<DropdownOptionProps, 'selected' | 'onClick'>[];
|
|
20
20
|
additionalOnChange?: (value: string) => void;
|
|
21
21
|
defaultAdditionalValue?: string;
|
|
22
|
+
useFullWidth?: boolean;
|
|
22
23
|
}
|
|
23
24
|
declare const Dropdown: {
|
|
24
|
-
({ checkbox, children, closeOnChange, closeOnBlur, defaultValue, disabled, hasArrow, maintainState, multiple, offset, onChange, open: openDirection, options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, ...rest }: DropdownProps): React.JSX.Element;
|
|
25
|
+
({ checkbox, children, closeOnChange, closeOnBlur, defaultValue, disabled, hasArrow, maintainState, multiple, offset, onChange, open: openDirection, options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, useFullWidth, ...rest }: DropdownProps): React.JSX.Element;
|
|
25
26
|
Option: {
|
|
26
27
|
({ checkbox, disabled, icon, label, onClick, selected, sublabel, sx, value, color, }: DropdownOptionProps): React.JSX.Element;
|
|
27
28
|
displayName: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Box, Checkbox, P } from '../../';
|
|
5
|
-
const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true, defaultValue = '', disabled = false, hasArrow, maintainState = true, multiple, offset = [0, 16], onChange, open: openDirection = 'right', options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, ...rest }) => {
|
|
5
|
+
const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true, defaultValue = '', disabled = false, hasArrow, maintainState = true, multiple, offset = [0, 16], onChange, open: openDirection = 'right', options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, useFullWidth = false, ...rest }) => {
|
|
6
6
|
const id = React.useId();
|
|
7
7
|
const wrapperRef = React.useRef(null);
|
|
8
8
|
const optionsRef = React.useRef(null);
|
|
@@ -104,7 +104,7 @@ const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true
|
|
|
104
104
|
trigger.type?.name !== 'Button')
|
|
105
105
|
? { onClick: handleOpen }
|
|
106
106
|
: { isDropdownOpen: open, onClick: handleOpen }),
|
|
107
|
-
open && (React.createElement(Container, { "$hasArrow": hasArrow, "$offset": offset, "$openDirection": openDirection, ref: optionsRef, "$sx": containerSx },
|
|
107
|
+
open && (React.createElement(Container, { "$hasArrow": hasArrow, "$offset": offset, "$openDirection": openDirection, ref: optionsRef, "$sx": containerSx, "$useFullWidth": useFullWidth },
|
|
108
108
|
React.createElement("div", { style: { display: 'flex' } },
|
|
109
109
|
React.createElement("div", { style: { display: 'flex', flexDirection: 'column' } }, dropdownOptions),
|
|
110
110
|
!!additionalOptions?.length && (React.createElement("div", { style: { display: 'flex', flexDirection: 'column' } }, additionalOptions.map((additionalOption) => (React.createElement(Option, { key: additionalOption.value, onClick: handleAdditionalChange, selected: additionalSelected === additionalOption.value, label: additionalOption.label, value: additionalOption.value }))))))))));
|
|
@@ -119,7 +119,7 @@ const Container = styled.div `
|
|
|
119
119
|
z-index: 1;
|
|
120
120
|
background-color: var(--color-white);
|
|
121
121
|
position: absolute;
|
|
122
|
-
width: max-content;
|
|
122
|
+
${({ $useFullWidth }) => $useFullWidth ? 'width: 100%;' : 'width: max-content;'}
|
|
123
123
|
z-index: 100;
|
|
124
124
|
outline: none;
|
|
125
125
|
cursor: pointer;
|
|
@@ -14,13 +14,14 @@ export interface AvatarProps extends NativeProps {
|
|
|
14
14
|
sx?: string;
|
|
15
15
|
textPosition?: 'left' | 'right';
|
|
16
16
|
title?: React.ReactNode;
|
|
17
|
+
tooltipContent?: React.ReactElement;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
*
|
|
20
21
|
* Avatar
|
|
21
22
|
*/
|
|
22
23
|
declare const Avatar: {
|
|
23
|
-
({ as, href, image, size, status, subtitle, sx, textPosition, title, ...rest }: AvatarProps): React.JSX.Element;
|
|
24
|
+
({ as, href, image, size, status, subtitle, sx, textPosition, title, tooltipContent, ...rest }: AvatarProps): React.JSX.Element;
|
|
24
25
|
displayName: string;
|
|
25
26
|
Group: {
|
|
26
27
|
({ children, numDisplayed, total }: AvatarGroupProps): React.JSX.Element;
|
|
@@ -57,10 +57,16 @@ const iconOffsetY = {
|
|
|
57
57
|
*
|
|
58
58
|
* Avatar
|
|
59
59
|
*/
|
|
60
|
-
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, ...rest }) => {
|
|
60
|
+
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, ...rest }) => {
|
|
61
61
|
const [displayDefault, setDisplayDefault] = React.useState(false);
|
|
62
62
|
const Icon = iconReference?.[status ?? 'none'];
|
|
63
|
-
return (React.createElement(Box, { "$align": "center", "$gap": 18,
|
|
63
|
+
return (React.createElement(Box, { "$align": "center", "$gap": 18, sx: `
|
|
64
|
+
position: relative;
|
|
65
|
+
&:hover > div:nth-of-type(2) {
|
|
66
|
+
display: flex;
|
|
67
|
+
}
|
|
68
|
+
${sx}
|
|
69
|
+
`, ...rest },
|
|
64
70
|
React.createElement(Container, { as: as, "$size": size, href: href },
|
|
65
71
|
!displayDefault && (React.createElement("img", { src: image ?? '', onError: () => setDisplayDefault(true) })),
|
|
66
72
|
displayDefault && React.createElement(Default, null),
|
|
@@ -68,7 +74,8 @@ const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, t
|
|
|
68
74
|
React.createElement(Icon, null))),
|
|
69
75
|
(title || subtitle) && (React.createElement(TextContainer, { "$textPosition": textPosition },
|
|
70
76
|
title && (React.createElement(H, { as: "h3", "$bold": true, "$color": "grey-2", "$textClampLines": 1, sx: "font-size: 26px;" }, title)),
|
|
71
|
-
subtitle && (React.createElement(P, { "$color": "grey-4", "$textClampLines": 1 }, subtitle))))
|
|
77
|
+
subtitle && (React.createElement(P, { "$color": "grey-4", "$textClampLines": 1 }, subtitle)))),
|
|
78
|
+
tooltipContent && React.createElement(TooltipContainer, null, tooltipContent)));
|
|
72
79
|
};
|
|
73
80
|
Avatar.displayName = 'Avatar';
|
|
74
81
|
const Container = styled.div `
|
|
@@ -107,6 +114,15 @@ const TextContainer = styled.div `
|
|
|
107
114
|
gap: 4px;
|
|
108
115
|
order: ${({ $textPosition }) => ($textPosition === 'left' ? -1 : 1)};
|
|
109
116
|
`;
|
|
117
|
+
const TooltipContainer = styled.div `
|
|
118
|
+
display: none;
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 100%;
|
|
121
|
+
left: -50%;
|
|
122
|
+
background-color: var(--color-white);
|
|
123
|
+
border-radius: 24px;
|
|
124
|
+
box-shadow: var(--elevation-2);
|
|
125
|
+
`;
|
|
110
126
|
const Group = ({ children, numDisplayed, total }) => {
|
|
111
127
|
let size = 0;
|
|
112
128
|
// filter out ReactNodes and ReactElements that are not Avatars
|