@bigmath-ui-library/core 2.0.4

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 (229) hide show
  1. package/LICENSE +7 -0
  2. package/LICENSE.md +1 -0
  3. package/README.md +42 -0
  4. package/dist/cjs/index.css +11 -0
  5. package/dist/cjs/index.js +134365 -0
  6. package/dist/esm/index.css +11 -0
  7. package/dist/esm/index.js +134258 -0
  8. package/package.json +58 -0
  9. package/rollup.config.js +73 -0
  10. package/src/BMClassnameSetup.ts +3 -0
  11. package/src/assets/icons/Calendar.svg +6 -0
  12. package/src/assets/icons/Close.svg +40 -0
  13. package/src/assets/icons/Default-Loading-Circles.svg +31 -0
  14. package/src/assets/icons/alert.svg +6 -0
  15. package/src/assets/icons/aws.svg +19 -0
  16. package/src/assets/icons/caret-down.svg +3 -0
  17. package/src/assets/icons/check.svg +6 -0
  18. package/src/assets/icons/circle-check-solid.svg +7 -0
  19. package/src/assets/icons/circle-check.svg +6 -0
  20. package/src/assets/icons/circle-selected.svg +3 -0
  21. package/src/assets/icons/circle-unselected.svg +3 -0
  22. package/src/assets/icons/close-basic.svg +3 -0
  23. package/src/assets/icons/close_collapse.svg +3 -0
  24. package/src/assets/icons/copy.svg +3 -0
  25. package/src/assets/icons/drag.svg +3 -0
  26. package/src/assets/icons/expand-more.svg +3 -0
  27. package/src/assets/icons/failed-solid.svg +7 -0
  28. package/src/assets/icons/globe.svg +3 -0
  29. package/src/assets/icons/google-cloud.svg +6 -0
  30. package/src/assets/icons/in-active.svg +4 -0
  31. package/src/assets/icons/info-solid.svg +6 -0
  32. package/src/assets/icons/info.svg +6 -0
  33. package/src/assets/icons/k8s.svg +4 -0
  34. package/src/assets/icons/lock-locked.svg +5 -0
  35. package/src/assets/icons/microsoft-azure.svg +9 -0
  36. package/src/assets/icons/onprem.svg +3 -0
  37. package/src/assets/icons/pencil.svg +3 -0
  38. package/src/assets/icons/search.svg +6 -0
  39. package/src/assets/icons/shield.svg +4 -0
  40. package/src/assets/icons/star.svg +3 -0
  41. package/src/assets/icons/success-tick.svg +3 -0
  42. package/src/assets/icons/timer.svg +3 -0
  43. package/src/assets/icons/visibility-off.svg +6 -0
  44. package/src/assets/icons/visibility.svg +6 -0
  45. package/src/assets/icons/warning.svg +6 -0
  46. package/src/bma/components/BMButton/BMButton.tsx +34 -0
  47. package/src/bma/components/BMButton/index.ts +1 -0
  48. package/src/bma/components/BMInput/BMInput.tsx +13 -0
  49. package/src/bma/components/BMInput/BMInputField.tsx +7 -0
  50. package/src/bma/components/BMInput/BMSearch.tsx +6 -0
  51. package/src/bma/components/BMInput/index.ts +3 -0
  52. package/src/bma/index.ts +3 -0
  53. package/src/bma/package.json +4 -0
  54. package/src/bma/theme/BMAutocomplete.ts +12 -0
  55. package/src/bma/theme/BMInput.ts +46 -0
  56. package/src/bma/theme/theme.ts +15 -0
  57. package/src/bma/theme/themeUtils.ts +10 -0
  58. package/src/components/BMAccordion/BMAccordion.tsx +150 -0
  59. package/src/components/BMAccordion/index.ts +1 -0
  60. package/src/components/BMAddSection/BMAddSection.tsx +38 -0
  61. package/src/components/BMAddSection/index.ts +1 -0
  62. package/src/components/BMAlert/BMAlert.tsx +168 -0
  63. package/src/components/BMAlert/index.ts +1 -0
  64. package/src/components/BMAutoComplete/BMAutoComplete.tsx +86 -0
  65. package/src/components/BMAutoComplete/index.ts +1 -0
  66. package/src/components/BMAvatar/BMAvatar.tsx +45 -0
  67. package/src/components/BMAvatar/index.ts +1 -0
  68. package/src/components/BMButton/BMButton.tsx +46 -0
  69. package/src/components/BMButton/BMButtonGroup.tsx +46 -0
  70. package/src/components/BMButton/BMSplitButton.tsx +72 -0
  71. package/src/components/BMButton/index.ts +3 -0
  72. package/src/components/BMCheckbox/BMCheckbox.tsx +44 -0
  73. package/src/components/BMCheckbox/BMCheckboxField.tsx +41 -0
  74. package/src/components/BMCheckbox/index.ts +2 -0
  75. package/src/components/BMCloudSelect/BMCloudList.tsx +43 -0
  76. package/src/components/BMCloudSelect/BMCloudSelect.tsx +109 -0
  77. package/src/components/BMCloudSelect/BMCloudSelectField.tsx +46 -0
  78. package/src/components/BMCloudSelect/index.ts +3 -0
  79. package/src/components/BMCodeBlock/BMCodeBlock.tsx +233 -0
  80. package/src/components/BMCodeBlock/index.ts +1 -0
  81. package/src/components/BMDatePicker/BMDatePicker.tsx +187 -0
  82. package/src/components/BMDatePicker/index.ts +1 -0
  83. package/src/components/BMDropdown/BMDropdown.tsx +107 -0
  84. package/src/components/BMDropdown/index.ts +1 -0
  85. package/src/components/BMForm/BMFormControlLabel.tsx +23 -0
  86. package/src/components/BMForm/BMLabel.tsx +24 -0
  87. package/src/components/BMForm/index.ts +2 -0
  88. package/src/components/BMHelloBanner/BMHelloBanner.tsx +68 -0
  89. package/src/components/BMHelloBanner/index.ts +1 -0
  90. package/src/components/BMInput/BMInput.tsx +31 -0
  91. package/src/components/BMInput/BMInputEditableCode.tsx +120 -0
  92. package/src/components/BMInput/BMInputField.tsx +37 -0
  93. package/src/components/BMInput/BMSearch.tsx +17 -0
  94. package/src/components/BMInput/BMStripeInput.tsx +24 -0
  95. package/src/components/BMInput/index.ts +5 -0
  96. package/src/components/BMLoadingBox/BMLoadingBox.tsx +45 -0
  97. package/src/components/BMLoadingBox/index.ts +1 -0
  98. package/src/components/BMMaps/BMMapMarker.css +12 -0
  99. package/src/components/BMMaps/BMMapMarker.tsx +68 -0
  100. package/src/components/BMMaps/BMMaps.tsx +129 -0
  101. package/src/components/BMMaps/MapIcons.tsx +83 -0
  102. package/src/components/BMMaps/icons/GeoPartition.svg +19 -0
  103. package/src/components/BMMaps/icons/GeoPartitionHover.svg +20 -0
  104. package/src/components/BMMaps/icons/MasterPreferred.svg +19 -0
  105. package/src/components/BMMaps/icons/MasterPreferredHover.svg +20 -0
  106. package/src/components/BMMaps/icons/ReadReplica.svg +18 -0
  107. package/src/components/BMMaps/icons/ReadReplicaHover.svg +19 -0
  108. package/src/components/BMMaps/icons/RegionNotSelected.svg +18 -0
  109. package/src/components/BMMaps/icons/RegionNotSelectedHover.svg +19 -0
  110. package/src/components/BMMaps/icons/RegionPreferred.svg +18 -0
  111. package/src/components/BMMaps/icons/RegionPreferredHover.svg +19 -0
  112. package/src/components/BMMaps/icons/RegionSelected.svg +18 -0
  113. package/src/components/BMMaps/icons/RegionSelectedHover.svg +19 -0
  114. package/src/components/BMMaps/index.ts +5 -0
  115. package/src/components/BMMaps/legend/MapLegend.tsx +80 -0
  116. package/src/components/BMMaps/markerTypes.ts +8 -0
  117. package/src/components/BMModal/BMModal.tsx +313 -0
  118. package/src/components/BMModal/index.ts +1 -0
  119. package/src/components/BMMultiEntry/BMMultiEntry.tsx +328 -0
  120. package/src/components/BMMultiEntry/BMMultiEntryField.tsx +47 -0
  121. package/src/components/BMMultiEntry/index.ts +2 -0
  122. package/src/components/BMMultiLevelStepper/BMMultiLevelStepper.tsx +191 -0
  123. package/src/components/BMMultiLevelStepper/index.ts +1 -0
  124. package/src/components/BMPagination/BMPagination.tsx +64 -0
  125. package/src/components/BMPagination/index.ts +1 -0
  126. package/src/components/BMPassword/BMPassword.tsx +37 -0
  127. package/src/components/BMPassword/BMPasswordField.tsx +50 -0
  128. package/src/components/BMPassword/index.ts +2 -0
  129. package/src/components/BMProgress/BMProgress.tsx +43 -0
  130. package/src/components/BMProgress/index.ts +1 -0
  131. package/src/components/BMRadio/BMRadio.tsx +162 -0
  132. package/src/components/BMRadio/BMRadioGroupField.tsx +40 -0
  133. package/src/components/BMRadio/index.ts +2 -0
  134. package/src/components/BMSelect/BMSelect.tsx +70 -0
  135. package/src/components/BMSelect/BMSelectField.tsx +47 -0
  136. package/src/components/BMSelect/index.ts +2 -0
  137. package/src/components/BMSlider/BMSlider.tsx +16 -0
  138. package/src/components/BMSlider/index.ts +1 -0
  139. package/src/components/BMSmartStatus/BMSmartStatus.tsx +185 -0
  140. package/src/components/BMSmartStatus/index.tsx +1 -0
  141. package/src/components/BMStatus/BMStatus.tsx +98 -0
  142. package/src/components/BMStatus/index.ts +1 -0
  143. package/src/components/BMTable/BMTable.tsx +131 -0
  144. package/src/components/BMTable/index.ts +1 -0
  145. package/src/components/BMTabs/BMTabs.tsx +50 -0
  146. package/src/components/BMTabs/index.ts +1 -0
  147. package/src/components/BMTag/BMTag.tsx +47 -0
  148. package/src/components/BMTag/index.ts +1 -0
  149. package/src/components/BMTagv2/BMTagv2.tsx +250 -0
  150. package/src/components/BMTagv2/index.ts +1 -0
  151. package/src/components/BMToggle/BMMultiToggleButton.tsx +99 -0
  152. package/src/components/BMToggle/BMToggle.tsx +35 -0
  153. package/src/components/BMToggle/BMToggleField.tsx +28 -0
  154. package/src/components/BMToggle/index.ts +3 -0
  155. package/src/components/BMTooltip/BMTooltip.tsx +52 -0
  156. package/src/components/BMTooltip/index.ts +1 -0
  157. package/src/components/BMWarning/BMWarning.tsx +39 -0
  158. package/src/components/BMWarning/index.ts +1 -0
  159. package/src/components/GenericFailure/GenericFailure.tsx +28 -0
  160. package/src/components/GenericFailure/index.ts +1 -0
  161. package/src/components/NoAccess/NoAccess.tsx +40 -0
  162. package/src/components/NoAccess/NoAccessActionTooltip.tsx +53 -0
  163. package/src/components/NoAccess/NoPermissionModal.tsx +55 -0
  164. package/src/components/NoAccess/index.ts +3 -0
  165. package/src/components/index.ts +34 -0
  166. package/src/index.ts +9 -0
  167. package/src/theme/BMAutoComplete.ts +152 -0
  168. package/src/theme/BMAvatar.ts +5 -0
  169. package/src/theme/BMButton.ts +132 -0
  170. package/src/theme/BMButtonGroup.ts +49 -0
  171. package/src/theme/BMCheckbox.ts +16 -0
  172. package/src/theme/BMFormHelperText.ts +19 -0
  173. package/src/theme/BMInput.ts +120 -0
  174. package/src/theme/BMMaps.ts +9 -0
  175. package/src/theme/BMRadio.ts +10 -0
  176. package/src/theme/BMTabs.ts +79 -0
  177. package/src/theme/BMTag.ts +28 -0
  178. package/src/theme/BMToggle.ts +50 -0
  179. package/src/theme/BMTooltip.ts +34 -0
  180. package/src/theme/theme.ts +326 -0
  181. package/src/theme/variables.ts +152 -0
  182. package/src/types/custom.d.ts +9 -0
  183. package/src/types/svg.d.ts +5 -0
  184. package/stories/BMAButton.stories.tsx +67 -0
  185. package/stories/BMAccordion.stories.tsx +55 -0
  186. package/stories/BMAddSection.stories.tsx +40 -0
  187. package/stories/BMAlert.stories.tsx +33 -0
  188. package/stories/BMAutoComplete.stories.tsx +65 -0
  189. package/stories/BMAvatar.stories.tsx +76 -0
  190. package/stories/BMButton.stories.tsx +57 -0
  191. package/stories/BMButton2.stories.tsx +131 -0
  192. package/stories/BMCheckbox.stories.tsx +23 -0
  193. package/stories/BMCloudSelectField.stories.tsx +40 -0
  194. package/stories/BMCodeBlock.stories.tsx +57 -0
  195. package/stories/BMDatePicker.stories.tsx +88 -0
  196. package/stories/BMDropdown.stories.tsx +84 -0
  197. package/stories/BMGroupButton.stories.tsx +53 -0
  198. package/stories/BMHelloBanner.stories.tsx +33 -0
  199. package/stories/BMInput.stories.tsx +184 -0
  200. package/stories/BMInputEditableCode.stories.tsx +86 -0
  201. package/stories/BMInputField.stories.tsx +50 -0
  202. package/stories/BMLoadingBox.stories.tsx +45 -0
  203. package/stories/BMMaps.stories.tsx +29 -0
  204. package/stories/BMModal.stories.tsx +218 -0
  205. package/stories/BMMultiEntry.stories.tsx +93 -0
  206. package/stories/BMMultiLevelStepper.stories.tsx +87 -0
  207. package/stories/BMPagination.stories.tsx +41 -0
  208. package/stories/BMPassword.stories.tsx +133 -0
  209. package/stories/BMProgress.stories.tsx +60 -0
  210. package/stories/BMRadio.stories.tsx +71 -0
  211. package/stories/BMSelect.stories.tsx +160 -0
  212. package/stories/BMSlider.stories.tsx +74 -0
  213. package/stories/BMSmartStatus.stories.tsx +98 -0
  214. package/stories/BMSplitButton.stories.tsx +32 -0
  215. package/stories/BMStatus.stories.tsx +29 -0
  216. package/stories/BMTable.stories.tsx +350 -0
  217. package/stories/BMTabs.stories.tsx +25 -0
  218. package/stories/BMTag.stories.tsx +63 -0
  219. package/stories/BMTagv2.stories.tsx +288 -0
  220. package/stories/BMToggle.stories.tsx +123 -0
  221. package/stories/BMTooltip.stories.tsx +59 -0
  222. package/stories/BMTypography.stories.tsx +79 -0
  223. package/stories/BMWarning.stories.tsx +55 -0
  224. package/stories/GenericFailure.stories.tsx +47 -0
  225. package/stories/NoAccess.stories.tsx +19 -0
  226. package/stories/NoAccessActionTooltip.stories.tsx +50 -0
  227. package/stories/NoPermissionModal.stories.tsx +46 -0
  228. package/tsconfig.base.json +21 -0
  229. package/tsconfig.build.json +23 -0
