@tap-payments/os-micro-frontend-shared 0.0.99 → 0.0.100

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Tap Payments
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tap Payments
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # os-micro-frontend-shared
2
-
3
- ## Publishing Workflow
4
-
5
- 1. Update version in package.json
6
- 2. Commit changes
7
- 3. Create and push a tag:
8
-
9
- ```bash
10
- npm version patch # or minor, major
11
- git push origin main --tags
12
- ```
1
+ # os-micro-frontend-shared
2
+
3
+ ## Publishing Workflow
4
+
5
+ 1. Update version in package.json
6
+ 2. Commit changes
7
+ 3. Create and push a tag:
8
+
9
+ ```bash
10
+ npm version patch # or minor, major
11
+ git push origin main --tags
12
+ ```
@@ -1,3 +1,3 @@
1
1
  import { IProps } from './type';
2
- declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, allowShadows, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
2
+ declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
3
3
  export default Dropdown;
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Divider, Box, useTheme } from '@mui/material';
14
14
  import { StyledListItemText, StyledMenu, StyledListItemIcon, StyledMenuItem } from './styles';
15
15
  function Dropdown(_a) {
16
- var { open, menuItems, anchorEl, onClose, selected, allowShadows = true } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected", "allowShadows"]);
16
+ var { open, menuItems, anchorEl, onClose, selected } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected"]);
17
17
  const theme = useTheme();
18
18
  return (_jsx(StyledMenu, Object.assign({ open: open, anchorEl: anchorEl, onClose: onClose, onContextMenu: (e) => {
19
19
  e.preventDefault();
@@ -27,7 +27,7 @@ function Dropdown(_a) {
27
27
  item.onClick(e);
28
28
  }, onContextMenu: item.onRightClick, selected: item.selected, sx: Object.assign({ '&:hover': {
29
29
  backgroundColor: 'transparent',
30
- boxShadow: allowShadows ? theme.shadows[10] : 'none',
30
+ boxShadow: theme.shadows[10],
31
31
  '& .sandbox-Icon': {
32
32
  display: 'none',
33
33
  },
@@ -36,7 +36,7 @@ function Dropdown(_a) {
36
36
  },
37
37
  } }, (idx === selected && {
38
38
  backgroundColor: 'transparent',
39
- boxShadow: allowShadows ? theme.shadows[10] : 'none',
39
+ boxShadow: theme.shadows[10],
40
40
  })) }, { children: [item.icon && _jsx(StyledListItemIcon, { children: item.icon }), _jsx(StyledListItemText, { children: item.label }), _jsx(Box, Object.assign({ className: item.alwaysShowRightAction ? '' : 'menu-right-action' }, { children: item.rightAction && item.rightAction }))] }))) }, `${item.label}-${idx}`));
41
41
  }) })));
42
42
  }
@@ -17,5 +17,4 @@ export interface IProps {
17
17
  anchorEl?: Element | null | undefined;
18
18
  style?: CSSProperties;
19
19
  selected?: number;
20
- allowShadows?: boolean;
21
20
  }
@@ -1,17 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { AvailableStatus } from '../TableHeader_V2';
3
- import { CurrencyOption } from '../MultiSelectStatusButton';
4
3
  import { TableHeaderStatus } from '../../types/index.js';
5
4
  interface StatusBarProps {
6
5
  status?: TableHeaderStatus;
7
6
  availableStatuses?: AvailableStatus[];
8
7
  isFilteredIdsShown?: boolean;
9
8
  onStatusChange?: (status: TableHeaderStatus) => void;
10
- onMultiSelectChange?: (status: TableHeaderStatus[]) => void;
11
- currencyOptions?: CurrencyOption[];
12
- selectedCurrencies?: TableHeaderStatus[];
13
- enableMultiSelectCurrency?: boolean;
14
9
  }
15
- declare function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status, onMultiSelectChange, currencyOptions, selectedCurrencies, enableMultiSelectCurrency, }: StatusBarProps): import("react/jsx-runtime").JSX.Element;
10
+ declare function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status }: StatusBarProps): import("react/jsx-runtime").JSX.Element;
16
11
  declare const _default: import("react").MemoExoticComponent<typeof StatusBar>;
17
12
  export default _default;
