@xipkg/button 0.0.2 → 0.0.3

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.
@@ -0,0 +1,49 @@
1
+
2
+ > @xipkg/button@0.0.2 build
3
+ > tsup index.ts --format cjs --dts
4
+
5
+ CLI Building entry: index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v6.7.0
8
+ CLI Target: es6
9
+ CJS Build start
10
+ CJS dist\index.js 2.50 KB
11
+ CJS ⚡️ Build success in 37ms
12
+ DTS Build start
13
+ Button.tsx(17,11): error TS2769: No overload matches this call.
14
+ Overload 1 of 3, '(props: { href: string; } & { children?: ReactNode; classes?: Partial<ButtonClasses> | undefined; color?: "primary" | "success" | "error" | "inherit" | "secondary" | "info" | "warning" | undefined; ... 9 more ...; variant?: "contained" | ... 2 more ... | undefined; } & Omit<...> & CommonProps & Omit<...>): Element', gave the following error.
15
+ Type '{ children: ReactNode; status?: Status | undefined; size?: "small" | "medium" | "large" | undefined; loadingPosition?: LoadingPosition | undefined; ... 302 more ...; component?: ElementType<...> | undefined; }' is not assignable to type '{ href: string; }'.
16
+ Types of property 'href' are incompatible.
17
+ Type 'string | undefined' is not assignable to type 'string'.
18
+ Type 'undefined' is not assignable to type 'string'.
19
+ Overload 2 of 3, '(props: { component: ElementType<any>; } & { children?: ReactNode; classes?: Partial<ButtonClasses> | undefined; color?: "primary" | ... 6 more ... | undefined; ... 9 more ...; variant?: "contained" | ... 2 more ... | undefined; } & Omit<...> & CommonProps & Omit<...>): Element | null', gave the following error.
20
+ Type '{ children: ReactNode; status?: Status | undefined; size?: "small" | "medium" | "large" | undefined; loadingPosition?: LoadingPosition | undefined; ... 302 more ...; component?: ElementType<...> | undefined; }' is not assignable to type '{ component: ElementType<any>; }'.
21
+ Types of property 'component' are incompatible.
22
+ Type 'ElementType<any> | undefined' is not assignable to type 'ElementType<any>'.
23
+ Type 'undefined' is not assignable to type 'ElementType<any>'.
24
+ Overload 3 of 3, '(props: DefaultComponentProps<ExtendButtonBaseTypeMap<ButtonTypeMap<{}, "button">>>): Element | null', gave the following error.
25
+ Type '{ children: ReactNode; status?: Status | undefined; size?: "small" | "medium" | "large" | undefined; loadingPosition?: LoadingPosition | undefined; ... 302 more ...; component?: ElementType<...> | undefined; }' is not assignable to type '{ children?: ReactNode; classes?: Partial<ButtonClasses> | undefined; color?: "primary" | "success" | "error" | "inherit" | "secondary" | "info" | "warning" | undefined; ... 9 more ...; variant?: "contained" | ... 2 more ... | undefined; }'.
26
+ Types of property 'color' are incompatible.
27
+ Type 'Color | undefined' is not assignable to type '"primary" | "success" | "error" | "inherit" | "secondary" | "info" | "warning" | undefined'.
28
+ Type '"gray"' is not assignable to type '"primary" | "success" | "error" | "inherit" | "secondary" | "info" | "warning" | undefined'.
29
+
30
+ Error: error occured in dts build
31
+ at Worker.<anonymous> (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\tsup\dist\index.js:2281:26)
32
+ at Worker.emit (node:events:513:28)
33
+ at MessagePort.<anonymous> (node:internal/worker:243:53)
34
+ at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
35
+ at exports.emitMessage (node:internal/per_context/messageport:23:28)
36
+ DTS Build error
37
+ RollupError: Failed to compile. Check the logs above.
38
+ at error (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\rollup\dist\shared\rollup.js:349:30)
39
+ at Object.error (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\rollup\dist\shared\rollup.js:1716:20)
40
+ at Object.error (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\rollup\dist\shared\rollup.js:25501:42)
41
+ at generateDtsFromTs (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\tsup\dist\rollup.js:7498:22)
42
+ at C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\tsup\dist\rollup.js:7505:59
43
+ at _nullishCoalesce (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\tsup\dist\rollup.js:1:198)
44
+ at Object.transform (C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\tsup\dist\rollup.js:7505:18)
45
+ at C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\node_modules\rollup\dist\shared\rollup.js:1909:40
46
+ npm ERR! Lifecycle script `build` failed with error:
47
+ npm ERR! Error: command failed
48
+ npm ERR! in workspace: @xipkg/button@0.0.2
49
+ npm ERR! at location: C:\Users\igorb\OneDrive\Рабочий стол\xi.kit\packages\pkg.button
package/Button.tsx CHANGED
@@ -1,24 +1,7 @@
1
- import 'pkg.config.muidts';
2
-
3
- import { Typography, Button as MuiButton, darken, useTheme } from '@mui/material';
4
- import React, { FC, MouseEvent } from 'react';
1
+ import { Button as MuiButton } from '@mui/material';
5
2
 