@@ -0,0 +1,15 @@
1
+ import { type ThemeOptions, createTheme } from "@mui/material";
2
+ import { deepmerge } from "@mui/utils";
3
+ import { coreTheme } from "../../theme/theme";
4
+ import { BMAInput, BMInputLabel } from "./BMInput";
5
+ import { BMAAutoComplete } from "./BMAutocomplete";
6
+
7
+ export const bmaTheme = createTheme(
8
+ deepmerge(coreTheme, {
9
+ components: {
10
+ MuiInput: BMAInput,
11
+ MuiInputLabel: BMInputLabel,
12
+ MuiAutocomplete: BMAAutoComplete
13
+ }
14
+ })as ThemeOptions,
15
+ );
@@ -0,0 +1,10 @@
1
+ import { Theme } from "@mui/material";
2
+
3
+ export const getOverrideContents = (fn: any, theme?: Theme) => {
4
+ if (typeof fn === 'function' && theme) {
5
+ return fn({ theme });
6
+ }
7
+ else {
8
+ return fn;
9
+ }
10
+ }
@@ -0,0 +1,150 @@
1
+ import { FC, useState, ReactNode } from "react";
2
+
3
+ import {
4
+ Box,
5
+ styled,
6
+ useTheme,
7
+ Accordion,
8
+ AccordionProps,
9
+ AccordionSummary,
10
+ AccordionDetails,
11
+ } from "@mui/material";
12
+
13
+ import ExpandMoreIcon from "../../assets/icons/expand-more.svg";
14
+
15
+ interface BMAccordionProps extends AccordionProps {
16
+ titleContent: ReactNode;
17
+ renderChips?: () => ReactNode;
18
+ renderChipsWithoutExpanded?: () => ReactNode;
19
+ isAccordionList?: boolean;
20
+ dataTestId?: string;
21
+ }
22
+
23
+ const StyledAccordion = styled(Accordion, {
24
+ shouldForwardProp: (prop) => prop !== "isAccordionList",
25
+ })<{ isAccordionList?: boolean }>(({ theme, isAccordionList }) => ({
26
+ ...(isAccordionList
27
+ ? {
28
+ borderBottom: "0px transparent",
29
+ borderRadius: 0,
30
+ margin: "0px",
31
+ "&:first-of-type": {
32
+ borderTopLeftRadius: theme.spacing(1),
33
+ borderTopRightRadius: theme.spacing(1),
34
+ "& > .MuiAccordionSummary-root": {
35
+ borderTopLeftRadius: theme.spacing(1),
36
+ borderTopRightRadius: theme.spacing(1),
37
+ },
38
+ },
39
+ "&:last-of-type": {
40
+ borderBottom: `1px solid ${theme.palette.grey[300]}`,
41
+ "& > .MuiAccordionSummary-root": {
42
+ borderBottomLeftRadius: theme.spacing(1),
43
+ borderBottomRightRadius: theme.spacing(1),
44
+ "&.Mui-expanded": {
45
+ borderBottomLeftRadius: 0,
46
+ borderBottomRightRadius: 0,
47
+ },
48
+ },
49
+ },
50
+ }
51
+ : {
52
+ border: `1px solid ${theme.palette.grey[200]}`,
53
+ }),
54
+ }));
55
+
56
+ const StyledAccordionSummary = styled(AccordionSummary, {
57
+ shouldForwardProp: (prop) => prop !== "isAccordionList",
58
+ })<{ isAccordionList?: boolean }>(({ theme, isAccordionList }) => ({
59
+ display: "flex",
60
+ width: "100%",
61
+ minHeight: isAccordionList ? theme.spacing(5.5) : theme.spacing(8),
62
+ paddingLeft: isAccordionList ? theme.spacing(3) : undefined,
63
+ paddingRight: isAccordionList ? theme.spacing(3) : undefined,
64
+ backgroundColor: isAccordionList ? `${theme.palette.grey[100]}40` : undefined,
65
+ borderBottom: isAccordionList
66
+ ? `1px solid ${theme.palette.grey[200]}`
67
+ : undefined,
68
+ "& .MuiAccordionSummary-content": {
69
+ margin: 0,
70
+ },
71
+ "&.Mui-expanded": {
72
+ minHeight: isAccordionList ? theme.spacing(5.5) : theme.spacing(8),
73
+ },
74
+ }));
75
+
76
+ const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
77
+ display: "inline-block",
78
+ width: "100%",
79
+ padding: theme.spacing(1, 2, 1.5),
80
+ }));
81
+
82
+ const TitleBox = styled(Box, {
83
+ shouldForwardProp: (prop) => prop !== "isAccordionList",
84
+ })<{ isAccordionList?: boolean }>(({ theme, isAccordionList }) => ({
85
+ display: "flex",
86
+ alignItems: "center",
87
+ flexGrow: 1,
88
+ fontWeight: 600,
89
+ fontSize: isAccordionList ? 13 : 15,
90
+ color: theme.palette.grey[900],
91
+ }));
92
+
93
+ const ShrinkContainer = styled(Box)({
94
+ display: "flex",
95
+ flexShrink: 1,
96
+ });
97
+
98
+ export const BMAccordion: FC<BMAccordionProps> = ({
99
+ titleContent,
100
+ renderChips,
101
+ renderChipsWithoutExpanded,
102
+ children,
103
+ defaultExpanded,
104
+ dataTestId,
105
+ isAccordionList = false,
106
+ ...rest
107
+ }) => {
108
+ const [accordionExpanded, setAccordionExpanded] = useState<boolean>(
109
+ !!defaultExpanded
110
+ );
111
+ const theme = useTheme();
112
+
113
+ const handleToggle = () => {
114
+ setAccordionExpanded(!accordionExpanded);
115
+ };
116
+
117
+ const accordion = (
118
+ <StyledAccordion
119
+ expanded={accordionExpanded}
120
+ isAccordionList={isAccordionList}
121
+ data-testid={dataTestId}
122
+ {...rest}
123
+ >
124
+ <StyledAccordionSummary
125
+ onClick={handleToggle}
126
+ isAccordionList={isAccordionList}
127
+ expandIcon={
128
+ <ExpandMoreIcon style={{ color: theme.palette.primary[900] }} />
129
+ }
130
+ >
131
+ <TitleBox isAccordionList={isAccordionList}>{titleContent}</TitleBox>
132
+
133
+ {!accordionExpanded && renderChips && (
134
+ <ShrinkContainer>{renderChips()}</ShrinkContainer>
135
+ )}
136
+ {renderChipsWithoutExpanded && (
137
+ <ShrinkContainer>{renderChipsWithoutExpanded()}</ShrinkContainer>
138
+ )}
139
+ </StyledAccordionSummary>
140
+
141
+ <StyledAccordionDetails>{children}</StyledAccordionDetails>
142
+ </StyledAccordion>
143
+ );
144
+
145
+ return isAccordionList ? (
146
+ accordion
147
+ ) : (
148
+ <Box sx={{ display: "flex", width: "100%" }}>{accordion}</Box>
149
+ );
150
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMAccordion";
@@ -0,0 +1,38 @@
1
+ import React, { FC } from "react";
2
+ import { Box, Typography, TypographyProps, styled } from "@mui/material";
3
+
4
+ import { BMLoadingBox } from "../BMLoadingBox";
5
+
6
+ interface BMAddSectionProps {
7
+ title?: string | React.ReactNode;
8
+ body: string;
9
+ bodyVariant?: TypographyProps["variant"];
10
+ controls?: React.ReactNode | React.ReactNode[];
11
+ }
12
+
13
+ const LoadingSection = styled(Box)(({ theme }) => ({
14
+ padding: theme.spacing(2, 0),
15
+ }));
16
+
17
+ export const BMAddSection: FC<BMAddSectionProps> = ({
18
+ title,
19
+ body,
20
+ bodyVariant,
21
+ controls,
22
+ }) => {
23
+ return (
24
+ <LoadingSection>
25
+ <BMLoadingBox>
26
+ {title && (
27
+ <Box sx={{ mt: 1, mb: 2 }}>
28
+ <Typography variant="h2">{title}</Typography>
29
+ </Box>
30
+ )}
31
+ <Box sx={{ mb: controls ? 2 : 0 }}>
32
+ <Typography variant={bodyVariant ?? "body2"}>{body}</Typography>
33
+ </Box>
34
+ {controls}
35
+ </BMLoadingBox>
36
+ </LoadingSection>
37
+ );
38
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMAddSection";
@@ -0,0 +1,168 @@
1
+ import { Fade, Snackbar, type Theme, Typography, styled } from "@mui/material";
2
+ import type { ReactNode } from "react";
3
+
4
+ import { Close as CloseIcon } from "@mui/icons-material";
5
+ import LoadingIcon from "../../assets/icons/Default-Loading-Circles.svg";
6
+ import WarningIcon from "../../assets/icons/alert.svg";
7
+ import SuccessIcon from "../../assets/icons/circle-check.svg";
8
+ import InfoIcon from "../../assets/icons/info.svg";
9
+ import ErrorIcon from "../../assets/icons/warning.svg";
10
+
11
+ export enum AlertVariant {
12
+ Info = "info",
13
+ Warning = "warning",
14
+ Error = "error",
15
+ Success = "success",
16
+ InProgress = "inProgress",
17
+ }
18
+
19
+ const DEFAULT_AUTO_DISMISS_MS = 6000;
20
+
21
+ interface TransitionProps {
22
+ appear?: number;
23
+ enter?: number;
24
+ exit?: number;
25
+ }
26
+
27
+ export interface BMAlertProps {
28
+ open: boolean;
29
+ text: string | ReactNode;
30
+ icon?: ReactNode;
31
+ onClose?: () => void;
32
+ autoDismiss?: number;
33
+ width?: number;
34
+ isToast?: boolean;
35
+ variant?: AlertVariant;
36
+ key?: string | number;
37
+ position?: number;
38
+ className?: string;
39
+ dataTestId?: string;
40
+ transitionTimeout?: number | TransitionProps;
41
+ }
42
+
43
+ const BMAlertDiv = styled("div")<Partial<BMAlertProps>>(
44
+ ({ theme, position, isToast, width, variant = AlertVariant.Info }) => ({
45
+ padding: theme.spacing(1),
46
+ borderRadius: theme.shape.borderRadius,
47
+ display: "flex",
48
+ alignItems: "center",
49
+ marginTop: (position ?? 0) * 58,
50
+ width: width === undefined ? "auto" : `${width}px`,
51
+ background: (theme.palette as unknown as Record<string, string>)[
52
+ variant === AlertVariant.InProgress ? AlertVariant.Info : variant
53
+ ][100],
54
+ ...(isToast && {
55
+ // padding: theme.spacing(1.5, 1),
56
+ border: `1px solid ${(theme.palette as unknown as Record<string, string>)[variant === AlertVariant.InProgress ? AlertVariant.Info : variant][300]}`,
57
+ boxShadow: "0 0 4px 0 rgba(0,0,0,0.1)",
58
+ minWidth: "200px",
59
+ }),
60
+ }),
61
+ );
62
+
63
+ const BMAlertText = styled(Typography)(({ theme }) => ({
64
+ marginLeft: theme.spacing(1),
65
+ marginRight: "auto",
66
+ fontWeight: 400,
67
+ color: '#0B1116'
68
+ }));
69
+
70
+ const BMAlertCloseIcon = styled(CloseIcon)(({ theme }) => ({
71
+ height: theme.spacing(1.5),
72
+ width: theme.spacing(1.5),
73
+ fill: theme.palette.text.primary,
74
+ marginRight: theme.spacing(0.5),
75
+ marginLeft: theme.spacing(1.5),
76
+ cursor: "pointer",
77
+ }));
78
+
79
+ const iconStyles = ({
80
+ theme,
81
+ variant,
82
+ }: { theme: Theme; variant: AlertVariant }) => ({
83
+ width: theme.spacing(3),
84
+ height: theme.spacing(3),
85
+ minWidth: theme.spacing(3),
86
+ minHeight: theme.spacing(3),
87
+ color: (theme.palette as unknown as Record<string, string>)[
88
+ variant === AlertVariant.InProgress ? AlertVariant.Info : variant
89
+ ][700],
90
+ });
91
+
92
+ const GetAlertIcon = (variant: AlertVariant) => {
93
+ const icons = {
94
+ [AlertVariant.Warning]: WarningIcon,
95
+ [AlertVariant.Success]: SuccessIcon,
96
+ [AlertVariant.Error]: ErrorIcon,
97
+ [AlertVariant.InProgress]: LoadingIcon,
98
+ [AlertVariant.Info]: InfoIcon,
99
+ };
100
+
101
+ return styled(icons[variant])(({ theme }) => iconStyles({ theme, variant }));
102
+ };
103
+
104
+ export const BMAlert = (props: BMAlertProps) => {
105
+ const {
106
+ open,
107
+ text,
108
+ autoDismiss,
109
+ dataTestId,
110
+ onClose,
111
+ variant = AlertVariant.Info,
112
+ isToast = false,
113
+ width,
114
+ icon,
115
+ className,
116
+ transitionTimeout,
117
+ ...alertProps
118
+ } = props;
119
+
120
+ const handleClose = (_event: unknown, reason: string) => {
121
+ if (reason === "clickaway") {
122
+ return;
123
+ }
124
+ if (onClose) {
125
+ onClose();
126
+ }
127
+ };
128
+
129
+ const AlertIcon = GetAlertIcon(variant);
130
+
131
+ if (isToast) {
132
+ return (
133
+ <Snackbar
134
+ open={open}
135
+ autoHideDuration={autoDismiss ?? DEFAULT_AUTO_DISMISS_MS}
136
+ TransitionComponent={Fade}
137
+ anchorOrigin={{ vertical: "top", horizontal: "center" }}
138
+ onClose={handleClose}
139
+ {...alertProps}
140
+ >
141
+ <BMAlertDiv
142
+ data-testid={dataTestId}
143
+ role="alert"
144
+ aria-label={`alert ${variant}`}
145
+ {...props}
146
+ >
147
+ {icon ?? <AlertIcon />}
148
+ <BMAlertText variant="body2">{text}</BMAlertText>
149
+ {onClose && <BMAlertCloseIcon onClick={onClose} />}
150
+ </BMAlertDiv>
151
+ </Snackbar>
152
+ );
153
+ }
154
+ return (
155
+ <Fade in={open} timeout={transitionTimeout}>
156
+ <BMAlertDiv
157
+ role="alert"
158
+ data-testid={dataTestId}
159
+ aria-label={`alert ${variant}`}
160
+ {...props}
161
+ >
162
+ {icon ?? <AlertIcon />}
163
+ <BMAlertText>{text}</BMAlertText>
164
+ {onClose && <BMAlertCloseIcon onClick={onClose} />}
165
+ </BMAlertDiv>
166
+ </Fade>
167
+ );
168
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMAlert";
@@ -0,0 +1,86 @@
1
+ import { FC, useCallback } from "react";
2
+ import { Autocomplete, AutocompleteProps, Paper } from "@mui/material";
3
+ import { styled } from "@mui/material/styles";
4
+ import { BMInput, BMInputProps } from "../../components/BMInput";
5
+ import { BMTooltip } from "../BMTooltip/BMTooltip";
6
+ import CaretDownIcon from "../../assets/icons/caret-down.svg";
7
+ import CloseIcon from "../../assets/icons/close-basic.svg";
8
+
9
+ declare module "@mui/material/Autocomplete" {
10
+ interface AutocompletePropsSizeOverrides {
11
+ large: true;
12
+ }
13
+ }
14
+
15
+ export interface BMAutoCompleteProps
16
+ extends Omit<
17
+ AutocompleteProps<Record<string, string>, boolean, boolean, boolean>,
18
+ "renderInput"
19
+ > {
20
+ getOptionLabel: (option: string | Record<string, string>) => string;
21
+ getOptionDisabled?: (option: Record<string, string>) => boolean;
22
+ bmInputProps?: BMInputProps;
23
+ autoCompleteDropdownID?: string;
24
+ tooltipText?: string | React.ReactNode;
25
+ size?: "medium" | "large";
26
+ dataTestId: string;
27
+ }
28
+
29
+ const CloseStyledIcon = styled(CloseIcon)(({ theme }) => ({
30
+ color: theme.palette.grey[600],
31
+ }));
32
+
33
+ export const BMAutoComplete: FC<BMAutoCompleteProps> = ({
34
+ bmInputProps,
35
+ options,
36
+ getOptionLabel,
37
+ getOptionDisabled,
38
+ autoCompleteDropdownID,
39
+ tooltipText,
40
+ dataTestId,
41
+ ...rest
42
+ }: BMAutoCompleteProps) => {
43
+ const memoPaperComp = useCallback(
44
+ ({ children }: { children?: React.ReactNode }) => {
45
+ return <Paper data-testid={autoCompleteDropdownID}>{children}</Paper>;
46
+ },
47
+ [autoCompleteDropdownID]
48
+ );
49
+
50
+ return (
51
+ <Autocomplete
52
+ options={options}
53
+ autoHighlight
54
+ autoSelect
55
+ getOptionLabel={getOptionLabel}
56
+ getOptionDisabled={getOptionDisabled}
57
+ popupIcon={<CaretDownIcon />}
58
+ clearIcon={<CloseStyledIcon />}
59
+ slotProps={{
60
+ chip: {
61
+ deleteIcon: <CloseStyledIcon />,
62
+ },
63
+ paper: memoPaperComp,
64
+ }}
65
+ data-testid={dataTestId}
66
+ renderInput={(params) => (
67
+ <BMTooltip placement="top-start" title={tooltipText ?? ""}>
68
+ <span>
69
+ <BMInput
70
+ dataTestId={`${dataTestId}-input`}
71
+ {...params}
72
+ {...bmInputProps}
73
+ slotProps={{
74
+ input: {
75
+ ...params.InputProps,
76
+ ...bmInputProps?.slotProps?.input,
77
+ },
78
+ }}
79
+ />
80
+ </span>
81
+ </BMTooltip>
82
+ )}
83
+ {...rest}
84
+ />
85
+ );
86
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMAutoComplete";
@@ -0,0 +1,45 @@
1
+ import { FC } from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import AccountCircleIcon from "@mui/icons-material/AccountCircle";
4
+
5
+ import { BMAvatarSizeMap } from "../../theme/BMAvatar";
6
+
7
+ export interface AvatarProps {
8
+ size?: "small" | "medium" | "large";
9
+ imageUrl?: string;
10
+ }
11
+
12
+ const getSizeDimension = (_: any, size: "small" | "medium" | "large") => {
13
+ return BMAvatarSizeMap[size] || BMAvatarSizeMap?.medium;
14
+ };
15
+
16
+ const StyledImage = styled("img")<{
17
+ size: "small" | "medium" | "large";
18
+ }>(({ theme, size }) => {
19
+ const dimension = getSizeDimension(theme, size);
20
+
21
+ return {
22
+ width: dimension,
23
+ height: dimension,
24
+ borderRadius: "50%",
25
+ objectFit: "cover",
26
+ };
27
+ });
28
+
29
+ const StyledIcon = styled(AccountCircleIcon)<{
30
+ size: "small" | "medium" | "large";
31
+ }>(({ theme, size }) => {
32
+ const dimension = getSizeDimension(theme, size);
33
+ return {
34
+ width: dimension,
35
+ height: dimension,
36
+ };
37
+ });
38
+
39
+ export const BMAvatar: FC<AvatarProps> = ({ size = "medium", imageUrl }) => {
40
+ if (!imageUrl) {
41
+ return <StyledIcon size={size} />;
42
+ }
43
+
44
+ return <StyledImage src={imageUrl} size={size} alt="avatar" />;
45
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMAvatar";
@@ -0,0 +1,46 @@
1
+ import { Box, type ButtonProps, CircularProgress } from "@mui/material";
2
+ import Button from "@mui/material/Button";
3
+ import type { OverridableStringUnion } from '@mui/types';
4
+
5
+ export interface BMAButtonVariantOverride {}
6
+
7
+ export interface BMButtonProps
8
+ extends Omit<ButtonProps, "classes" | "variant" | "size`"> {
9
+ showSpinner?: boolean;
10
+ variant?: OverridableStringUnion<"primary" | "secondary" | "ghost" | "gradient", BMAButtonVariantOverride>;
11
+ size?: "small" | "large" | "medium";
12
+ dataTestId: string;
13
+ }
14
+
15
+ export const BMButton: React.FC<BMButtonProps> = (props) => {
16
+ const { showSpinner, variant = "primary", size, color, ...muiProps } = props;
17
+ const muiButtonProps: BMButtonProps = muiProps;
18
+
19
+ if (showSpinner) {
20
+ muiButtonProps.startIcon = (
21
+ <Box color={props.disabled ? "grey.500" : ""}>
22
+ <CircularProgress
23
+ size={16}
24
+ sx={{
25
+ color: props.disabled
26
+ ? "inherit"
27
+ : variant && ["primary", "gradient"].includes(variant)
28
+ ? "white"
29
+ : "primary",
30
+ }}
31
+ thickness={5}
32
+ />
33
+ </Box>
34
+ );
35
+ }
36
+
37
+ return (
38
+ <Button
39
+ {...muiButtonProps}
40
+ size={size}
41
+ color={color ?? muiButtonProps.color}
42
+ variant={variant as ButtonProps['variant']}
43
+ data-testid={props.dataTestId}
44
+ />
45
+ );
46
+ };
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { BMButton, BMButtonProps } from './BMButton';
3
+ import { ButtonGroup } from '@mui/material';
4
+
5
+ export interface BMButtonGroupProps {
6
+ buttons: {
7
+ label: string;
8
+ onClick: () => void;
9
+ buttonProps?: BMButtonProps;
10
+ }[];
11
+ active?: string;
12
+ className?: string;
13
+ orientation?: 'horizontal' | 'vertical';
14
+ dataTestId: string;
15
+ }
16
+
17
+ export const BMButtonGroup: React.FC<BMButtonGroupProps> = ({
18
+ buttons,
19
+ className,
20
+ active,
21
+ dataTestId,
22
+ orientation = 'horizontal',
23
+ }) => {
24
+ const [activeBut, setActiveBut] = React.useState<string | null>(active ?? null);
25
+ return (
26
+ <ButtonGroup orientation={orientation} className={className}>
27
+ {buttons.map((button, index) => (
28
+ <>
29
+ <BMButton
30
+ key={index}
31
+ onClick={() => {
32
+ setActiveBut(button.label);
33
+ button.onClick();
34
+ }}
35
+ {...button.buttonProps}
36
+ className={`${button.buttonProps?.className} ${button.label === activeBut ? 'bm-active' : ''}`}
37
+ dataTestId={`${dataTestId}-${button.label}`}
38
+ >
39
+ {button.label}
40
+ {(index !== buttons.length - 1 && activeBut !== button.label) && <div className="bm-divider" />}
41
+ </BMButton>
42
+ </>
43
+ ))}
44
+ </ButtonGroup>
45
+ );
46
+ };
@@ -0,0 +1,72 @@
1
+ import React, { useState } from 'react';
2
+ import { BMButton, BMButtonProps } from '../BMButton/BMButton';
3
+ import { Menu, MenuItem, MenuProps } from '@mui/material';
4
+ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
5
+
6
+
7
+ export interface BMSplitButtonProps extends BMButtonProps {
8
+ label: string;
9
+ options: { label: string; onClick: () => void }[];
10
+ menuProps: Partial<MenuProps>;
11
+ ButtonComp?: React.ElementType;
12
+ dataTestId: string;
13
+ }
14
+
15
+ export const BMSplitButton: React.FC<BMSplitButtonProps> = ({
16
+ label,
17
+ options,
18
+ menuProps,
19
+ ButtonComp=BMButton,
20
+ ...props
21
+ }) => {
22
+ const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
23
+ let [buttonRef, setButtonRef] = useState<HTMLButtonElement|null>(null);
24
+ const handleDropdownClick = (event: React.MouseEvent<HTMLElement>) => {
25
+ !buttonRef && setButtonRef(event.currentTarget as HTMLButtonElement);
26
+ setAnchorEl(event.currentTarget);
27
+ };
28
+
29
+ const handleClose = () => {
30
+ setAnchorEl(null);
31
+ };
32
+ return (
33
+ <div style={{ display: 'inline-flex', alignItems: 'center' }}>
34
+ <ButtonComp
35
+ onClick={handleDropdownClick}
36
+ style={{ marginLeft: '4px', padding: '0 8px' }}
37
+ data-testid={props.dataTestId}
38
+ {...props}
39
+ >
40
+ {label}
41
+ <ArrowDropDownIcon />
42
+ </ButtonComp>
43
+
44
+ <Menu
45
+ anchorEl={anchorEl}
46
+ open={Boolean(anchorEl)}
47
+ onClose={handleClose}
48
+ anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
49
+ transformOrigin={{ vertical: 'top', horizontal: 'right' }}
50
+ PaperProps={{
51
+ style: {
52
+ width: buttonRef?.clientWidth
53
+ }
54
+ }}
55
+ {...menuProps}
56
+ >
57
+ {options?.map((option, index) => (
58
+ <MenuItem
59
+ key={index}
60
+ onClick={() => {
61
+ option.onClick();
62
+ handleClose();
63
+ }}
64
+ data-testid={`${props.dataTestId}-${option.label}`}
65
+ >
66
+ {option.label}
67
+ </MenuItem>
68
+ ))}
69
+ </Menu>
70
+ </div>
71
+ );
72
+ };