@xqmsg/ui-core 0.15.3 → 0.16.0

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.15.3",
2
+ "version": "0.16.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -31,6 +31,38 @@ const meta: Meta<BannerProps> = {
31
31
  export default meta;
32
32
  const Template: Story<BannerProps> = args => (
33
33
  <>
34
+ <Box mb="20px">
35
+ <Banner
36
+ {...args}
37
+ type="condensed"
38
+ variant="positive"
39
+ message="Positive message."
40
+ />
41
+ </Box>
42
+ <Box mb="20px">
43
+ <Banner
44
+ {...args}
45
+ type="condensed"
46
+ variant="warning"
47
+ message="Warning message."
48
+ />
49
+ </Box>
50
+ <Box mb="20px">
51
+ <Banner
52
+ {...args}
53
+ type="condensed"
54
+ variant="error"
55
+ message="Error message."
56
+ />
57
+ </Box>
58
+ <Box mb="20px">
59
+ <Banner
60
+ {...args}
61
+ type="condensed"
62
+ variant="neutral"
63
+ message="Neutral message."
64
+ />
65
+ </Box>
34
66
  <Box mb="20px">
35
67
  <Banner
36
68
  {...args}
@@ -13,6 +13,7 @@ export interface BannerProps {
13
13
  message: ReactNode;
14
14
  buttonText?: string;
15
15
  onClick?: () => void;
16
+ type?: 'condensed' | 'expanded';
16
17
  }
17
18
 
18
19
  /**
@@ -23,6 +24,7 @@ export const Banner: React.FC<BannerProps> = ({
23
24
  message,
24
25
  buttonText,
25
26
  onClick,
27
+ type = 'expanded',
26
28
  }) => {
27
29
  const Icon = useMemo(() => {
28
30
  switch (variant) {
@@ -42,19 +44,28 @@ export const Banner: React.FC<BannerProps> = ({
42
44
  return (
43
45
  <Alert variant={variant}>
44
46
  <AlertDescription>
45
- <Box pb="8px">{Icon}</Box>
46
- {message}
47
- {onClick && buttonText && (
48
- <Flex pt="8px" justifyContent="flex-end">
49
- <Button
50
- variant="secondary"
51
- onClick={onClick}
52
- text={buttonText}
53
- width="variable"
54
- ariaLabel="banner button"
55
- />
56
- </Flex>
57
- )}
47
+ <Flex
48
+ flexDirection={type === 'condensed' ? 'row' : 'column'}
49
+ alignItems={type === 'condensed' ? 'center' : ''}
50
+ >
51
+ <Box pr="8px">{Icon}</Box>
52
+ <Box pt={type === 'condensed' ? 0 : '8px'}> {message}</Box>
53
+ {onClick && buttonText && (
54
+ <Flex
55
+ ml={type === 'condensed' ? 'auto' : ''}
56
+ pt={type === 'condensed' ? 0 : '8px'}
57
+ justifyContent={type === 'condensed' ? 'flex-end' : 'flex-end'}
58
+ >
59
+ <Button
60
+ variant="secondary"
61
+ onClick={onClick}
62
+ text={buttonText}
63
+ width="variable"
64
+ ariaLabel="banner button"
65
+ />
66
+ </Flex>
67
+ )}
68
+ </Flex>
58
69
  </AlertDescription>
59
70
  </Alert>
60
71
  );
@@ -37,7 +37,7 @@ const meta: Meta<ButtonProps> = {
37
37
  };
38
38
  export default meta;
39
39
  const Template: Story<ButtonProps> = args => (
40
- <Flex flexDir="column" height="200px" justifyContent="space-between">
40
+ <Flex flexDir="column" height="150px" justifyContent="space-between">
41
41
  <Button {...args} text="Primary Fixed" variant="primary" width="fixed" />
42
42
  <Button
43
43
  {...args}
@@ -15,14 +15,13 @@ export const SpinnerButton: React.FC<SpinnerButtonProps> = ({
15
15
  onClick,
16
16
  type,
17
17
  ariaLabel,
18
- variant = 'solid',
19
-
18
+ variant = 'primary',
20
19
  disabled,
21
20
  className,
22
21
  }) => {
23
22
  return (
24
23
  <Button
25
- spinner={<Spinner size={'md'} />}
24
+ spinner={<Spinner size={'sm'} />}
26
25
  isLoading={isLoading}
27
26
  onClick={onClick}
28
27
  type={type}
@@ -8,7 +8,7 @@ import {
8
8
  } from '@chakra-ui/react';
9
9
  import { FieldOptions } from '../InputTypes';
10
10
  import { StackedInputProps } from '../StackedInput/StackedInput';
11
- import colors from '../../../../src/theme/foundations/colors';
11
+ import colors from '../../../theme/foundations/colors';
12
12
  import { UseFormSetValue, FieldValues, Control } from 'react-hook-form';
13
13
  import SubtractIcon from './assets/svg/subtract.svg';
14
14
  import { Dropdown } from '../components/dropdown';
@@ -27,7 +27,16 @@ export interface StackedSelectProps extends StackedInputProps {
27
27
  */
28
28
  const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
29
29
  (
30
- { isRequired, options, name, setValue, handleOnChange, value, ...props },
30
+ {
31
+ isRequired,
32
+ options,
33
+ name,
34
+ setValue,
35
+ handleOnChange,
36
+ disabled,
37
+ value,
38
+ ...props
39
+ },
31
40
  _ref
32
41
  ) => {
33
42
  const dropdownRef = useRef<HTMLDivElement>(null);
@@ -85,6 +94,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
85
94
  fontSize="13px"
86
95
  textShadow={`0 0 0 ${colors.label.primary.light}`}
87
96
  value={selectedOption}
97
+ disabled={disabled}
88
98
  autoComplete="off"
89
99
  onKeyDown={e => {
90
100
  if (isFocussed) {
@@ -105,8 +115,8 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
105
115
  }}
106
116
  />
107
117
  <InputRightElement
108
- cursor="pointer"
109
- onClick={() => setIsFocussed(!isFocussed)}
118
+ cursor={disabled ? 'not-allowed' : 'pointer'}
119
+ onClick={() => !disabled && setIsFocussed(!isFocussed)}
110
120
  >
111
121
  <Image src={SubtractIcon} alt="subtract" boxSize="16px" />
112
122
  </InputRightElement>
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import StackedCheckBox from './StackedCheckbox/StackedCheckbox';
3
3
  import StackedInput from './StackedInput/StackedInput';
4
4
  import StackedRadioGroup from './StackedRadio/StackedRadioGroup';
5
- import StackedSelect from './StackedSelect/StackedSelect';
5
+ import StackedSelect from './StackedSelect';
6
6
  import StackedTextarea from './StackedTextarea/StackedTextarea';
7
7
  import { FieldOptions, ValidationProps, InputType } from './InputTypes';
8
8
  import {
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { Table as ChakraTable, Tbody, Td, Tr } from '@chakra-ui/react';
3
+
4
+ /**
5
+ * A React component utilized to render the `EmptyTable` component
6
+ */
7
+ export const EmptyTable: React.FC = () => {
8
+ const getOpacity = (index: number) => {
9
+ switch (index) {
10
+ case 1:
11
+ return 0.7;
12
+ case 3:
13
+ return 0.6;
14
+ case 5:
15
+ return 0.5;
16
+ case 7:
17
+ return 0.4;
18
+ case 9:
19
+ return 0.3;
20
+ case 11:
21
+ return 0.2;
22
+ case 13:
23
+ return 0.1;
24
+ default:
25
+ return 1;
26
+ }
27
+ };
28
+
29
+ return (
30
+ <ChakraTable
31
+ variant="unstyled"
32
+ width="100%"
33
+ style={{
34
+ borderCollapse: 'separate',
35
+ borderSpacing: '0px',
36
+ }}
37
+ >
38
+ <Tbody>
39
+ {Array.from({ length: 14 }, (_, i) => i + 1).map(i => (
40
+ <Tr>
41
+ <Td height="26px" opacity={getOpacity(i)}></Td>
42
+ </Tr>
43
+ ))}
44
+ </Tbody>
45
+ </ChakraTable>
46
+ );
47
+ };
@@ -9,7 +9,6 @@ import { generateTableColumnsAsConst } from './utils/generateTableColumns';
9
9
 
10
10
  import {
11
11
  Table as ChakraTable,
12
- TableCaption,
13
12
  TableContainer,
14
13
  Tbody,
15
14
  Td,
@@ -19,6 +18,7 @@ import {
19
18
  } from '@chakra-ui/react';
20
19
  import { TableLoadingRows } from './components/loading';
21
20
  import colors from '../../theme/foundations/colors';
21
+ import { EmptyTable } from './empty';
22
22
 
23
23
  export interface TableProps<T extends ReadonlyTableColumns> {
24
24
  columns: TableColumns;
@@ -36,46 +36,47 @@ export function Table<T extends ReadonlyTableColumns>({
36
36
  columns,
37
37
  headers,
38
38
  body,
39
- placeholder = 'There is currently no available data',
40
39
  loading,
41
-
42
40
  loadMore,
43
41
  }: TableProps<T>) {
44
42
  const columnsAsConst = generateTableColumnsAsConst(columns);
45
43
 
46
44
  return (
47
45
  <TableContainer border="none" overflowX="auto" bg="white" width="100%">
48
- <ChakraTable
49
- variant="unstyled"
50
- width="100%"
51
- style={{
52
- borderCollapse: 'separate',
53
- borderSpacing: '0px',
54
- }}
55
- >
56
- <Thead>
57
- <Tr _odd={{ bg: colors.label.primary.dark }}>
58
- {columnsAsConst.map(column => (
59
- // @ts-ignore
60
- <Th>{headers[column]}</Th>
61
- ))}
62
- </Tr>
63
- </Thead>
64
- <Tbody>
65
- {body.map(row => (
66
- <Tr>
46
+ {body.length ? (
47
+ <ChakraTable
48
+ variant="unstyled"
49
+ width="100%"
50
+ style={{
51
+ borderCollapse: 'separate',
52
+ borderSpacing: '0px',
53
+ }}
54
+ >
55
+ <Thead>
56
+ <Tr _odd={{ bg: colors.label.primary.dark }}>
67
57
  {columnsAsConst.map(column => (
68
58
  // @ts-ignore
69
- <Td>{row[column]}</Td>
59
+ <Th>{headers[column]}</Th>
70
60
  ))}
71
61
  </Tr>
72
- ))}
73
- </Tbody>
74
- {!body.length && <TableCaption py={10}>{placeholder}</TableCaption>}{' '}
75
- </ChakraTable>
76
- {loadMore && loading !== undefined && (
77
- <TableLoadingRows isLoading={loading} onLoadMore={loadMore} />
62
+ </Thead>
63
+ <Tbody>
64
+ {body.map(row => (
65
+ <Tr>
66
+ {columnsAsConst.map(column => (
67
+ // @ts-ignore
68
+ <Td>{row[column]}</Td>
69
+ ))}
70
+ </Tr>
71
+ ))}
72
+ </Tbody>
73
+ </ChakraTable>
74
+ ) : (
75
+ <EmptyTable />
78
76
  )}
77
+ {loadMore && loading !== undefined && body.length ? (
78
+ <TableLoadingRows isLoading={loading} onLoadMore={loadMore} />
79
+ ) : null}
79
80
  </TableContainer>
80
81
  );
81
82
  }
@@ -6,6 +6,7 @@ const baseStyle = defineStyle({
6
6
  fontSize: '13px',
7
7
  bg: colors.fill.action,
8
8
  color: colors.label.primary.dark,
9
+ h: '26px',
9
10
  border: 'none',
10
11
  px: '8px',
11
12
  py: '4px',
@@ -11,8 +11,12 @@ const baseStyle = {
11
11
  },
12
12
  tr: {
13
13
  fontSize: '13px',
14
+ h: '26px',
15
+ lineHeight: 'normal',
14
16
  _odd: {
15
17
  td: {
18
+ h: '26px ',
19
+ lineHeight: 'normal',
16
20
  bg: colors.fill.light.tertiary,
17
21
  _first: {
18
22
  borderTopLeftRadius: 'md',
@@ -27,6 +31,8 @@ const baseStyle = {
27
31
  },
28
32
  td: {
29
33
  padding: '5px 8px !important',
34
+ lineHeight: 'normal',
35
+ h: '26px',
30
36
  },
31
37
  };
32
38
 
@@ -7,7 +7,7 @@ const baseStyle: Partial<TextProps> = {
7
7
  fontWeight: typography.fontWeights.normal,
8
8
  fontFamily: typography.fonts.base,
9
9
  fontSize: typography.fontSizes.sm,
10
- lineHeight: typography.lineHeights.base,
10
+ lineHeight: typography.lineHeights.normal,
11
11
  letterSpacing: typography.letterSpacings.wide,
12
12
  };
13
13
 
@@ -8,6 +8,7 @@ export default {
8
8
  base: 'visible',
9
9
  lg: 'hidden',
10
10
  },
11
+ lineHeight: 'normal',
11
12
  },
12
13
  '*, *::before, *::after': {
13
14
  borderColor: 'gray.200',