@@ -1,68 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  import { createElement as _createElement } from "react";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { memo, useCallback, useState, useEffect } from 'react';
3
+ import { memo, useCallback } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { StatusButton } from '../TableHeader_V2';
6
- import MultiSelectStatusButton from '../MultiSelectStatusButton';
7
- function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status, onMultiSelectChange, currencyOptions, selectedCurrencies = [], enableMultiSelectCurrency = false, }) {
6
+ function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status }) {
8
7
  const { t } = useTranslation();
9
- const [multiSelectValues, setMultiSelectValues] = useState(selectedCurrencies);
10
- useEffect(() => {
11
- if (status && multiSelectValues.length > 0) {
12
- setMultiSelectValues([]);
13
- }
14
- }, [status, multiSelectValues.length]);
15
- useEffect(() => {
16
- if (!status) {
17
- setMultiSelectValues(selectedCurrencies);
18
- }
19
- }, [selectedCurrencies, status]);
20
- const getButtonStatus = useCallback((buttonStatus) => {
21
- if (multiSelectValues.length > 0) {
22
- return 'inActive';
23
- }
24
- return buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive';
25
- }, [status, isFilteredIdsShown, multiSelectValues.length]);
26
- const handleMultiSelectChange = useCallback((selected) => {
27
- setMultiSelectValues(selected);
28
- onMultiSelectChange === null || onMultiSelectChange === void 0 ? void 0 : onMultiSelectChange(selected);
29
- if (selected.length > 0) {
30
- onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange('');
31
- }
32
- }, [onMultiSelectChange, onStatusChange]);
33
- const handleStatusChange = useCallback((newStatus) => {
34
- if (multiSelectValues.length > 0) {
35
- setMultiSelectValues([]);
36
- onMultiSelectChange === null || onMultiSelectChange === void 0 ? void 0 : onMultiSelectChange([]);
37
- }
38
- onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(newStatus);
39
- }, [multiSelectValues.length, onMultiSelectChange, onStatusChange]);
40
- useEffect(() => {
41
- if (enableMultiSelectCurrency && multiSelectValues.length === 0 && selectedCurrencies.length === 0 && !status) {
42
- handleStatusChange('all');
43
- }
44
- }, [enableMultiSelectCurrency, multiSelectValues.length, selectedCurrencies.length, status, handleStatusChange]);
45
- return (_jsxs(_Fragment, { children: [enableMultiSelectCurrency && currencyOptions && (_jsx(MultiSelectStatusButton, { options: currencyOptions, selectedValues: multiSelectValues, onSelectionChange: handleMultiSelectChange, label: t('Currencies') || 'Currencies', variant: multiSelectValues.length > 0 && !status ? 'active' : 'inActive' })), availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((s) => {
46
- var _a, _b;
47
- if (!Array.isArray(s.status)) {
48
- return (_createElement(StatusButton, Object.assign({}, s, { key: `status-button-array-${s.status}`, variant: getButtonStatus(s.status), onClick: () => {
49
- if (!Array.isArray(s.status)) {
50
- handleStatusChange(s.status);
51
- }
52
- } })));
53
- }
54
- const isCurrentStatusDropdown = (_a = s.status) === null || _a === void 0 ? void 0 : _a.includes(status || '');
55
- const variant = multiSelectValues.length > 0 ? 'inActive' : isCurrentStatusDropdown ? 'active' : 'inActive';
56
- const statusLabel = isCurrentStatusDropdown ? status : s.status[0];
57
- return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
58
- handleStatusChange(buttonStatus);
59
- }, dropdownOptions: s.status.map((stat) => ({
60
- label: t(stat || ''),
61
- onClick: () => {
62
- handleStatusChange(stat);
63
- },
64
- status: stat,
65
- })) })) }, (_b = s === null || s === void 0 ? void 0 : s.status) === null || _b === void 0 ? void 0 : _b[0]));
66
- })] }));
8
+ const getButtonStatus = useCallback((buttonStatus) => (buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive'), [status, isFilteredIdsShown]);
9
+ return (_jsx(_Fragment, { children: availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((s) => {
10
+ var _a, _b;
11
+ if (!Array.isArray(s.status)) {
12
+ return (_createElement(StatusButton, Object.assign({}, s, { key: `status-button-array-${s.status}`, variant: getButtonStatus(s.status), onClick: () => {
13
+ if (!Array.isArray(s.status)) {
14
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(s.status);
15
+ }
16
+ } })));
17
+ }
18
+ const isCurrentStatusDropdown = (_a = s.status) === null || _a === void 0 ? void 0 : _a.includes(status || '');
19
+ const variant = isCurrentStatusDropdown ? 'active' : 'inActive';
20
+ const statusLabel = isCurrentStatusDropdown ? status : s.status[0];
21
+ return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
22
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(buttonStatus);
23
+ }, dropdownOptions: s.status.map((stat) => ({
24
+ label: t(stat || ''),
25
+ onClick: () => {
26
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(stat);
27
+ },
28
+ status: stat,
29
+ })) })) }, (_b = s === null || s === void 0 ? void 0 : s.status) === null || _b === void 0 ? void 0 : _b[0]));
30
+ }) }));
67
31
  }
