@rango-dev/ui 0.28.2-next.0 → 0.28.2-next.2

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 (64) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/index.js.map +4 -4
  3. package/dist/widget/ui/src/components/Alert/Alert.d.ts.map +1 -1
  4. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +4 -4
  5. package/dist/widget/ui/src/components/Alert/Alert.types.d.ts +2 -0
  6. package/dist/widget/ui/src/components/Alert/Alert.types.d.ts.map +1 -1
  7. package/dist/widget/ui/src/components/Button/Button.d.ts +6 -6
  8. package/dist/widget/ui/src/components/Button/Button.styles.d.ts +1 -1
  9. package/dist/widget/ui/src/components/Divider/Divider.d.ts +1 -1
  10. package/dist/widget/ui/src/components/Divider/Divider.d.ts.map +1 -1
  11. package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts +2 -2
  12. package/dist/widget/ui/src/components/Icon/common.d.ts +2 -2
  13. package/dist/widget/ui/src/components/MessageBox/MessageBox.styles.d.ts +1 -1
  14. package/dist/widget/ui/src/components/Modal/Modal.d.ts.map +1 -1
  15. package/dist/widget/ui/src/components/Modal/Modal.types.d.ts +6 -1
  16. package/dist/widget/ui/src/components/Modal/Modal.types.d.ts.map +1 -1
  17. package/dist/widget/ui/src/components/RadioGroup/RadioGroup.styles.d.ts +1 -1
  18. package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts +4 -4
  19. package/dist/widget/ui/src/components/SvgIcon/SvgIcon.style.d.ts +1 -1
  20. package/dist/widget/ui/src/components/Toast/Toast.Provider.d.ts.map +1 -1
  21. package/dist/widget/ui/src/components/Toast/Toast.d.ts.map +1 -1
  22. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts +4 -3
  23. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts.map +1 -1
  24. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +4 -6
  25. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -1
  26. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts +14 -14
  27. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts.map +1 -1
  28. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts +1 -1
  29. package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts +163 -0
  30. package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts.map +1 -0
  31. package/dist/widget/ui/src/components/Typography/Typography.types.d.ts +1 -1
  32. package/dist/widget/ui/src/components/Typography/Typography.types.d.ts.map +1 -1
  33. package/dist/widget/ui/src/components/Typography/index.d.ts +1 -0
  34. package/dist/widget/ui/src/components/Typography/index.d.ts.map +1 -1
  35. package/dist/widget/ui/src/containers/ConnectWalletsModal/ConnectWalletsModal.d.ts.map +1 -1
  36. package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +6 -6
  37. package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +6 -6
  38. package/dist/widget/ui/src/icons/Autorenew.d.ts +5 -0
  39. package/dist/widget/ui/src/icons/Autorenew.d.ts.map +1 -0
  40. package/dist/widget/ui/src/icons/Exit.d.ts +5 -0
  41. package/dist/widget/ui/src/icons/Exit.d.ts.map +1 -0
  42. package/dist/widget/ui/src/icons/Swap.d.ts +5 -0
  43. package/dist/widget/ui/src/icons/Swap.d.ts.map +1 -0
  44. package/dist/widget/ui/src/icons/index.d.ts +3 -0
  45. package/dist/widget/ui/src/icons/index.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/components/Alert/Alert.tsx +2 -0
  48. package/src/components/Alert/Alert.types.ts +2 -0
  49. package/src/components/Divider/Divider.tsx +2 -1
  50. package/src/components/Modal/Modal.tsx +6 -5
  51. package/src/components/Modal/Modal.types.ts +6 -1
  52. package/src/components/Toast/Toast.Provider.tsx +82 -44
  53. package/src/components/Toast/Toast.stories.tsx +18 -21
  54. package/src/components/Toast/Toast.styles.ts +74 -38
  55. package/src/components/Toast/Toast.tsx +54 -27
  56. package/src/components/Toast/Toast.types.ts +19 -17
  57. package/src/components/Typography/NotSelectableTypography.ts +7 -0
  58. package/src/components/Typography/Typography.types.tsx +1 -1
  59. package/src/components/Typography/index.ts +1 -0
  60. package/src/containers/ConnectWalletsModal/ConnectWalletsModal.tsx +3 -1
  61. package/src/icons/Autorenew.tsx +20 -0
  62. package/src/icons/Exit.tsx +20 -0
  63. package/src/icons/Swap.tsx +20 -0
  64. package/src/icons/index.ts +3 -0
@@ -2,9 +2,12 @@ import type { ToastProps } from './Toast.types';
2
2
 
3
3
  import React, { useEffect } from 'react';
4
4
 
5
+ import { CloseIcon } from '../../icons';
6
+ import { Alert } from '../Alert';
5
7
  import { IconHighlight } from '../Alert/Alert.styles';
6
8
  import AlertIcon from '../Alert/AlertIcon';
7
9
  import { Divider } from '../Divider';
10
+ import { IconButton } from '../IconButton';
8
11
 
9
12
  import { useToast } from './Toast.Provider';
