@tap-payments/os-micro-frontend-shared 0.1.64 → 0.1.65

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,10 @@
1
+ import { type SxProps } from '@mui/material/styles';
2
+ type ColorPickerProps = {
3
+ id: string;
4
+ value?: string;
5
+ onChange: (value: string) => void;
6
+ onReset?: () => void;
7
+ sx?: SxProps;
8
+ };
9
+ declare const ColorPicker: ({ id, value, onChange, onReset, sx }: ColorPickerProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default ColorPicker;
@@ -0,0 +1,59 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useCallback, useRef, useState } from 'react';
14
+ import { RgbaColorPicker } from 'react-colorful';
15
+ import { useTranslation } from 'react-i18next';
16
+ import Color from 'color';
17
+ import Box from '@mui/material/Box';
18
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
19
+ import Divider from '@mui/material/Divider';
20
+ import Popper from '@mui/material/Popper';
21
+ import Stack from '@mui/material/Stack';
22
+ import Typography from '@mui/material/Typography';
23
+ import { CancelButton, ConfirmButton, Footer, StyledCloseButtonWrapper, StyledColorWidgetWrapper } from './style';
24
+ import { closeXIcon } from '../../constants/index.js';
25
+ const hexa2Rgba = (value) => {
26
+ const colorInstance = Color(value).rgb();
27
+ const { r, g, b, alpha = 1 } = colorInstance.object();
28
+ return {
29
+ value: { r, g, b, alpha },
30
+ stringified: `rgba(${r},${g},${b},${alpha})`,
31
+ };
32
+ };
33
+ const rgba2Hexa = (value) => Color(value).hexa();
34
+ const ColorPicker = ({ id, value = '#ffffff', onChange, onReset, sx }) => {
35
+ const { t } = useTranslation();
36
+ const [anchorEl, setAnchorEl] = useState(null);
37
+ const rootRef = useRef(null);
38
+ const [color, setColor] = useState(() => {
39
+ const _a = hexa2Rgba(value).value, { alpha: a } = _a, rest = __rest(_a, ["alpha"]);
40
+ return Object.assign(Object.assign({}, rest), { a });
41
+ });
42
+ const handleOpen = useCallback(() => {
43
+ setAnchorEl(rootRef.current);
44
+ const _a = hexa2Rgba(value).value, { alpha: a } = _a, rest = __rest(_a, ["alpha"]);
45
+ setColor(Object.assign(Object.assign({}, rest), { a }));
46
+ }, [value]);
47
+ const handleCancel = useCallback(() => {
48
+ const _a = hexa2Rgba(value).value, { alpha: a } = _a, rest = __rest(_a, ["alpha"]);
49
+ setColor(Object.assign(Object.assign({}, rest), { a }));
50
+ setAnchorEl(null);
51
+ }, [value]);
52
+ const handleConfirm = useCallback(() => {
53
+ const { a: alpha } = color, rest = __rest(color, ["a"]);
54
+ onChange(rgba2Hexa(Object.assign(Object.assign({}, rest), { alpha })));
55
+ setAnchorEl(null);
56
+ }, [onChange, color]);
57
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: () => setAnchorEl(null) }, { children: _jsxs(Stack, Object.assign({ ref: rootRef, bgcolor: "grey.400", borderRadius: "4px", p: "4px", pr: "12px", direction: "row", justifyContent: "space-between", spacing: 1, alignItems: "center", className: "color-picker" }, { children: [_jsxs(Stack, Object.assign({ sx: sx, direction: "row", spacing: 1, alignItems: "center", className: "color-picker__controls-wrapper" }, { children: [_jsx(Box, { borderRadius: "5px", width: 32, height: 32, sx: { backgroundColor: value }, className: "color-picker__viewer" }), _jsxs(Box, Object.assign({ className: "color-picker__actions-wrapper" }, { children: [_jsx(Typography, Object.assign({ className: "color-picker__label", fontWeight: 500, fontSize: 9, color: "text.primary", textTransform: "uppercase" }, { children: value })), _jsx(Typography, Object.assign({ className: "color-picker__edit-btn", role: "button", onClick: handleOpen, htmlFor: id, fontWeight: 500, fontSize: 9, color: "info.dark", component: "label", sx: { textDecoration: 'underline', cursor: 'pointer' } }, { children: "Edit" }))] }))] })), _jsx(StyledCloseButtonWrapper, Object.assign({ className: "color-picker__close-btn", type: "button", onClick: onReset }, { children: _jsx(Box, { component: "img", src: closeXIcon, width: 10, height: 10 }) })), _jsx(Popper, Object.assign({ anchorEl: anchorEl, open: !!anchorEl, placement: "top" }, { children: _jsxs(StyledColorWidgetWrapper, Object.assign({ className: "color-picker__widget" }, { children: [_jsx(RgbaColorPicker, { color: color, onChange: setColor }), _jsx(Divider, { sx: { my: '12px' } }), _jsxs(Footer, Object.assign({ className: "color-picker__widget-actions" }, { children: [_jsx(CancelButton, Object.assign({ className: "color-picker__widget-actions__cancel", onClick: handleCancel }, { children: t('cancel') })), _jsx(ConfirmButton, Object.assign({ className: "color-picker__widget-actions__confirm", onClick: handleConfirm }, { children: t('okay') }))] }))] })) }))] })) })));
58
+ };
59
+ export default ColorPicker;
@@ -0,0 +1,2 @@
1
+ import ColorPicker from './ColorPicker';
2
+ export default ColorPicker;
@@ -0,0 +1,2 @@
1
+ import ColorPicker from './ColorPicker';
2
+ export default ColorPicker;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledCloseButtonWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
3
+ export declare const StyledColorWidgetWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
4
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
5
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
6
+ export declare const Footer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
7
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
8
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
9
+ export declare const ConfirmButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
10
+ ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
11
+ }, "disabled" | "style" | "color" | "className" | "classes" | "tabIndex" | "children" | "sx" | "variant" | "size" | "fullWidth" | "href" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
12
+ export declare const CancelButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
13
+ ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
14
+ }, "disabled" | "style" | "color" | "className" | "classes" | "tabIndex" | "children" | "sx" | "variant" | "size" | "fullWidth" | "href" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -0,0 +1,85 @@
1
+ import { Box, Button } from '@mui/material';
2
+ import { styled } from '@mui/material/styles';
3
+ export const StyledCloseButtonWrapper = styled('button')({
4
+ background: 'transparent',
5
+ border: 'none',
6
+ padding: 0,
7
+ margin: 0,
8
+ cursor: 'pointer',
9
+ width: 10,
10
+ height: 10,
11
+ display: 'flex',
12
+ justifyContent: 'center',
13
+ alignItems: 'center'
14
+ });
15
+ export const StyledColorWidgetWrapper = styled(Box)(({ theme }) => ({
16
+ boxShadow: '0px 8px 30px rgba(0, 0, 0, 0.16)',
17
+ minWidth: 264,
18
+ backgroundColor: '#ffffff',
19
+ padding: '12px',
20
+ borderRadius: theme.spacing(1),
21
+ '& .react-colorful': {
22
+ width: '100%',
23
+ '&__saturation': {
24
+ minHeight: 152,
25
+ borderRadius: '4px',
26
+ marginBottom: theme.spacing(2),
27
+ border: 0,
28
+ '&-pointer': {
29
+ width: 13,
30
+ height: 13
31
+ }
32
+ },
33
+ '&__hue': {
34
+ marginBottom: theme.spacing(2),
35
+ borderRadius: '4px',
36
+ height: '16px',
37
+ '&-pointer': {
38
+ width: 10,
39
+ height: 10
40
+ }
41
+ },
42
+ '&__alpha': {
43
+ border: 0,
44
+ borderRadius: '4px',
45
+ height: '16px',
46
+ '&-pointer': {
47
+ width: 10,
48
+ height: 10
49
+ }
50
+ }
51
+ }
52
+ }));
53
+ export const Footer = styled(Box)(() => ({
54
+ display: 'flex',
55
+ gap: '8px',
56
+ justifyContent: 'flex-end'
57
+ }));
58
+ export const ConfirmButton = styled(Button)(({ theme }) => ({
59
+ textTransform: 'capitalize',
60
+ minWidth: 'auto',
61
+ width: 74,
62
+ borderRadius: '4px',
63
+ border: `1px solid ${theme.palette.info.dark}`,
64
+ backgroundColor: theme.palette.info.dark,
65
+ fontWeight: 700,
66
+ fontSize: '11px',
67
+ color: theme.palette.common.white,
68
+ '&:hover': {
69
+ backgroundColor: theme.palette.info.dark
70
+ }
71
+ }));
72
+ export const CancelButton = styled(Button)(({ theme }) => ({
73
+ textTransform: 'capitalize',
74
+ minWidth: 'auto',
75
+ width: 74,
76
+ borderRadius: '4px',
77
+ border: `1px solid ${theme.palette.divider}`,
78
+ backgroundColor: theme.palette.common.white,
79
+ fontWeight: 500,
80
+ fontSize: '11px',
81
+ color: theme.palette.text.primary,
82
+ '&:hover': {
83
+ background: 'transparent'
84
+ }
85
+ }));
@@ -1,3 +1,3 @@
1
1
  import type { FileUploaderComponentProps } from './type';
