@xqmsg/ui-core 0.18.8 → 0.19.1

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 (31) hide show
  1. package/dist/components/icons/neutral/index.d.ts +1 -0
  2. package/dist/components/toast/Toast.stories.d.ts +5 -0
  3. package/dist/components/toast/index.d.ts +12 -0
  4. package/dist/hooks/useToast.d.ts +6 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/theme/provider/index.d.ts +1 -1
  7. package/dist/ui-core.cjs.development.js +122 -19
  8. package/dist/ui-core.cjs.development.js.map +1 -1
  9. package/dist/ui-core.cjs.production.min.js +1 -1
  10. package/dist/ui-core.cjs.production.min.js.map +1 -1
  11. package/dist/ui-core.esm.js +122 -20
  12. package/dist/ui-core.esm.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/components/breadcrumbs/index.tsx +1 -0
  15. package/src/components/form/section/index.tsx +1 -0
  16. package/src/components/icons/neutral/index.tsx +3 -2
  17. package/src/components/icons/neutral/neutral.svg +1 -1
  18. package/src/components/input/StackedMultiSelect/index.tsx +8 -2
  19. package/src/components/input/StackedPilledInput/index.tsx +1 -0
  20. package/src/components/input/components/dropdown/index.tsx +3 -3
  21. package/src/components/navigation/index.tsx +4 -3
  22. package/src/components/table/empty/index.tsx +1 -1
  23. package/src/components/table/index.tsx +6 -6
  24. package/src/components/tabs/index.tsx +2 -2
  25. package/src/components/toast/Toast.stories.tsx +52 -0
  26. package/src/components/toast/index.tsx +78 -0
  27. package/src/components/toolbar/components/breadcrumbs/index.tsx +1 -1
  28. package/src/components/toolbar/components/dropdown/index.tsx +2 -2
  29. package/src/hooks/useToast.tsx +13 -0
  30. package/src/index.tsx +1 -0
  31. package/src/theme/provider/index.tsx +1 -1
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.18.8",
2
+ "version": "0.19.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -34,6 +34,7 @@ export const Breadcrumbs: React.FC<BreadcrumbsProps> = ({
34
34
  <Flex flexDir={orientation === 'horizontal' ? 'row' : 'column'}>
