@registrucentras/rc-ses-react-components 1.6.4 → 1.6.5
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/IconProps.d.ts +2 -0
- package/dist/assets/icons/CheckIcon.d.ts +3 -0
- package/dist/assets/icons/PencilSimpleLineIcon.d.ts +3 -0
- package/dist/components/common/Card/index.d.ts +4 -1
- package/dist/components/form/inputs/Select/Select.types.d.ts +5 -0
- package/dist/components/form/inputs/Select/hooks/useFilteredOptions.d.ts +3 -0
- package/dist/components/form/inputs/Select/hooks/useSelectAllLogic.d.ts +7 -0
- package/dist/components/form/inputs/{Select.d.ts → Select/index.d.ts} +12 -12
- package/dist/library/icons.d.ts +2 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +11 -11
- package/dist/registrucentras-rc-ses-react-components.js +3154 -2747
- package/dist/stories/components/display/Card.stories.d.ts +6 -47
- package/dist/stories/components/display/ImageCard.stories.d.ts +6 -6
- package/dist/stories/components/feedback/Alert.stories.d.ts +7 -16
- package/dist/stories/components/form/CardFormContainer.stories.d.ts +5 -5
- package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -23
- package/dist/stories/components/form/ServiceFormActions.stories.d.ts +3 -9
- package/dist/stories/components/icons/Icons.stories.d.ts +3 -2
- package/dist/stories/components/inputs/FileDropzone.stories.d.ts +3 -29
- package/dist/stories/components/inputs/NumberStepper.stories.d.ts +3 -31
- package/dist/stories/components/inputs/RadioButtonGroup.stories.d.ts +4 -32
- package/dist/stories/components/inputs/SearchableField.stories.d.ts +3 -332
- package/dist/stories/components/inputs/Select.stories.d.ts +4 -871
- package/dist/stories/components/inputs/TextField.stories.d.ts +3 -610
- package/dist/stories/components/layout/Footer.stories.d.ts +3 -5
- package/dist/stories/components/navigation/Breadcrumbs.stories.d.ts +4 -6
- package/dist/stories/components/navigation/ServiceWizardStepper.stories.d.ts +5 -5
- package/package.json +1 -1
- package/src/assets/IconProps.ts +2 -0
- package/src/assets/icons/CheckIcon.tsx +23 -0
- package/src/assets/icons/PencilSimpleLineIcon.tsx +17 -0
- package/src/components/common/Card/index.test.tsx +8 -0
- package/src/components/common/Card/index.tsx +64 -25
- package/src/components/common/SelectableCardList/index.tsx +2 -1
- package/src/components/form/components/FormControlWrapper/index.tsx +6 -1
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +11 -3
- package/src/components/form/inputs/Select/Select.types.ts +5 -0
- package/src/components/form/inputs/Select/hooks/useFilteredOptions.ts +18 -0
- package/src/components/form/inputs/Select/hooks/useSelectAllLogic.ts +22 -0
- package/src/components/form/inputs/Select/index.tsx +494 -0
- package/src/library/icons.ts +2 -0
- package/src/stories/components/display/Card.stories.tsx +64 -47
- package/src/stories/components/display/ImageCard.stories.tsx +29 -27
- package/src/stories/components/feedback/Alert.stories.tsx +59 -50
- package/src/stories/components/form/CardFormContainer.stories.tsx +77 -63
- package/src/stories/components/form/CheckboxFormControl.stories.tsx +29 -71
- package/src/stories/components/form/ServiceFormActions.stories.tsx +18 -21
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -1
- package/src/stories/components/icons/Icons.stories.tsx +6 -2
- package/src/stories/components/inputs/FileDropzone.stories.tsx +17 -34
- package/src/stories/components/inputs/NumberStepper.stories.tsx +32 -60
- package/src/stories/components/inputs/RadioButtonGroup.stories.tsx +22 -20
- package/src/stories/components/inputs/SearchableField.stories.tsx +16 -14
- package/src/stories/components/inputs/Select.stories.tsx +245 -13
- package/src/stories/components/inputs/TextField.stories.tsx +47 -47
- package/src/stories/components/layout/Footer.stories.tsx +6 -6
- package/src/stories/components/navigation/Breadcrumbs.stories.tsx +6 -8
- package/src/stories/components/navigation/ServiceWizardStepper.stories.tsx +29 -22
- package/src/theme/light/MuiAutocomplete.ts +52 -3
- package/src/components/form/inputs/Select.tsx +0 -152
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Meta,
|
|
2
|
-
import { default as RcSesBreadcrumbs
|
|
3
|
-
import { AnnotatedStoryFn } from '@storybook/core/csf';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as RcSesBreadcrumbs } from '../../../components/common/Breadcrumbs';
|
|
4
3
|
declare const meta: Meta<typeof RcSesBreadcrumbs>;
|
|
5
4
|
export default meta;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}>;
|
|
5
|
+
type Story = StoryObj<typeof RcSesBreadcrumbs>;
|
|
6
|
+
export declare const Main: Story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Meta,
|
|
2
|
-
import { default as ServiceWizardStepper
|
|
3
|
-
import { StoryAnnotations } from '@storybook/core/csf';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as ServiceWizardStepper } from '../../../components/layout/ServiceWizardStepper';
|
|
4
3
|
declare const meta: Meta<typeof ServiceWizardStepper>;
|
|
5
4
|
export default meta;
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
5
|
+
type Story = StoryObj<typeof ServiceWizardStepper>;
|
|
6
|
+
export declare const Horizontal: Story;
|
|
7
|
+
export declare const Vertical: Story;
|
package/package.json
CHANGED
package/src/assets/IconProps.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CheckIcon as CheckFillIcon } from '@phosphor-icons/react'
|
|
2
|
+
|
|
3
|
+
import IconProps from '../IconProps'
|
|
4
|
+
|
|
5
|
+
function CheckIcon({
|
|
6
|
+
className,
|
|
7
|
+
fillColor,
|
|
8
|
+
size = 24,
|
|
9
|
+
weight = 'fill',
|
|
10
|
+
...rest
|
|
11
|
+
}: IconProps) {
|
|
12
|
+
return (
|
|
13
|
+
<CheckFillIcon
|
|
14
|
+
{...rest}
|
|
15
|
+
className={className}
|
|
16
|
+
size={size}
|
|
17
|
+
weight={weight}
|
|
18
|
+
color={fillColor}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default CheckIcon
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PencilSimpleLineIcon as PencilSimpleLine } from '@phosphor-icons/react'
|
|
2
|
+
|
|
3
|
+
import IconProps from '../IconProps'
|
|
4
|
+
|
|
5
|
+
function PencilSimpleLineIcon({ className, fillColor, size = 24, ...rest }: IconProps) {
|
|
6
|
+
return (
|
|
7
|
+
<PencilSimpleLine
|
|
8
|
+
{...rest}
|
|
9
|
+
className={className}
|
|
10
|
+
size={size}
|
|
11
|
+
weight='fill'
|
|
12
|
+
color={fillColor}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default PencilSimpleLineIcon
|
|
@@ -16,6 +16,7 @@ describe('RcSesCard', () => {
|
|
|
16
16
|
<RcSesCard
|
|
17
17
|
title='Card title'
|
|
18
18
|
description='Card description'
|
|
19
|
+
headerAction={<button type='button'>Edit</button>}
|
|
19
20
|
leadingActions={<button type='button'>Back</button>}
|
|
20
21
|
trailingActions={<button type='button'>Continue</button>}
|
|
21
22
|
>
|
|
@@ -26,6 +27,7 @@ describe('RcSesCard', () => {
|
|
|
26
27
|
expect(screen.getByText('Card title')).toBeInTheDocument()
|
|
27
28
|
expect(screen.getByText('Card description')).toBeInTheDocument()
|
|
28
29
|
expect(screen.getByText('Card content')).toBeInTheDocument()
|
|
30
|
+
expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument()
|
|
29
31
|
expect(screen.getByRole('button', { name: 'Back' })).toBeInTheDocument()
|
|
30
32
|
expect(screen.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
|
|
31
33
|
})
|
|
@@ -47,6 +49,7 @@ describe('RcSesCard', () => {
|
|
|
47
49
|
<RcSesCard
|
|
48
50
|
title='Slotted title'
|
|
49
51
|
description='Slotted description'
|
|
52
|
+
headerAction={<button type='button'>Edit</button>}
|
|
50
53
|
leadingActions={<button type='button'>Leading</button>}
|
|
51
54
|
trailingActions={<button type='button'>Trailing</button>}
|
|
52
55
|
slotProps={{
|
|
@@ -54,6 +57,7 @@ describe('RcSesCard', () => {
|
|
|
54
57
|
content: { className: 'content-slot' },
|
|
55
58
|
description: { className: 'description-slot' },
|
|
56
59
|
header: { className: 'header-slot' },
|
|
60
|
+
headerAction: { className: 'header-action-slot' },
|
|
57
61
|
leadingActions: { className: 'leading-actions-slot' },
|
|
58
62
|
title: { className: 'title-slot' },
|
|
59
63
|
trailingActions: { className: 'trailing-actions-slot' },
|
|
@@ -64,6 +68,7 @@ describe('RcSesCard', () => {
|
|
|
64
68
|
)
|
|
65
69
|
|
|
66
70
|
expect(container.querySelector('.header-slot')).toBeInTheDocument()
|
|
71
|
+
expect(container.querySelector('.header-action-slot')).toBeInTheDocument()
|
|
67
72
|
expect(container.querySelector('.title-slot')).toBeInTheDocument()
|
|
68
73
|
expect(container.querySelector('.description-slot')).toBeInTheDocument()
|
|
69
74
|
expect(container.querySelector('.content-slot')).toBeInTheDocument()
|
|
@@ -77,11 +82,13 @@ describe('RcSesCard', () => {
|
|
|
77
82
|
<RcSesCard
|
|
78
83
|
title='Test id title'
|
|
79
84
|
description='Test id description'
|
|
85
|
+
headerAction={<button type='button'>Edit</button>}
|
|
80
86
|
leadingActions={<button type='button'>Leading</button>}
|
|
81
87
|
trailingActions={<button type='button'>Trailing</button>}
|
|
82
88
|
testIds={{
|
|
83
89
|
root: 'card-root',
|
|
84
90
|
header: 'card-header',
|
|
91
|
+
headerAction: 'card-header-action',
|
|
85
92
|
title: 'card-title',
|
|
86
93
|
description: 'card-description',
|
|
87
94
|
content: 'card-content',
|
|
@@ -96,6 +103,7 @@ describe('RcSesCard', () => {
|
|
|
96
103
|
|
|
97
104
|
expect(screen.getByTestId('card-root')).toBeInTheDocument()
|
|
98
105
|
expect(screen.getByTestId('card-header')).toBeInTheDocument()
|
|
106
|
+
expect(screen.getByTestId('card-header-action')).toBeInTheDocument()
|
|
99
107
|
expect(screen.getByTestId('card-title')).toBeInTheDocument()
|
|
100
108
|
expect(screen.getByTestId('card-description')).toBeInTheDocument()
|
|
101
109
|
expect(screen.getByTestId('card-content')).toBeInTheDocument()
|
|
@@ -18,6 +18,7 @@ export type RcSesCardTestIds = {
|
|
|
18
18
|
root?: string
|
|
19
19
|
image?: string
|
|
20
20
|
header?: string
|
|
21
|
+
headerAction?: string
|
|
21
22
|
title?: string
|
|
22
23
|
description?: string
|
|
23
24
|
content?: string
|
|
@@ -30,6 +31,7 @@ export type RcSesCardProps = Omit<CardProps, 'children' | 'title'> & {
|
|
|
30
31
|
title: ReactNode
|
|
31
32
|
description?: ReactNode
|
|
32
33
|
image?: ReactNode
|
|
34
|
+
headerAction?: ReactNode
|
|
33
35
|
centered?: boolean
|
|
34
36
|
contentBackground?: boolean
|
|
35
37
|
children?: ReactNode
|
|
@@ -41,6 +43,7 @@ export type RcSesCardProps = Omit<CardProps, 'children' | 'title'> & {
|
|
|
41
43
|
content?: BoxProps
|
|
42
44
|
description?: TypographyProps
|
|
43
45
|
header?: StackProps
|
|
46
|
+
headerAction?: BoxProps
|
|
44
47
|
image?: BoxProps
|
|
45
48
|
leadingActions?: StackProps
|
|
46
49
|
title?: TypographyProps
|
|
@@ -73,6 +76,7 @@ function RcSesCard({
|
|
|
73
76
|
title,
|
|
74
77
|
description,
|
|
75
78
|
image,
|
|
79
|
+
headerAction,
|
|
76
80
|
centered = false,
|
|
77
81
|
contentBackground = true,
|
|
78
82
|
children,
|
|
@@ -87,6 +91,7 @@ function RcSesCard({
|
|
|
87
91
|
const contentProps = slotProps?.content
|
|
88
92
|
const descriptionProps = slotProps?.description
|
|
89
93
|
const headerProps = slotProps?.header
|
|
94
|
+
const headerActionProps = slotProps?.headerAction
|
|
90
95
|
const imageProps = slotProps?.image
|
|
91
96
|
const leadingActionsProps = slotProps?.leadingActions
|
|
92
97
|
const titleProps = slotProps?.title
|
|
@@ -95,6 +100,7 @@ function RcSesCard({
|
|
|
95
100
|
const normalizedSx = normalizeSx(sx)
|
|
96
101
|
const normalizedTitleSx = normalizeSx(titleProps?.sx)
|
|
97
102
|
const normalizedDescriptionSx = normalizeSx(descriptionProps?.sx)
|
|
103
|
+
const normalizedHeaderActionSx = normalizeSx(headerActionProps?.sx)
|
|
98
104
|
const normalizedContentSx = normalizeSx(contentProps?.sx)
|
|
99
105
|
const normalizedActionsSx = normalizeSx(actionsProps?.sx)
|
|
100
106
|
const normalizedImageSx = normalizeSx(imageProps?.sx)
|
|
@@ -135,45 +141,78 @@ function RcSesCard({
|
|
|
135
141
|
) : null}
|
|
136
142
|
|
|
137
143
|
<Stack
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
direction='row'
|
|
145
|
+
sx={{
|
|
146
|
+
alignItems: 'flex-start',
|
|
147
|
+
justifyContent: 'space-between',
|
|
148
|
+
width: '100%',
|
|
149
|
+
}}
|
|
142
150
|
>
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
data-testid={testIds?.
|
|
146
|
-
|
|
147
|
-
{...titleProps}
|
|
151
|
+
<Stack
|
|
152
|
+
{...headerProps}
|
|
153
|
+
data-testid={testIds?.header}
|
|
154
|
+
spacing={0.5}
|
|
148
155
|
sx={[
|
|
149
156
|
{
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
flex: 1,
|
|
158
|
+
minWidth: 0,
|
|
152
159
|
},
|
|
153
|
-
|
|
160
|
+
centered ? { alignItems: 'center' } : {},
|
|
161
|
+
...normalizeSx(headerProps?.sx),
|
|
154
162
|
]}
|
|
155
163
|
>
|
|
156
|
-
{title}
|
|
157
|
-
</Typography>
|
|
158
|
-
|
|
159
|
-
{!!description && (
|
|
160
164
|
<Typography
|
|
161
|
-
color={palette.grey[
|
|
162
|
-
data-testid={testIds?.
|
|
163
|
-
variant='
|
|
164
|
-
{...
|
|
165
|
+
color={palette.grey[900]}
|
|
166
|
+
data-testid={testIds?.title}
|
|
167
|
+
variant='h5'
|
|
168
|
+
{...titleProps}
|
|
165
169
|
sx={[
|
|
166
170
|
{
|
|
167
|
-
|
|
168
|
-
lineHeight: '1.25rem',
|
|
171
|
+
lineHeight: '1.75rem',
|
|
169
172
|
...(centered ? { textAlign: 'center' } : {}),
|
|
170
173
|
},
|
|
171
|
-
...
|
|
174
|
+
...normalizedTitleSx,
|
|
172
175
|
]}
|
|
173
176
|
>
|
|
174
|
-
{
|
|
177
|
+
{title}
|
|
175
178
|
</Typography>
|
|
176
|
-
|
|
179
|
+
|
|
180
|
+
{!!description && (
|
|
181
|
+
<Typography
|
|
182
|
+
color={palette.grey[800]}
|
|
183
|
+
data-testid={testIds?.description}
|
|
184
|
+
variant='body2'
|
|
185
|
+
{...descriptionProps}
|
|
186
|
+
sx={[
|
|
187
|
+
{
|
|
188
|
+
fontWeight: 300,
|
|
189
|
+
lineHeight: '1.25rem',
|
|
190
|
+
...(centered ? { textAlign: 'center' } : {}),
|
|
191
|
+
},
|
|
192
|
+
...normalizedDescriptionSx,
|
|
193
|
+
]}
|
|
194
|
+
>
|
|
195
|
+
{description}
|
|
196
|
+
</Typography>
|
|
197
|
+
)}
|
|
198
|
+
</Stack>
|
|
199
|
+
|
|
200
|
+
{headerAction ? (
|
|
201
|
+
<Box
|
|
202
|
+
{...headerActionProps}
|
|
203
|
+
data-testid={testIds?.headerAction}
|
|
204
|
+
sx={[
|
|
205
|
+
{
|
|
206
|
+
alignItems: 'flex-start',
|
|
207
|
+
display: 'flex',
|
|
208
|
+
flexShrink: 0,
|
|
209
|
+
},
|
|
210
|
+
...normalizedHeaderActionSx,
|
|
211
|
+
]}
|
|
212
|
+
>
|
|
213
|
+
{headerAction}
|
|
214
|
+
</Box>
|
|
215
|
+
) : null}
|
|
177
216
|
</Stack>
|
|
178
217
|
|
|
179
218
|
{children ? (
|
|
@@ -59,7 +59,12 @@ function RcSesFormControlWrapper({
|
|
|
59
59
|
xs: '0 0 0%',
|
|
60
60
|
sm: labelOnTop ? '0 0 0%' : `0 0 ${formControlDesktopLabelWidth}`,
|
|
61
61
|
},
|
|
62
|
-
...(labelOnTop && {
|
|
62
|
+
...(labelOnTop && {
|
|
63
|
+
'&': {
|
|
64
|
+
fontSize: '.8125rem',
|
|
65
|
+
fontWeight: 400,
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
63
68
|
marginBottom: { xs: '.25rem', sm: labelOnTop ? '.25rem' : '0' },
|
|
64
69
|
pr: 3,
|
|
65
70
|
textAlign: { xs: 'left', sm: labelOnTop ? 'left' : 'right' },
|
|
@@ -83,13 +83,21 @@ function RcSesPhoneInputFormControl(props: Props) {
|
|
|
83
83
|
rules: {
|
|
84
84
|
...rules,
|
|
85
85
|
validate: {
|
|
86
|
-
phoneNoFormat: (value) =>
|
|
87
|
-
|
|
86
|
+
phoneNoFormat: (value) => {
|
|
87
|
+
if (typeof value !== 'string') {
|
|
88
|
+
return t('invalid')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return mask.completed(value.replace(country.code ?? '', '')) || t('invalid')
|
|
92
|
+
},
|
|
88
93
|
...rules?.validate,
|
|
89
94
|
},
|
|
90
95
|
},
|
|
91
96
|
})
|
|
92
97
|
|
|
98
|
+
const phoneValue =
|
|
99
|
+
typeof controllerProps.value === 'string' ? controllerProps.value : ''
|
|
100
|
+
|
|
93
101
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null)
|
|
94
102
|
|
|
95
103
|
const handleClick = (e: React.MouseEvent<HTMLElement>) => setAnchorEl(e.currentTarget)
|
|
@@ -172,7 +180,7 @@ function RcSesPhoneInputFormControl(props: Props) {
|
|
|
172
180
|
pattern: '^[0-9\\(\\)\\- ]*$/',
|
|
173
181
|
}}
|
|
174
182
|
placeholder={mask.opts.mask?.toString()}
|
|
175
|
-
value={mask.masked(
|
|
183
|
+
value={mask.masked(phoneValue.replace(country.code ?? '', ''))}
|
|
176
184
|
onChange={(e) =>
|
|
177
185
|
controllerProps.onChange({
|
|
178
186
|
...e,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Option } from '../Select.types'
|
|
4
|
+
|
|
5
|
+
function useFilteredOptions(options: Option[], search: string) {
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
const normalized = search.trim().toLowerCase()
|
|
8
|
+
if (!normalized) return options
|
|
9
|
+
|
|
10
|
+
return options.filter((opt) => {
|
|
11
|
+
const label = opt.label?.toLowerCase() ?? ''
|
|
12
|
+
const desc = opt.description?.toLowerCase() ?? ''
|
|
13
|
+
return label.includes(normalized) || desc.includes(normalized)
|
|
14
|
+
})
|
|
15
|
+
}, [options, search])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default useFilteredOptions
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Option } from '../Select.types'
|
|
2
|
+
|
|
3
|
+
type OnChange = (values: string[]) => void
|
|
4
|
+
|
|
5
|
+
function useSelectAll(options: Option[], selectedValues: string[], onChange: OnChange) {
|
|
6
|
+
const allSelected =
|
|
7
|
+
options.length > 0 && options.every((o) => selectedValues.includes(o.value))
|
|
8
|
+
|
|
9
|
+
const toggle = () => {
|
|
10
|
+
const values = options.map((o) => o.value)
|
|
11
|
+
|
|
12
|
+
if (allSelected) {
|
|
13
|
+
onChange(selectedValues.filter((v) => !values.includes(v)))
|
|
14
|
+
} else {
|
|
15
|
+
onChange(Array.from(new Set([...selectedValues, ...values])))
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return { allSelected, toggle }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default useSelectAll
|