@groupeactual/ui-kit 0.4.30 → 0.4.32

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.
Files changed (34) hide show
  1. package/dist/cjs/index.js +94 -1199
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +113 -57176
  4. package/dist/esm/index.js.map +1 -1
  5. package/package.json +8 -11
  6. package/src/DesignSystemProvider.tsx +0 -61
  7. package/src/components/Accordion/Accordion.tsx +0 -72
  8. package/src/components/Accordion/index.ts +0 -1
  9. package/src/components/Button/Button.tsx +0 -18
  10. package/src/components/Button/index.ts +0 -1
  11. package/src/components/Chip/Chip.tsx +0 -125
  12. package/src/components/Chip/index.ts +0 -1
  13. package/src/components/EmbbededNotification/EmbeddedNotification.tsx +0 -95
  14. package/src/components/EmbbededNotification/index.ts +0 -1
  15. package/src/components/Form/Checkbox/Checkbox.tsx +0 -86
  16. package/src/components/Form/Checkbox/index.ts +0 -1
  17. package/src/components/Form/MultiSelect/MultiSelect.tsx +0 -184
  18. package/src/components/Form/MultiSelect/index.ts +0 -1
  19. package/src/components/Form/Select/Select.tsx +0 -154
  20. package/src/components/Form/Select/index.ts +0 -1
  21. package/src/components/Form/TextField/TextField.tsx +0 -98
  22. package/src/components/Form/TextField/index.ts +0 -1
  23. package/src/components/Icon/Icon.tsx +0 -126
  24. package/src/components/Icon/index.ts +0 -1
  25. package/src/components/Link/Link.tsx +0 -11
  26. package/src/components/Link/index.ts +0 -1
  27. package/src/components/Pagination/Pagination.tsx +0 -116
  28. package/src/components/Pagination/index.ts +0 -1
  29. package/src/components/Text/Text.tsx +0 -26
  30. package/src/components/Text/index.ts +0 -1
  31. package/src/components/Tooltip/Tooltip.tsx +0 -33
  32. package/src/components/Tooltip/index.ts +0 -1
  33. package/src/components/index.ts +0 -13
  34. package/src/index.ts +0 -6
