@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,50 @@
1
+ import { type ReactElement, useEffect, useRef } from "react";
2
+ import {
3
+ type FieldValues,
4
+ type UseControllerProps,
5
+ useController,
6
+ } from "react-hook-form";
7
+ import type { BMInputProps } from "../BMInput";
8
+ import { BMPassword } from "./BMPassword";
9
+
10
+ type BMPasswordFieldProps<T extends FieldValues> = UseControllerProps<T> &
11
+ BMInputProps & { hidePasswordButton?: boolean };
12
+
13
+ export const BMPasswordField = <T extends FieldValues>(
14
+ props: BMPasswordFieldProps<T>,
15
+ ): ReactElement => {
16
+ const inputElement = useRef<HTMLInputElement | null>(null) as React.MutableRefObject<HTMLInputElement | null>;
17
+ const {
18
+ name,
19
+ rules,
20
+ defaultValue,
21
+ control,
22
+ shouldUnregister,
23
+ ...bmInputProps
24
+ } = props;
25
+ const {
26
+ field: { ref, value, ...fieldProps },
27
+ fieldState,
28
+ } = useController({ name, rules, defaultValue, control, shouldUnregister });
29
+
30
+ // assign value to input directly as using "value" prop will reveal password as plain text in "value" attribute in DOM
31
+ // useEffect() is important because on the very first render ref is not defined yet and field initiation won't happen
32
+ useEffect(() => {
33
+ if (inputElement.current) {
34
+ inputElement.current.value = value ? (value as string) : "";
35
+ }
36
+ }, [value]);
37
+
38
+ return (
39
+ <BMPassword
40
+ {...fieldProps}
41
+ {...bmInputProps}
42
+ inputRef={(element: HTMLInputElement) => {
43
+ inputElement.current = element;
44
+ ref(element);
45
+ }}
46
+ error={!!fieldState.error}
47
+ helperText={fieldState.error?.message ?? bmInputProps.helperText}
48
+ />
49
+ );
50
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./BMPassword";
2
+ export * from "./BMPasswordField";
@@ -0,0 +1,43 @@
1
+ import {
2
+ LinearProgress,
3
+ type LinearProgressProps,
4
+ linearProgressClasses,
5
+ styled,
6
+ } from "@mui/material";
7
+ import type { FC } from "react";
8
+
9
+ const BMProgressBar = styled(LinearProgress)(({ theme, color }) => ({
10
+ flexGrow: 1,
11
+ height: theme.spacing(1),
12
+ borderRadius: theme.spacing(0.5),
13
+ backgroundColor: theme.palette.grey[200],
14
+ boxShadow: `inset ${(theme.shape as unknown as Record<string, string>).shadowLight}`,
15
+ [`&.${linearProgressClasses.colorPrimary}`]: {
16
+ boxShadow: ({ flat }: { flat: boolean }) =>
17
+ flat
18
+ ? "none"
19
+ : `inset ${(theme.shape as unknown as Record<string, string>).shadowLight}`,
20
+ },
21
+ [`& .${linearProgressClasses.bar}`]: {
22
+ borderRadius: theme.spacing(0.5),
23
+ backgroundColor: color || theme.palette.primary.main,
24
+ },
25
+ }));
26
+
27
+ export interface ProgressProps {
28
+ color?: LinearProgressProps["color"] | (string & {});
29
+ value?: number;
30
+ }
31
+
32
+ export const BMProgress: FC<ProgressProps> = ({
33
+ color = "primary",
34
+ value = 0,
35
+ }: ProgressProps) => {
36
+ return (
37
+ <BMProgressBar
38
+ variant="determinate"
39
+ value={value}
40
+ color={color as LinearProgressProps["color"]}
41
+ />
42
+ );
43
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMProgress";
@@ -0,0 +1,162 @@
1
+ import {
2
+ FormLabel,
3
+ type InputProps,
4
+ Radio,
5
+ RadioGroup,
6
+ type RadioGroupProps,
7
+ type RadioProps,
8
+ type Theme,
9
+ styled,
10
+ } from "@mui/material";
11
+ import type { FC, ReactNode } from "react";
12
+ import { BMFormControlLabel } from "../BMForm/BMFormControlLabel";
13
+
14
+ const StyledRadio = styled(Radio)(({ theme }) => ({
15
+ "&:hover": {
16
+ backgroundColor: "transparent",
17
+ },
18
+ padding: 0,
19
+ paddingRight: theme.spacing(1),
20
+ }));
21
+
22
+ const iconStyles = (theme: Theme, disabled = false) => ({
23
+ borderRadius: "50%",
24
+ width: theme.spacing(2),
25
+ height: theme.spacing(2),
26
+ boxShadow: `inset 0 0 0 2px ${theme.palette.grey[400]}, inset 0 -1px 0 ${theme.palette.grey[400]}`,
27
+ backgroundColor: disabled ? theme.palette.grey[200] : theme.palette.common.white,
28
+ backgroundImage:
29
+ "linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))",
30
+ });
31
+
32
+ const disabledCheckedIconStyles = (theme: Theme) => ({
33
+ backgroundColor: theme.palette.grey[300],
34
+ backgroundImage:
35
+ "linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))",
36
+ boxShadow: "none",
37
+ "&:before": {
38
+ display: "block",
39
+ width: theme.spacing(2),
40
+ height: theme.spacing(2),
41
+ backgroundImage: `radial-gradient(${theme.palette.grey[200]},${theme.palette.grey[200]} 28%,transparent 32%)`,
42
+ content: '""',
43
+ }
44
+ });
45
+
46
+ const checkedIconStyles = (theme: Theme) => ({
47
+ backgroundColor: theme.palette.primary.main,
48
+ backgroundImage:
49
+ "linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))",
50
+ boxShadow: "none",
51
+ "&:before": {
52
+ display: "block",
53
+ width: theme.spacing(2),
54
+ height: theme.spacing(2),
55
+ backgroundImage: `radial-gradient(${theme.palette.common.white},${theme.palette.common.white} 28%,transparent 32%)`,
56
+ content: '""',
57
+ },
58
+ "input:hover ~ &": {
59
+ backgroundColor: theme.palette.primary.main,
60
+ },
61
+ });
62
+
63
+ const CheckedIcon = styled("span")(({ theme, disabled }: { theme: Theme, disabled: boolean }) => ({
64
+ ...iconStyles(theme),
65
+ ... (disabled ? disabledCheckedIconStyles(theme) : checkedIconStyles(theme)),
66
+ }));
67
+
68
+ const Icon = styled("span")(({ theme, disabled }: { theme: Theme, disabled: boolean }) => ({
69
+ ...iconStyles(theme, disabled),
70
+ }));
71
+
72
+ const StyledFormLabel = styled(FormLabel)(({ theme }) => ({
73
+ ...theme.typography.subtitle2,
74
+ fontWeight: theme.typography.fontWeightMedium as number,
75
+ fontSize: theme.typography.subtitle1.fontSize,
76
+ textTransform: "uppercase",
77
+ marginBottom: theme.spacing(0.5),
78
+ marginTop: theme.spacing(0.5),
79
+ }));
80
+
81
+ export interface BMRadioProps extends RadioProps {
82
+ inputProps?: InputProps["inputProps"]; // override type to make it accept custom attributes like "data-testid"
83
+ label?: string;
84
+ dataTestId: string;
85
+ }
86
+
87
+ export const BMRadio: FC<BMRadioProps> = (props) => {
88
+ const Radio = <StyledRadio
89
+ className={props.className}
90
+ color="default"
91
+ {...props}
92
+ checkedIcon={<CheckedIcon />}
93
+ icon={<Icon />}
94
+ />;
95
+ if (props.label) {
96
+ return (
97
+ <BMFormControlLabel
98
+ control={Radio}
99
+ label={props.label}
100
+ disabled={props.disabled}
101
+ />
102
+ );
103
+ }
104
+ return Radio;
105
+ };
106
+
107
+ export interface OptionProps {
108
+ value: string;
109
+ label: ReactNode;
110
+ disabled?: boolean;
111
+ "data-testid"?: string;
112
+ }
113
+
114
+ export enum RadioOrientation {
115
+ Vertical = "vertical",
116
+ Horizontal = "horizontal",
117
+ }
118
+
119
+ export interface BMRadioGroupProps extends RadioGroupProps {
120
+ label?: ReactNode;
121
+ options: OptionProps[];
122
+ orientation?: RadioOrientation;
123
+ dataTestId: string;
124
+
125
+ }
126
+
127
+ export const BMRadioGroup: FC<BMRadioGroupProps> = ({
128
+ label,
129
+ options = [],
130
+ orientation = RadioOrientation.Vertical,
131
+ className,
132
+ dataTestId,
133
+ ...muiRadioGroupProps
134
+ }) => {
135
+ return (
136
+ <>
137
+ {label && <StyledFormLabel>{label}</StyledFormLabel>}
138
+ <RadioGroup
139
+ className={className}
140
+ sx={
141
+ orientation === "horizontal"
142
+ ? { flexDirection: "row", margin: 0 }
143
+ : {}
144
+ }
145
+ aria-label="radio-group"
146
+ {...muiRadioGroupProps}
147
+ >
148
+ {options.map((option) => (
149
+ <BMFormControlLabel
150
+ key={`form-radio-option-${option.value}`}
151
+ value={option.value}
152
+ control={
153
+ <BMRadio dataTestId={`${dataTestId}-${option['data-testid']}`} inputProps={{ "data-testid": option["data-testid"] }} />
154
+ }
155
+ label={option.label}
156
+ disabled={option.disabled}
157
+ />
158
+ ))}
159
+ </RadioGroup>
160
+ </>
161
+ );
162
+ };
@@ -0,0 +1,40 @@
1
+ import { ReactElement } from "react";
2
+
3
+ import {
4
+ FieldValues,
5
+ useController,
6
+ UseControllerProps,
7
+ } from "react-hook-form";
8
+
9
+ import { BMRadioGroup, BMRadioGroupProps } from "./BMRadio";
10
+
11
+ export type BMRadioGroupFieldProps<T extends FieldValues> = UseControllerProps<T> &
12
+ Omit<BMRadioGroupProps, "value" | "onChange" | "onBlur" | "name">;
13
+
14
+ export const BMRadioGroupField = <T extends FieldValues>(
15
+ props: BMRadioGroupFieldProps<T>
16
+ ): ReactElement => {
17
+ const { name, control, rules, defaultValue, shouldUnregister, ...restProps } =
18
+ props;
19
+
20
+ const { field } = useController({
21
+ name,
22
+ control,
23
+ rules,
24
+ defaultValue,
25
+ shouldUnregister,
26
+ });
27
+
28
+ return (
29
+ <BMRadioGroup
30
+ name={field.name}
31
+ value={field.value ?? ""}
32
+ onChange={field.onChange}
33
+ onBlur={field.onBlur}
34
+ label={restProps.label}
35
+ orientation={restProps.orientation}
36
+ className={restProps.className}
37
+ {...restProps}
38
+ />
39
+ );
40
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./BMRadio";
2
+ export * from "./BMRadioGroupField";
@@ -0,0 +1,70 @@
1
+ import { FC, ReactNode } from "react";
2
+ import {
3
+ TextField,
4
+ StandardTextFieldProps,
5
+ MenuProps,
6
+ SelectProps,
7
+ SlotProps,
8
+ TextFieldOwnerState,
9
+ } from "@mui/material";
10
+ import { BMTooltip } from "../BMTooltip/BMTooltip";
11
+ import CaretDownIcon from "../../assets/icons/caret-down.svg";
12
+
13
+ export type BMSelectProps = {
14
+ tooltip?: ReactNode;
15
+ renderValue?: (value: unknown) => ReactNode;
16
+ menuProps?: Partial<MenuProps>;
17
+ size?: "medium" | "large";
18
+ selectProps?: Partial<
19
+ SlotProps<React.ElementType<SelectProps>, {}, TextFieldOwnerState>
20
+ >;
21
+ dataTestId: string;
22
+ } & Omit<
23
+ StandardTextFieldProps,
24
+ | "variant"
25
+ | "color"
26
+ | "classes"
27
+ | "select"
28
+ | "placeholder"
29
+ | "FormHelperTextProps"
30
+ | "SelectProps"
31
+ >;
32
+
33
+ export const BMSelect: FC<BMSelectProps> = ({
34
+ label,
35
+ tooltip,
36
+ renderValue,
37
+ menuProps,
38
+ selectProps = {},
39
+ dataTestId,
40
+ ...props
41
+ }) => (
42
+ <TextField
43
+ {...props}
44
+ label={
45
+ label ? (
46
+ <>
47
+ {label} {tooltip && <BMTooltip title={tooltip} />}
48
+ </>
49
+ ) : null // don't render <Label> if it's empty
50
+ }
51
+ select
52
+ data-testid={dataTestId}
53
+ slotProps={{
54
+ select: {
55
+ autoWidth: false,
56
+ IconComponent: CaretDownIcon,
57
+ renderValue,
58
+ MenuProps: {
59
+ anchorOrigin: {
60
+ vertical: "bottom",
61
+ horizontal: "left",
62
+ },
63
+ ...menuProps,
64
+ },
65
+ ...selectProps,
66
+ },
67
+ }}
68
+ variant="standard"
69
+ />
70
+ );
@@ -0,0 +1,47 @@
1
+ import { ReactElement } from "react";
2
+
3
+ import {
4
+ FieldValues,
5
+ useController,
6
+ UseControllerProps,
7
+ } from "react-hook-form";
8
+
9
+ import { BMSelect, BMSelectProps } from "./BMSelect";
10
+
11
+ type BMSelectFieldProps<T extends FieldValues> = UseControllerProps<T> &
12
+ BMSelectProps;
13
+
14
+ export const BMSelectField = <T extends FieldValues>(
15
+ props: BMSelectFieldProps<T>
16
+ ): ReactElement => {
17
+ const {
18
+ name,
19
+ rules,
20
+ defaultValue,
21
+ control,
22
+ shouldUnregister,
23
+ children,
24
+ helperText,
25
+ ...bmSelectProps
26
+ } = props;
27
+
28
+ const {
29
+ field: { onChange, onBlur, value, name: fieldName, ref },
30
+ fieldState: { error },
31
+ } = useController({ name, rules, defaultValue, control, shouldUnregister });
32
+
33
+ return (
34
+ <BMSelect
35
+ {...bmSelectProps}
36
+ name={fieldName}
37
+ value={value}
38
+ onChange={onChange}
39
+ onBlur={onBlur}
40
+ inputRef={ref}
41
+ error={!!error}
42
+ helperText={error?.message ?? helperText}
43
+ >
44
+ {children}
45
+ </BMSelect>
46
+ );
47
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./BMSelect";
2
+ export * from "./BMSelectField";
@@ -0,0 +1,16 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { Slider, SliderProps } from "@mui/material";
3
+
4
+ export type Mark = {
5
+ value: number;
6
+ label?: ReactNode;
7
+ };
8
+
9
+ export interface BMSliderProps extends SliderProps {
10
+ marksList: Mark[];
11
+ dataTestId: string;
12
+ }
13
+
14
+ export const BMSlider: FC<BMSliderProps> = ({ marksList, dataTestId, ...props }) => {
15
+ return <Slider valueLabelDisplay="on" marks={[...marksList]} {...props} data-testid={dataTestId} />;
16
+ };
@@ -0,0 +1 @@
1
+ export * from "./BMSlider";
@@ -0,0 +1,185 @@
1
+ import React from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import SuccessIcon from "@coreApp/assets/icons/success-tick.svg";
4
+ import LoadingIcon from "@coreApp/assets/icons/Default-Loading-Circles.svg";
5
+ import FailedIcon from "@coreApp/assets/icons/failed-solid.svg";
6
+ import AlertIcon from "@coreApp/assets/icons/alert.svg";
7
+ import InactiveIcon from "@coreApp/assets/icons/in-active.svg";
8
+ import TimerIcon from "@coreApp/assets/icons/timer.svg";
9
+ import ShieldIcon from "@coreApp/assets/icons/shield.svg";
10
+
11
+ export enum StatusType {
12
+ SUCCESS = "SUCCESS",
13
+ IN_PROGRESS = "IN_PROGRESS",
14
+ PENDING = "PENDING",
15
+ ERROR = "ERROR",
16
+ WARNING = "WARNING",
17
+ INACTIVE = "INACTIVE",
18
+ OTHER = "OTHER",
19
+ }
20
+
21
+ export enum IconPosition {
22
+ PREFIX = "PREFIX",
23
+ SUFFIX = "SUFFIX",
24
+ }
25
+
26
+ export interface BMSmartStatusProps {
27
+ type: StatusType;
28
+ label?: string;
29
+ className?: string;
30
+ iconPosition?: IconPosition;
31
+ }
32
+
33
+ interface StyledProps {
34
+ $type: StatusType;
35
+ }
36
+
37
+ const getStatusContainerStyles = (theme: any, $type: StatusType) => {
38
+ switch ($type) {
39
+ case StatusType.SUCCESS:
40
+ return {
41
+ backgroundColor: theme.palette.success[100],
42
+ color: theme.palette.success[700],
43
+ };
44
+ case StatusType.IN_PROGRESS:
45
+ return {
46
+ backgroundColor: theme.palette.info[200],
47
+ color: theme.palette.primary[700],
48
+ };
49
+ case StatusType.PENDING:
50
+ return {
51
+ backgroundColor: theme.palette.warning[100],
52
+ color: theme.palette.warning[900],
53
+ };
54
+ case StatusType.ERROR:
55
+ return {
56
+ backgroundColor: theme.palette.error[100],
57
+ color: theme.palette.error[700],
58
+ };
59
+ case StatusType.WARNING:
60
+ return {
61
+ backgroundColor: theme.palette.warning[100],
62
+ color: theme.palette.warning[900],
63
+ };
64
+ case StatusType.INACTIVE:
65
+ return {
66
+ backgroundColor: theme.palette.grey[200],
67
+ color: theme.palette.grey[700],
68
+ opacity: 0.7,
69
+ };
70
+ case StatusType.OTHER:
71
+ return {
72
+ backgroundColor: theme.palette.secondary[200],
73
+ color: theme.palette.secondary.main,
74
+ };
75
+ default:
76
+ return {};
77
+ }
78
+ };
79
+
80
+ const StatusContainer = styled("div", {
81
+ shouldForwardProp: (prop) => prop !== '$type',
82
+ })<StyledProps>(({ theme, $type }) => ({
83
+ display: "inline-flex",
84
+ alignItems: "center",
85
+ gap: theme.spacing(0.75),
86
+ padding: theme.spacing(0.5, 1),
87
+ borderRadius: theme.shape.borderRadius - 2,
88
+ fontSize: theme.typography.body2.fontSize,
89
+ fontWeight: 500,
90
+ width: "fit-content",
91
+ ...getStatusContainerStyles(theme, $type),
92
+ }));
93
+
94
+ const getStatusIconStyles = (theme: any, $type: StatusType) => {
95
+ switch ($type) {
96
+ case StatusType.SUCCESS:
97
+ return {
98
+ color: theme.palette.success[500],
99
+ paddingTop: theme.spacing(1),
100
+ width: "10px",
101
+ height: "8px",
102
+ };
103
+ case StatusType.IN_PROGRESS:
104
+ return { color: theme.palette.primary[600] };
105
+ case StatusType.PENDING:
106
+ return { color: theme.palette.warning[500] };
107
+ case StatusType.ERROR:
108
+ return { color: theme.palette.error[500] };
109
+ case StatusType.WARNING:
110
+ return { color: theme.palette.warning[500] };
111
+ case StatusType.OTHER:
112
+ return { color: theme.palette.grey[600] };
113
+ case StatusType.INACTIVE:
114
+ return {
115
+ color: theme.palette.grey[600],
116
+ opacity: 0.7,
117
+ };
118
+ default:
119
+ return {};
120
+ }
121
+ };
122
+
123
+ const StatusIcon = styled("span", {
124
+ shouldForwardProp: (prop) => prop !== '$type',
125
+ })<StyledProps>(({ theme, $type }) => ({
126
+ width: "16px",
127
+ height: "16px",
128
+ display: "inline-flex",
129
+ alignItems: "center",
130
+ justifyContent: "center",
131
+
132
+ "& svg": {
133
+ width: "16px",
134
+ height: "16px",
135
+ },
136
+
137
+ ...getStatusIconStyles(theme, $type),
138
+ }));
139
+
140
+ const getStatusIcon = (type: StatusType) => {
141
+ switch (type) {
142
+ case StatusType.SUCCESS:
143
+ return <SuccessIcon />;
144
+ case StatusType.IN_PROGRESS:
145
+ return <LoadingIcon />;
146
+ case StatusType.PENDING:
147
+ return <TimerIcon />;
148
+ case StatusType.ERROR:
149
+ return <FailedIcon />;
150
+ case StatusType.WARNING:
151
+ return <AlertIcon />;
152
+ case StatusType.INACTIVE:
153
+ return <InactiveIcon />;
154
+ case StatusType.OTHER:
155
+ return <ShieldIcon />;
156
+ default:
157
+ return null;
158
+ }
159
+ };
160
+
161
+ export const BMSmartStatus: React.FC<BMSmartStatusProps> = ({
162
+ type,
163
+ label,
164
+ className,
165
+ iconPosition = IconPosition.SUFFIX,
166
+ }) => {
167
+ const displayLabel =
168
+ label ||
169
+ type
170
+ .split("-")
171
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
172
+ .join(" ");
173
+
174
+ const icon = <StatusIcon $type={type}>{getStatusIcon(type)}</StatusIcon>;
175
+
176
+ return (
177
+ <StatusContainer $type={type} className={className}>
178
+ {iconPosition === IconPosition.PREFIX && icon}
179
+ {displayLabel}
180
+ {iconPosition === IconPosition.SUFFIX && icon}
181
+ </StatusContainer>
182
+ );
183
+ };
184
+
185
+ export default BMSmartStatus;
@@ -0,0 +1 @@
1
+ export * from "./BMSmartStatus";