68
32
  export default memo(StatusBar);
@@ -1,2 +1,2 @@
1
1
  import { ChevronIconProps } from './type';
2
- export declare function ChevronIcon({ isActive, disableHover }: ChevronIconProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ChevronIcon({ isActive }: ChevronIconProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { useTheme } from '@mui/material';
4
- export function ChevronIcon({ isActive, disableHover }) {
4
+ export function ChevronIcon({ isActive }) {
5
5
  const [isHovered, setIsHovered] = useState(false);
6
6
  const theme = useTheme();
7
7
  const handleMouseEnter = () => {
8
- if (!disableHover) {
9
- setIsHovered(true);
10
- }
8
+ setIsHovered(true);
11
9
  };
12
10
  const handleMouseLeave = () => {
13
11
  setIsHovered(false);
@@ -58,7 +58,6 @@ export const ChevronContainer = styled('span')(() => ({
58
58
  right: '0',
59
59
  bottom: '0',
60
60
  overflow: 'hidden',
61
- transition: 'opacity 1s ease',
62
61
  }));
63
62
  export const Label = styled(Box)(({ variant }) => ({
64
63
  display: 'flex',
@@ -15,11 +15,8 @@ export interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'childr
15
15
  dropdownOptions?: Array<MenuItemI & {
16
16
  status: TableHeaderStatus;
17
17
  }>;
18
- render?: (status: TableHeaderStatus) => ReactNode;
19
- onMultiSelectChange?: (status: TableHeaderStatus[]) => void;
20
18
  }
21
19
  export interface ChevronIconProps {
22
20
  isActive?: boolean;
23
- disableHover?: boolean;
24
21
  }
25
22
  export type StatusButtonIcon = keyof typeof statusButtonIcons;
@@ -86,7 +86,6 @@ export { default as FlagDetails } from './FlagDetails';
86
86
  export { default as TapLoader } from './Loaders';
87
87
  export { default as Error } from './Error';
88
88
  export { default as StatusBar } from './StatusBar';
89
- export { default as MultiSelectStatusButton, type CurrencyOption, type MultiSelectStatusButtonProps } from './MultiSelectStatusButton';
90
89
  export * from './Chip';
91
90
  export * from './TableHeader_V2';
92
91
  export { default as RangeCalender } from './RangeCalender';
@@ -86,7 +86,6 @@ export { default as FlagDetails } from './FlagDetails';
86
86
  export { default as TapLoader } from './Loaders';
87
87
  export { default as Error } from './Error';
88
88
  export { default as StatusBar } from './StatusBar';
89
- export { default as MultiSelectStatusButton } from './MultiSelectStatusButton';
90
89
  export * from './Chip';
91
90
  export * from './TableHeader_V2';
92
91
  export { default as RangeCalender } from './RangeCalender';
@@ -3,3 +3,4 @@ export declare function formatNumber(num: number): string;
3
3
  export declare const stringToNumber: (value: string) => number;
4
4
  export declare const numberToString: (value: number, fixed?: number) => string;
5
5
  export declare function pad(num: number, length?: number): string;
6
+ export declare function isNegative(num: number): boolean;
@@ -25,3 +25,6 @@ export const numberToString = (value, fixed) => {
25
25
  export function pad(num, length = 2) {
26
26
  return num.toString().padStart(length, '0');
27
27
  }
28
+ export function isNegative(num) {
29
+ return Math.sign(num) === -1;
30
+ }
package/package.json CHANGED
@@ -1,132 +1,132 @@
1
- {
2
- "name": "@tap-payments/os-micro-frontend-shared",
3
- "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.0.99",
5
- "type": "module",
6
- "main": "build/index.js",
7
- "module": "build/index.js",
8
- "types": "build/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./build/index.d.ts",
12
- "import": "./build/index.js",
13
- "require": "./build/index.js"
14
- },
15
- "./constants": {
16
- "types": "./build/constants/index.d.ts",
17
- "import": "./build/constants/index.js",
18
- "require": "./build/constants/index.js"
19
- },
20
- "./components": {
21
- "types": "./build/components/index.d.ts",
22
- "import": "./build/components/index.js",
23
- "require": "./build/components/index.js"
24
- },
25
- "./components/*": {
26
- "types": "./build/components/*/index.d.ts",
27
- "import": "./build/components/*/index.js",
28
- "require": "./build/components/*/index.js"
29
- },
30
- "./hooks": {
31
- "types": "./build/hooks/index.d.ts",
32
- "import": "./build/hooks/index.js",
33
- "require": "./build/hooks/index.js"
34
- },
35
- "./utils": {
36
- "types": "./build/utils/index.d.ts",
37
- "import": "./build/utils/index.js",
38
- "require": "./build/utils/index.js"
39
- },
40
- "./theme": {
41
- "types": "./build/theme/index.d.ts",
42
- "import": "./build/theme/index.js",
43
- "require": "./build/theme/index.js"
44
- },
45
- "./types": {
46
- "types": "./build/types/index.d.ts",
47
- "import": "./build/types/index.js",
48
- "require": "./build/types/index.js"
49
- }
50
- },
51
- "license": "MIT",
52
- "author": {
53
- "name": "Ahmed Sharkawy",
54
- "email": "a.elsharkawy@tap.company"
55
- },
56
- "files": [
57
- "build",
58
- "readme.md"
59
- ],
60
- "scripts": {
61
- "ts:build": "rm -rf build && tsc -p tsconfig.npm.json && tsc-alias -p tsconfig.npm.json",
62
- "push": "npm version patch --no-git-tag-version && npm run ts:build && npm publish --access public",
63
- "dev": "vite",
64
- "build": "tsc -b && vite build ",
65
- "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\"",
66
- "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\"",
67
- "lint": "eslint . --color",
68
- "lint:fix": "eslint src --fix --color",
69
- "preview": "vite preview",
70
- "prepare": "husky"
71
- },
72
- "dependencies": {
73
- "@emotion/react": "^11.11.0",
74
- "@emotion/styled": "^11.11.0",
75
- "@hookform/resolvers": "^3.3.1",
76
- "@mui/material": "^5.12.3",
77
- "@uiw/react-json-view": "^2.0.0-alpha.16",
78
- "axios": "^1.4.0",
79
- "dayjs": "^1.11.8",
80
- "framer-motion": "10.11.0",
81
- "i18next": "^22.4.15",
82
- "memoize-one": "^6.0.0",
83
- "re-resizable": "^6.9.9",
84
- "react": "^18.2.0",
85
- "react-currency-input-field": "^3.6.11",
86
- "react-dom": "^18.2.0",
87
- "react-draggable": "^4.4.6",
88
- "react-dropzone": "^14.2.3",
89
- "react-hook-form": "^7.45.4",
90
- "react-hot-toast": "^2.4.1",
91
- "react-i18next": "^12.2.2",
92
- "react-multi-date-picker": "^4.1.2",
93
- "react-router-dom": "^6.14.2",
94
- "react-virtualized-auto-sizer": "^1.0.20",
95
- "react-window": "^1.8.9",
96
- "react-window-infinite-loader": "^1.0.9",
97
- "react18-input-otp": "^1.1.4",
98
- "recharts": "^2.15.1"
99
- },
100
- "devDependencies": {
101
- "@eslint/js": "^9.17.0",
102
- "@testing-library/jest-dom": "^5.16.5",
103
- "@types/lodash": "^4.17.15",
104
- "@types/react": "^18.2.6",
105
- "@types/react-dom": "^18.3.5",
106
- "@types/react-virtualized-auto-sizer": "^1.0.8",
107
- "@types/react-window": "^1.8.5",
108
- "@types/react-window-infinite-loader": "^1.0.6",
109
- "@vitejs/plugin-react": "^4.3.4",
110
- "eslint": "^9.17.0",
111
- "eslint-plugin-react-hooks": "^5.0.0",
112
- "eslint-plugin-react-refresh": "^0.4.16",
113
- "globals": "^15.14.0",
114
- "husky": "^8.0.3",
115
- "lint-staged": "^13.2.2",
116
- "prettier": "^2.8.8",
117
- "tsc-alias": "^1.8.16",
118
- "typescript": "5.0.2",
119
- "typescript-eslint": "^8.18.2",
120
- "vite": "6.0.5",
121
- "vite-tsconfig-paths": "^4.2.0"
122
- },
123
- "lint-staged": {
124
- "src/**/*.{ts,tsx,json,js,jsx}": [
125
- "yarn run prettier:fix",
126
- "yarn run lint"
127
- ]
128
- },
129
- "publishConfig": {
130
- "registry": "https://registry.npmjs.org/"
131
- }
132
- }
1
+ {
2
+ "name": "@tap-payments/os-micro-frontend-shared",
3
+ "description": "Shared components and utilities for Tap Payments micro frontends",
4
+ "version": "0.0.100",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "module": "build/index.js",
8
+ "types": "build/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./build/index.d.ts",
12
+ "import": "./build/index.js",
13
+ "require": "./build/index.js"
14
+ },
15
+ "./constants": {
16
+ "types": "./build/constants/index.d.ts",
17
+ "import": "./build/constants/index.js",
18
+ "require": "./build/constants/index.js"
19
+ },
20
+ "./components": {
21
+ "types": "./build/components/index.d.ts",
22
+ "import": "./build/components/index.js",
23
+ "require": "./build/components/index.js"
24
+ },
25
+ "./components/*": {
26
+ "types": "./build/components/*/index.d.ts",
27
+ "import": "./build/components/*/index.js",
28
+ "require": "./build/components/*/index.js"
29
+ },
30
+ "./hooks": {
31
+ "types": "./build/hooks/index.d.ts",
32
+ "import": "./build/hooks/index.js",
33
+ "require": "./build/hooks/index.js"
34
+ },
35
+ "./utils": {
36
+ "types": "./build/utils/index.d.ts",
37
+ "import": "./build/utils/index.js",
38
+ "require": "./build/utils/index.js"
39
+ },
40
+ "./theme": {
41
+ "types": "./build/theme/index.d.ts",
42
+ "import": "./build/theme/index.js",
43
+ "require": "./build/theme/index.js"
44
+ },
45
+ "./types": {
46
+ "types": "./build/types/index.d.ts",
47
+ "import": "./build/types/index.js",
48
+ "require": "./build/types/index.js"
49
+ }
50
+ },
51
+ "license": "MIT",
52
+ "author": {
53
+ "name": "Ahmed Sharkawy",
54
+ "email": "a.elsharkawy@tap.company"
55
+ },
56
+ "files": [
57
+ "build",
58
+ "readme.md"
59
+ ],
60
+ "scripts": {
61
+ "ts:build": "rm -rf build && tsc -p tsconfig.npm.json && tsc-alias -p tsconfig.npm.json",
62
+ "push": "npm version patch --no-git-tag-version && npm run ts:build && npm publish --access public",
63
+ "dev": "vite",
64
+ "build": "tsc -b && vite build ",
65
+ "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\"",
66
+ "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\"",
67
+ "lint": "eslint . --color",
68
+ "lint:fix": "eslint src --fix --color",
69
+ "preview": "vite preview",
70
+ "prepare": "husky"
71
+ },
72
+ "dependencies": {
73
+ "@emotion/react": "^11.11.0",
74
+ "@emotion/styled": "^11.11.0",
75
+ "@hookform/resolvers": "^3.3.1",
76
+ "@mui/material": "^5.12.3",
77
+ "@uiw/react-json-view": "^2.0.0-alpha.16",
78
+ "axios": "^1.4.0",
79
+ "dayjs": "^1.11.8",
80
+ "framer-motion": "10.11.0",
81
+ "i18next": "^22.4.15",
82
+ "memoize-one": "^6.0.0",
83
+ "re-resizable": "^6.9.9",
84
+ "react": "^18.2.0",
85
+ "react-currency-input-field": "^3.6.11",
86
+ "react-dom": "^18.2.0",
87
+ "react-draggable": "^4.4.6",
88
+ "react-dropzone": "^14.2.3",
89
+ "react-hook-form": "^7.45.4",
90
+ "react-hot-toast": "^2.4.1",
91
+ "react-i18next": "^12.2.2",
92
+ "react-multi-date-picker": "^4.1.2",
93
+ "react-router-dom": "^6.14.2",
94
+ "react-virtualized-auto-sizer": "^1.0.20",
95
+ "react-window": "^1.8.9",
96
+ "react-window-infinite-loader": "^1.0.9",
97
+ "react18-input-otp": "^1.1.4",
98
+ "recharts": "^2.15.1"
99
+ },
100
+ "devDependencies": {
101
+ "@eslint/js": "^9.17.0",
102
+ "@testing-library/jest-dom": "^5.16.5",
103
+ "@types/lodash": "^4.17.15",
104
+ "@types/react": "^18.2.6",
105
+ "@types/react-dom": "^18.3.5",
106
+ "@types/react-virtualized-auto-sizer": "^1.0.8",
107
+ "@types/react-window": "^1.8.5",
108
+ "@types/react-window-infinite-loader": "^1.0.6",
109
+ "@vitejs/plugin-react": "^4.3.4",
110
+ "eslint": "^9.17.0",
111
+ "eslint-plugin-react-hooks": "^5.0.0",
112
+ "eslint-plugin-react-refresh": "^0.4.16",
113
+ "globals": "^15.14.0",
114
+ "husky": "^8.0.3",
115
+ "lint-staged": "^13.2.2",
116
+ "prettier": "^2.8.8",
117
+ "tsc-alias": "^1.8.16",
118
+ "typescript": "5.0.2",
119
+ "typescript-eslint": "^8.18.2",
120
+ "vite": "6.0.5",
121
+ "vite-tsconfig-paths": "^4.2.0"
122
+ },
123
+ "lint-staged": {
124
+ "src/**/*.{ts,tsx,json,js,jsx}": [
125
+ "yarn run prettier:fix",
126
+ "yarn run lint"
127
+ ]
128
+ },
129
+ "publishConfig": {
130
+ "registry": "https://registry.npmjs.org/"
131
+ }
132
+ }
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { MultiSelectStatusButtonProps } from './type';
3
- declare function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant }: MultiSelectStatusButtonProps): import("react/jsx-runtime").JSX.Element;
4
- declare const _default: import("react").MemoExoticComponent<typeof MultiSelectStatusButton>;
5
- export default _default;
@@ -1,97 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { memo, useState, useRef, useEffect } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
- import { Typography, Checkbox } from '@mui/material';
5
- import { ChevronIcon } from '../TableHeader_V2/components/StatusButtons/ChevronIcon';
6
- import StyledBadge, { BadgeVariants } from '../CountBadge';
7
- import CountryFlag from '../CountryFlag';
8
- import { formatNumber } from '../../utils/index.js';
9
- import { closeXIcon } from '../../constants/index.js';
10
- import { ChevronContainer, Label, LabelWrapper, StyledDropdown, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
11
- function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant = 'inActive' }) {
12
- const { t } = useTranslation();
13
- const [anchorEl, setAnchorEl] = useState(null);
14
- const buttonRef = useRef(null);
15
- const [internalSelectedValues, setInternalSelectedValues] = useState(selectedValues);
16
- const [dropdownWidth, setDropdownWidth] = useState(0);
17
- const [isHovered, setIsHovered] = useState(false);
18
- const isOpen = Boolean(anchorEl);
19
- useEffect(() => {
20
- if (!isOpen) {
21
- setInternalSelectedValues(selectedValues);
22
- }
23
- }, [selectedValues, isOpen]);
24
- const handleDropdownClick = (event) => {
25
- var _a;
26
- event.stopPropagation();
27
- event.preventDefault();
28
- if (isOpen) {
29
- handleClose();
30
- return;
31
- }
32
- setAnchorEl(buttonRef.current);
33
- const buttonWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 200;
34
- setDropdownWidth(Math.max(buttonWidth, 200));
35
- };
36
- const handleClose = () => {
37
- const hasChanged = JSON.stringify([...internalSelectedValues].sort()) !== JSON.stringify([...selectedValues].sort());
38
- if (hasChanged) {
39
- onSelectionChange(internalSelectedValues);
40
- }
41
- setAnchorEl(null);
42
- setDropdownWidth(0);
43
- };
44
- const handleClearAll = (event) => {
45
- event.stopPropagation();
46
- event.preventDefault();
47
- setInternalSelectedValues([]);
48
- onSelectionChange([]);
49
- };
50
- const handleOptionToggle = (optionStatus, event) => {
51
- if (event) {
52
- event.stopPropagation();
53
- event.preventDefault();
54
- }
55
- const newSelection = internalSelectedValues.includes(optionStatus)
56
- ? internalSelectedValues.filter((status) => status !== optionStatus)
57
- : [...internalSelectedValues, optionStatus];
58
- setInternalSelectedValues(newSelection);
59
- };
60
- const getDisplayLabel = () => {
61
- return (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: t('Currencies') })));
62
- };
63
- const countBadge = (_jsx(StyledBadge, Object.assign({ pointer: true, variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(selectedValues.length > 0 ? selectedValues.length : options.length) })));
64
- return (_jsxs(_Fragment, { children: [_jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
65
- paddingInlineEnd: '27px',
66
- }, "data-testid": "MultiSelectStatusButton", onClick: handleDropdownClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [getDisplayLabel(), countBadge] })), _jsxs(ChevronContainer, Object.assign({ onClick: isHovered && internalSelectedValues.length > 0 ? handleClearAll : undefined, sx: {
67
- '&:hover': {
68
- backgroundColor: 'transparent',
69
- },
70
- } }, { children: [_jsx(ClearIcon, { variant: variant, src: closeXIcon, alt: "clear all", sx: {
71
- opacity: isHovered && internalSelectedValues.length > 0 ? 1 : 0,
72
- pointerEvents: isHovered && internalSelectedValues.length > 0 ? 'auto' : 'none',
73
- } }), _jsx(ChevronIconWrapper, Object.assign({ isVisible: !(isHovered && internalSelectedValues.length > 0) }, { children: _jsx(ChevronIcon, { disableHover: true, isActive: variant === 'active' }) }))] }))] }) })), isOpen && anchorEl && (_jsx(StyledDropdown, { open: isOpen, onClose: handleClose, anchorEl: anchorEl, allowShadows: false, style: {
74
- minWidth: dropdownWidth || 200,
75
- width: dropdownWidth || 'auto',
76
- marginTop: '6px',
77
- maxWidth: 300,
78
- }, sx: {
79
- boxShadow: 'none !important',
80
- '&:hover': {
81
- boxShadow: 'none !important',
82
- },
83
- }, menuItems: options.map((option) => ({
84
- label: (_jsxs(MenuItemContainer, { children: [_jsx(Checkbox, { checked: internalSelectedValues.includes(option.status), size: "small", sx: CheckboxStyles, onClick: (e) => {
85
- var _a;
86
- e.stopPropagation();
87
- handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
88
- } }), _jsx(CountryFlag, { code: option.flagCode || option.code, sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name }))] })),
89
- onClick: (e) => {
90
- var _a;
91
- e.preventDefault();
92
- e.stopPropagation();
93
- handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
94
- },
95
- })) }))] }));
96
- }
97
- export default memo(MultiSelectStatusButton);
@@ -1,3 +0,0 @@
1
- import MultiSelectStatusButton from './MultiSelectStatusButton';
2
- export default MultiSelectStatusButton;
3
- export type { CurrencyOption, MultiSelectStatusButtonProps } from './type';
@@ -1,2 +0,0 @@
1
- import MultiSelectStatusButton from './MultiSelectStatusButton';
2
- export default MultiSelectStatusButton;
@@ -1,41 +0,0 @@
1
- import type React from 'react';
2
- import { type Theme } from '@mui/material';
3
- export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
4
- export declare const StyledStatusButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
5
- ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
6
- }, "disabled" | "className" | "style" | "classes" | "color" | "children" | "sx" | "tabIndex" | "size" | "variant" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
7
- buttonVariant: 'active' | 'inActive';
8
- }, {}, {}>;
9
- export declare const FlagContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
10
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
11
- }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
12
- export declare const MenuItemContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
13
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
14
- }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
15
- export declare const CheckboxStyles: {
16
- padding: number;
17
- color: string;
18
- '&.Mui-checked': {
19
- color: string;
20
- };
21
- '&.MuiCheckbox-root': {
22
- color: string;
23
- };
24
- '& .MuiSvgIcon-root': {
25
- color: string;
26
- };
27
- '&.Mui-checked .MuiSvgIcon-root': {
28
- color: string;
29
- '& path': {
30
- fill: string;
31
- };
32
- };
33
- };
34
- export declare const ClearIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & {
35
- variant: 'active' | 'inActive';
36
- }, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
37
- export declare const ChevronIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
38
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
39
- }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
40
- isVisible: boolean;
41
- }, {}, {}>;
@@ -1,71 +0,0 @@
1
- import { Box, Button } from '@mui/material';
2
- import { styled } from '@mui/material/styles';
3
- export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
4
- const baseButtonStyle = (theme) => (Object.assign(Object.assign({}, theme.typography.subtitle1), { borderRadius: '50px', borderWidth: '1px', borderStyle: 'solid', minWidth: '135.11px', height: '32px', display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px', textTransform: 'none', transition: 'background-color 0.5s ease, color 0.3s ease', paddingInline: theme.spacing(2) }));
5
- export const StyledStatusButton = styled(Button, {
6
- shouldForwardProp: (prop) => prop !== 'buttonVariant',
7
- })(({ theme, buttonVariant }) => (Object.assign(Object.assign({}, baseButtonStyle(theme)), (buttonVariant === 'active'
8
- ? {
9
- background: theme.palette.background.gradient.shadedBlue,
10
- color: theme.palette.common.white,
11
- }
12
- : {
13
- backgroundColor: theme.palette.common.white,
14
- borderColor: theme.palette.grey[100],
15
- color: theme.palette.text.primary,
16
- '&:hover': {
17
- backgroundColor: 'white',
18
- },
19
- }))));
20
- export const FlagContainer = styled(Box)(({ theme }) => ({
21
- display: 'flex',
22
- alignItems: 'center',
23
- gap: theme.spacing(0.5),
24
- }));
25
- export const MenuItemContainer = styled(Box)(({ theme }) => ({
26
- display: 'flex',
27
- alignItems: 'center',
28
- gap: theme.spacing(0.3),
29
- width: '100%',
30
- }));
31
- export const CheckboxStyles = {
32
- padding: 0.3,
33
- color: '#8C9196',
34
- '&.Mui-checked': {
35
- color: '#1F88D0',
36
- },
37
- '&.MuiCheckbox-root': {
38
- color: '#8C9196',
39
- },
40
- '& .MuiSvgIcon-root': {
41
- color: 'inherit',
42
- },
43
- '&.Mui-checked .MuiSvgIcon-root': {
44
- color: '#1F88D0',
45
- '& path': {
46
- fill: '#1F88D0',
47
- },
48
- },
49
- };
50
- export const ClearIcon = styled('img')(({ variant }) => ({
51
- width: '10px',
52
- height: '10px',
53
- filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
54
- cursor: 'pointer',
55
- position: 'absolute',
56
- top: '50%',
57
- left: '47%',
58
- transform: 'translate(-50%, -50%)',
59
- transition: 'opacity 0.2s ease-in-out',
60
- }));
61
- export const ChevronIconWrapper = styled(Box, {
62
- shouldForwardProp: (prop) => prop !== 'isVisible',
63
- })(({ isVisible }) => ({
64
- opacity: isVisible ? 1 : 0,
65
- transition: 'opacity 0.2s ease-in-out',
66
- display: 'flex',
67
- alignItems: 'center',
68
- justifyContent: 'center',
69
- width: '100%',
70
- height: '100%',
71
- }));
@@ -1,14 +0,0 @@
1
- import { TableHeaderStatus } from '../../types/index.js';
2
- export interface CurrencyOption {
3
- code: string;
4
- name: string;
5
- flagCode?: string;
6
- status: TableHeaderStatus;
7
- }
8
- export interface MultiSelectStatusButtonProps {
9
- options: CurrencyOption[];
10
- selectedValues: TableHeaderStatus[];
11
- onSelectionChange: (selected: TableHeaderStatus[]) => void;
12
- label?: string;
13
- variant?: 'active' | 'inActive';
14
- }
@@ -1 +0,0 @@
1
- export {};