@@ -1,154 +0,0 @@
1
- import React, { BaseSyntheticEvent, useMemo, useState } from 'react';
2
- import { FormHelperText, InputLabel, MenuItem } from '@mui/material';
3
- import Box from '@mui/material/Box';
4
- import FormControl from '@mui/material/FormControl';
5
- import MuiSelect, {
6
- SelectChangeEvent,
7
- SelectProps
8
- } from '@mui/material/Select';
9
- import { faChevronDown, faCheck } from '@fortawesome/pro-solid-svg-icons';
10
- import Icon from '../../Icon';
11
-
12
- interface Props<T>
13
- extends Omit<
14
- SelectProps<T>,
15
- 'value' | 'onChange' | 'defaultValue' | 'color'
16
- > {
17
- label?: string;
18
- helperText?: string;
19
- options: T[];
20
- getOptionLabel?: (option: T) => string;
21
- color?: 'success';
22
- onChange: (value: T) => void;
23
- defaultValue?: T | undefined;
24
- width?: number;
25
- }
26
-
27
- const Select = <T extends {}>({
28
- label = '',
29
- defaultValue,
30
- options,
31
- color,
32
- error,
33
- placeholder,
34
- onChange,
35
- getOptionLabel,
36
- helperText,
37
- onBlur,
38
- width = 200,
39
- ...props
40
- }: Props<T>) => {
41
- const [value, setValue] = useState(defaultValue);
42
-
43
- const handleChange = (event: SelectChangeEvent<T>) => {
44
- const newValue = event.target.value as T;
45
- onChange(newValue);
46
- setValue(newValue);
47
- };
48
-
49
- const getFormControlClassName = useMemo(() => {
50
- const classNames: string[] = ['DsSelect'];
51
- if (props.disabled) classNames.push('Mui-disabled');
52
- if (value) classNames.push('Mui-filled');
53
-
54
- return classNames;
55
- }, [value, props.disabled]);
56
-
57
- const getInputLabelClassName = useMemo(() => {
58
- const classNames: string[] = [];
59
- if (error) classNames.push('Mui-error');
60
- if (props.disabled) classNames.push('Mui-disabled');
61
-
62
- return classNames;
63
- }, [error, props.disabled]);
64
-
65
- return (
66
- <Box sx={{ width }}>
67
- <FormControl
68
- id={label === placeholder ? 'select-mui' : 'select-ds'}
69
- fullWidth
70
- color={color}
71
- className={getFormControlClassName.join(' ')}
72
- sx={{
73
- '.MuiOutlinedInput-input': {
74
- marginTop: value ? '0px' : '2px'
75
- }
76
- }}
77
- >
78
- <InputLabel className={getInputLabelClassName.join(' ')}>
79
- {label}
80
- </InputLabel>
81
- <MuiSelect
82
- sx={{
83
- color: color + '! important',
84
- '& .MuiSelect-select .notranslate::after': placeholder
85
- ? {
86
- content: `"${placeholder}"`,
87
- opacity:
88
- label === placeholder ? '0 !important' : '1 !important'
89
- }
90
- : {}
91
- }}
92
- label={label}
93
- placeholder={label === placeholder ? '' : placeholder}
94
- value={value}
95
- error={!!error}
96
- notched={
97
- /* eslint-disable-next-line no-undefined */
98
- label === placeholder ? undefined : true
99
- }
100
- onChange={handleChange}
101
- onBlur={onBlur}
102
- IconComponent={({ className }) => (
103
- <Icon
104
- className={
105
- props.disabled ? 'Mui-disabled SelectIcon' : 'SelectIcon'
106
- }
107
- icon={color === 'success' ? faCheck : faChevronDown}
108
- size={color === 'success' ? 'md' : 'sm'}
109
- sx={{
110
- marginRight: '12px',
111
- marginTop: color === 'success' ? '2px' : '0px',
112
- transform:
113
- className.toString().includes('iconOpen') &&
114
- color !== 'success'
115
- ? 'rotate(180deg)'
116
- : 'none'
117
- }}
118
- />
119
- )}
120
- MenuProps={{
121
- PaperProps: {
122
- style: {
123
- width
124
- }
125
- }
126
- }}
127
- {...props}
128
- >
129
- {options?.map((option, i) => (
130
- <MenuItem
131
- key={i}
132
- value={option as any}
133
- onMouseEnter={(e: BaseSyntheticEvent) =>
134
- (e.target.style.backgroundColor = '#D3E4F0')
135
- }
136
- onMouseLeave={(e: BaseSyntheticEvent) =>
137
- (e.target.style.backgroundColor = '#ffffff')
138
- }
139
- >
140
- {getOptionLabel ? getOptionLabel(option) : option['label']}
141
- </MenuItem>
142
- ))}
143
- </MuiSelect>
144
- {(error || helperText) && (
145
- <FormHelperText component="span" className={error ? 'Mui-error' : ''}>
146
- {error || helperText}
147
- </FormHelperText>
148
- )}
149
- </FormControl>
150
- </Box>
151
- );
152
- };
153
-
154
- export default Select;
@@ -1 +0,0 @@
1
- export { default } from './Select';
@@ -1,98 +0,0 @@
1
- import React, {
2
- FocusEventHandler,
3
- ReactNode,
4
- useEffect,
5
- useState
6
- } from 'react';
7
-
8
- import MuiTextField, { TextFieldProps } from '@mui/material/TextField';
9
- import { InputProps as StandardInputProps } from '@mui/material/Input/Input';
10
-
11
- interface Props extends Omit<TextFieldProps, 'error'> {
12
- error?: string;
13
- onBlur?: FocusEventHandler<unknown>;
14
- onChange?: StandardInputProps['onChange'];
15
- label: string;
16
- value: string;
17
- name: string;
18
- placeholder?: string;
19
- disabled?: boolean;
20
- endAdornment?: ReactNode;
21
- maxLength?: number;
22
- }
23
- const TextField = ({
24
- name,
25
- value,
26
- error,
27
- onBlur,
28
- onChange,
29
- label,
30
- disabled,
31
- endAdornment,
32
- placeholder = '',
33
- maxLength,
34
- ...props
35
- }: Props) => {
36
- const [internalValue, setInternalValue] = useState(value);
37
- useEffect(() => {
38
- if (value !== internalValue) {
39
- setInternalValue(value);
40
- }
41
- }, [value]);
42
-
43
- return (
44
- <MuiTextField
45
- id={label === placeholder ? 'text-field-mui' : 'text-field-ds'}
46
- className="DsTextField"
47
- variant="outlined"
48
- name={name}
49
- label={label}
50
- value={internalValue}
51
- placeholder={label === placeholder ? '' : placeholder}
52
- FormHelperTextProps={{ component: 'div' } as any}
53
- InputLabelProps={{
54
- shrink:
55
- /* eslint-disable-next-line no-undefined */
56
- label === placeholder ? undefined : true
57
- }}
58
- onClick={(e) => e.stopPropagation()}
59
- onChange={(e) => {
60
- setInternalValue(e.currentTarget.value);
61
- if (onChange) {
62
- onChange(e);
63
- }
64
- }}
65
- onBlur={(e) => {
66
- if (onBlur) {
67
- onBlur(e);
68
- }
69
- }}
70
- error={!!error}
71
- disabled={disabled}
72
- InputProps={{ endAdornment }}
73
- inputProps={{ maxLength }}
74
- {...props}
75
- helperText={
76
- <div style={{ display: 'table', width: '100%' }}>
77
- {(error || props.helperText) && (
78
- <div
79
- style={{
80
- display: maxLength ? 'table-cell' : '',
81
- float: 'left'
82
- }}
83
- >
84
- {error || props.helperText}
85
- </div>
86
- )}
87
- {maxLength && (
88
- <div style={{ display: 'table-cell', float: 'right' }}>
89
- {internalValue.length}/{maxLength} caract.
90
- </div>
91
- )}
92
- </div>
93
- }
94
- />
95
- );
96
- };
97
-
98
- export default TextField;
@@ -1 +0,0 @@
1
- export { default } from './TextField';
@@ -1,126 +0,0 @@
1
- import React, { forwardRef, ReactElement } from 'react';
2
- import SvgIcon from '@mui/material/SvgIcon';
3
- import { SxProps, Theme } from '@mui/material/styles';
4
- import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
5
- import Box, { BoxProps } from '@mui/material/Box';
6
- import { useTheme } from '@mui/system';
7
-
8
- const FontSizes = {
9
- xs: 8,
10
- sm: 12,
11
- md: 16,
12
- lg: 24,
13
- xl: 32,
14
- xxl: 40,
15
- xxxl: 72
16
- };
17
-
18
- interface Props {
19
- variant?: 'square' | 'none';
20
- icon: IconDefinition;
21
- color?: string;
22
- size?: number | keyof typeof FontSizes;
23
- }
24
-
25
- interface FontAwesomeSvgIconProps {
26
- icon: any;
27
- fontSize: number | undefined;
28
- }
29
-
30
- // eslint-disable-next-line react/display-name
31
- const FontAwesomeSvgIcon = forwardRef<SVGSVGElement, FontAwesomeSvgIconProps>(
32
- ({ icon, fontSize }, ref) => {
33
- const {
34
- icon: [width, height, , , svgPathData]
35
- } = icon;
36
-
37
- return (
38
- <SvgIcon
39
- ref={ref}
40
- viewBox={`0 0 ${width as string} ${height as string}`}
41
- sx={{
42
- fontSize: fontSize ?? '14px'
43
- }}
44
- >
45
- {typeof svgPathData === 'string' ? (
46
- <path d={svgPathData} />
47
- ) : (
48
- /**
49
- * A multi-path Font Awesome icon seems to imply a duotune icon. The 0th path seems to
50
- * be the faded element (referred to as the "secondary" path in the Font Awesome docs)
51
- * of a duotone icon. 40% is the default opacity.
52
- *
53
- * @see https://fontawesome.com/how-to-use/on-the-web/styling/duotone-icons#changing-opacity
54
- */
55
- svgPathData.map((d: string, i: number) => (
56
- <path style={{ opacity: i === 0 ? 0.4 : 1 }} d={d} key={i} />
57
- ))
58
- )}
59
- </SvgIcon>
60
- );
61
- }
62
- );
63
-
64
- const IconProvider = ({
65
- variant = 'none',
66
- icon,
67
- color = '#136cac', // blueClickable
68
- size = 16,
69
- ...props
70
- }: Props & BoxProps): ReactElement => {
71
- const getStyles = (): SxProps<Theme> => {
72
- const theme = useTheme();
73
- const usedColor = theme.palette[color]
74
- ? theme.palette[color]
75
- : !color || color?.length === 0
76
- ? '#136cac'
77
- : color;
78
-
79
- switch (variant) {
80
- case 'square':
81
- return {
82
- color: usedColor,
83
- backgroundColor: `${usedColor}14`,
84
- borderRadius: '4px',
85
- borderColor: '1px solid ' + usedColor,
86
- overflow: 'visible',
87
- padding: '10px',
88
- width: '35px',
89
- height: '35px',
90
- display: 'flex',
91
- justifyContent: 'center',
92
- alignItems: 'center'
93
- };
94
- default:
95
- return {
96
- color: usedColor,
97
- width: usedFontSize,
98
- height: size,
99
- display: 'inline-flex',
100
- alignItems: 'center',
101
- justifyContent: 'center'
102
- };
103
- }
104
- };
105
-
106
- const isKey = (key: PropertyKey): key is keyof typeof FontSizes => {
107
- return key in FontSizes;
108
- };
109
-
110
- const usedFontSize: number =
111
- variant === 'square'
112
- ? 16
113
- : isKey(size)
114
- ? FontSizes[size]
115
- : size >= 0
116
- ? size
117
- : 16;
118
-
119
- return (
120
- <Box component="span" sx={getStyles()} {...props}>
121
- <FontAwesomeSvgIcon icon={icon} fontSize={usedFontSize} />
122
- </Box>
123
- );
124
- };
125
-
126
- export default IconProvider;
@@ -1 +0,0 @@
1
- export { default } from './Icon';
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { Link as LinkMui, LinkProps } from '@mui/material';
3
-
4
- interface Props extends Omit<LinkProps, 'variant'> {
5
- variant?: 'link1' | 'link2';
6
- component?: any;
7
- }
8
-
9
- const Link = (props: Props) => <LinkMui {...(props as LinkProps)} />;
10
-
11
- export default Link;
@@ -1 +0,0 @@
1
- export { default } from './Link';
@@ -1,116 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import {
3
- Box,
4
- Divider,
5
- Pagination as MUIPagination,
6
- MenuItem,
7
- Select
8
- } from '@mui/material';
9
-
10
- import Text from '../Text';
11
-
12
- interface Props {
13
- totalString: string;
14
- totalPerPageString: string;
15
- totalPages: number;
16
- limitsPerPage: number[];
17
- setLimit?: (limit: number) => void;
18
- setPage?: (page: number) => void;
19
- page?: number;
20
- limit?: number;
21
- }
22
-
23
- const Pagination = ({
24
- totalString,
25
- totalPerPageString,
26
- totalPages,
27
- limitsPerPage,
28
- setLimit,
29
- setPage,
30
- page = 1,
31
- limit
32
- }: Props) => {
33
- const [internalPage, setInternalPage] = useState<number>(page);
34
- const [internalLimit, setInternalLimit] = useState<number>(
35
- limit ?? limitsPerPage[0]
36
- );
37
- useEffect(() => {
38
- if (page !== internalPage) {
39
- setInternalPage(page);
40
- }
41
- }, [page]);
42
-
43
- useEffect(() => {
44
- if (limit && limit !== internalLimit) {
45
- setInternalLimit(limit);
46
- }
47
- }, [limit]);
48
-
49
- return (
50
- <>
51
- <Box display="flex">
52
- <Text color="greyXDark" variant="body1Bold" pt="10px" pr="16px">
53
- {totalString}
54
- </Text>
55
- {totalPages > 1 && (
56
- <>
57
- <Divider
58
- orientation="vertical"
59
- sx={{ marginRight: '16px', color: 'greyXLight' }}
60
- />
61
- <Select
62
- sx={{
63
- // @TODO replace by Select from ui-kit when ready
64
- height: '32px',
65
- width: '75px',
66
- fontSize: '14px',
67
- fontWeight: 400
68
- }}
69
- labelId="select-label"
70
- id="dac-select-label"
71
- value={internalLimit}
72
- onChange={(event) => {
73
- setInternalLimit(Number(event?.target?.value));
74
- setLimit && setLimit(Number(event?.target?.value));
75
- }}
76
- >
77
- {limitsPerPage.map((limit, id) => (
78
- <MenuItem key={id} value={limit}>
79
- {limit}
80
- </MenuItem>
81
- ))}
82
- </Select>
83
- <Text
84
- color="greyXDark"
85
- variant="body1Regular"
86
- pt="6px"
87
- pl="6px"
88
- pr="16px"
89
- >
90
- {totalPerPageString}
91
- </Text>
92
- <Divider
93
- orientation="vertical"
94
- sx={{ marginRight: '16px', color: 'greyXLight' }}
95
- />
96
- </>
97
- )}
98
- </Box>
99
- {totalPages > 1 && (
100
- <Box display="flex" pr="4px">
101
- <MUIPagination
102
- variant="outlined"
103
- shape="rounded"
104
- count={totalPages}
105
- page={internalPage}
106
- onChange={(event: React.ChangeEvent<unknown>, value: number) => {
107
- setInternalPage(value);
108
- setPage && setPage(value);
109
- }}
110
- />
111
- </Box>
112
- )}
113
- </>
114
- );
115
- };
116
- export default Pagination;
@@ -1 +0,0 @@
1
- export { default } from './Pagination';
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { Typography, TypographyProps } from '@mui/material';
3
-
4
- interface Props extends Omit<TypographyProps, 'variant'> {
5
- variant?:
6
- | 'bigNumber'
7
- | 'body1Regular'
8
- | 'body1Medium'
9
- | 'body1Bold'
10
- | 'body2Regular'
11
- | 'body2Medium'
12
- | 'body2Bold'
13
- | 'caption'
14
- | 'buttonNotif'
15
- | 'header1'
16
- | 'header2'
17
- | 'header3'
18
- | 'header4';
19
- component?: any;
20
- }
21
-
22
- const Text = (props: Props) => (
23
- <Typography color="greyXDark" {...(props as TypographyProps)} />
24
- );
25
-
26
- export default Text;
@@ -1 +0,0 @@
1
- export { default } from './Text';
@@ -1,33 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { IconButton, Tooltip as TooltipMui, TooltipProps } from '@mui/material';
3
- import Text from '../Text/Text';
4
-
5
- interface Props extends Omit<TooltipProps, 'icon' | 'children'> {
6
- title: string;
7
- children: ReactNode;
8
- }
9
-
10
- const Tooltip = ({ title, children, ...props }: Props) => (
11
- <TooltipMui
12
- title={
13
- <Text variant="body2Regular" color="white">
14
- {title}
15
- </Text>
16
- }
17
- {...props}
18
- className="DsTooltip-root"
19
- >
20
- <IconButton
21
- sx={{
22
- padding: 0,
23
- '& .MuiBox-root': {
24
- width: 0
25
- }
26
- }}
27
- >
28
- {children}
29
- </IconButton>
30
- </TooltipMui>
31
- );
32
-
33
- export default Tooltip;
@@ -1 +0,0 @@
1
- export { default } from './Tooltip';
@@ -1,13 +0,0 @@
1
- export { default as Text } from './Text';
2
- export { default as Link } from './Link';
3
- export { default as Button } from './Button';
4
- export { default as TextField } from './Form/TextField';
5
- export { default as Select } from './Form/Select';
6
- export { default as MultiSelect } from './Form/MultiSelect';
7
- export { default as Checkbox } from './Form/Checkbox';
8
- export { default as Accordion } from './Accordion';
9
- export { default as IconProvider } from './Icon/Icon';
10
- export { default as Pagination } from './Pagination';
11
- export { default as Chip } from './Chip/Chip';
12
- export { default as EmbeddedNotification } from './EmbbededNotification/EmbeddedNotification';
13
- export { default as Tooltip } from './Tooltip/Tooltip';
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './components';
2
- export {
3
- default as DesignSystemProvider,
4
- DesignSystemContext,
5
- type DesignSystemContextValues
6
- } from './DesignSystemProvider';