@groupeactual/ui-kit 0.4.21 → 0.4.23

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 (30) hide show
  1. package/dist/cjs/components/Accordion/Accordion.d.ts +5 -4
  2. package/dist/cjs/components/Chip/Chip.d.ts +4 -0
  3. package/dist/cjs/components/Chip/index.d.ts +1 -0
  4. package/dist/cjs/components/Form/Checkbox/Checkbox.d.ts +1 -1
  5. package/dist/cjs/components/Form/TextField/TextField.d.ts +6 -5
  6. package/dist/cjs/components/Pagination/Pagination.d.ts +13 -0
  7. package/dist/cjs/components/Pagination/index.d.ts +1 -0
  8. package/dist/cjs/components/index.d.ts +2 -0
  9. package/dist/cjs/index.js +2067 -174
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/esm/components/Accordion/Accordion.d.ts +5 -4
  12. package/dist/esm/components/Chip/Chip.d.ts +4 -0
  13. package/dist/esm/components/Chip/index.d.ts +1 -0
  14. package/dist/esm/components/Form/Checkbox/Checkbox.d.ts +1 -1
  15. package/dist/esm/components/Form/TextField/TextField.d.ts +6 -5
  16. package/dist/esm/components/Pagination/Pagination.d.ts +13 -0
  17. package/dist/esm/components/Pagination/index.d.ts +1 -0
  18. package/dist/esm/components/index.d.ts +2 -0
  19. package/dist/esm/index.js +2067 -176
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/index.d.ts +37 -20
  22. package/package.json +1 -1
  23. package/src/components/Accordion/Accordion.tsx +23 -5
  24. package/src/components/Chip/Chip.tsx +8 -0
  25. package/src/components/Chip/index.ts +1 -0
  26. package/src/components/Form/Checkbox/Checkbox.tsx +2 -2
  27. package/src/components/Form/TextField/TextField.tsx +12 -13
  28. package/src/components/Pagination/Pagination.tsx +110 -0
  29. package/src/components/Pagination/index.ts +1 -0
  30. package/src/components/index.ts +2 -0
package/dist/index.d.ts CHANGED
@@ -2,35 +2,37 @@
2
2
  import { TypographyProps, LinkProps } from '@mui/material';
3
3
  import { ButtonProps } from '@mui/material/Button';
4
4
  import * as react from 'react';
5
- import { FocusEventHandler, ChangeEventHandler, ReactNode, PropsWithChildren } from 'react';
5
+ import { FocusEventHandler, ReactNode, MouseEventHandler, PropsWithChildren } from 'react';
6
6
  import { TextFieldProps } from '@mui/material/TextField';
7
+ import { InputProps } from '@mui/material/Input/Input';
7
8
  import { CheckboxProps } from '@mui/material/Checkbox';
8
9
  import { AccordionProps } from '@mui/material/Accordion';
9
10
  import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
10
11
  import { BoxProps } from '@mui/material/Box';
12
+ import { ChipProps } from '@mui/material/Chip';
11
13
 