35
35
  {steps.map((step, idx) => (
36
36
  <Flex
37
+ key={idx}
37
38
  alignItems="center"
38
39
  pr={orientation === 'horizontal' ? '16px' : 0}
39
40
  py="4px"
@@ -62,6 +62,7 @@ export function FormSection<
62
62
  defaultValue,
63
63
  }: FormInput) => (
64
64
  <Input<U>
65
+ key={name}
65
66
  control={form.control}
66
67
  label={label}
67
68
  inputType={inputType}
@@ -3,11 +3,12 @@ import { ReactComponent as NeutralIcon } from './neutral.svg';
3
3
 
4
4
  export interface NeutralProps {
5
5
  boxSize: number | string;
6
+ color?: string;
6
7
  }
7
8
 
8
9
  /**
9
10
  * A functional React component utilized to render the `Neutral` icon component
10
11
  */
11
- export const Neutral: React.FC<NeutralProps> = ({ boxSize }) => {
12
- return <NeutralIcon boxSize={boxSize} />;
12
+ export const Neutral: React.FC<NeutralProps> = ({ color, boxSize }) => {
13
+ return <NeutralIcon boxSize={boxSize} fill={color || '#3C3C43'} />;
13
14
  };
@@ -1,3 +1,3 @@
1
1
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M7 4.5V4C6.72386 4 6.5 4.22386 6.5 4.5H7ZM7.005 4.5H7.505C7.505 4.22386 7.28114 4 7.005 4V4.5ZM7.005 4.505V5.005C7.28114 5.005 7.505 4.78114 7.505 4.505H7.005ZM7 4.505H6.5C6.5 4.78114 6.72386 5.005 7 5.005V4.505ZM6.27639 6.05279C6.0294 6.17628 5.92929 6.47662 6.05279 6.72361C6.17628 6.9706 6.47662 7.07071 6.72361 6.94721L6.27639 6.05279ZM6.52766 6.48617L6.30405 6.03896L6.52766 6.48617ZM7.23634 7.05465L7.72141 7.17592L7.23634 7.05465ZM6.76366 8.94535L6.27859 8.82408L6.76366 8.94535ZM7.47234 9.51383L7.69595 9.96104L7.69595 9.96104L7.47234 9.51383ZM7.72361 9.94721C7.9706 9.82371 8.07071 9.52337 7.94721 9.27639C7.82371 9.0294 7.52337 8.92929 7.27639 9.05279L7.72361 9.94721ZM12.5 7C12.5 10.0376 10.0376 12.5 7 12.5V13.5C10.5899 13.5 13.5 10.5899 13.5 7H12.5ZM7 12.5C3.96243 12.5 1.5 10.0376 1.5 7H0.5C0.5 10.5899 3.41015 13.5 7 13.5V12.5ZM1.5 7C1.5 3.96243 3.96243 1.5 7 1.5V0.5C3.41015 0.5 0.5 3.41015 0.5 7H1.5ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7H13.5C13.5 3.41015 10.5899 0.5 7 0.5V1.5ZM7 5H7.005V4H7V5ZM6.505 4.5V4.505H7.505V4.5H6.505ZM7.005 4.005H7V5.005H7.005V4.005ZM7.5 4.505V4.5H6.5V4.505H7.5ZM6.72361 6.94721L6.75127 6.93338L6.30405 6.03896L6.27639 6.05279L6.72361 6.94721ZM6.75127 6.93338L6.27859 8.82408L7.24873 9.06662L7.72141 7.17592L6.75127 6.93338ZM7.69595 9.96104L7.72361 9.94721L7.27639 9.05279L7.24873 9.06662L7.69595 9.96104ZM6.27859 8.82408C6.07138 9.65293 6.93179 10.3431 7.69595 9.96104L7.24873 9.06662L6.27859 8.82408ZM6.75127 6.93338L7.72141 7.17592C7.92862 6.34708 7.06821 5.65688 6.30405 6.03896L6.75127 6.93338Z" fill="#3C3C43" fill-opacity="0.6"/>
2
+ <path d="M7 4.5V4C6.72386 4 6.5 4.22386 6.5 4.5H7ZM7.005 4.5H7.505C7.505 4.22386 7.28114 4 7.005 4V4.5ZM7.005 4.505V5.005C7.28114 5.005 7.505 4.78114 7.505 4.505H7.005ZM7 4.505H6.5C6.5 4.78114 6.72386 5.005 7 5.005V4.505ZM6.27639 6.05279C6.0294 6.17628 5.92929 6.47662 6.05279 6.72361C6.17628 6.9706 6.47662 7.07071 6.72361 6.94721L6.27639 6.05279ZM6.52766 6.48617L6.30405 6.03896L6.52766 6.48617ZM7.23634 7.05465L7.72141 7.17592L7.23634 7.05465ZM6.76366 8.94535L6.27859 8.82408L6.76366 8.94535ZM7.47234 9.51383L7.69595 9.96104L7.69595 9.96104L7.47234 9.51383ZM7.72361 9.94721C7.9706 9.82371 8.07071 9.52337 7.94721 9.27639C7.82371 9.0294 7.52337 8.92929 7.27639 9.05279L7.72361 9.94721ZM12.5 7C12.5 10.0376 10.0376 12.5 7 12.5V13.5C10.5899 13.5 13.5 10.5899 13.5 7H12.5ZM7 12.5C3.96243 12.5 1.5 10.0376 1.5 7H0.5C0.5 10.5899 3.41015 13.5 7 13.5V12.5ZM1.5 7C1.5 3.96243 3.96243 1.5 7 1.5V0.5C3.41015 0.5 0.5 3.41015 0.5 7H1.5ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7H13.5C13.5 3.41015 10.5899 0.5 7 0.5V1.5ZM7 5H7.005V4H7V5ZM6.505 4.5V4.505H7.505V4.5H6.505ZM7.005 4.005H7V5.005H7.005V4.005ZM7.5 4.505V4.5H6.5V4.505H7.5ZM6.72361 6.94721L6.75127 6.93338L6.30405 6.03896L6.27639 6.05279L6.72361 6.94721ZM6.75127 6.93338L6.27859 8.82408L7.24873 9.06662L7.72141 7.17592L6.75127 6.93338ZM7.69595 9.96104L7.72361 9.94721L7.27639 9.05279L7.24873 9.06662L7.69595 9.96104ZM6.27859 8.82408C6.07138 9.65293 6.93179 10.3431 7.69595 9.96104L7.24873 9.06662L6.27859 8.82408ZM6.75127 6.93338L7.72141 7.17592C7.92862 6.34708 7.06821 5.65688 6.30405 6.03896L6.75127 6.93338Z" fill="current" fill-opacity="0.6"/>
3
3
  </svg>
@@ -298,8 +298,14 @@ const StackedMultiSelect = React.forwardRef<
298
298
  ref={scrollRef}
299
299
  >
300
300
  {localValues.length ? (
301
- localValues.map(option => (
302
- <Box mr="4px" width="fit-content" h="16px" borderRadius="full">
301
+ localValues.map((option, idx) => (
302
+ <Box
303
+ key={idx}
304
+ mr="4px"
305
+ width="fit-content"
306
+ h="16px"
307
+ borderRadius="full"
308
+ >
303
309
  <Token
304
310
  label={option.label}
305
311
  onDelete={() => handleDelete(option)}
@@ -278,6 +278,7 @@ const StackedPilledInput = React.forwardRef<
278
278
  {lastestFormValueToArray.length
279
279
  ? lastestFormValueToArray.map((label, index) => (
280
280
  <Box
281
+ key={index}
281
282
  mr="4px"
282
283
  border={
283
284
  tokenIndex === index
@@ -23,14 +23,14 @@ export const Dropdown: React.FC<DropdownProps> = ({
23
23
  }) => {
24
24
  const DropdownContent = useMemo(() => {
25
25
  return options.map((option, idx) => (
26
- <>
26
+ <Box key={idx} width="100%">
27
27
  {option.value === 'section_header' &&
28
28
  options[idx + 1] &&
29
29
  options[idx + 1].value !== 'section_header' && (
30
30
  <Box
31
31
  color={colors.label.secondary.light}
32
32
  fontSize="13px"
33
- width="fit-content"
33
+ width="100%"
34
34
  fontWeight="bold"
35
35
  px="8px"
36
36
  bg="inherit"
@@ -75,7 +75,7 @@ export const Dropdown: React.FC<DropdownProps> = ({
75
75
  {option.label}
76
76
  </Box>
77
77
  )}
78
- </>
78
+ </Box>
79
79
  ));
80
80
  }, [onSelectItem, optionIndex, options]);
81
81
 
@@ -48,14 +48,15 @@ export const NavigationMenu: React.FC<NavigationMenuProps> = ({
48
48
  overflowY="auto"
49
49
  width="220px"
50
50
  >
51
- {sortedGroupedMenuItems?.map(menuItemGroup => (
52
- <Box _notLast={{ paddingBottom: '8px' }}>
51
+ {sortedGroupedMenuItems?.map((menuItemGroup, idx) => (
52
+ <Box key={idx} _notLast={{ paddingBottom: '8px' }}>
53
53
  {menuItemGroup.groupHeader && (
54
54
  <NavigationMenuHeader label={menuItemGroup.groupHeader} />
55
55
  )}
56
- {menuItemGroup.groupMenuItems.map(item => (
56
+ {menuItemGroup.groupMenuItems.map((item, idx) => (
57
57
  <NavigationMenuItem
58
58
  {...item}
59
+ key={idx}
59
60
  isSelected={selectedMenuItem === item.label}
60
61
  onClick={() => setSelectedMenuItem(item.label)}
61
62
  />
@@ -37,7 +37,7 @@ export const EmptyTable: React.FC = () => {
37
37
  >
38
38
  <Tbody>
39
39
  {Array.from({ length: 14 }, (_, i) => i + 1).map(i => (
40
- <Tr>
40
+ <Tr key={i}>
41
41
  <Td height="26px" opacity={getOpacity(i)}></Td>
42
42
  </Tr>
43
43
  ))}
@@ -55,19 +55,19 @@ export function Table<T extends ReadonlyTableColumns>({
55
55
  {headers && (
56
56
  <Thead>
57
57
  <Tr _odd={{ bg: colors.label.primary.dark }}>
58
- {columnsAsConst.map(column => (
58
+ {columnsAsConst.map((column, idx) => (
59
59
  // @ts-ignore
60
- <Th>{headers[column]}</Th>
60
+ <Th key={idx}>{headers[column]}</Th>
61
61
  ))}
62
62
  </Tr>
63
63
  </Thead>
64
64
  )}
65
65
  <Tbody>
66
- {body.map(row => (
67
- <Tr>
68
- {columnsAsConst.map(column => (
66
+ {body.map((row, idx) => (
67
+ <Tr key={idx}>
68
+ {columnsAsConst.map((column, idx) => (
69
69
  // @ts-ignore
70
- <Td>{row[column]}</Td>
70
+ <Td key={idx}>{row[column]}</Td>
71
71
  ))}
72
72
  </Tr>
73
73
  ))}
@@ -29,8 +29,8 @@ export const TabsWrapper: React.FC<TabsWrapperProps> = ({
29
29
  borderBottomLeftRadius={0}
30
30
  borderBottomRightRadius={0}
31
31
  >
32
- {navItems.map(navItem => (
33
- <Tab>{navItem}</Tab>
32
+ {navItems.map((navItem, idx) => (
33
+ <Tab key={idx}>{navItem}</Tab>
34
34
  ))}
35
35
  </TabList>
36
36
  {children}
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import { Toast, ToastProps } from '.';
4
+ import alertTheme from '../../theme/components/alert';
5
+ import { Box } from '@chakra-ui/react';
6
+
7
+ const meta: Meta<ToastProps> = {
8
+ title: 'Toast example',
9
+ component: Toast,
10
+ argTypes: {
11
+ variant: {
12
+ control: 'select',
13
+ options: Object.keys(alertTheme.variants),
14
+ description: 'The `variant` of the `Toast` component',
15
+ },
16
+ message: {
17
+ description: 'The `message` of the `Toast` component',
18
+ },
19
+ buttonText: {
20
+ description: "The `buttonText` of the `Toast` component's action button",
21
+ },
22
+ onClick: {
23
+ description:
24
+ "The `onClick` handler of the `Toast` component's action button",
25
+ },
26
+ },
27
+ parameters: {
28
+ controls: { expanded: true },
29
+ },
30
+ };
31
+ export default meta;
32
+ const Template: Story<ToastProps> = args => (
33
+ <>
34
+ <Box mb="20px">
35
+ <Toast {...args} variant="positive" message="Positive message." />
36
+ </Box>
37
+ <Box mb="20px">
38
+ <Toast {...args} variant="warning" message="Warning message." />
39
+ </Box>
40
+ <Box mb="20px">
41
+ <Toast {...args} variant="error" message="Error message." />
42
+ </Box>
43
+ <Box mb="20px">
44
+ <Toast {...args} variant="neutral" message="Neutral message." />
45
+ </Box>
46
+ </>
47
+ );
48
+
49
+ export const Default = Template.bind({});
50
+ Default.args = {
51
+ buttonText: 'Action',
52
+ };
@@ -0,0 +1,78 @@
1
+ import React, { ReactNode, useMemo } from 'react';
2
+ import { Box, Button, Flex, Text } from '@chakra-ui/react';
3
+ import { Error } from '../icons/error';
4
+ import { Neutral } from '../icons/neutral';
5
+ import { Positive } from '../icons/positive';
6
+ import { Warning } from '../icons/warning';
7
+ import colors from '../../theme/foundations/colors';
8
+
9
+ export type ToastVariant = 'positive' | 'warning' | 'error' | 'neutral';
10
+
11
+ export interface ToastProps {
12
+ variant: ToastVariant;
13
+ message: ReactNode;
14
+ buttonText?: string;
15
+ onClick?: () => void;
16
+ }
17
+
18
+ /**
19
+ * A functional React component utilized to render the `Toast` component
20
+ */
21
+ export const Toast: React.FC<ToastProps> = ({
22
+ variant,
23
+ message,
24
+ buttonText,
25
+ onClick,
26
+ }) => {
27
+ const Icon = useMemo(() => {
28
+ switch (variant) {
29
+ case 'error':
30
+ return <Error boxSize="16px" />;
31
+ case 'neutral':
32
+ return <Neutral boxSize="16px" color="white" />;
33
+ case 'positive':
34
+ return <Positive boxSize="16px" />;
35
+ case 'warning':
36
+ return <Warning boxSize="16px" />;
37
+ default:
38
+ return null;
39
+ }
40
+ }, [variant]);
41
+
42
+ return (
43
+ <Flex
44
+ alignItems="center"
45
+ width="fit-content"
46
+ height="32px"
47
+ p="8px"
48
+ bg="#151515D9"
49
+ borderColor="#9999991A"
50
+ borderRadius="8px"
51
+ >
52
+ <Box pr="8px">{Icon}</Box>
53
+ <Text pr="16px" fontSize="13px" color={colors.label.primary.dark}>
54
+ {message}
55
+ </Text>
56
+ {onClick && buttonText && (
57
+ <Flex ml="auto" justifyContent="flex-end">
58
+ <Button
59
+ color={colors.fill.action}
60
+ style={{
61
+ background: 'transparent',
62
+ border: 'transparent',
63
+ boxShadow: 'none',
64
+ }}
65
+ _hover={{
66
+ bg: 'transparent',
67
+ border: 'transparent',
68
+ boxShadow: 'none',
69
+ }}
70
+ onClick={onClick}
71
+ >
72
+ {buttonText}
73
+ </Button>
74
+ </Flex>
75
+ )}
76
+ </Flex>
77
+ );
78
+ };
@@ -45,7 +45,7 @@ export const ToolbarBreadcrumbs: React.FC<ToolbarBreadcrumbsProps> = ({
45
45
  return (
46
46
  <Flex height="26px">
47
47
  {filteredPageList.map((page, i) => (
48
- <Flex alignItems="center">
48
+ <Flex alignItems="center" key={i}>
49
49
  <ToolbarBreadcrumbItem
50
50
  page={getPageType(i)}
51
51
  pageLabel={page.label}
@@ -26,7 +26,7 @@ export const Dropdown: React.FC<DropdownProps> = ({
26
26
  }) => {
27
27
  const DropdownContent = useMemo(() => {
28
28
  return options.map((option, idx) => (
29
- <>
29
+ <Box key={idx}>
30
30
  {option.value === 'section_header' &&
31
31
  options[idx + 1] &&
32
32
  options[idx + 1].value !== 'section_header' && (
@@ -74,7 +74,7 @@ export const Dropdown: React.FC<DropdownProps> = ({
74
74
  {option.label}
75
75
  </Flex>
76
76
  )}
77
- </>
77
+ </Box>
78
78
  ));
79
79
  }, [onSelectItem, optionIndex, options, setOptionIndex]);
80
80
 
@@ -0,0 +1,13 @@
1
+ import { ToastPosition, useToast as useChakraToast } from '@chakra-ui/react';
2
+ import React from 'react';
3
+ import { Toast, ToastProps } from '../components/toast';
4
+
5
+ export const useToast = (props: ToastProps & { position: ToastPosition }) => {
6
+ const toast = useChakraToast();
7
+
8
+ return () =>
9
+ toast({
10
+ position: props.position,
11
+ render: () => <Toast {...props} />,
12
+ });
13
+ };
package/src/index.tsx CHANGED
@@ -55,6 +55,7 @@ export * from './theme/provider';
55
55
  export * from './components/toolbar';
56
56
 
57
57
  // Hooks
58
+ export * from './hooks/useToast';
58
59
 
59
60
  //Utils
60
61
  export * from './components/form/utils/formErrors';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ChakraProvider, ChakraProviderProps } from '@chakra-ui/provider';
2
+ import { ChakraProvider, ChakraProviderProps } from '@chakra-ui/react';
3
3
  import customXQChakraTheme from '../customXQChakraTheme';
4
4
 
5
5
  /**