2
- declare const FileUploader: ({ getRootProps, getInputProps, open, onChangeFiles, processFiles, disabled, errorMessage, maxFileSize, preventDuplicates, }: FileUploaderComponentProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const FileUploader: ({ getRootProps, getInputProps, open, onChangeFiles, processFiles, disabled, errorMessage, maxFileSize, preventDuplicates, label, hintText, sx, }: FileUploaderComponentProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default FileUploader;
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Box from '@mui/material/Box';
3
3
  import { redVerifyIcon, uploadBlueIcon } from '../../constants/index.js';
4
4
  import { Content, ErrorMessage, StyledFileUploader, IconWrapper, Maximum, TextWrapper, Upload } from './style';
5
- const FileUploader = ({ getRootProps, getInputProps, open, onChangeFiles, processFiles, disabled, errorMessage, maxFileSize, preventDuplicates, }) => {
6
- return (_jsxs(StyledFileUploader, Object.assign({}, getRootProps(), { onClick: open }, { children: [_jsx("input", Object.assign({}, getInputProps(), { onChange: (e) => {
5
+ const FileUploader = ({ getRootProps, getInputProps, open, onChangeFiles, processFiles, disabled, errorMessage, maxFileSize, preventDuplicates, label = 'Click to upload', hintText, sx, }) => {
6
+ return (_jsxs(StyledFileUploader, Object.assign({}, getRootProps(), { sx: sx, onClick: open }, { children: [_jsx("input", Object.assign({ "data-slot": "input" }, getInputProps(), { onChange: (e) => {
7
7
  const processedFiles = processFiles(Array.from(e.target.files || []));
8
8
  if (processedFiles.length > 0 || !preventDuplicates) {
9
9
  onChangeFiles(processedFiles);
10
10
  }
11
- }, disabled: disabled })), _jsxs(Content, { children: [_jsx(IconWrapper, { children: _jsx(Box, { component: "img", src: errorMessage ? redVerifyIcon : uploadBlueIcon, width: 16, height: 16 }) }), errorMessage ? (_jsxs(TextWrapper, { children: [_jsx(ErrorMessage, { children: errorMessage }), _jsx(Upload, { children: "Click to upload again" })] })) : (_jsxs(TextWrapper, { children: [_jsx(Upload, { children: "Click to upload" }), _jsxs(Maximum, { children: ["PDF, JPG or PNG files up to ", maxFileSize] })] }))] })] })));
11
+ }, disabled: disabled })), _jsxs(Content, Object.assign({ "data-slot": "content" }, { children: [_jsx(IconWrapper, Object.assign({ "data-slot": "icon-wrapper" }, { children: _jsx(Box, { component: "img", src: errorMessage ? redVerifyIcon : uploadBlueIcon, width: 16, height: 16 }) })), errorMessage ? (_jsxs(TextWrapper, { children: [_jsx(ErrorMessage, { children: errorMessage }), _jsx(Upload, { children: "Click to upload again" })] })) : (_jsxs(TextWrapper, { children: [_jsx(Upload, { children: label }), _jsx(Maximum, { children: hintText || `PDF, JPG or PNG files up to ${maxFileSize}` })] }))] }))] })));
12
12
  };
13
13
  export default FileUploader;
@@ -1,5 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import type { DropzoneInputProps, DropzoneRootProps } from 'react-dropzone';
2
3
  import type { FileType } from '../../types/index.js';
4
+ import { SxProps, Theme } from '@mui/material/styles';
3
5
  export interface FileUploaderComponentProps {
4
6
  getRootProps: <T extends DropzoneRootProps>(props?: T | undefined) => T;
5
7
  getInputProps: <T extends DropzoneInputProps>(props?: T | undefined) => T;
@@ -10,4 +12,7 @@ export interface FileUploaderComponentProps {
10
12
  errorMessage?: string;
11
13
  maxFileSize: string;
12
14
  preventDuplicates?: boolean;
15
+ label?: React.ReactNode;
16
+ hintText?: React.ReactNode;
17
+ sx?: SxProps<Theme>;
13
18
  }
@@ -102,3 +102,4 @@ export { default as StatusChipWithCopy } from './StatusChipWithCopy';
102
102
  export * from './RadioButton';
103
103
  export * from './RadioGroup';
104
104
  export * from './LeftPeekRightExpandingChip';
105
+ export { default as ColorPicker } from './ColorPicker';
@@ -102,3 +102,4 @@ export { default as StatusChipWithCopy } from './StatusChipWithCopy';
102
102
  export * from './RadioButton';
103
103
  export * from './RadioGroup';
104
104
  export * from './LeftPeekRightExpandingChip';
105
+ export { default as ColorPicker } from './ColorPicker';
@@ -525,3 +525,12 @@ export declare const exclamationOutlinedCircle: string;
525
525
  export declare const outlinedCircle: string;
526
526
  export declare const greenCheck2ACE00: string;
527
527
  export declare const blueCopyIcon: string;
528
+ export declare const blackLinkIcon: string;
529
+ export declare const blackSettingsIcon: string;
530
+ export declare const blackWallet: string;
531
+ export declare const blueGradientBrushIcon: string;
532
+ export declare const gadientLink: string;
533
+ export declare const gradientSettings: string;
534
+ export declare const gradientWallet: string;
535
+ export declare const manyCurrencyCoin: string;
536
+ export declare const manyCurrencyCoinGradient: string;
@@ -529,3 +529,12 @@ export const exclamationOutlinedCircle = `${lightUrl}/exclamationOutlinedCircle.
529
529
  export const outlinedCircle = `${lightUrl}/outlinedCircle.svg`;
530
530
  export const greenCheck2ACE00 = `${lightUrl}/greenCheck2ACE00.svg`;
531
531
  export const blueCopyIcon = `${lightUrl}/blueCopyIcon.svg`;
532
+ export const blackLinkIcon = `${lightUrl}/blackLinkIcon.svg`;
533
+ export const blackSettingsIcon = `${lightUrl}/blackSettingsIcon.svg`;
534
+ export const blackWallet = `${lightUrl}/blackWallet.svg`;
535
+ export const blueGradientBrushIcon = `${lightUrl}/blueGradientBrushIcon.svg`;
536
+ export const gadientLink = `${lightUrl}/gadientLink.svg`;
537
+ export const gradientSettings = `${lightUrl}/gradientSettings.svg`;
538
+ export const gradientWallet = `${lightUrl}/gradientWallet.svg`;
539
+ export const manyCurrencyCoin = `${lightUrl}/manyCurrencyCoin.svg`;
540
+ export const manyCurrencyCoinGradient = `${lightUrl}/manyCurrencyCoinGradient.svg`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.64",
4
+ "version": "0.1.65",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
@@ -79,12 +79,14 @@
79
79
  "@mui/material": "^5.12.3",
80
80
  "@uiw/react-json-view": "^2.0.0-alpha.16",
81
81
  "axios": "^1.4.0",
82
+ "color": "^5.0.0",
82
83
  "dayjs": "^1.11.8",
83
84
  "framer-motion": "10.11.0",
84
85
  "i18next": "^22.4.15",
85
86
  "memoize-one": "^6.0.0",
86
87
  "re-resizable": "^6.9.9",
87
88
  "react": "^18.2.0",
89
+ "react-colorful": "^5.6.1",
88
90
  "react-currency-input-field": "^3.6.11",
89
91
  "react-dom": "^18.2.0",
90
92
  "react-draggable": "^4.4.6",