12
- interface Props$7 extends Omit<TypographyProps, 'variant'> {
14
+ interface Props$8 extends Omit<TypographyProps, 'variant'> {
13
15
  variant?: 'bigNumber' | 'body1Regular' | 'body1Medium' | 'body1Bold' | 'body2Regular' | 'body2Medium' | 'body2Bold' | 'caption' | 'buttonNotif' | 'header1' | 'header2' | 'header3' | 'header4';
14
16
  component?: any;
15
17
  }
16
- declare const Text: (props: Props$7) => JSX.Element;
18
+ declare const Text: (props: Props$8) => JSX.Element;
17
19
 
18
- interface Props$6 extends Omit<LinkProps, 'variant'> {
20
+ interface Props$7 extends Omit<LinkProps, 'variant'> {
19
21
  variant?: 'link1' | 'link2';
20
22
  component?: any;
21
23
  }
22
- declare const Link: (props: Props$6) => JSX.Element;
24
+ declare const Link: (props: Props$7) => JSX.Element;
23
25
 
24
- interface Props$5 extends Omit<ButtonProps, 'variant'> {
26
+ interface Props$6 extends Omit<ButtonProps, 'variant'> {
25
27
  variant?: 'primary' | 'secondary';
26
28
  component?: any;
27
29
  }
28
- declare const Button: (props: Props$5) => JSX.Element;
30
+ declare const Button: (props: Props$6) => JSX.Element;
29
31
 
30
- interface Props$4 {
32
+ interface Props$5 extends Omit<TextFieldProps, 'error'> {
31
33
  error?: string;
32
- onBlur: FocusEventHandler<unknown>;
33
- onChange: ChangeEventHandler<unknown>;
34
+ onBlur?: FocusEventHandler<unknown>;
35
+ onChange?: InputProps['onChange'];
34
36
  label: string;
35
37
  value: string;
36
38
  name: string;
@@ -40,24 +42,25 @@ interface Props$4 {
40
42
  endAdornment?: ReactNode;
41
43
  maxLength?: number;
42
44
  }
43
- declare const TextField: ({ name, value, error, onBlur, onChange, label, disabled, endAdornment, isValid, placeholder, maxLength, ...props }: Omit<TextFieldProps, 'error'> & Props$4) => JSX.Element;
45
+ declare const TextField: ({ name, value, error, onBlur, onChange, label, disabled, endAdornment, isValid, placeholder, maxLength, ...props }: Props$5) => JSX.Element;
44
46
 
45
- interface Props$3 {
47
+ interface Props$4 {
46
48
  name: string;
47
49
  value: boolean;
48
50
  label: string;
49
- onChange: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
51
+ onChange?: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
50
52
  error?: string;
51
53
  }
52
- declare const Checkbox: ({ name, value, error, label, onChange, ...props }: CheckboxProps & Props$3) => JSX.Element;
54
+ declare const Checkbox: ({ name, value, error, label, onChange, ...props }: CheckboxProps & Props$4) => JSX.Element;
53
55
 
54
- interface Props$2 extends Omit<AccordionProps, 'children'> {
56
+ interface Props$3 extends AccordionProps {
55
57
  icon: ReactNode;
56
- content: ReactNode;
57
58
  title?: string;
58
59
  summaryHeight?: number;
60
+ expanded?: boolean;
61
+ onClick?: MouseEventHandler;
59
62
  }
60
- declare const Accordion: ({ icon, title, content, summaryHeight, ...props }: Props$2) => JSX.Element;
63
+ declare const Accordion: ({ icon, title, summaryHeight, expanded, onClick, children, ...props }: Props$3) => JSX.Element;
61
64
 
62
65
  declare const FontSizes: {
63
66
  xs: number;
@@ -68,13 +71,27 @@ declare const FontSizes: {
68
71
  xxl: number;
69
72
  xxxl: number;
70
73
  };
71
- interface Props$1 {
74
+ interface Props$2 {
72
75
  variant?: 'square' | 'none';
73
76
  icon: IconDefinition;
74
77
  color?: string;
75
78
  size?: number | keyof typeof FontSizes;
76
79
  }
77
- declare const Icon: ({ variant, icon, color, size, ...props }: Props$1 & BoxProps) => JSX.Element;
80
+ declare const Icon: ({ variant, icon, color, size, ...props }: Props$2 & BoxProps) => JSX.Element;
81
+
82
+ interface Props$1 {
83
+ totalString: string;
84
+ totalPerPageString: string;
85
+ totalPages: number;
86
+ limitsPerPage: number[];
87
+ setLimit?: (limit: number) => void;
88
+ setPage?: (page: number) => void;
89
+ page?: number;
90
+ limit?: number;
91
+ }
92
+ declare const Pagination: ({ totalString, totalPerPageString, totalPages, limitsPerPage, setLimit, setPage, page, limit }: Props$1) => JSX.Element;
93
+
94
+ declare const Chip: (props: ChipProps) => JSX.Element;
78
95
 
79
96
  type Theme = 'Default' | 'Ep';
80
97
  interface DesignSystemContextValues {
@@ -88,4 +105,4 @@ interface Props {
88
105
  }
89
106
  declare const DesignSystemProvider: ({ children, name: themeName }: PropsWithChildren<Props>) => JSX.Element;
90
107
 
91
- export { Accordion, Button, Checkbox, DesignSystemContext, DesignSystemContextValues, DesignSystemProvider, Icon as IconProvider, Link, Text, TextField };
108
+ export { Accordion, Button, Checkbox, Chip, DesignSystemContext, DesignSystemContextValues, DesignSystemProvider, Icon as IconProvider, Link, Pagination, Text, TextField };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupeactual/ui-kit",
3
- "version": "0.4.21",
3
+ "version": "0.4.23",
4
4
  "description": "A simple template for a custom React component library",
5
5
  "devDependencies": {
6
6
  "@babel/core": "^7.20.5",
@@ -1,25 +1,43 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEventHandler, ReactNode, useEffect, useState } from 'react';
2
2
  import AccordionMui, { AccordionProps } from '@mui/material/Accordion';
3
3
  import AccordionSummary from '@mui/material/AccordionSummary';
4
4
  import AccordionDetails from '@mui/material/AccordionDetails';
5
5
 
6
- interface Props extends Omit<AccordionProps, 'children'> {
6
+ interface Props extends AccordionProps {
7
7
  icon: ReactNode;
8
- content: ReactNode;
9
8
  title?: string;
10
9
  summaryHeight?: number;
10
+ expanded?: boolean;
11
+ onClick?: MouseEventHandler;
11
12
  }
12
13
 
13
14
  const Accordion = ({
14
15
  icon,
15
16
  title,
16
- content,
17
17
  summaryHeight,
18
+ expanded = false,
19
+ onClick,
20
+ children,
18
21
  ...props
19
22
  }: Props) => {
23
+ const [internalExpanded, setInternalExpanded] = useState(expanded);
24
+
25
+ useEffect(() => {
26
+ if (expanded !== internalExpanded) {
27
+ setInternalExpanded(expanded);
28
+ }
29
+ }, [expanded]);
30
+
20
31
  return (
21
32
  <AccordionMui
22
33
  sx={{ border: `1px solid`, borderColor: 'greyLightDefaultBorder' }}
34
+ expanded={internalExpanded}
35
+ onClick={(e) => {
36
+ if (!props.disabled) {
37
+ setInternalExpanded(!internalExpanded);
38
+ onClick && onClick(e);
39
+ }
40
+ }}
23
41
  {...props}
24
42
  >
25
43
  <AccordionSummary
@@ -40,7 +58,7 @@ const Accordion = ({
40
58
  borderColor: 'greyLightDefaultBorder'
41
59
  }}
42
60
  >
43
- {content}
61
+ {children}
44
62
  </AccordionDetails>
45
63
  </AccordionMui>
46
64
  );
@@ -0,0 +1,8 @@
1
+ import { ChipProps as ChipPropsMUI } from '@mui/material/Chip';
2
+ import { Chip as ChipMUI } from '@mui/material';
3
+
4
+ const Chip = (props: ChipPropsMUI) => {
5
+ return <ChipMUI {...(props as ChipPropsMUI)} />;
6
+ };
7
+
8
+ export default Chip;
@@ -0,0 +1 @@
1
+ export { default } from './Chip';
@@ -10,7 +10,7 @@ interface Props {
10
10
  name: string;
11
11
  value: boolean;
12
12
  label: string;
13
- onChange: (
13
+ onChange?: (
14
14
  field: string,
15
15
  value: any,
16
16
  shouldValidate?: boolean | undefined
@@ -46,7 +46,7 @@ const Checkbox = ({
46
46
  color="primary"
47
47
  onChange={(e) => {
48
48
  setInternalValue(e.target.checked);
49
- onChange(name, e.target.checked, true);
49
+ onChange && onChange(name, e.target.checked, true);
50
50
  }}
51
51
  {...props}
52
52
  />
@@ -1,17 +1,12 @@
1
- import {
2
- ChangeEventHandler,
3
- FocusEventHandler,
4
- ReactNode,
5
- useEffect,
6
- useState
7
- } from 'react';
1
+ import { FocusEventHandler, ReactNode, useEffect, useState } from 'react';
8
2
 
9
3
  import MuiTextField, { TextFieldProps } from '@mui/material/TextField';
4
+ import { InputProps as StandardInputProps } from '@mui/material/Input/Input';
10
5
 
11
- interface Props {
6
+ interface Props extends Omit<TextFieldProps, 'error'> {
12
7
  error?: string;
13
- onBlur: FocusEventHandler<unknown>;
14
- onChange: ChangeEventHandler<unknown>;
8
+ onBlur?: FocusEventHandler<unknown>;
9
+ onChange?: StandardInputProps['onChange'];
15
10
  label: string;
16
11
  value: string;
17
12
  name: string;
@@ -34,7 +29,7 @@ const TextField = ({
34
29
  placeholder = '',
35
30
  maxLength,
36
31
  ...props
37
- }: Omit<TextFieldProps, 'error'> & Props): JSX.Element => {
32
+ }: Props) => {
38
33
  const [internalValue, setInternalValue] = useState(value);
39
34
  useEffect(() => {
40
35
  if (value !== internalValue) {
@@ -55,10 +50,14 @@ const TextField = ({
55
50
  onClick={(e) => e.stopPropagation()}
56
51
  onChange={(e) => {
57
52
  setInternalValue(e.currentTarget.value);
58
- onChange(e);
53
+ if (onChange) {
54
+ onChange(e);
55
+ }
59
56
  }}
60
57
  onBlur={(e) => {
61
- onBlur(e);
58
+ if (onBlur) {
59
+ onBlur(e);
60
+ }
62
61
  }}
63
62
  error={!!error}
64
63
  disabled={disabled}
@@ -0,0 +1,110 @@
1
+ import { 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={{ height: '32px', width: '65px' }}
63
+ labelId="select-label"
64
+ id="dac-select-label"
65
+ value={internalLimit}
66
+ onChange={(event) => {
67
+ setInternalLimit(Number(event?.target?.value));
68
+ setLimit && setLimit(Number(event?.target?.value));
69
+ }}
70
+ >
71
+ {limitsPerPage.map((limit, id) => (
72
+ <MenuItem key={id} value={limit}>
73
+ {limit}
74
+ </MenuItem>
75
+ ))}
76
+ </Select>
77
+ <Text
78
+ color="greyXDark"
79
+ variant="body1Regular"
80
+ pt="6px"
81
+ pl="6px"
82
+ pr="16px"
83
+ >
84
+ {totalPerPageString}
85
+ </Text>
86
+ <Divider
87
+ orientation="vertical"
88
+ sx={{ marginRight: '16px', color: 'greyXLight' }}
89
+ />
90
+ </>
91
+ )}
92
+ </Box>
93
+ {totalPages > 1 && (
94
+ <Box display="flex" pr="4px">
95
+ <MUIPagination
96
+ variant="outlined"
97
+ shape="rounded"
98
+ count={totalPages}
99
+ page={internalPage}
100
+ onChange={(event: React.ChangeEvent<unknown>, value: number) => {
101
+ setInternalPage(value);
102
+ setPage && setPage(value);
103
+ }}
104
+ />
105
+ </Box>
106
+ )}
107
+ </>
108
+ );
109
+ };
110
+ export default Pagination;
@@ -0,0 +1 @@
1
+ export { default } from './Pagination';
@@ -5,3 +5,5 @@ export { default as TextField } from './Form/TextField';
5
5
  export { default as Checkbox } from './Form/Checkbox';
6
6
  export { default as Accordion } from './Accordion';
7
7
  export { default as IconProvider } from './Icon/Icon';
8
+ export { default as Pagination } from './Pagination';
9
+ export { default as Chip } from './Chip/Chip';