@sonardigital/carbon-ui 1.2.14 → 1.2.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonardigital/carbon-ui",
3
- "version": "1.2.14",
3
+ "version": "1.2.17",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -1,15 +1,7 @@
1
- import {
2
- ClickAwayListener,
3
- IconButton,
4
- Stack,
5
- TextField,
6
- TextFieldProps,
7
- } from '@mui/material';
1
+ import { Stack, TextField, TextFieldProps } from '@mui/material';
8
2
  import { Controller } from 'react-hook-form';
9
3
  import { FormLabel } from '../layout';
10
4
  import { FormError } from '../layout/FormError';
11
- import { useState } from 'react';
12
- import { RiCloseFill } from 'react-icons/ri';
13
5
 
14
6
  interface FormInputProps extends TextFieldProps<'standard'> {
15
7
  name: string;
@@ -21,34 +13,13 @@ export function FormInput({
21
13
  label,
22
14
  ...props
23
15
  }: FormInputProps): React.ReactElement {
24
- const [isFocused, setIsFocused] = useState(false);
25
16
  return (
26
17
  <Controller
27
18
  name={name}
28
19
  render={({ field, fieldState }) => (
29
20
  <FormLabel label={label}>
30
21
  <Stack gap={0.8}>
31
- <ClickAwayListener onClickAway={() => setIsFocused(false)}>
32
- <TextField
33
- {...field}
34
- {...props}
35
- onFocus={() => setIsFocused(true)}
36
- InputProps={{
37
- endAdornment: isFocused && field.value && (
38
- <IconButton
39
- size="medium"
40
- onClick={() => {
41
- field.onChange(undefined);
42
- setIsFocused(false);
43
- }}
44
- >
45
- <RiCloseFill size={18} />
46
- </IconButton>
47
- ),
48
- ...props.InputProps,
49
- }}
50
- />
51
- </ClickAwayListener>
22
+ <TextField {...field} {...props} />
52
23
  {fieldState.error && (
53
24
  <FormError label={fieldState.error?.message ?? ''} />
54
25
  )}
@@ -1,5 +1,10 @@
1
1
  import { Theme } from '@emotion/react';
2
- import { Components, CssVarsTheme, linearProgressClasses } from '@mui/material';
2
+ import {
3
+ ButtonProps,
4
+ Components,
5
+ CssVarsTheme,
6
+ linearProgressClasses,
7
+ } from '@mui/material';
3
8
  import { palette } from './palette';
4
9
 
5
10
  const defaultButtonStyle = {
@@ -13,6 +18,27 @@ const defaultButtonStyle = {
13
18
 
14
19
  const borderRadius = 1;
15
20
 
21
+ const generateButtonVariants = (
22
+ color: Exclude<NonNullable<ButtonProps['color']>, 'inherit'>,
23
+ ) => {
24
+ return {
25
+ props: {
26
+ variant: 'contained' as const,
27
+ color,
28
+ },
29
+ style: ({ theme }: any) => ({
30
+ ...defaultButtonStyle,
31
+ backgroundColor: theme.palette[color].light,
32
+ color: theme.palette[color].main,
33
+ '&:hover': {
34
+ boxShadow: 0,
35
+ backgroundColor: theme.palette[color].main,
36
+ color: 'white',
37
+ },
38
+ }),
39
+ };
40
+ };
41
+
16
42
  export const components: Components<
17
43
  Omit<Theme, 'components' | 'palette'> & CssVarsTheme
18
44
  > = {
@@ -202,7 +228,15 @@ export const components: Components<
202
228
  },
203
229
  },
204
230
  },
205
-
231
+ MuiSkeleton: {
232
+ defaultProps: {
233
+ variant: 'rounded',
234
+ animation: 'wave',
235
+ sx: {
236
+ bgcolor: 'grey.100',
237
+ },
238
+ },
239
+ },
206
240
  MuiAccordionDetails: {
207
241
  defaultProps: {
208
242
  sx: {
@@ -290,54 +324,12 @@ export const components: Components<
290
324
  },
291
325
  MuiButton: {
292
326
  variants: [
293
- {
294
- props: {
295
- variant: 'contained',
296
- color: 'primary',
297
- },
298
- style: ({ theme }) => ({
299
- ...defaultButtonStyle,
300
- backgroundColor: theme.palette.primary.light,
301
- color: theme.palette.primary.main,
302
- '&:hover': {
303
- boxShadow: 0,
304
- backgroundColor: theme.palette.primary.main,
305
- color: 'white',
306
- },
307
- }),
308
- },
309
- {
310
- props: {
311
- variant: 'contained',
312
- color: 'secondary',
313
- },
314
- style: ({ theme }) => ({
315
- ...defaultButtonStyle,
316
- backgroundColor: theme.palette.secondary.light,
317
- color: theme.palette.secondary.main,
318
- '&:hover': {
319
- boxShadow: 0,
320
- backgroundColor: theme.palette.secondary.main,
321
- color: 'white',
322
- },
323
- }),
324
- },
325
- {
326
- props: {
327
- variant: 'contained',
328
- color: 'info',
329
- },
330
- style: ({ theme }) => ({
331
- ...defaultButtonStyle,
332
- paddingTop: 10,
333
- backgroundColor: theme.palette.info.light,
334
- color: theme.palette.info.main,
335
- '&:hover': {
336
- backgroundColor: theme.palette.info.main,
337
- color: 'white',
338
- },
339
- }),
340
- },
327
+ generateButtonVariants('primary'),
328
+ generateButtonVariants('secondary'),
329
+ generateButtonVariants('info'),
330
+ generateButtonVariants('error'),
331
+ generateButtonVariants('success'),
332
+ generateButtonVariants('warning'),
341
333
  {
342
334
  props: {
343
335
  variant: 'text',