@xqmsg/ui-core 0.18.7 → 0.19.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.18.7",
2
+ "version": "0.19.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -99,11 +99,13 @@
99
99
  "@emotion/react": "~11.9.0",
100
100
  "@emotion/styled": "~11.6.0",
101
101
  "@hookform/resolvers": "^2.9.7",
102
+ "@types/react-router-dom": "^5.3.3",
102
103
  "axios": "^0.27.2",
103
104
  "framer-motion": "6.3.0",
104
105
  "react-hook-form": "^7.34.0",
105
106
  "react-icons": "^4.4.0",
106
107
  "react-is": "^18.2.0",
108
+ "react-router-dom": "^5.3.3",
107
109
  "react-select": "^5.4.0",
108
110
  "yup": "^0.32.11"
109
111
  },
@@ -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>
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Box, Flex, Link } from '@chakra-ui/react';
3
+ import { Link as RouterLink } from 'react-router-dom';
3
4
  import colors from '../../../../theme/foundations/colors';
4
5
 
5
6
  export interface NavigationMenuItemProps {
6
7
  leftIcon: JSX.Element;
7
8
  label: string;
9
+ to?: string;
8
10
  href?: string;
9
11
  isSelected: boolean;
10
12
  onClick: () => void;
@@ -19,6 +21,7 @@ export const NavigationMenuItem: React.FC<NavigationMenuItemProps> = ({
19
21
  label,
20
22
  leftIcon,
21
23
  href,
24
+ to,
22
25
  rightIcon,
23
26
  isExternal,
24
27
  isSelected,
@@ -26,17 +29,28 @@ export const NavigationMenuItem: React.FC<NavigationMenuItemProps> = ({
26
29
  }) => {
27
30
  let additionalProps = {};
28
31
 
32
+ let reactRouterLinkProps = {};
33
+
34
+ if (to) {
35
+ reactRouterLinkProps = {
36
+ to,
37
+ as: RouterLink,
38
+ };
39
+ }
40
+
29
41
  if (isExternal) {
30
42
  additionalProps = {
31
43
  ...additionalProps,
32
44
  referrerPolicy: 'no-referrer',
33
45
  target: '_blank',
46
+ href,
47
+ isExternal: true,
34
48
  };
35
49
  }
36
50
 
37
51
  return (
38
52
  <Link
39
- href={href}
53
+ {...reactRouterLinkProps}
40
54
  {...additionalProps}
41
55
  onClick={onClick}
42
56
  display="flex"
@@ -7,6 +7,7 @@ export type GroupMenuItems = {
7
7
  leftIcon: JSX.Element;
8
8
  label: string;
9
9
  href?: string;
10
+ to?: string;
10
11
  rightIcon?: JSX.Element;
11
12
  isExternal?: boolean;
12
13
  };
@@ -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
+ };
@@ -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
  /**