@groupeactual/ui-kit 0.4.26 → 0.4.27
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/cjs/components/Chip/Chip.d.ts +13 -1
- package/dist/cjs/components/Icon/Icon.d.ts +2 -2
- package/dist/cjs/index.js +130 -38
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/Chip/Chip.d.ts +13 -1
- package/dist/esm/components/Icon/Icon.d.ts +2 -2
- package/dist/esm/index.js +130 -38
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +33 -22
- package/package.json +1 -1
- package/src/components/Chip/Chip.tsx +120 -4
- package/src/components/Form/MultiSelect/MultiSelect.tsx +11 -3
- package/src/components/Icon/Icon.tsx +3 -3
- package/src/components/Tooltip/Tooltip.tsx +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TypographyProps, LinkProps, BoxProps as BoxProps$1, TooltipProps } from '@mui/material';
|
|
3
|
-
import React, { ReactNode, FocusEventHandler, MouseEventHandler, PropsWithChildren } from 'react';
|
|
3
|
+
import React, { ReactNode, FocusEventHandler, MouseEventHandler, ReactElement, PropsWithChildren } from 'react';
|
|
4
4
|
import { ButtonProps } from '@mui/material/Button';
|
|
5
5
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
6
6
|
import { InputProps } from '@mui/material/Input/Input';
|
|
@@ -11,25 +11,25 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
|
11
11
|
import { BoxProps } from '@mui/material/Box';
|
|
12
12
|
import { ChipProps } from '@mui/material/Chip';
|
|
13
13
|
|
|
14
|
-
interface Props$
|
|
14
|
+
interface Props$d extends Omit<TypographyProps, 'variant'> {
|
|
15
15
|
variant?: 'bigNumber' | 'body1Regular' | 'body1Medium' | 'body1Bold' | 'body2Regular' | 'body2Medium' | 'body2Bold' | 'caption' | 'buttonNotif' | 'header1' | 'header2' | 'header3' | 'header4';
|
|
16
16
|
component?: any;
|
|
17
17
|
}
|
|
18
|
-
declare const Text: (props: Props$
|
|
18
|
+
declare const Text: (props: Props$d) => JSX.Element;
|
|
19
19
|
|
|
20
|
-
interface Props$
|
|
20
|
+
interface Props$c extends Omit<LinkProps, 'variant'> {
|
|
21
21
|
variant?: 'link1' | 'link2';
|
|
22
22
|
component?: any;
|
|
23
23
|
}
|
|
24
|
-
declare const Link: (props: Props$
|
|
24
|
+
declare const Link: (props: Props$c) => JSX.Element;
|
|
25
25
|
|
|
26
|
-
interface Props$
|
|
26
|
+
interface Props$b extends Omit<ButtonProps, 'variant' | 'children'> {
|
|
27
27
|
variant?: 'primary' | 'secondary';
|
|
28
28
|
children?: ReactNode;
|
|
29
29
|
}
|
|
30
|
-
declare const Button: ({ variant, children, ...props }: Props$
|
|
30
|
+
declare const Button: ({ variant, children, ...props }: Props$b) => JSX.Element;
|
|
31
31
|
|
|
32
|
-
interface Props$
|
|
32
|
+
interface Props$a extends Omit<TextFieldProps, 'error'> {
|
|
33
33
|
error?: string;
|
|
34
34
|
onBlur?: FocusEventHandler<unknown>;
|
|
35
35
|
onChange?: InputProps['onChange'];
|
|
@@ -41,9 +41,9 @@ interface Props$9 extends Omit<TextFieldProps, 'error'> {
|
|
|
41
41
|
endAdornment?: ReactNode;
|
|
42
42
|
maxLength?: number;
|
|
43
43
|
}
|
|
44
|
-
declare const TextField: ({ name, value, error, onBlur, onChange, label, disabled, endAdornment, placeholder, maxLength, ...props }: Props$
|
|
44
|
+
declare const TextField: ({ name, value, error, onBlur, onChange, label, disabled, endAdornment, placeholder, maxLength, ...props }: Props$a) => JSX.Element;
|
|
45
45
|
|
|
46
|
-
interface Props$
|
|
46
|
+
interface Props$9<T> extends Omit<SelectProps<T>, 'value' | 'onChange' | 'defaultValue' | 'color'> {
|
|
47
47
|
label?: string;
|
|
48
48
|
helperText?: string;
|
|
49
49
|
options: T[];
|
|
@@ -53,9 +53,9 @@ interface Props$8<T> extends Omit<SelectProps<T>, 'value' | 'onChange' | 'defaul
|
|
|
53
53
|
defaultValue?: T | undefined;
|
|
54
54
|
width?: number;
|
|
55
55
|
}
|
|
56
|
-
declare const Select: <T extends {}>({ label, defaultValue, options, color, error, placeholder, onChange, getOptionLabel, helperText, onBlur, width, ...props }: Props$
|
|
56
|
+
declare const Select: <T extends {}>({ label, defaultValue, options, color, error, placeholder, onChange, getOptionLabel, helperText, onBlur, width, ...props }: Props$9<T>) => JSX.Element;
|
|
57
57
|
|
|
58
|
-
interface Props$
|
|
58
|
+
interface Props$8<T> extends Omit<SelectProps<T[]>, 'value' | 'onChange' | 'defaultValue' | 'color'> {
|
|
59
59
|
label: string;
|
|
60
60
|
options: T[];
|
|
61
61
|
helperText?: string;
|
|
@@ -65,25 +65,25 @@ interface Props$7<T> extends Omit<SelectProps<T[]>, 'value' | 'onChange' | 'defa
|
|
|
65
65
|
defaultValue?: T[];
|
|
66
66
|
width?: number;
|
|
67
67
|
}
|
|
68
|
-
declare const MultiSelect: <T extends {}>({ label, options, color, error, placeholder, width, defaultValue, getOptionLabel, helperText, onChange, onBlur, ...props }: Props$
|
|
68
|
+
declare const MultiSelect: <T extends {}>({ label, options, color, error, placeholder, width, defaultValue, getOptionLabel, helperText, onChange, onBlur, ...props }: Props$8<T>) => JSX.Element;
|
|
69
69
|
|
|
70
|
-
interface Props$
|
|
70
|
+
interface Props$7 {
|
|
71
71
|
name: string;
|
|
72
72
|
value: boolean;
|
|
73
73
|
label: string;
|
|
74
74
|
onChange?: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
|
|
75
75
|
error?: string;
|
|
76
76
|
}
|
|
77
|
-
declare const Checkbox: ({ name, value, error, label, onChange, ...props }: CheckboxProps & Props$
|
|
77
|
+
declare const Checkbox: ({ name, value, error, label, onChange, ...props }: CheckboxProps & Props$7) => JSX.Element;
|
|
78
78
|
|
|
79
|
-
interface Props$
|
|
79
|
+
interface Props$6 extends AccordionProps {
|
|
80
80
|
icon: ReactNode;
|
|
81
81
|
title?: string;
|
|
82
82
|
summaryHeight?: number;
|
|
83
83
|
expanded?: boolean;
|
|
84
84
|
onClick?: MouseEventHandler;
|
|
85
85
|
}
|
|
86
|
-
declare const Accordion: ({ icon, title, summaryHeight, expanded, onClick, children, ...props }: Props$
|
|
86
|
+
declare const Accordion: ({ icon, title, summaryHeight, expanded, onClick, children, ...props }: Props$6) => JSX.Element;
|
|
87
87
|
|
|
88
88
|
declare const FontSizes: {
|
|
89
89
|
xs: number;
|
|
@@ -94,15 +94,15 @@ declare const FontSizes: {
|
|
|
94
94
|
xxl: number;
|
|
95
95
|
xxxl: number;
|
|
96
96
|
};
|
|
97
|
-
interface Props$
|
|
97
|
+
interface Props$5 {
|
|
98
98
|
variant?: 'square' | 'none';
|
|
99
99
|
icon: IconDefinition;
|
|
100
100
|
color?: string;
|
|
101
101
|
size?: number | keyof typeof FontSizes;
|
|
102
102
|
}
|
|
103
|
-
declare const IconProvider: ({ variant, icon, color, size, ...props }: Props$
|
|
103
|
+
declare const IconProvider: ({ variant, icon, color, size, ...props }: Props$5 & BoxProps) => ReactElement;
|
|
104
104
|
|
|
105
|
-
interface Props$
|
|
105
|
+
interface Props$4 {
|
|
106
106
|
totalString: string;
|
|
107
107
|
totalPerPageString: string;
|
|
108
108
|
totalPages: number;
|
|
@@ -112,9 +112,20 @@ interface Props$3 {
|
|
|
112
112
|
page?: number;
|
|
113
113
|
limit?: number;
|
|
114
114
|
}
|
|
115
|
-
declare const Pagination: ({ totalString, totalPerPageString, totalPages, limitsPerPage, setLimit, setPage, page, limit }: Props$
|
|
115
|
+
declare const Pagination: ({ totalString, totalPerPageString, totalPages, limitsPerPage, setLimit, setPage, page, limit }: Props$4) => JSX.Element;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
interface Props$3 extends Omit<ChipProps, 'suffix' | 'prefix' | 'onDelete' | 'onDeleteIcon'> {
|
|
118
|
+
label: string;
|
|
119
|
+
size?: 'small';
|
|
120
|
+
prefixIcon?: IconDefinition;
|
|
121
|
+
suffixIcon?: IconDefinition;
|
|
122
|
+
suffixAction?: (e: any) => void;
|
|
123
|
+
suffixTooltip?: string;
|
|
124
|
+
tooltip?: string;
|
|
125
|
+
maxWidth?: number;
|
|
126
|
+
maxLength?: number;
|
|
127
|
+
}
|
|
128
|
+
declare const Chip: ({ label, prefixIcon, suffixIcon, suffixTooltip, suffixAction, tooltip, size, maxWidth, maxLength, ...props }: Props$3) => JSX.Element;
|
|
118
129
|
|
|
119
130
|
interface Props$2 extends BoxProps$1 {
|
|
120
131
|
variant: 'warning' | 'error' | 'success' | 'infos';
|
package/package.json
CHANGED
|
@@ -1,9 +1,125 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { ChipProps as ChipPropsMUI } from '@mui/material/Chip';
|
|
3
|
-
import { Chip as ChipMUI } from '@mui/material';
|
|
3
|
+
import { Chip as ChipMUI, Tooltip } from '@mui/material';
|
|
4
|
+
import { useTheme } from '@mui/system';
|
|
5
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
import IconProvider from '../Icon';
|
|
8
|
+
|
|
9
|
+
interface Props
|
|
10
|
+
extends Omit<
|
|
11
|
+
ChipPropsMUI,
|
|
12
|
+
'suffix' | 'prefix' | 'onDelete' | 'onDeleteIcon'
|
|
13
|
+
> {
|
|
14
|
+
label: string;
|
|
15
|
+
size?: 'small';
|
|
16
|
+
prefixIcon?: IconDefinition;
|
|
17
|
+
suffixIcon?: IconDefinition;
|
|
18
|
+
suffixAction?: (e: any) => void;
|
|
19
|
+
suffixTooltip?: string;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
maxLength?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Chip = ({
|
|
26
|
+
label,
|
|
27
|
+
prefixIcon,
|
|
28
|
+
suffixIcon,
|
|
29
|
+
suffixTooltip,
|
|
30
|
+
suffixAction,
|
|
31
|
+
tooltip,
|
|
32
|
+
size = 'small',
|
|
33
|
+
maxWidth = 300,
|
|
34
|
+
maxLength = 17,
|
|
35
|
+
...props
|
|
36
|
+
}: Props) => {
|
|
37
|
+
const theme = useTheme();
|
|
38
|
+
const [currentLabel, setCurrentLabel] = useState<string>(label);
|
|
39
|
+
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
40
|
+
|
|
41
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
42
|
+
|
|
43
|
+
let backgroundColor: string =
|
|
44
|
+
props.color && theme.palette[props.color]
|
|
45
|
+
? typeof theme.palette[props.color] === 'object'
|
|
46
|
+
? theme.palette[props.color]['main']
|
|
47
|
+
: theme.palette[props.color]
|
|
48
|
+
: props.color ?? 'white';
|
|
49
|
+
|
|
50
|
+
if (props.variant === 'filled') {
|
|
51
|
+
// opacity 0.08
|
|
52
|
+
backgroundColor = `${backgroundColor}14`;
|
|
53
|
+
} else {
|
|
54
|
+
backgroundColor = 'white';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const emptyOnDelete = () => {
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// use maxwidth props to set the max width of the chip based on the column width
|
|
62
|
+
// if a chip is in a table, the width should match the width of the column.
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (
|
|
65
|
+
ref?.current?.offsetWidth &&
|
|
66
|
+
ref?.current?.offsetWidth > maxWidth &&
|
|
67
|
+
`${label.substring(0, maxLength)}...` !== currentLabel
|
|
68
|
+
) {
|
|
69
|
+
setCurrentLabel(`${label.substring(0, maxLength)}...`);
|
|
70
|
+
} else if (
|
|
71
|
+
ref?.current?.offsetWidth &&
|
|
72
|
+
ref?.current?.offsetWidth <= maxWidth &&
|
|
73
|
+
label === `${label.substring(0, maxLength)}...`
|
|
74
|
+
) {
|
|
75
|
+
setCurrentLabel(label);
|
|
76
|
+
}
|
|
77
|
+
}, [ref?.current?.offsetWidth]);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Tooltip title={tooltip} placement="right-start">
|
|
81
|
+
<Tooltip
|
|
82
|
+
title={suffixTooltip}
|
|
83
|
+
open={isOpen}
|
|
84
|
+
placement="bottom-end"
|
|
85
|
+
sx={{ cursor: suffixAction ? 'pointer !important' : 'default' }}
|
|
86
|
+
>
|
|
87
|
+
<ChipMUI
|
|
88
|
+
label={currentLabel}
|
|
89
|
+
ref={ref}
|
|
90
|
+
size={size}
|
|
91
|
+
sx={{
|
|
92
|
+
backgroundColor: backgroundColor,
|
|
93
|
+
'&.MuiChip-colorSecondary:hover': suffixIcon &&
|
|
94
|
+
suffixAction && {
|
|
95
|
+
backgroundColor: '#004f88 !important'
|
|
96
|
+
},
|
|
97
|
+
'&.MuiChip-deleteIconColorPrimary:hover': suffixIcon &&
|
|
98
|
+
suffixAction && {
|
|
99
|
+
backgroundColor: '#004f88 !important'
|
|
100
|
+
}
|
|
101
|
+
}}
|
|
102
|
+
avatar={
|
|
103
|
+
prefixIcon ? <IconProvider icon={prefixIcon} size="sm" /> : <></>
|
|
104
|
+
}
|
|
105
|
+
deleteIcon={
|
|
106
|
+
suffixIcon ? (
|
|
107
|
+
<IconProvider
|
|
108
|
+
icon={suffixIcon}
|
|
109
|
+
onMouseEnter={() => suffixTooltip && setIsOpen(true)}
|
|
110
|
+
onMouseLeave={() => suffixTooltip && setIsOpen(false)}
|
|
111
|
+
size="sm"
|
|
112
|
+
/>
|
|
113
|
+
) : (
|
|
114
|
+
<></>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
onDelete={suffixAction ?? emptyOnDelete}
|
|
118
|
+
{...props}
|
|
119
|
+
/>
|
|
120
|
+
</Tooltip>
|
|
121
|
+
</Tooltip>
|
|
122
|
+
);
|
|
7
123
|
};
|
|
8
124
|
|
|
9
125
|
export default Chip;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { FormHelperText, InputLabel, MenuItem } from '@mui/material';
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
4
|
import FormControl from '@mui/material/FormControl';
|
|
@@ -6,7 +6,11 @@ import MuiSelect, {
|
|
|
6
6
|
SelectChangeEvent,
|
|
7
7
|
SelectProps
|
|
8
8
|
} from '@mui/material/Select';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
faChevronDown,
|
|
11
|
+
faCheck,
|
|
12
|
+
faTimesCircle
|
|
13
|
+
} from '@fortawesome/pro-solid-svg-icons';
|
|
10
14
|
import Icon from '../../Icon';
|
|
11
15
|
import Chip from '../../Chip/Chip';
|
|
12
16
|
|
|
@@ -111,8 +115,12 @@ const MultiSelect = <T extends {}>({
|
|
|
111
115
|
{selected?.map((selectedOption: T, i) => (
|
|
112
116
|
<Chip
|
|
113
117
|
key={i}
|
|
118
|
+
disabled={props.disabled}
|
|
119
|
+
variant="filled"
|
|
120
|
+
color="default"
|
|
114
121
|
label={getOptionLabel(selectedOption)}
|
|
115
|
-
|
|
122
|
+
suffixIcon={faTimesCircle}
|
|
123
|
+
suffixAction={() =>
|
|
116
124
|
!props.disabled && handleDeleteChip(selectedOption)
|
|
117
125
|
}
|
|
118
126
|
onMouseDown={(event) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, ReactElement } from 'react';
|
|
2
2
|
import SvgIcon from '@mui/material/SvgIcon';
|
|
3
3
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
4
4
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
@@ -64,10 +64,10 @@ const FontAwesomeSvgIcon = forwardRef<SVGSVGElement, FontAwesomeSvgIconProps>(
|
|
|
64
64
|
const IconProvider = ({
|
|
65
65
|
variant = 'none',
|
|
66
66
|
icon,
|
|
67
|
-
color = '#136cac',
|
|
67
|
+
color = '#136cac', // blueClickable
|
|
68
68
|
size = 16,
|
|
69
69
|
...props
|
|
70
|
-
}: Props & BoxProps) => {
|
|
70
|
+
}: Props & BoxProps): ReactElement => {
|
|
71
71
|
const getStyles = (): SxProps<Theme> => {
|
|
72
72
|
const theme = useTheme();
|
|
73
73
|
const usedColor = theme.palette[color]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { IconButton, Tooltip as TooltipMui, TooltipProps } from '@mui/material';
|
|
3
|
+
import Text from '../Text/Text';
|
|
3
4
|
|
|
4
5
|
interface Props extends Omit<TooltipProps, 'icon' | 'children'> {
|
|
5
6
|
title: string;
|
|
@@ -7,7 +8,15 @@ interface Props extends Omit<TooltipProps, 'icon' | 'children'> {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const Tooltip = ({ title, children, ...props }: Props) => (
|
|
10
|
-
<TooltipMui
|
|
11
|
+
<TooltipMui
|
|
12
|
+
title={
|
|
13
|
+
<Text variant="body2Regular" color="white">
|
|
14
|
+
{title}
|
|
15
|
+
</Text>
|
|
16
|
+
}
|
|
17
|
+
{...props}
|
|
18
|
+
className="DsTooltip-root"
|
|
19
|
+
>
|
|
11
20
|
<IconButton
|
|
12
21
|
sx={{
|
|
13
22
|
padding: 0,
|