6
3
  import { ButtonProps } from './types';
7
4
 
8
- import {
9
- buttonVariantsColor,
10
- buttonSizes,
11
- getButtonPadding,
12
- buttonDisabledStyle,
13
- getActionButtonStyle,
14
- typographyVariants,
15
- clickedPadding,
16
- buttonBorderStyle,
17
- } from './styles';
18
- import { ButtonSnackbar } from './ButtonSnackbar';
19
- import { IconContainer } from './IconContainer';
20
- import { Loading } from './Loading';
21
-
22
5
  declare module '@mui/material/Typography' {
23
6
  export interface TypographyPropsVariantOverrides {
24
7
  xl: true;
@@ -30,123 +13,6 @@ declare module '@mui/material/Typography' {
30
13
  }
31
14
  }
32
15
 
33
- export const Button: FC<ButtonProps> = ({
34
- status = 'idle',
35
- size = 'medium',
36
- loadingPosition = 'center',
37
- variant = 'contained',
38
- color = 'primary',
39
- children,
40
- startIcon,
41
- endIcon,
42
- isSnackbar,
43
- snackbarText,
44
- isSnackbarIconStart,
45
- isSnackbarIconEnd,
46
- snackbarLoadingPosition,
47
- snackbarPosition,
48
- ...props
49
- }) => {
50
- const { sx, onClick, ...otherButtonProps } = props;
51
-
52
- const theme = useTheme();
53
-
54
- const actionButtonStyle = getActionButtonStyle(
55
- variant,
56
- color === 'grayscale' ? 'grayscale' : darken(theme.palette[color].dark, 0.2),
57
- );
58
-
59
- const buttonPadding = getButtonPadding(!!children, !!startIcon, !!endIcon);
60
-
61
- const buttonBorder = variant === 'outlined' ? buttonBorderStyle[size] : 'none';
62
- const buttonDisabled = status !== 'completed' ? buttonDisabledStyle[variant] : actionButtonStyle;
63
-
64
- const onButtonClick = (e: MouseEvent<HTMLButtonElement>) => {
65
- if (status === 'completed') return;
66
-
67
- if (onClick) {
68
- onClick(e);
69
- }
70
- };
71
-
72
- return (
73
- <MuiButton
74
- onClick={onButtonClick}
75
- disabled={status === 'pending' || status === 'completed'}
76
- size={size}
77
- disableRipple
78
- disableElevation
79
- sx={{
80
- textTransform: 'none',
81
- position: 'relative',
82
- minWidth: 0,
83
- border: buttonBorder,
84
- '&:hover': {
85
- ...actionButtonStyle,
86
- },
87
- '&:disabled': {
88
- ...buttonDisabled,
89
- },
90
- '&:active': {
91
- ...actionButtonStyle,
92
- pt: clickedPadding[size].pt,
93
- pb: clickedPadding[size].pb,
94
- },
95
- ...buttonSizes[size],
96
- ...buttonVariantsColor[variant][color],
97
- ...buttonPadding[size],
98
- ...sx,
99
- }}
100
- {...otherButtonProps}
101
- >
102
- {startIcon && (
103
- <IconContainer
104
- Icon={startIcon}
105
- size={size}
106
- order={0}
107
- status={status}
108
- isLoadingIcon={loadingPosition !== 'center'}
109
- />
110
- )}
111
- {endIcon && (
112
- <IconContainer
113
- Icon={endIcon}
114
- size={size}
115
- order={2}
116
- status={status}
117
- isLoadingIcon={loadingPosition !== 'center'}
118
- />
119
- )}
120
-
121
- {children && (
122
- <Typography
123
- order={1}
124
- variant={typographyVariants[size]}
125
- sx={{
126
- color: 'inherit',
127
- opacity: loadingPosition === 'center' && status === 'pending' ? 0 : 1,
128
- }}
129
- >
130
- {children}
131
- </Typography>
132
- )}
133
-
134
- {status === 'pending' && loadingPosition === 'center' && (
135
- <Loading top="50%" left="50%" transform="translate(-50%,-50%)" size={size} />
136
- )}
137
-
138
- {isSnackbar && status !== 'idle' && (
139
- <ButtonSnackbar
140
- size={size}
141
- variant={variant}
142
- status={status}
143
- snackbarText={snackbarText}
144
- isSnackbarIconStart={isSnackbarIconStart}
145
- isSnackbarIconEnd={isSnackbarIconEnd}
146
- snackbarLoadingPosition={snackbarLoadingPosition}
147
- snackbarPosition={snackbarPosition}
148
- />
149
- )}
150
- </MuiButton>
151
- );
16
+ export const Button = ({ children, ...props }: ButtonProps) => {
17
+ return <MuiButton {...props}>{children}</MuiButton>;
152
18
  };
@@ -1,104 +1,104 @@
1
- import { Typography, Stack } from '@mui/material';
2
- import React, { FC } from 'react';
3
-
4
- import {
5
- buttonSizes,
6
- typographyVariants,
7
- buttonDisabledStyle,
8
- getButtonPadding,
9
- getSnackbarCurrentPosition,
10
- buttonBorderStyle,
11
- } from './styles';
12
- import { LoadingPosition, Size, SnackbarPosition, Status, Variant } from './types';
13
- import { IconContainer } from './IconContainer';
14
- import { Loading } from './Loading';
15
-
16
- export const ButtonSnackbar: FC<ButtonSnackbarProps> = ({
17
- size,
18
- variant,
19
- status,
20
- snackbarText,
21
- isSnackbarIconStart,
22
- isSnackbarIconEnd,
23
- snackbarLoadingPosition = 'center',
24
- snackbarPosition = 'right',
25
- }) => {
26
- const snackbarRef = React.useRef<HTMLDivElement | null>(null);
27
- const [snackbarSize, setSnackbarSize] = React.useState(0);
28
- const snackbarCurrentPosition = getSnackbarCurrentPosition(snackbarSize, snackbarPosition);
29
-
30
- const buttonBorder = variant === 'outlined' ? buttonBorderStyle[size] : 'none';
31
-
32
- const snackbarPadding = getButtonPadding(
33
- !!snackbarText,
34
- !!isSnackbarIconStart,
35
- !!isSnackbarIconEnd,
36
- );
37
-
38
- React.useLayoutEffect(() => {
39
- if (!snackbarRef?.current) return;
40
- if (snackbarPosition === 'left' || snackbarPosition === 'right') {
41
- setSnackbarSize(snackbarRef.current.clientWidth);
42
- }
43
- if (snackbarPosition === 'top' || snackbarPosition === 'bottom') {
44
- setSnackbarSize(snackbarRef.current.clientHeight);
45
- }
46
- }, [snackbarPosition, size, snackbarText]);
47
-
48
- return (
49
- <Stack
50
- ref={snackbarRef}
51
- direction="row"
52
- alignItems="center"
53
- sx={{
54
- position: 'absolute',
55
- border: buttonBorder,
56
- ...snackbarCurrentPosition,
57
- ...buttonSizes[size],
58
- ...snackbarPadding[size],
59
- ...buttonDisabledStyle[variant],
60
- }}
61
- >
62
- {status === 'pending' && snackbarLoadingPosition === 'center' && (
63
- <Loading top="50%" left="50%" transform="translate(-50%,-50%)" size={size} />
64
- )}
65
- {isSnackbarIconStart && (
66
- <IconContainer
67
- size={size}
68
- order={0}
69
- status={status}
70
- isLoadingIcon={snackbarLoadingPosition !== 'center'}
71
- />
72
- )}
73
- {isSnackbarIconEnd && (
74
- <IconContainer
75
- size={size}
76
- order={2}
77
- status={status}
78
- isLoadingIcon={snackbarLoadingPosition !== 'center'}
79
- />
80
- )}
81
-
82
- {snackbarText && (
83
- <Typography
84
- color="inherit"
85
- sx={{ opacity: snackbarLoadingPosition === 'center' && status === 'pending' ? 0 : 1 }}
86
- variant={typographyVariants[size]}
87
- >
88
- {snackbarText}
89
- </Typography>
90
- )}
91
- </Stack>
92
- );
93
- };
94
-
95
- type ButtonSnackbarProps = {
96
- size: Size;
97
- variant: Variant;
98
- status: Status;
99
- snackbarText?: string;
100
- isSnackbarIconStart?: boolean;
101
- isSnackbarIconEnd?: boolean;
102
- snackbarLoadingPosition?: LoadingPosition;
103
- snackbarPosition?: SnackbarPosition;
104
- };
1
+ import { Typography, Stack } from '@mui/material';
2
+ import React, { FC } from 'react';
3
+
4
+ import {
5
+ buttonSizes,
6
+ typographyVariants,
7
+ buttonDisabledStyle,
8
+ getButtonPadding,
9
+ getSnackbarCurrentPosition,
10
+ buttonBorderStyle,
11
+ } from './styles';
12
+ import { LoadingPosition, Size, SnackbarPosition, Status, Variant } from './types';
13
+ import { IconContainer } from './IconContainer';
14
+ import { Loading } from './Loading';
15
+
16
+ export const ButtonSnackbar: FC<ButtonSnackbarProps> = ({
17
+ size,
18
+ variant,
19
+ status,
20
+ snackbarText,
21
+ isSnackbarIconStart,
22
+ isSnackbarIconEnd,
23
+ snackbarLoadingPosition = 'center',
24
+ snackbarPosition = 'right',
25
+ }) => {
26
+ const snackbarRef = React.useRef<HTMLDivElement | null>(null);
27
+ const [snackbarSize, setSnackbarSize] = React.useState(0);
28
+ const snackbarCurrentPosition = getSnackbarCurrentPosition(snackbarSize, snackbarPosition);
29
+
30
+ const buttonBorder = variant === 'outlined' ? buttonBorderStyle[size] : 'none';
31
+
32
+ const snackbarPadding = getButtonPadding(
33
+ !!snackbarText,
34
+ !!isSnackbarIconStart,
35
+ !!isSnackbarIconEnd,
36
+ );
37
+
38
+ React.useLayoutEffect(() => {
39
+ if (!snackbarRef?.current) return;
40
+ if (snackbarPosition === 'left' || snackbarPosition === 'right') {
41
+ setSnackbarSize(snackbarRef.current.clientWidth);
42
+ }
43
+ if (snackbarPosition === 'top' || snackbarPosition === 'bottom') {
44
+ setSnackbarSize(snackbarRef.current.clientHeight);
45
+ }
46
+ }, [snackbarPosition, size, snackbarText]);
47
+
48
+ return (
49
+ <Stack
50
+ ref={snackbarRef}
51
+ direction="row"
52
+ alignItems="center"
53
+ sx={{
54
+ position: 'absolute',
55
+ border: buttonBorder,
56
+ ...snackbarCurrentPosition,
57
+ ...buttonSizes[size],
58
+ ...snackbarPadding[size],
59
+ ...buttonDisabledStyle[variant],
60
+ }}
61
+ >
62
+ {status === 'pending' && snackbarLoadingPosition === 'center' && (
63
+ <Loading top="50%" left="50%" transform="translate(-50%,-50%)" size={size} />
64
+ )}
65
+ {isSnackbarIconStart && (
66
+ <IconContainer
67
+ size={size}
68
+ order={0}
69
+ status={status}
70
+ isLoadingIcon={snackbarLoadingPosition !== 'center'}
71
+ />
72
+ )}
73
+ {isSnackbarIconEnd && (
74
+ <IconContainer
75
+ size={size}
76
+ order={2}
77
+ status={status}
78
+ isLoadingIcon={snackbarLoadingPosition !== 'center'}
79
+ />
80
+ )}
81
+
82
+ {snackbarText && (
83
+ <Typography
84
+ color="inherit"
85
+ sx={{ opacity: snackbarLoadingPosition === 'center' && status === 'pending' ? 0 : 1 }}
86
+ variant={typographyVariants[size]}
87
+ >
88
+ {snackbarText}
89
+ </Typography>
90
+ )}
91
+ </Stack>
92
+ );
93
+ };
94
+
95
+ type ButtonSnackbarProps = {
96
+ size: Size;
97
+ variant: Variant;
98
+ status: Status;
99
+ snackbarText?: string;
100
+ isSnackbarIconStart?: boolean;
101
+ isSnackbarIconEnd?: boolean;
102
+ snackbarLoadingPosition?: LoadingPosition;
103
+ snackbarPosition?: SnackbarPosition;
104
+ };
package/IconContainer.tsx CHANGED
@@ -1,52 +1,52 @@
1
- import { Stack } from '@mui/material';
2
- import { Check } from 'pkg.icons';
3
- import { FC } from 'react';
4
- import { Loading } from './Loading';
5
- import { iconSizes } from './styles';
6
- import { Size, Status } from './types';
7
-
8
- export const IconContainer: FC<IconComponentProps> = ({
9
- order,
10
- Icon,
11
- size,
12
- status,
13
- isLoadingIcon,
14
- }) => (
15
- <Stack order={order} sx={{ position: 'relative', ...iconSizes[size] }}>
16
- {!!Icon && (
17
- <Icon
18
- sx={{
19
- opacity: status === 'idle' ? 1 : 0,
20
- color: 'inherit',
21
- ...iconSizes[size],
22
- }}
23
- />
24
- )}
25
- <Check
26
- sx={{
27
- opacity: status === 'completed' ? 1 : 0,
28
- position: 'absolute',
29
- top: '50%',
30
- transform: 'translateY(-50%)',
31
- color: 'inherit',
32
- ...iconSizes[size],
33
- }}
34
- />
35
- {isLoadingIcon && (
36
- <Loading
37
- size={size}
38
- top="50%"
39
- transform="translateY(-50%)"
40
- opacity={status === 'pending' ? 1 : 0}
41
- />
42
- )}
43
- </Stack>
44
- );
45
-
46
- type IconComponentProps = {
47
- Icon?: any;
48
- order: number;
49
- size: Size;
50
- status: Status;
51
- isLoadingIcon: boolean;
52
- };
1
+ import { Stack } from '@mui/material';
2
+ import { Check } from '@xipkg/icons';
3
+ import { FC } from 'react';
4
+ import { Loading } from './Loading';
5
+ import { iconSizes } from './styles';
6
+ import { Size, Status } from './types';
7
+
8
+ export const IconContainer: FC<IconComponentProps> = ({
9
+ order,
10
+ Icon,
11
+ size,
12
+ status,
13
+ isLoadingIcon,
14
+ }) => (
15
+ <Stack order={order} sx={{ position: 'relative', ...iconSizes[size] }}>
16
+ {!!Icon && (
17
+ <Icon
18
+ sx={{
19
+ opacity: status === 'idle' ? 1 : 0,
20
+ color: 'inherit',
21
+ ...iconSizes[size],
22
+ }}
23
+ />
24
+ )}
25
+ <Check
26
+ sx={{
27
+ opacity: status === 'completed' ? 1 : 0,
28
+ position: 'absolute',
29
+ top: '50%',
30
+ transform: 'translateY(-50%)',
31
+ color: 'inherit',
32
+ ...iconSizes[size],
33
+ }}
34
+ />
35
+ {isLoadingIcon && (
36
+ <Loading
37
+ size={size}
38
+ top="50%"
39
+ transform="translateY(-50%)"
40
+ opacity={status === 'pending' ? 1 : 0}
41
+ />
42
+ )}
43
+ </Stack>
44
+ );
45
+
46
+ type IconComponentProps = {
47
+ Icon?: any;
48
+ order: number;
49
+ size: Size;
50
+ status: Status;
51
+ isLoadingIcon: boolean;
52
+ };
package/Loading.tsx CHANGED
@@ -1,18 +1,18 @@
1
- import { FC } from 'react';
2
- import { CircularProgress, Stack, SxProps } from '@mui/material';
3
- import { iconSizes, spinnerSizes } from './styles';
4
- import { Size } from './types';
5
-
6
- export const Loading: FC<LoadingProps> = ({ size, ...props }) => (
7
- <Stack
8
- sx={{
9
- position: 'absolute',
10
- ...iconSizes[size],
11
- ...props,
12
- }}
13
- >
14
- <CircularProgress size={spinnerSizes[size]} color="inherit" />
15
- </Stack>
16
- );
17
-
18
- type LoadingProps = { size: Size } & SxProps;
1
+ import { FC } from 'react';
2
+ import { CircularProgress, Stack, SxProps } from '@mui/material';
3
+ import { iconSizes, spinnerSizes } from './styles';
4
+ import { Size } from './types';
5
+
6
+ export const Loading: FC<LoadingProps> = ({ size, ...props }) => (
7
+ <Stack
8
+ sx={{
9
+ position: 'absolute',
10
+ ...iconSizes[size],
11
+ ...props,
12
+ }}
13
+ >
14
+ <CircularProgress size={spinnerSizes[size]} color="inherit" />
15
+ </Stack>
16
+ );
17
+
18
+ type LoadingProps = { size: Size } & SxProps;
@@ -0,0 +1,39 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps as ButtonProps$1 } from '@mui/material';
3
+
4
+ type Status = 'idle' | 'pending' | 'completed';
5
+ type Size = 'small' | 'medium' | 'large';
6
+ type Variant = 'contained' | 'outlined' | 'text';
7
+ type Color = 'primary' | 'success' | 'error' | 'gray';
8
+ type LoadingPosition = 'icon' | 'center';
9
+ type SnackbarPosition = 'left' | 'right' | 'top' | 'bottom';
10
+ type ButtonProps = {
11
+ status?: Status;
12
+ size?: Size;
13
+ loadingPosition?: LoadingPosition;
14
+ variant?: Variant;
15
+ color?: Color;
16
+ startIcon?: any;
17
+ endIcon?: any;
18
+ isSnackbar?: boolean;
19
+ snackbarText?: string;
20
+ isSnackbarIconStart?: boolean;
21
+ isSnackbarIconEnd?: boolean;
22
+ snackbarLoadingPosition?: LoadingPosition;
23
+ snackbarPosition?: SnackbarPosition;
24
+ sx?: any;
25
+ } & Omit<ButtonProps$1, 'startIcon' | 'endIcon' | 'color'>;
26
+
27
+ declare module '@mui/material/Typography' {
28
+ interface TypographyPropsVariantOverrides {
29
+ xl: true;
30
+ l: true;
31
+ m: true;
32
+ s: true;
33
+ xs: true;
34
+ xxs: true;
35
+ }
36
+ }
37
+ declare const Button: ({ children, ...props }: ButtonProps) => react_jsx_runtime.JSX.Element;
38
+
39
+ export { Button, ButtonProps };
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
39
+ var __copyProps = (to, from, except, desc) => {
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (let key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(to, key) && key !== except)
43
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
44
+ }
45
+ return to;
46
+ };
47
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+
49
+ // index.ts
50
+ var pkg_exports = {};
51
+ __export(pkg_exports, {
52
+ Button: () => Button
53
+ });
54
+ module.exports = __toCommonJS(pkg_exports);
55
+
56
+ // Button.tsx
57
+ var import_material = require("@mui/material");
58
+ var import_jsx_runtime = require("react/jsx-runtime");
59
+ var Button = (_a) => {
60
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Button, __spreadProps(__spreadValues({}, props), { children }));
62
+ };
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ Button
66
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xipkg/button",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -14,14 +14,14 @@
14
14
  "@emotion/react": "^11.11.1",