10
13
  import {
@@ -14,46 +17,70 @@ import {
14
17
  ToastContentContainer,
15
18
  } from './Toast.styles';
16
19
 
17
- const DEFAULT_HIDE_DURATION = 3_000;
18
-
19
20
  export const Toast = (props: ToastProps) => {
20
- const { id, horizontal, autoHideDuration = DEFAULT_HIDE_DURATION } = props;
21
+ const {
22
+ id,
23
+ autoHideDuration,
24
+ onClose,
25
+ type,
26
+ title,
27
+ position,
28
+ hasCloseIcon = true,
29
+ hideOnTap = true,
30
+ variant = 'standard',
31
+ } = props;
21
32
  const { removeToast } = useToast();
22
33
  useEffect(() => {
23
- const timer = setTimeout(() => {
24
- removeToast(id);
25
- }, autoHideDuration);
34
+ let cleanup;
35
+
36
+ if (autoHideDuration) {
37
+ const timer = setTimeout(() => {
38
+ handleClose();
39
+ }, autoHideDuration);
26
40
 
27
- return () => {
28
- clearTimeout(timer);
29
- };
41
+ cleanup = () => clearTimeout(timer);
42
+ }
43
+
44
+ return cleanup;
30
45
  }, [id]);
31
46
 
47
+ const handleClose = () => {
48
+ removeToast(id, position);
49
+ onClose?.();
50
+ };
51
+
32
52
  return (
33
- <ToastContentContainer horizontal={horizontal}>
34
- {'component' in props ? (
35
- props.component
36
- ) : (
37
- <AlertBox
38
- onClick={() => removeToast(id)}
39
- type={props.type}
40
- style={props.style}>
53
+ <ToastContentContainer>
54
+ <AlertBox
55
+ onClick={hideOnTap ? handleClose : undefined}
56
+ variant={variant}
57
+ type={type}>
58
+ {variant === 'custom' ? (
41
59
  <AlertFlexContainer>
42
- <IconHighlight type={props.type} align="center">
43
- <AlertIcon type={props.type} />
60
+ <IconHighlight type={type} align="center">
61
+ <AlertIcon type={type} />
44
62
  </IconHighlight>
45
63
  <Divider direction="horizontal" size={10} />
46
- <StyledTypography
47
- variant="body"
48
- size="small"
49
- color={props.titleColor}
50
- hasColor={!!props.titleColor}
51
- align="left">
64
+ <StyledTypography variant="body" size="small" align="left">
52
65
  {props.title}
53
66
  </StyledTypography>
54
67
  </AlertFlexContainer>
55
- </AlertBox>
56
- )}
68
+ ) : (
69
+ <Alert
70
+ title={title}
71
+ type={type}
72
+ variant="alarm"
73
+ titleAlign="left"
74
+ action={
75
+ hasCloseIcon ? (
76
+ <IconButton variant="ghost" size="xsmall" onClick={handleClose}>
77
+ <CloseIcon size={12} />
78
+ </IconButton>
79
+ ) : undefined
80
+ }
81
+ />
82
+ )}
83
+ </AlertBox>
57
84
  </ToastContentContainer>
58
85
  );
59
86
  };
@@ -1,31 +1,33 @@
1
+ import type { ToastContainer } from './Toast.styles';
1
2
  import type { Type } from '../Alert/Alert.types';
2
- import type { CSSProperties } from '@stitches/react';
3
+ import type * as Stitches from '@stitches/react';
4
+ import type { CSSProperties } from 'react';
3
5
 
6
+ type BaseProps = Stitches.VariantProps<typeof ToastContainer>;
7
+ export type ToastPosition = Exclude<BaseProps['position'], object>;
4
8
  export interface ProviderPropTypes {
5
9
  container: HTMLElement;
6
- anchorOrigin?: {
7
- horizontal: 'left' | 'right';
8
- vertical: 'bottom' | 'top';
9
- };
10
- containerStyle?: CSSProperties;
11
10
  }
12
11
 
13
- export type ToastType = { autoHideDuration?: number; id?: number | string } & (
14
- | {
15
- title: string;
16
- type: Type;
17
- titleColor?: string;
18
- style?: CSSProperties;
19
- }
20
- | { component: React.ReactNode }
21
- );
12
+ export type ToastType = {
13
+ autoHideDuration?: number;
14
+ id?: number | string;
15
+ containerStyle?: CSSProperties;
16
+ onClose?: () => void;
17
+ position: ToastPosition;
18
+ title: string;
19
+ type: Type;
20
+ style?: CSSProperties;
21
+ hasCloseIcon?: boolean;
22
+ hideOnTap?: boolean;
23
+ variant?: 'custom' | 'standard';
24
+ };
22
25
 
23
26
  export type ToastProps = ToastType & {
24
27
  id: number | string;
25
- horizontal: 'left' | 'right';
26
28
  };
27
29
 
28
30
  export type ProviderContext = {
29
31
  addToast: (content: ToastType) => void;
30
- removeToast: (id: number | string) => void;
32
+ removeToast: (id: number | string, position: ToastPosition) => void;
31
33
  };
@@ -0,0 +1,7 @@
1
+ import { styled } from '../../theme';
2
+
3
+ import { Typography } from './Typography';
4
+
5
+ export const NotSelectableTypography = styled(Typography, {
6
+ userSelect: 'none',
7
+ });
@@ -4,7 +4,7 @@ import type * as Stitches from '@stitches/react';
4
4
  type BaseProps = Stitches.VariantProps<typeof TypographyContainer>;
5
5
  type BaseSizes = Exclude<BaseProps['size'], object>;
6
6
  type BaseVariants = Exclude<BaseProps['variant'], object>;
7
- type BaseAlign = Exclude<BaseProps['align'], object>;
7
+ export type BaseAlign = Exclude<BaseProps['align'], object>;
8
8
 
9
9
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
10
10
  type margin = 2 | 4 | 8 | 12;
@@ -1,2 +1,3 @@
1
1
  export { Typography } from './Typography';
2
+ export { NotSelectableTypography } from './NotSelectableTypography';
2
3
  export type { PropTypes as TypographyPropTypes } from './Typography.types';
@@ -30,7 +30,9 @@ export function ConnectWalletsModal(props: PropTypes) {
30
30
  title={i18n.t('Connect Wallets')}
31
31
  open={open}
32
32
  onClose={onClose}
33
- containerStyle={{ width: '75%', maxWidth: '30rem', height: '60%' }}>
33
+ styles={{
34
+ container: { width: '75%', maxWidth: '30rem', height: '60%' },
35
+ }}>
34
36
  <ModalContent>
35
37
  {list.map((info) => (
36
38
  <Wallet {...info} key={info.title} onClick={onSelect} />
@@ -0,0 +1,20 @@
1
+ import type { SvgIconPropsWithChildren } from '../components/SvgIcon';
2
+
3
+ import React, { createElement } from 'react';
4
+
5
+ import { SvgIcon } from '../components/SvgIcon';
6
+
7
+ function SvgAutorenew(props: SvgIconPropsWithChildren) {
8
+ return createElement(
9
+ SvgIcon,
10
+ props,
11
+ <svg viewBox="0 0 24 24">
12
+ <path
13
+ fillRule="evenodd"
14
+ d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"
15
+ fill="currentColor"
16
+ />
17
+ </svg>
18
+ );
19
+ }
20
+ export default SvgAutorenew;
@@ -0,0 +1,20 @@
1
+ import type { SvgIconPropsWithChildren } from '../components/SvgIcon';
2
+
3
+ import React, { createElement } from 'react';
4
+
5
+ import { SvgIcon } from '../components/SvgIcon';
6
+
7
+ function SvgExit(props: SvgIconPropsWithChildren) {
8
+ return createElement(
9
+ SvgIcon,
10
+ props,
11
+ <svg viewBox="0 0 24 24">
12
+ <path
13
+ fillRule="evenodd"
14
+ d="M10.09 15.59 11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
15
+ fill="currentColor"
16
+ />
17
+ </svg>
18
+ );
19
+ }
20
+ export default SvgExit;
@@ -0,0 +1,20 @@
1
+ import type { SvgIconPropsWithChildren } from '../components/SvgIcon';
2
+
3
+ import React, { createElement } from 'react';
4
+
5
+ import { SvgIcon } from '../components/SvgIcon';
6
+
7
+ function SvgSwap(props: SvgIconPropsWithChildren) {
8
+ return createElement(
9
+ SvgIcon,
10
+ props,
11
+ <svg viewBox="0 0 24 24">
12
+ <path
13
+ fillRule="evenodd"
14
+ d="M6.99 11 3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"
15
+ fill="currentColor"
16
+ />
17
+ </svg>
18
+ );
19
+ }
20
+ export default SvgSwap;
@@ -1,5 +1,6 @@
1
1
  export { default as AddIcon } from './Add';
2
2
  export { default as AutoThemeIcon } from './AutoTheme';
3
+ export { default as AutorenewIcon } from './Autorenew';
3
4
  export { default as BorderRadiusIcon } from './BorderRadius';
4
5
  export { default as ChevronDownIcon } from './ChevronDown';
5
6
  export { default as ChevronLeftIcon } from './ChevronLeft';
@@ -16,6 +17,7 @@ export { default as DesktopIcon } from './Desktop';
16
17
  export { default as DoneIcon } from './Done';
17
18
  export { default as EvmCategoryIcon } from './EvmCategory';
18
19
  export { default as ErrorIcon } from './Error';
20
+ export { default as ExitIcon } from './Exit';
19
21
  export { default as ExternalLinkIcon } from './ExternalLink';
20
22
  export { default as FontIcon } from './Font';
21
23
  export { default as GasIcon } from './Gas';
@@ -41,6 +43,7 @@ export { default as RefreshIcon } from './Refresh';
41
43
  export { default as ReverseIcon } from './Reverse';
42
44
  export { default as RouteIcon } from './Route';
43
45
  export { default as SearchIcon } from './Search';
46
+ export { default as SwapIcon } from './Swap';
44
47
  export { default as TimeIcon } from './Time';
45
48
  export { default as TransactionIcon } from './Transaction';
46
49
  export { default as UtxoCategoryIcon } from './UtxoCategory';