@registrucentras/rc-ses-react-components 1.6.6 → 1.7.0
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/dist/assets/icons/SearchHelpIcon.d.ts +3 -0
- package/dist/assets/icons/SearchXIcon.d.ts +3 -0
- package/dist/components/common/Breadcrumbs/index.d.ts +3 -1
- package/dist/components/common/Snackbar/SnackbarProvider.d.ts +22 -0
- package/dist/components/common/Snackbar/config.d.ts +21 -0
- package/dist/components/common/Snackbar/index.d.ts +16 -0
- package/dist/components/common/Snackbar/types.d.ts +2 -0
- package/dist/components/form/inputs/CheckboxFormControl.d.ts +2 -0
- package/dist/components/form/inputs/FormControlLabel.d.ts +10 -0
- package/dist/components/form/inputs/SimpleCheckbox.d.ts +6 -0
- package/dist/components/layout/ServiceHeader.d.ts +2 -1
- package/dist/components/utils/loading.d.ts +3 -0
- package/dist/library/icons.d.ts +4 -1
- package/dist/library/index.d.ts +9 -2
- package/dist/library/types.d.ts +3 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +9 -26
- package/dist/registrucentras-rc-ses-react-components.js +3155 -2755
- package/dist/stories/components/actions/Button.stories.d.ts +5 -0
- package/dist/stories/components/{SelectableCardList.stories.d.ts → display/SelectableCardList.stories.d.ts} +1 -1
- package/dist/stories/components/feedback/Snackbar.stories.d.ts +143 -0
- package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -0
- package/dist/stories/components/form/SimpleCheckbox.stories.d.ts +19 -0
- package/dist/stories/components/layout/ServiceHeader.stories.d.ts +1 -0
- package/dist/theme/light/index.d.ts +6 -0
- package/dist/theme/palette.d.ts +9 -1
- package/package.json +1 -1
- package/src/assets/icons/CheckIcon.tsx +1 -1
- package/src/assets/icons/SearchHelpIcon.tsx +44 -0
- package/src/assets/icons/SearchXIcon.tsx +41 -0
- package/src/components/common/Breadcrumbs/index.tsx +4 -3
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +5 -3
- package/src/components/common/ListWithIcons/index.tsx +1 -1
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +3 -1
- package/src/components/common/Snackbar/SnackbarProvider.tsx +78 -0
- package/src/components/common/Snackbar/config.ts +77 -0
- package/src/components/common/Snackbar/index.test.tsx +119 -0
- package/src/components/common/Snackbar/index.tsx +181 -0
- package/src/components/common/Snackbar/types.ts +2 -0
- package/src/components/form/inputs/Checkbox.tsx +2 -2
- package/src/components/form/inputs/CheckboxFormControl.test.tsx +68 -0
- package/src/components/form/inputs/CheckboxFormControl.tsx +48 -29
- package/src/components/form/inputs/FormControlLabel.tsx +36 -0
- package/src/components/form/inputs/SimpleCheckbox.tsx +23 -0
- package/src/components/layout/ServiceHeader.tsx +22 -8
- package/src/components/utils/loading.tsx +9 -0
- package/src/i18n/namespaces/input/en.json +6 -0
- package/src/i18n/namespaces/input/lt.json +6 -0
- package/src/library/icons.ts +6 -0
- package/src/library/index.ts +13 -1
- package/src/library/types.ts +9 -1
- package/src/stories/Colors.mdx +127 -0
- package/src/stories/components/actions/Button.stories.tsx +130 -0
- package/src/stories/components/{SelectableCardList.stories.tsx → display/SelectableCardList.stories.tsx} +36 -19
- package/src/stories/components/feedback/Snackbar.stories.tsx +504 -0
- package/src/stories/components/form/CheckboxFormControl.stories.tsx +312 -2
- package/src/stories/components/form/SimpleCheckbox.stories.tsx +52 -0
- package/src/stories/components/icons/Icons.stories.tsx +35 -0
- package/src/stories/components/layout/ServiceHeader.stories.tsx +43 -8
- package/src/theme/light/MuiButton.tsx +34 -1
- package/src/theme/light/index.tsx +6 -0
- package/src/theme/light/themePalette.tsx +2 -0
- package/src/theme/palette.tsx +11 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Snackbar as MuiSnackbar,
|
|
4
|
+
Slide,
|
|
5
|
+
Typography,
|
|
6
|
+
useMediaQuery,
|
|
7
|
+
useTheme,
|
|
8
|
+
} from '@mui/material'
|
|
9
|
+
import { useEffect, useState } from 'react'
|
|
10
|
+
import { useTranslation } from 'react-i18next'
|
|
11
|
+
|
|
12
|
+
import CloseIcon from '@/assets/icons/CloseIcon'
|
|
13
|
+
import { grey } from '@/theme/palette'
|
|
14
|
+
|
|
15
|
+
import RcSesButton from '../Button'
|
|
16
|
+
import { SNACKBAR_DURATION, SNACKBAR_ICON_SIZE, sizeConfig, stateConfig } from './config'
|
|
17
|
+
import { type SnackbarSize, type SnackbarState } from './types'
|
|
18
|
+
|
|
19
|
+
export interface RcSesSnackbarProps {
|
|
20
|
+
state: SnackbarState
|
|
21
|
+
message: string
|
|
22
|
+
size?: SnackbarSize
|
|
23
|
+
onAction?: () => void
|
|
24
|
+
actionLabel?: string
|
|
25
|
+
onClose?: () => void
|
|
26
|
+
open?: boolean
|
|
27
|
+
dismissOnAction?: boolean
|
|
28
|
+
duration?: number
|
|
29
|
+
persist?: boolean
|
|
30
|
+
showClose?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function RcSesSnackbar({
|
|
34
|
+
state,
|
|
35
|
+
size = 'standard',
|
|
36
|
+
message,
|
|
37
|
+
onClose,
|
|
38
|
+
onAction,
|
|
39
|
+
dismissOnAction = true,
|
|
40
|
+
actionLabel,
|
|
41
|
+
open: controlledOpen,
|
|
42
|
+
duration = SNACKBAR_DURATION,
|
|
43
|
+
persist: controlledPersist,
|
|
44
|
+
showClose = true,
|
|
45
|
+
}: RcSesSnackbarProps) {
|
|
46
|
+
const theme = useTheme()
|
|
47
|
+
const { t } = useTranslation('input')
|
|
48
|
+
const [internalOpen, setInternalOpen] = useState(controlledOpen ?? true)
|
|
49
|
+
const [isPaused, setIsPaused] = useState(false)
|
|
50
|
+
const persist = controlledPersist ?? state === 'action-needed'
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (controlledOpen !== undefined) {
|
|
54
|
+
setInternalOpen(controlledOpen)
|
|
55
|
+
}
|
|
56
|
+
}, [controlledOpen])
|
|
57
|
+
|
|
58
|
+
const config = stateConfig[state]
|
|
59
|
+
const StateIcon = config.icon
|
|
60
|
+
const isStandard = size === 'standard'
|
|
61
|
+
|
|
62
|
+
const handleClose = () => {
|
|
63
|
+
setInternalOpen(false)
|
|
64
|
+
onClose?.()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleAction = () => {
|
|
68
|
+
onAction?.()
|
|
69
|
+
if (dismissOnAction) handleClose()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)')
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<MuiSnackbar
|
|
76
|
+
open={internalOpen}
|
|
77
|
+
autoHideDuration={persist || isPaused ? null : duration}
|
|
78
|
+
onClose={handleClose}
|
|
79
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
80
|
+
onMouseEnter={() => setIsPaused(true)}
|
|
81
|
+
onMouseLeave={() => setIsPaused(false)}
|
|
82
|
+
onKeyDown={(e) => e.key === 'Escape' && handleClose()}
|
|
83
|
+
TransitionComponent={Slide}
|
|
84
|
+
transitionDuration={prefersReducedMotion ? { enter: 0, exit: 0 } : undefined}
|
|
85
|
+
sx={{
|
|
86
|
+
transition: prefersReducedMotion ? 'none' : `bottom 150ms ease-in-out !important`,
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<Box
|
|
90
|
+
role={config.ariaLive === 'assertive' ? 'alert' : 'status'}
|
|
91
|
+
aria-live={config.ariaLive}
|
|
92
|
+
aria-atomic='true'
|
|
93
|
+
sx={{
|
|
94
|
+
display: 'flex',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
gap: theme.spacing(1),
|
|
97
|
+
width: `${sizeConfig[size].width}px`,
|
|
98
|
+
maxHeight: `${sizeConfig[size].maxHeight}px`,
|
|
99
|
+
backgroundColor: grey['900'],
|
|
100
|
+
color: grey['50'],
|
|
101
|
+
borderRadius: '8px',
|
|
102
|
+
padding: sizeConfig[size].padding,
|
|
103
|
+
opacity: internalOpen ? 1 : 0,
|
|
104
|
+
transition: 'opacity 200ms ease-out',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Box
|
|
108
|
+
sx={{
|
|
109
|
+
flexShrink: 0,
|
|
110
|
+
display: 'flex',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center',
|
|
113
|
+
'& svg': {
|
|
114
|
+
width: `${SNACKBAR_ICON_SIZE.width}px !important`,
|
|
115
|
+
height: `${SNACKBAR_ICON_SIZE.height}px !important`,
|
|
116
|
+
},
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
<StateIcon fillColor={config.color} aria-hidden />
|
|
120
|
+
</Box>
|
|
121
|
+
<Typography
|
|
122
|
+
variant='body2'
|
|
123
|
+
sx={{
|
|
124
|
+
flex: 1,
|
|
125
|
+
minWidth: 0,
|
|
126
|
+
overflow: 'hidden',
|
|
127
|
+
display: '-webkit-box',
|
|
128
|
+
WebkitBoxOrient: 'vertical',
|
|
129
|
+
WebkitLineClamp: 3,
|
|
130
|
+
textOverflow: 'ellipsis',
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{message}
|
|
134
|
+
</Typography>
|
|
135
|
+
<Box sx={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
|
|
136
|
+
{onAction && isStandard && (
|
|
137
|
+
<RcSesButton
|
|
138
|
+
size='small'
|
|
139
|
+
variant='outlined'
|
|
140
|
+
color='light'
|
|
141
|
+
onClick={handleAction}
|
|
142
|
+
sx={{
|
|
143
|
+
textTransform: 'none',
|
|
144
|
+
fontSize: '0.875rem',
|
|
145
|
+
flexShrink: 0,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{actionLabel}
|
|
149
|
+
</RcSesButton>
|
|
150
|
+
)}
|
|
151
|
+
{showClose && (
|
|
152
|
+
<RcSesButton
|
|
153
|
+
variant='outlined'
|
|
154
|
+
color='ghost'
|
|
155
|
+
onClick={handleClose}
|
|
156
|
+
sx={{
|
|
157
|
+
minWidth: 'auto',
|
|
158
|
+
padding: theme.spacing(0.625),
|
|
159
|
+
display: 'flex',
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
justifyContent: 'center',
|
|
162
|
+
width: '34px',
|
|
163
|
+
height: '34px',
|
|
164
|
+
flexShrink: 0,
|
|
165
|
+
'& svg': {
|
|
166
|
+
width: '20px',
|
|
167
|
+
height: '20px',
|
|
168
|
+
},
|
|
169
|
+
}}
|
|
170
|
+
aria-label={t('components.RcSesSnackbar.aria.close')}
|
|
171
|
+
>
|
|
172
|
+
<CloseIcon />
|
|
173
|
+
</RcSesButton>
|
|
174
|
+
)}
|
|
175
|
+
</Box>
|
|
176
|
+
</Box>
|
|
177
|
+
</MuiSnackbar>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default RcSesSnackbar
|
|
@@ -32,7 +32,7 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function RcSesCheckbox(props: Props) {
|
|
35
|
-
const { errors, label, slotProps } = props
|
|
35
|
+
const { errors, label, slotProps, loading } = props
|
|
36
36
|
|
|
37
37
|
// eslint-disable-next-line react/destructuring-assignment
|
|
38
38
|
const id = useMemo(() => props.id ?? uuidv4(), [props.id])
|
|
@@ -44,7 +44,7 @@ function RcSesCheckbox(props: Props) {
|
|
|
44
44
|
required={!!props?.rules?.required}
|
|
45
45
|
{...slotProps?.wrapper}
|
|
46
46
|
>
|
|
47
|
-
<RcSesCheckboxFormControl {...props} id={id} />
|
|
47
|
+
<RcSesCheckboxFormControl {...props} id={id} loading={loading} />
|
|
48
48
|
</RcSesFormControlWrapper>
|
|
49
49
|
)
|
|
50
50
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { useForm } from 'react-hook-form'
|
|
4
|
+
import { describe, expect, test, vi } from 'vitest'
|
|
5
|
+
|
|
6
|
+
import theme from '@/theme/light'
|
|
7
|
+
|
|
8
|
+
import RcSesCheckboxFormControl from './CheckboxFormControl'
|
|
9
|
+
|
|
10
|
+
type WrapperProps = Partial<React.ComponentProps<typeof RcSesCheckboxFormControl>> & {
|
|
11
|
+
defaultValue?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TestWrapper = ({ defaultValue = false, ...props }: WrapperProps) => {
|
|
15
|
+
const { control } = useForm({ defaultValues: { checkbox: defaultValue } })
|
|
16
|
+
return (
|
|
17
|
+
<ThemeProvider theme={theme}>
|
|
18
|
+
<RcSesCheckboxFormControl
|
|
19
|
+
id='checkbox'
|
|
20
|
+
name='checkbox'
|
|
21
|
+
control={control}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
Test Checkbox
|
|
25
|
+
</RcSesCheckboxFormControl>
|
|
26
|
+
</ThemeProvider>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('RcSesCheckboxFormControl - Indeterminate State', () => {
|
|
31
|
+
test('should auto-check parent when all children are checked', () => {
|
|
32
|
+
const { container } = render(<TestWrapper childValues={[true, true, true]} />)
|
|
33
|
+
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
34
|
+
expect(checkbox.checked).toBe(true)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('should auto-uncheck parent when all children are unchecked', () => {
|
|
38
|
+
const { container } = render(<TestWrapper childValues={[false, false, false]} />)
|
|
39
|
+
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
40
|
+
expect(checkbox.checked).toBe(false)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('should call onChildValuesChange with [true, true, true] when clicking parent in indeterminate state', () => {
|
|
44
|
+
const onChildValuesChange = vi.fn()
|
|
45
|
+
const { container } = render(
|
|
46
|
+
<TestWrapper
|
|
47
|
+
childValues={[true, false, true]}
|
|
48
|
+
onChildValuesChange={onChildValuesChange}
|
|
49
|
+
/>,
|
|
50
|
+
)
|
|
51
|
+
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
52
|
+
checkbox.click()
|
|
53
|
+
expect(onChildValuesChange).toHaveBeenCalledWith([true, true, true])
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('should call onChildValuesChange with [false, false, false] when clicking checked parent', () => {
|
|
57
|
+
const onChildValuesChange = vi.fn()
|
|
58
|
+
const { container } = render(
|
|
59
|
+
<TestWrapper
|
|
60
|
+
childValues={[true, true, true]}
|
|
61
|
+
onChildValuesChange={onChildValuesChange}
|
|
62
|
+
/>,
|
|
63
|
+
)
|
|
64
|
+
const checkbox = container.querySelector('input#checkbox') as HTMLInputElement
|
|
65
|
+
checkbox.click()
|
|
66
|
+
expect(onChildValuesChange).toHaveBeenCalledWith([false, false, false])
|
|
67
|
+
})
|
|
68
|
+
})
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FormControlLabel,
|
|
3
2
|
FormControlLabelProps,
|
|
4
3
|
FormLabel,
|
|
5
4
|
Checkbox as MuiCheckbox,
|
|
6
5
|
CheckboxProps as MuiCheckboxProps,
|
|
7
|
-
styled,
|
|
8
6
|
} from '@mui/material'
|
|
9
|
-
import React from 'react'
|
|
7
|
+
import React, { useEffect, useMemo } from 'react'
|
|
10
8
|
import { UseControllerProps, useController } from 'react-hook-form'
|
|
11
9
|
|
|
12
10
|
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
13
11
|
import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
|
|
14
|
-
import
|
|
12
|
+
import RcSesFormControlLabel from '@/components/form/inputs/FormControlLabel'
|
|
13
|
+
import getLoadingIcon from '@/components/utils/loading'
|
|
15
14
|
import palette from '@/theme/palette'
|
|
16
15
|
|
|
17
16
|
import { RcSesFormControlWrapperProps } from '../components/FormControlWrapper'
|
|
@@ -32,6 +31,8 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
32
31
|
children: React.ReactNode
|
|
33
32
|
loading?: boolean
|
|
34
33
|
variant?: 'flat' | 'outlined'
|
|
34
|
+
childValues?: boolean[]
|
|
35
|
+
onChildValuesChange?: (childValues: boolean[]) => void
|
|
35
36
|
slotProps?: {
|
|
36
37
|
field?: Partial<Omit<TFieldProps, ImmediateFieldProps>>
|
|
37
38
|
label?: Partial<FormControlLabelProps>
|
|
@@ -39,46 +40,63 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
const LoadingStateIcon = styled(SpinnerGapBoldIcon)(`
|
|
43
|
-
@keyframes loadingStateIconRotation {
|
|
44
|
-
12.5% { transform: rotateZ( 45deg); }
|
|
45
|
-
25.0% { transform: rotateZ( 90deg); }
|
|
46
|
-
37.5% { transform: rotateZ(135deg); }
|
|
47
|
-
50.0% { transform: rotateZ(180deg); }
|
|
48
|
-
62.5% { transform: rotateZ(225deg); }
|
|
49
|
-
75.0% { transform: rotateZ(270deg); }
|
|
50
|
-
87.5% { transform: rotateZ(315deg); }
|
|
51
|
-
100.0% { transform: rotateZ(360deg); }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
animation-duration: 1s;
|
|
55
|
-
animation-iteration-count: infinite;
|
|
56
|
-
animation-name: loadingStateIconRotation;
|
|
57
|
-
animation-timing-function: step-start;
|
|
58
|
-
box-shadow: none !important;
|
|
59
|
-
`)
|
|
60
|
-
|
|
61
43
|
function RcSesCheckboxFormControl(props: Props) {
|
|
62
|
-
const {
|
|
63
|
-
|
|
44
|
+
const {
|
|
45
|
+
children,
|
|
46
|
+
control,
|
|
47
|
+
disabled,
|
|
48
|
+
id,
|
|
49
|
+
loading,
|
|
50
|
+
name,
|
|
51
|
+
rules,
|
|
52
|
+
slotProps,
|
|
53
|
+
variant,
|
|
54
|
+
childValues = [],
|
|
55
|
+
onChildValuesChange,
|
|
56
|
+
} = props
|
|
64
57
|
|
|
65
58
|
const {
|
|
66
|
-
field: { value, ...controllerProps },
|
|
59
|
+
field: { value, onChange, ...controllerProps },
|
|
67
60
|
} = useController({
|
|
68
61
|
control,
|
|
69
62
|
name,
|
|
70
63
|
rules,
|
|
71
64
|
})
|
|
72
65
|
|
|
66
|
+
const checkedCount = useMemo(() => childValues.filter(Boolean).length, [childValues])
|
|
67
|
+
|
|
68
|
+
const computedIndeterminate = useMemo(
|
|
69
|
+
() => checkedCount > 0 && checkedCount < childValues.length,
|
|
70
|
+
[checkedCount, childValues.length],
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!childValues.length) return
|
|
75
|
+
const expectedValue = checkedCount === childValues.length
|
|
76
|
+
|
|
77
|
+
if (expectedValue !== value) onChange(expectedValue)
|
|
78
|
+
}, [checkedCount, childValues.length, value, onChange])
|
|
79
|
+
|
|
80
|
+
const handleParentChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
81
|
+
const newValue = event.target.checked
|
|
82
|
+
onChange(newValue)
|
|
83
|
+
|
|
84
|
+
if (onChildValuesChange && childValues.length > 0) {
|
|
85
|
+
onChildValuesChange(childValues.map(() => newValue))
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
73
89
|
return (
|
|
74
|
-
<
|
|
90
|
+
<RcSesFormControlLabel
|
|
75
91
|
control={
|
|
76
92
|
<MuiCheckbox
|
|
77
93
|
id={id}
|
|
78
94
|
checked={value === true}
|
|
79
|
-
|
|
95
|
+
indeterminate={computedIndeterminate}
|
|
96
|
+
checkedIcon={getLoadingIcon(<CheckBoldIcon />, loading)}
|
|
80
97
|
disabled={disabled}
|
|
81
|
-
icon={
|
|
98
|
+
icon={getLoadingIcon(<CheckUncheckedBoldIcon />, loading)}
|
|
99
|
+
onChange={handleParentChange}
|
|
82
100
|
{...controllerProps}
|
|
83
101
|
{...slotProps?.field}
|
|
84
102
|
disableRipple
|
|
@@ -94,6 +112,7 @@ function RcSesCheckboxFormControl(props: Props) {
|
|
|
94
112
|
)}
|
|
95
113
|
</FormLabel>
|
|
96
114
|
}
|
|
115
|
+
loading={loading}
|
|
97
116
|
{...slotProps?.label}
|
|
98
117
|
slotProps={{
|
|
99
118
|
typography: {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FormControlLabel, FormControlLabelProps, Skeleton } from '@mui/material'
|
|
2
|
+
import React, { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
export type RcSesFormControlLabelProps = Omit<FormControlLabelProps, 'label'> & {
|
|
5
|
+
loading?: boolean
|
|
6
|
+
label: ReactNode
|
|
7
|
+
skeletonWidth?: number
|
|
8
|
+
skeletonHeight?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function RcSesFormControlLabel({
|
|
12
|
+
loading = false,
|
|
13
|
+
label,
|
|
14
|
+
skeletonWidth = 100,
|
|
15
|
+
skeletonHeight = 20,
|
|
16
|
+
...props
|
|
17
|
+
}: RcSesFormControlLabelProps) {
|
|
18
|
+
return (
|
|
19
|
+
<FormControlLabel
|
|
20
|
+
{...props}
|
|
21
|
+
label={
|
|
22
|
+
loading ? (
|
|
23
|
+
<Skeleton
|
|
24
|
+
width={skeletonWidth}
|
|
25
|
+
height={skeletonHeight}
|
|
26
|
+
sx={{ display: 'inline-block' }}
|
|
27
|
+
/>
|
|
28
|
+
) : (
|
|
29
|
+
label
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default RcSesFormControlLabel
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Checkbox as MuiCheckbox, CheckboxProps as MuiCheckboxProps } from '@mui/material'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
5
|
+
import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
|
|
6
|
+
import getLoadingIcon from '@/components/utils/loading'
|
|
7
|
+
|
|
8
|
+
export type SimpleCheckboxProps = MuiCheckboxProps & {
|
|
9
|
+
loading?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function RcSesSimpleCheckbox({ loading, ...props }: SimpleCheckboxProps) {
|
|
13
|
+
return (
|
|
14
|
+
<MuiCheckbox
|
|
15
|
+
checkedIcon={getLoadingIcon(<CheckBoldIcon />, loading)}
|
|
16
|
+
icon={getLoadingIcon(<CheckUncheckedBoldIcon />, loading)}
|
|
17
|
+
{...props}
|
|
18
|
+
disableRipple
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default RcSesSimpleCheckbox
|
|
@@ -3,16 +3,24 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
5
5
|
import theme from '@/theme/light'
|
|
6
|
-
import Colors from '@/theme/palette'
|
|
6
|
+
import Colors, { common } from '@/theme/palette'
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
9
9
|
breadcrumbsProps: React.ComponentProps<typeof RcSesBreadcrumbs>
|
|
10
10
|
children?: React.ReactNode
|
|
11
11
|
title: string
|
|
12
|
+
backgroundColor?: 'primary' | 'white'
|
|
12
13
|
}
|
|
13
|
-
function ServiceHeader({
|
|
14
|
+
function ServiceHeader({
|
|
15
|
+
breadcrumbsProps,
|
|
16
|
+
children,
|
|
17
|
+
title,
|
|
18
|
+
backgroundColor = 'primary',
|
|
19
|
+
}: Props) {
|
|
20
|
+
const bgColor = backgroundColor === 'white' ? common.white : Colors.primary['50']
|
|
21
|
+
|
|
14
22
|
return (
|
|
15
|
-
<Box sx={{ backgroundColor:
|
|
23
|
+
<Box sx={{ backgroundColor: bgColor }}>
|
|
16
24
|
<Container
|
|
17
25
|
sx={{
|
|
18
26
|
pb: { xs: '2rem', md: '2.25rem' },
|
|
@@ -23,14 +31,19 @@ function ServiceHeader({ breadcrumbsProps, children, title }: Props) {
|
|
|
23
31
|
flexDirection: 'column',
|
|
24
32
|
}}
|
|
25
33
|
>
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
<RcSesBreadcrumbs
|
|
35
|
+
{...breadcrumbsProps}
|
|
36
|
+
sx={{
|
|
37
|
+
pb: { xs: '.25rem', md: '.5rem' },
|
|
38
|
+
fontSize: '0.75rem',
|
|
39
|
+
lineHeight: '1.25rem',
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
29
42
|
|
|
30
43
|
<Typography
|
|
31
44
|
variant='h1'
|
|
32
45
|
sx={{
|
|
33
|
-
lineHeight: { xs: '2rem', md: '2.
|
|
46
|
+
lineHeight: { xs: '2rem', md: '2.5rem' },
|
|
34
47
|
}}
|
|
35
48
|
>
|
|
36
49
|
{title}
|
|
@@ -45,7 +58,8 @@ function ServiceHeader({ breadcrumbsProps, children, title }: Props) {
|
|
|
45
58
|
rowGap: '10px',
|
|
46
59
|
|
|
47
60
|
'.MuiTypography-body1': {
|
|
48
|
-
|
|
61
|
+
fontSize: '1rem',
|
|
62
|
+
lineHeight: '1.5rem',
|
|
49
63
|
|
|
50
64
|
[theme.breakpoints.down('md')]: {
|
|
51
65
|
fontSize: '.8125rem',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Skeleton } from '@mui/material'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
const LOADING_SKELETON = <Skeleton variant='rounded' width={20} height={20} />
|
|
5
|
+
|
|
6
|
+
const getLoadingIcon = (fallback: React.ReactNode, loading?: boolean) =>
|
|
7
|
+
loading ? LOADING_SKELETON : fallback
|
|
8
|
+
|
|
9
|
+
export default getLoadingIcon
|
package/src/library/icons.ts
CHANGED
|
@@ -14,6 +14,7 @@ import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
|
|
|
14
14
|
import CaretRightBoldIcon from '@/assets/icons/CaretRightBoldIcon'
|
|
15
15
|
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
16
16
|
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
17
|
+
import CheckIcon from '@/assets/icons/CheckIcon'
|
|
17
18
|
import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
|
|
18
19
|
import CircleFilledIcon from '@/assets/icons/CircleFilledIcon'
|
|
19
20
|
import CloseIcon from '@/assets/icons/CloseIcon'
|
|
@@ -30,6 +31,8 @@ import QuestionFillIcon from '@/assets/icons/QuestionFillIcon'
|
|
|
30
31
|
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
31
32
|
import ScalesIcon from '@/assets/icons/ScalesIcon'
|
|
32
33
|
import ScrollIcon from '@/assets/icons/ScrollIcon'
|
|
34
|
+
import SearchHelpIcon from '@/assets/icons/SearchHelpIcon'
|
|
35
|
+
import SearchXIcon from '@/assets/icons/SearchXIcon'
|
|
33
36
|
import SpinnerGapBoldIcon from '@/assets/icons/SpinnerGapBoldIcon'
|
|
34
37
|
import UploadSimpleIcon from '@/assets/icons/UploadSimpleIcon'
|
|
35
38
|
import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
|
|
@@ -54,6 +57,7 @@ export {
|
|
|
54
57
|
CaretRightBoldIcon,
|
|
55
58
|
CheckBoldIcon,
|
|
56
59
|
CheckCircleFillIcon,
|
|
60
|
+
CheckIcon,
|
|
57
61
|
CheckUncheckedBoldIcon,
|
|
58
62
|
CircleFilledIcon,
|
|
59
63
|
CloseIcon,
|
|
@@ -70,6 +74,8 @@ export {
|
|
|
70
74
|
QuestionIcon,
|
|
71
75
|
ScalesIcon,
|
|
72
76
|
ScrollIcon,
|
|
77
|
+
SearchHelpIcon,
|
|
78
|
+
SearchXIcon,
|
|
73
79
|
SpinnerGapBoldIcon,
|
|
74
80
|
UploadSimpleIcon,
|
|
75
81
|
WarningDiamondFillIcon,
|
package/src/library/index.ts
CHANGED
|
@@ -14,6 +14,11 @@ import DataPagination from '@/components/common/DataPagination'
|
|
|
14
14
|
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
15
15
|
import RcSesImageCard from '@/components/common/ImageCard'
|
|
16
16
|
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
17
|
+
import RcSesSnackbar from '@/components/common/Snackbar'
|
|
18
|
+
import {
|
|
19
|
+
RcSesSnackbarProvider,
|
|
20
|
+
useSnackbar,
|
|
21
|
+
} from '@/components/common/Snackbar/SnackbarProvider'
|
|
17
22
|
import RcSesTab from '@/components/common/Tabs/Tab'
|
|
18
23
|
import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
|
|
19
24
|
import RcSesTabs from '@/components/common/Tabs/Tabs'
|
|
@@ -24,6 +29,7 @@ import RcSesCheckboxFormControl from '@/components/form/inputs/CheckboxFormContr
|
|
|
24
29
|
import RcSesDatepicker from '@/components/form/inputs/Datepicker'
|
|
25
30
|
import RcSesFileDropzone from '@/components/form/inputs/FileDropzone'
|
|
26
31
|
import RcSesFileUpload from '@/components/form/inputs/FileUpload'
|
|
32
|
+
import RcSesFormControlLabel from '@/components/form/inputs/FormControlLabel'
|
|
27
33
|
import RcSesNumberStepper from '@/components/form/inputs/NumberStepper'
|
|
28
34
|
import RcSesPhoneInput from '@/components/form/inputs/PhoneInput'
|
|
29
35
|
import RcSesPhoneInputFormControl from '@/components/form/inputs/PhoneInputFormControl'
|
|
@@ -31,6 +37,7 @@ import RcSesRadioButtonGroup from '@/components/form/inputs/RadioButtonGroup'
|
|
|
31
37
|
import RcSesSearchInput from '@/components/form/inputs/SearchInput'
|
|
32
38
|
import RcSesSearchableField from '@/components/form/inputs/SearchableField'
|
|
33
39
|
import RcSesSelect from '@/components/form/inputs/Select'
|
|
40
|
+
import RcSesSimpleCheckbox from '@/components/form/inputs/SimpleCheckbox'
|
|
34
41
|
import RcSesTextField from '@/components/form/inputs/TextField'
|
|
35
42
|
import RcSesFooter from '@/components/layout/Footer'
|
|
36
43
|
import RcSesServiceFormActions from '@/components/layout/ServiceFormActions'
|
|
@@ -60,8 +67,11 @@ export {
|
|
|
60
67
|
RcSesCard,
|
|
61
68
|
RcSesFooter,
|
|
62
69
|
RcSesImageCard,
|
|
70
|
+
RcSesSnackbar,
|
|
71
|
+
RcSesSnackbarProvider,
|
|
63
72
|
}
|
|
64
|
-
export { RcSesCheckbox, RcSesCheckboxFormControl }
|
|
73
|
+
export { RcSesCheckbox, RcSesCheckboxFormControl, RcSesSimpleCheckbox }
|
|
74
|
+
export { useSnackbar }
|
|
65
75
|
export { RcSesDatepicker }
|
|
66
76
|
export { RcSesFileUpload }
|
|
67
77
|
export { RcSesFileDropzone }
|
|
@@ -76,8 +86,10 @@ export { RcSesTextField }
|
|
|
76
86
|
export { DataPagination }
|
|
77
87
|
export { ListWithIcons }
|
|
78
88
|
export { ServiceWizardStepper }
|
|
89
|
+
export { RcSesFormControlLabel }
|
|
79
90
|
export { SelectableCardList }
|
|
80
91
|
export type * from './types'
|
|
92
|
+
export type { SnackbarSize, SnackbarState } from '@/components/common/Snackbar/types'
|
|
81
93
|
|
|
82
94
|
export {
|
|
83
95
|
RcSesServiceFormActions,
|
package/src/library/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RcSesCardProps } from '@/components/common/Card'
|
|
2
2
|
import { ListWithIconsProps } from '@/components/common/ListWithIcons'
|
|
3
3
|
import { ListWithIconsItemData } from '@/components/common/ListWithIcons/ListWithIcons.types'
|
|
4
|
+
import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControlLabel'
|
|
5
|
+
import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
|
|
4
6
|
import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
5
7
|
import { ServiceWizardStepperProps } from '@/components/layout/ServiceWizardStepper'
|
|
6
8
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
@@ -8,4 +10,10 @@ import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
|
8
10
|
export type { ListWithIconsProps, ListWithIconsItemData }
|
|
9
11
|
export type { ButtonProps }
|
|
10
12
|
|
|
11
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
RcSesCardFormContainerProps,
|
|
15
|
+
RcSesCardProps,
|
|
16
|
+
ServiceWizardStepperProps,
|
|
17
|
+
SimpleCheckboxProps,
|
|
18
|
+
RcSesFormControlLabelProps,
|
|
19
|
+
}
|