15
15
  "@emotion/styled": "^11.11.0",
16
16
  "@mui/material": "^5.14.0",
17
- "@xipkg/icons": "^0.4.3",
17
+ "@xipkg/icons": "^0.4.4",
18
18
  "react": "^18.2.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^17.0.12",
22
22
  "@types/react": "^18.2.14",
23
23
  "@types/react-dom": "^18.2.6",
24
- "@xipkg/eslint": "^0.0.2",
24
+ "@xipkg/eslint": "^0.0.3",
25
25
  "@xipkg/typescript": "^0.0.0",
26
26
  "eslint": "^7.32.0",
27
27
  "typescript": "^5.1.3"
@@ -30,5 +30,6 @@
30
30
  "access": "public"
31
31
  },
32
32
  "author": "xi.effect",
33
- "description": ""
33
+ "description": "",
34
+ "gitHead": "0ee562e7c7723699c85daf61b493d6a57b7c1f08"
34
35
  }
package/styles.ts CHANGED
@@ -21,60 +21,60 @@ export const buttonSizes = {
21
21
  export const buttonVariantsColor = {
22
22
  contained: {
23
23
  primary: {
24
- bgcolor: 'brand.80',
25
- color: 'petersburg.0',
24
+ bgcolor: 'var(--xi-brand-80)',
25
+ color: 'var(--xi-gray-0)',
26
26
  },
27
27
  success: {
28
- bgcolor: 'ekaterinburg.80',
29
- color: 'petersburg.0',
28
+ bgcolor: 'var(--xi-green-80)',
29
+ color: 'var(--xi-gray-0)',
30
30
  },
31
31
  error: {
32
- bgcolor: 'moscow.80',
33
- color: 'petersburg.0',
32
+ bgcolor: 'var(--xi-red-80)',
33
+ color: 'var(--xi-gray-0)',
34
34
  },
35
- grayscale: {
36
- bgcolor: 'petersburg.40',
37
- color: 'petersburg.100',
35
+ gray: {
36
+ bgcolor: 'var(--xi-gray-40)',
37
+ color: 'var(--xi-gray-100)',
38
38
  },
39
39
  },
40
40
  outlined: {
41
41
  primary: {
42
- borderColor: 'brand.80',
43
- color: 'brand.80',
42
+ borderColor: 'var(--xi-brand-80)',
43
+ color: 'var(--xi-brand-80)',
44
44
  },
45
45
  success: {
46
- borderColor: 'ekaterinburg.80',
47
- color: 'ekaterinburg.80',
46
+ borderColor: 'var(--xi-green-80)',
47
+ color: 'var(--xi-green-80)',
48
48
  },
49
49
  error: {
50
- borderColor: 'moscow.80',
51
- color: 'moscow.80',
50
+ borderColor: 'var(--xi-red-80)',
51
+ color: 'var(--xi-red-80)',
52
52
  },
53
- grayscale: {
54
- color: 'petersburg.100',
55
- borderColor: 'petersburg.40',
53
+ gray: {
54
+ color: 'var(--xi-gray-100)',
55
+ borderColor: 'var(--xi-gray-40)',
56
56
  },
57
57
  },
58
58
  text: {
59
- primary: { color: 'brand.80' },
60
- success: { color: 'ekaterinburg.80' },
61
- error: { color: 'moscow.80' },
62
- grayscale: { color: 'petersburg.100' },
59
+ primary: { color: 'var(--xi-brand-80)' },
60
+ success: { color: 'var(--xi-green-80)' },
61
+ error: { color: 'var(--xi-red-80)' },
62
+ gray: { color: 'var(--xi-gray-100)' },
63
63
  },
64
64
  };
65
65
 
66
66
  export const buttonDisabledStyle = {
67
67
  contained: {
68
- backgroundColor: 'petersburg.10',
69
- color: 'petersburg.40',
68
+ backgroundColor: 'var(--xi-gray-10)',
69
+ color: 'var(--xi-gray-40)',
70
70
  },
71
71
  outlined: {
72
72
  border: '1px solid',
73
- borderColor: 'petersburg.10',
74
- color: 'petersburg.40',
73
+ borderColor: 'var(--xi-gray-10)',
74
+ color: 'var(--xi-gray-40)',
75
75
  },
76
76
  text: {
77
- color: 'petersburg.40',
77
+ color: 'var(--xi-gray-40)',
78
78
  },
79
79
  };
80
80
 
@@ -117,22 +117,22 @@ export const spinnerSizes = {
117
117
  small: 16,
118
118
  };
119
119
 
120
+ const style = {
121
+ large: {
122
+ padding: '13px 32px',
123
+ },
124
+ medium: {
125
+ padding: '12px 24px',
126
+ },
127
+ small: {
128
+ padding: '8px 16px',
129
+ },
130
+ };
131
+
120
132
  export const getButtonPadding = (isText: boolean, startIcon: boolean, endIcon: boolean) => {
121
133
  const isTextIconButton = isText && (startIcon || endIcon);
122
134
  const isIconButton = !isText && (startIcon || endIcon);
123
135
 
124
- const style = {
125
- large: {
126
- padding: '13px 32px',
127
- },
128
- medium: {
129
- padding: '12px 24px',
130
- },
131
- small: {
132
- padding: '8px 16px',
133
- },
134
- };
135
-
136
136
  if (isTextIconButton) {
137
137
  if (startIcon) {
138
138
  style.large.padding = '13px 24px 13px 12px';
@@ -173,18 +173,18 @@ export const getSnackbarCurrentPosition = (snackbarSize: number, position: Snack
173
173
  };
174
174
 
175
175
  export const getActionButtonStyle = (variant: Variant, color: string) => {
176
- if (color === 'grayscale') {
177
- return { bgcolor: 'petersburg.5', color: 'petersburg.100' };
176
+ if (color === 'gray') {
177
+ return { bgcolor: 'var(--xi-gray-5)', color: 'var(--xi-gray-100)' };
178
178
  }
179
179
 
180
180
  switch (variant) {
181
181
  case 'contained':
182
- return { bgcolor: color, color: 'petersburg.0' };
182
+ return { bgcolor: color, color: 'var(--xi-gray-0)' };
183
183
  case 'outlined':
184
- return { bgcolor: 'petersburg.5', borderColor: color, color };
184
+ return { bgcolor: 'var(--xi-gray-5)', borderColor: color, color };
185
185
  default:
186
186
  return {
187
- bgcolor: 'petersburg.5',
187
+ bgcolor: 'var(--xi-gray-5)',
188
188
  color,
189
189
  };
190
190
  }
package/types.ts CHANGED
@@ -1,38 +1,38 @@
1
- import { ButtonProps as MuiButtonProps } from '@mui/material';
2
-
3
- export type Status = 'idle' | 'pending' | 'completed';
4
- export type Size = 'small' | 'medium' | 'large';
5
- export type Variant = 'contained' | 'outlined' | 'text';
6
- export type Color = 'primary' | 'success' | 'error' | 'grayscale';
7
- export type LoadingPosition = 'icon' | 'center';
8
- export type SnackbarPosition = 'left' | 'right' | 'top' | 'bottom';
9
-
10
- export type ButtonProps = {
11
- // button status: pending = spinner appears, completed button disabled with active color
12
- // completed and startIcon or endIcon or only icon without text appears check
13
- status?: Status;
14
- size?: Size; // button size
15
- // button spinner position: icon above icon and center
16
- loadingPosition?: LoadingPosition;
17
- // button variant
18
- variant?: Variant;
19
- // button color
20
- color?: Color;
21
- // start or end button icon if icon without text, icon position will be center
22
- startIcon?: any;
23
- endIcon?: any;
24
- // whether to display snackbar
25
- isSnackbar?: boolean;
26
- // snackbar text
27
- snackbarText?: string;
28
- // start or end snackbar icon if icon without text, icon position will be center
29
- isSnackbarIconStart?: boolean;
30
- isSnackbarIconEnd?: boolean;
31
- // snackbar spinner position: icon above icon and center
32
- snackbarLoadingPosition?: LoadingPosition;
33
- // snackbar position: default right
34
- snackbarPosition?: SnackbarPosition;
35
- // styles
36
- sx?: any;
37
- // you can also pass default mui button attributes
38
- } & Omit<MuiButtonProps, 'startIcon' | 'endIcon' | 'color'>;
1
+ import { ButtonProps as MuiButtonProps } from '@mui/material';
2
+
3
+ export type Status = 'idle' | 'pending' | 'completed';
4
+ export type Size = 'small' | 'medium' | 'large';
5
+ export type Variant = 'contained' | 'outlined' | 'text';
6
+ export type Color = 'primary' | 'success' | 'error' | 'gray';
7
+ export type LoadingPosition = 'icon' | 'center';
8
+ export type SnackbarPosition = 'left' | 'right' | 'top' | 'bottom';
9
+
10
+ export type ButtonProps = {
11
+ // button status: pending = spinner appears, completed button disabled with active color
12
+ // completed and startIcon or endIcon or only icon without text appears check
13
+ status?: Status;
14
+ size?: Size; // button size
15
+ // button spinner position: icon above icon and center
16
+ loadingPosition?: LoadingPosition;
17
+ // button variant
18
+ variant?: Variant;
19
+ // button color
20
+ color?: Color;
21
+ // start or end button icon if icon without text, icon position will be center
22
+ startIcon?: any;
23
+ endIcon?: any;
24
+ // whether to display snackbar
25
+ isSnackbar?: boolean;
26
+ // snackbar text
27
+ snackbarText?: string;
28
+ // start or end snackbar icon if icon without text, icon position will be center
29
+ isSnackbarIconStart?: boolean;
30
+ isSnackbarIconEnd?: boolean;
31
+ // snackbar spinner position: icon above icon and center
32
+ snackbarLoadingPosition?: LoadingPosition;
33
+ // snackbar position: default right
34
+ snackbarPosition?: SnackbarPosition;
35
+ // styles
36
+ sx?: any;
37
+ // you can also pass default mui button attributes
38
+ } & Omit<MuiButtonProps, 'startIcon' | 'endIcon' | 'color'>;