@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,80 @@
1
+ import React, { FC } from 'react';
2
+ import { styled, Typography } from '@mui/material';
3
+
4
+ export interface MapLegendProps {
5
+ mapLegendItems: Array<React.ReactElement<MapLegendItemProps>>;
6
+ }
7
+
8
+ const IconHolder = styled('div')({
9
+ width: '16px',
10
+ height: '16px',
11
+ });
12
+
13
+ export interface MapLegendItemProps {
14
+ icon: React.ReactElement;
15
+ label: string;
16
+ subText?: string;
17
+ extraProps?: React.ReactElement;
18
+ }
19
+
20
+ export const MapLegendItem: FC<MapLegendItemProps> = ({ icon, label, subText, extraProps }) => {
21
+ return (<div
22
+ style={{
23
+ display: 'flex',
24
+ flexDirection: 'row',
25
+ alignItems: 'flex-start',
26
+ gap: '4px'
27
+ }}
28
+ >
29
+ <IconHolder>
30
+ {icon}
31
+ </IconHolder>
32
+ <div
33
+ style={{
34
+ display: 'flex',
35
+ alignItems: 'flex-start',
36
+ flexDirection: 'column',
37
+ fontSize: '11.5px',
38
+ fontWeight: 500,
39
+ lineHeight: '16px',
40
+ color: '#4E5F6D',
41
+ }}
42
+ >
43
+ {label}
44
+ {subText && <Typography
45
+ variant="subtitle1"
46
+ style={{
47
+ color: '#6D7C88',
48
+ fontSize: '11px',
49
+ fontWeight: 500,
50
+ lineHeight: '16px'
51
+ }}
52
+ >{subText}</Typography>}
53
+ {extraProps}
54
+ </div>
55
+ </div>);
56
+ };
57
+
58
+ export const MapLegend: FC<MapLegendProps> = ({ mapLegendItems }) => {
59
+ return <div
60
+ className="leaflet-bottom leaflet-left"
61
+ style={{
62
+ marginBottom: '8px',
63
+ marginLeft: '18px',
64
+ borderRadius: '4px',
65
+ padding: '6px 8px',
66
+ border: `1px solid #E9EEF2`,
67
+ background: '#fff',
68
+ boxShadow: `0px 2px 4px -2px rgba(24, 39, 75, 0.12)`,
69
+ display: 'flex',
70
+ flexDirection: 'row',
71
+ gap: '8px',
72
+ maxWidth: '50%',
73
+ flexWrap: 'wrap'
74
+ }}
75
+ >
76
+ {mapLegendItems.map((Item) => (
77
+ Item
78
+ ))}
79
+ </div >
80
+ }
@@ -0,0 +1,8 @@
1
+ export enum MarkerType {
2
+ REGION_SELECTED = 'REGION_SELECTED',
3
+ REGION_NOT_SELECTED = 'REGION_NOT_SELECTED',
4
+ READ_REPLICA = 'READ_REPLICA',
5
+ REGION_PREFERRED = 'REGION_PREFERRED',
6
+ MASTER_PREFERRED = 'MASTER_PREFERRED',
7
+ GEO_PARTITION = 'GEO_PARTITION',
8
+ };
@@ -0,0 +1,313 @@
1
+ import {
2
+ Dialog,
3
+ DialogActions,
4
+ DialogContent,
5
+ type DialogContentProps,
6
+ type DialogProps,
7
+ DialogTitle,
8
+ Slide,
9
+ Typography,
10
+ dialogClasses,
11
+ styled,
12
+ } from "@mui/material";
13
+ import type { TransitionProps } from "@mui/material/transitions";
14
+ import React, { type FC, type ReactElement } from "react";
15
+ import { BMButton, type BMButtonProps } from "../BMButton";
16
+ import CloseIcon from "../../assets/icons/Close.svg";
17
+ import { BMTooltip } from "../BMTooltip";
18
+
19
+ export interface OverrideButtonProps {
20
+ primary?: BMButtonProps;
21
+ secondary?: BMButtonProps;
22
+ }
23
+
24
+ export interface BMModalProps extends DialogProps {
25
+ title?: string;
26
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
27
+ overrideHeight?: string | number;
28
+ overrideWidth?: string | number;
29
+ isSidePanel?: boolean;
30
+ titleSeparator?: boolean;
31
+ titleIcon?: React.ReactNode;
32
+ actionsInfo?: React.ReactNode;
33
+ onClose?: () => void;
34
+ onSubmit?: () => void;
35
+ enableBackdropDismiss?: boolean;
36
+ submitLabel?: string;
37
+ submitButtonTooltip?: string | ReactElement;
38
+ submitTestId?: string;
39
+ customSubmitButton?: React.ReactNode;
40
+ cancelLabel?: React.ReactNode;
41
+ cancelButtonTooltip?: string;
42
+ cancelTestId?: string;
43
+ buttonProps?: OverrideButtonProps;
44
+ customTitle?: React.ReactNode;
45
+ hideCloseBtn?: boolean;
46
+ dialogContentProps?: DialogContentProps;
47
+ gradientTag?: string;
48
+ }
49
+
50
+ export const SlideTransition = React.forwardRef(
51
+ (
52
+ props: TransitionProps & { children: React.ReactElement<unknown> },
53
+ ref: React.Ref<unknown>,
54
+ ) => {
55
+ return <Slide direction="left" ref={ref} {...props} />;
56
+ },
57
+ );
58
+ SlideTransition.displayName = "SlideTransition";
59
+
60
+ const ModalSizes: Record<
61
+ NonNullable<BMModalProps["size"]>,
62
+ { width: number; height: number }
63
+ > = {
64
+ xs: { width: 480, height: 272 },
65
+ sm: { width: 608, height: 400 },
66
+ md: { width: 800, height: 600 },
67
+ lg: { width: 1024, height: 768 },
68
+ xl: { width: 800, height: 800 },
69
+ };
70
+
71
+ const BMDialog = styled(Dialog)<BMModalProps>(
72
+ ({ isSidePanel, overrideWidth, overrideHeight, size = "md" }) => {
73
+ const modalSize = ModalSizes[size as keyof typeof ModalSizes];
74
+ return {
75
+ [`& .${dialogClasses.paper}`]: {
76
+ ...modalSize,
77
+ width: overrideWidth ?? modalSize.width,
78
+ height: overrideHeight ?? modalSize.height,
79
+ ...(isSidePanel && {
80
+ width: 736,
81
+ height: "100%",
82
+ maxHeight: "100%",
83
+ margin: "0 0 0 auto",
84
+ borderRadius: "0 !important",
85
+ overflowY: "unset",
86
+ }),
87
+ },
88
+ }
89
+ }
90
+ );
91
+
92
+ const ModalDialogTitle = styled(DialogTitle)<BMModalProps>(
93
+ ({ theme, titleSeparator, size }) => ({
94
+
95
+ padding: size === 'xs' ? theme.spacing(1.5, 1.5, 1.5, 2) : theme.spacing(2, 1.5, 2, 2),
96
+ fontSize: theme.typography.body1.fontSize,
97
+ fontWeight: 400,
98
+ ...(titleSeparator && {
99
+ borderBottom: `1px solid ${theme.palette.grey[200]}`,
100
+ }),
101
+ }),
102
+ );
103
+
104
+ const BMForm = styled("form")`
105
+ display: flex;
106
+ flex-direction: column;
107
+ margin: 0;
108
+ min-height: 100%;
109
+ `;
110
+ const ModalTitle = styled("div")(() => ({
111
+ display: "flex",
112
+ alignItems: "center",
113
+ }));
114
+ const Title = styled(Typography)`
115
+ display: flex;
116
+ align-items: center;
117
+ `;
118
+ const Text = styled("span")`
119
+ margin-left: 8px;
120
+ whitespace: nowrap;
121
+ `;
122
+
123
+ const StyledDialogContent = styled(DialogContent)`
124
+ padding: 8px 16px !important;
125
+ font-weight: 400;
126
+ `;
127
+
128
+ const BMDialogActions = styled(DialogActions)<BMModalProps>(
129
+ ({ theme }) => ({
130
+ padding: theme.spacing(2),
131
+ background: theme.palette.grey[200],
132
+ border: `1px solid ${theme.palette.grey[200]}`
133
+ }),
134
+ );
135
+
136
+ const CloseButton = styled("span")(({ theme }) => ({
137
+ background: theme.palette.grey[100],
138
+ padding: theme.spacing(0.5),
139
+ height: theme.spacing(4),
140
+ borderRadius: "50%",
141
+ float: "right",
142
+ margin: "auto 0 auto auto",
143
+ cursor: "pointer",
144
+ }));
145
+
146
+ export const BMModal: FC<BMModalProps> = (props: BMModalProps) => {
147
+ const {
148
+ title,
149
+ titleSeparator,
150
+ titleIcon,
151
+ actionsInfo,
152
+ onClose,
153
+ onSubmit,
154
+ children,
155
+ cancelLabel,
156
+ cancelTestId,
157
+ submitLabel,
158
+ submitTestId,
159
+ enableBackdropDismiss,
160
+ size,
161
+ isSidePanel,
162
+ buttonProps,
163
+ customTitle,
164
+ hideCloseBtn,
165
+ customSubmitButton,
166
+ submitButtonTooltip,
167
+ cancelButtonTooltip,
168
+ dialogContentProps = {},
169
+ gradientTag,
170
+ ...dialogProps
171
+ } = props;
172
+
173
+ const handleClose = () => {
174
+ if (onClose) {
175
+ onClose();
176
+ }
177
+ };
178
+
179
+ const handleSubmitBtnClick = (event: React.MouseEvent) => {
180
+ if (onSubmit) {
181
+ onSubmit();
182
+ // Prevent event propagation to avoid unintended page refresh
183
+ event.preventDefault();
184
+ }
185
+ };
186
+
187
+ const showDialogActions =
188
+ !!cancelLabel || !!submitLabel || !!customSubmitButton;
189
+
190
+ if (isSidePanel) {
191
+ dialogProps.TransitionComponent = SlideTransition;
192
+ }
193
+
194
+ const submitBtnProps = buttonProps?.primary ?? {};
195
+ const cancelBtnProps = buttonProps?.secondary ?? {};
196
+
197
+ const getCancelButton = (): ReactElement | undefined => {
198
+ const returnComponent: ReactElement | undefined = cancelLabel ? (
199
+ <BMButton
200
+ variant="secondary"
201
+ onClick={handleClose}
202
+ {...cancelBtnProps}
203
+ dataTestId={cancelTestId ?? 'modal-cancel-button'}
204
+ >
205
+ {cancelLabel}
206
+ </BMButton>
207
+ ) : undefined;
208
+
209
+ if (cancelButtonTooltip) {
210
+ return (
211
+ <BMTooltip title={cancelButtonTooltip}>
212
+ <span>{returnComponent}</span>
213
+ </BMTooltip>
214
+ );
215
+ }
216
+ return returnComponent;
217
+ };
218
+
219
+ const getSubmitButton = (): React.ReactNode => {
220
+ if (customSubmitButton) return customSubmitButton;
221
+
222
+ const returnComponent: ReactElement | undefined = submitLabel ? (
223
+ <BMButton
224
+ variant="primary"
225
+ onClick={handleSubmitBtnClick}
226
+ {...submitBtnProps}
227
+ type="submit"
228
+ autoFocus
229
+ dataTestId={submitTestId ?? 'modal-submit-button'}
230
+ >
231
+ {submitLabel}
232
+ </BMButton>
233
+ ) : undefined;
234
+
235
+ if (submitButtonTooltip) {
236
+ return (
237
+ <BMTooltip title={submitButtonTooltip}>
238
+ <span>{returnComponent}</span>
239
+ </BMTooltip>
240
+ );
241
+ }
242
+ return returnComponent;
243
+ };
244
+
245
+ return (
246
+ <BMDialog
247
+ aria-labelledby="form-dialog-title"
248
+ size={size}
249
+ {...dialogProps}
250
+ fullWidth={true}
251
+ maxWidth={size}
252
+ onClose={enableBackdropDismiss ? handleClose : undefined}
253
+ isSidePanel={isSidePanel}
254
+ disableEnforceFocus
255
+ >
256
+ <BMForm>
257
+ {customTitle ? (
258
+ <ModalDialogTitle
259
+ open={props.open}
260
+ titleSeparator={props.titleSeparator}
261
+ typography={{ variant: "h4" }}
262
+ size={size}
263
+ >
264
+ {customTitle}
265
+ </ModalDialogTitle>
266
+ ) : (
267
+ title && (
268
+ <ModalDialogTitle
269
+ id="form-dialog-title"
270
+ open={props.open}
271
+ titleSeparator={props.titleSeparator}
272
+ size={size}
273
+ >
274
+ <Title variant="h4">
275
+ {titleIcon ? (
276
+ <ModalTitle>
277
+ {titleIcon}
278
+ <Text>{title}</Text>
279
+ </ModalTitle>
280
+ ) : (
281
+ <ModalTitle>{title}</ModalTitle>
282
+ )}
283
+ {/* {gradientTag && <BMTag text={gradientTag} />} */}
284
+ {!hideCloseBtn && (
285
+ <CloseButton>
286
+ <CloseIcon
287
+ data-testid={cancelTestId ? `${cancelTestId}Header` : ""}
288
+ onClick={handleClose}
289
+ />
290
+ </CloseButton>
291
+ )}
292
+ </Title>
293
+ </ModalDialogTitle>
294
+ )
295
+ )}
296
+ <StyledDialogContent {...dialogContentProps}>{children}</StyledDialogContent>
297
+ {showDialogActions && (
298
+ <BMDialogActions open={props.open}>
299
+ {actionsInfo && <div style={{ marginRight: "auto" }}>{actionsInfo}</div>}
300
+ {getCancelButton()}
301
+ {getSubmitButton()}
302
+ </BMDialogActions>
303
+ )}
304
+ </BMForm>
305
+ </BMDialog>
306
+ );
307
+ };
308
+
309
+ export type BMSidePanelProps = Omit<BMModalProps, "isSidePanel">;
310
+
311
+ export const BMSidePanel: FC<BMSidePanelProps> = (props) => (
312
+ <BMModal {...props} isSidePanel={true} />
313
+ );
@@ -0,0 +1 @@
1
+ export * from "./BMModal";