@registrucentras/rc-ses-react-components 1.9.0 → 1.11.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/PencilSimpleLineIcon.d.ts +1 -1
- package/dist/components/common/Badge/index.d.ts +10 -0
- package/dist/components/common/SegmentedControl/components/SegmentButton/index.d.ts +19 -0
- package/dist/components/common/SegmentedControl/index.d.ts +14 -0
- package/dist/components/common/Switch/index.d.ts +10 -0
- package/dist/components/form/inputs/SearchInput/index.d.ts +10 -0
- package/dist/library/index.d.ts +5 -1
- package/dist/library/types.d.ts +3 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
- package/dist/registrucentras-rc-ses-react-components.js +2885 -2460
- package/dist/stories/components/display/Badge.stories.d.ts +9 -0
- package/dist/stories/components/display/SegmentedControl.stories.d.ts +202 -0
- package/dist/stories/components/inputs/Switch.stories.d.ts +17 -0
- package/dist/theme/light/MuiSwitch.d.ts +3 -0
- package/package.json +1 -1
- package/src/assets/icons/PencilSimpleLineIcon.tsx +8 -2
- package/src/components/common/Badge/index.test.tsx +129 -0
- package/src/components/common/Badge/index.tsx +162 -0
- package/src/components/common/SegmentedControl/components/SegmentButton/index.test.tsx +85 -0
- package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +110 -0
- package/src/components/common/SegmentedControl/index.test.tsx +164 -0
- package/src/components/common/SegmentedControl/index.tsx +188 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +74 -1
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +16 -1
- package/src/components/common/Switch/index.test.tsx +214 -0
- package/src/components/common/Switch/index.tsx +49 -0
- package/src/components/form/inputs/SearchInput/index.test.tsx +68 -2
- package/src/components/form/inputs/SearchInput/index.tsx +24 -13
- package/src/i18n/namespaces/common/en.json +4 -0
- package/src/i18n/namespaces/common/lt.json +4 -0
- package/src/i18n/namespaces/input/en.json +6 -0
- package/src/i18n/namespaces/input/lt.json +6 -0
- package/src/library/index.ts +6 -0
- package/src/library/types.ts +8 -0
- package/src/stories/components/display/Badge.stories.tsx +165 -0
- package/src/stories/components/display/SegmentedControl.stories.tsx +311 -0
- package/src/stories/components/inputs/Switch.stories.tsx +70 -0
- package/src/theme/light/MuiSwitch.tsx +77 -0
- package/src/theme/light/index.tsx +2 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import RcSesSwitch from './index'
|
|
5
|
+
|
|
6
|
+
describe('RcSesSwitch Component', () => {
|
|
7
|
+
describe('Switch semantics', () => {
|
|
8
|
+
it('should expose role="switch" instead of the native checkbox role', () => {
|
|
9
|
+
render(<RcSesSwitch label='Notifications' checked={false} onChange={vi.fn()} />)
|
|
10
|
+
|
|
11
|
+
expect(screen.getByRole('switch')).toBeInTheDocument()
|
|
12
|
+
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('should reflect the checked state via the native checked attribute', () => {
|
|
16
|
+
render(<RcSesSwitch label='Notifications' checked onChange={vi.fn()} />)
|
|
17
|
+
|
|
18
|
+
expect(screen.getByRole('switch')).toBeChecked()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should update checked state when the checked prop changes', () => {
|
|
22
|
+
const { rerender } = render(
|
|
23
|
+
<RcSesSwitch label='Notifications' checked={false} onChange={vi.fn()} />,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const input = screen.getByRole('switch')
|
|
27
|
+
expect(input).not.toBeChecked()
|
|
28
|
+
|
|
29
|
+
rerender(<RcSesSwitch label='Notifications' checked onChange={vi.fn()} />)
|
|
30
|
+
|
|
31
|
+
expect(input).toBeChecked()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('Accessible name', () => {
|
|
36
|
+
it('should associate the visible label with the switch via FormControlLabel', () => {
|
|
37
|
+
render(<RcSesSwitch label='Notifications' checked={false} onChange={vi.fn()} />)
|
|
38
|
+
|
|
39
|
+
expect(screen.getByRole('switch', { name: 'Notifications' })).toBeInTheDocument()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should use ariaLabel as the accessible name when no visible label is given', () => {
|
|
43
|
+
render(<RcSesSwitch ariaLabel='Notifications' checked={false} onChange={vi.fn()} />)
|
|
44
|
+
|
|
45
|
+
const input = screen.getByRole('switch', { name: 'Notifications' })
|
|
46
|
+
expect(input).toBeInTheDocument()
|
|
47
|
+
expect(screen.queryByText('Notifications')).not.toBeInTheDocument()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should keep the visible label as the accessible name even when ariaLabel is also passed', () => {
|
|
51
|
+
render(
|
|
52
|
+
<RcSesSwitch
|
|
53
|
+
label='Notifications'
|
|
54
|
+
ariaLabel='Enable notifications'
|
|
55
|
+
checked={false}
|
|
56
|
+
onChange={vi.fn()}
|
|
57
|
+
/>,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(screen.getByRole('switch', { name: 'Notifications' })).toBeInTheDocument()
|
|
61
|
+
expect(
|
|
62
|
+
screen.queryByRole('switch', { name: 'Enable notifications' }),
|
|
63
|
+
).not.toBeInTheDocument()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should not set aria-label at all when a visible label is present', () => {
|
|
67
|
+
render(
|
|
68
|
+
<RcSesSwitch
|
|
69
|
+
label='Notifications'
|
|
70
|
+
ariaLabel=''
|
|
71
|
+
checked={false}
|
|
72
|
+
onChange={vi.fn()}
|
|
73
|
+
/>,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const input = screen.getByRole('switch')
|
|
77
|
+
expect(input).not.toHaveAttribute('aria-label')
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('Checked state', () => {
|
|
82
|
+
it('should reflect checked=false', () => {
|
|
83
|
+
render(<RcSesSwitch label='Notifications' checked={false} onChange={vi.fn()} />)
|
|
84
|
+
|
|
85
|
+
expect(screen.getByRole('switch')).not.toBeChecked()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should reflect checked=true', () => {
|
|
89
|
+
render(<RcSesSwitch label='Notifications' checked onChange={vi.fn()} />)
|
|
90
|
+
|
|
91
|
+
expect(screen.getByRole('switch')).toBeChecked()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('should not change visually on click unless the caller updates the checked prop', () => {
|
|
95
|
+
const handleChange = vi.fn()
|
|
96
|
+
render(
|
|
97
|
+
<RcSesSwitch label='Notifications' checked={false} onChange={handleChange} />,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const input = screen.getByRole('switch')
|
|
101
|
+
fireEvent.click(input)
|
|
102
|
+
|
|
103
|
+
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
104
|
+
expect(input).not.toBeChecked()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should support uncontrolled usage via defaultChecked', () => {
|
|
108
|
+
render(<RcSesSwitch label='Notifications' defaultChecked onChange={vi.fn()} />)
|
|
109
|
+
|
|
110
|
+
const input = screen.getByRole('switch')
|
|
111
|
+
expect(input).toBeChecked()
|
|
112
|
+
|
|
113
|
+
fireEvent.click(input)
|
|
114
|
+
|
|
115
|
+
expect(input).not.toBeChecked()
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
describe('onChange', () => {
|
|
120
|
+
it('should call onChange with the new checked value when toggled on', () => {
|
|
121
|
+
const handleChange = vi.fn()
|
|
122
|
+
render(
|
|
123
|
+
<RcSesSwitch label='Notifications' checked={false} onChange={handleChange} />,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
fireEvent.click(screen.getByRole('switch'))
|
|
127
|
+
|
|
128
|
+
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
129
|
+
expect(handleChange.mock.calls[0][1]).toBe(true)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('should call onChange with false when toggled off', () => {
|
|
133
|
+
const handleChange = vi.fn()
|
|
134
|
+
render(<RcSesSwitch label='Notifications' checked onChange={handleChange} />)
|
|
135
|
+
|
|
136
|
+
fireEvent.click(screen.getByRole('switch'))
|
|
137
|
+
|
|
138
|
+
expect(handleChange.mock.calls[0][1]).toBe(false)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('should toggle when the visible label is clicked', () => {
|
|
142
|
+
const handleChange = vi.fn()
|
|
143
|
+
render(
|
|
144
|
+
<RcSesSwitch label='Notifications' checked={false} onChange={handleChange} />,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
fireEvent.click(screen.getByText('Notifications'))
|
|
148
|
+
|
|
149
|
+
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
150
|
+
expect(handleChange.mock.calls[0][1]).toBe(true)
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
describe('Keyboard interaction', () => {
|
|
155
|
+
it('should toggle when Enter is pressed', () => {
|
|
156
|
+
const handleChange = vi.fn()
|
|
157
|
+
render(
|
|
158
|
+
<RcSesSwitch label='Notifications' checked={false} onChange={handleChange} />,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
fireEvent.keyDown(screen.getByRole('switch'), { key: 'Enter' })
|
|
162
|
+
|
|
163
|
+
expect(handleChange).toHaveBeenCalledTimes(1)
|
|
164
|
+
expect(handleChange.mock.calls[0][1]).toBe(true)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('should not toggle on Enter when disabled', () => {
|
|
168
|
+
const handleChange = vi.fn()
|
|
169
|
+
render(
|
|
170
|
+
<RcSesSwitch
|
|
171
|
+
label='Notifications'
|
|
172
|
+
disabled
|
|
173
|
+
checked={false}
|
|
174
|
+
onChange={handleChange}
|
|
175
|
+
/>,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
fireEvent.keyDown(screen.getByRole('switch'), { key: 'Enter' })
|
|
179
|
+
|
|
180
|
+
expect(handleChange).not.toHaveBeenCalled()
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
describe('Disabled state', () => {
|
|
185
|
+
it('should disable the switch when disabled=true', () => {
|
|
186
|
+
render(
|
|
187
|
+
<RcSesSwitch label='Notifications' disabled checked={false} onChange={vi.fn()} />,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
expect(screen.getByRole('switch')).toBeDisabled()
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('should mark the FormControlLabel as disabled', () => {
|
|
194
|
+
const { container } = render(
|
|
195
|
+
<RcSesSwitch label='Notifications' disabled checked={false} onChange={vi.fn()} />,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
expect(container.querySelector('.MuiFormControlLabel-root')).toHaveClass(
|
|
199
|
+
'Mui-disabled',
|
|
200
|
+
)
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
describe('Without a visible label', () => {
|
|
205
|
+
it('should render the bare switch without a wrapping FormControlLabel', () => {
|
|
206
|
+
const { container } = render(
|
|
207
|
+
<RcSesSwitch ariaLabel='Notifications' checked={false} onChange={vi.fn()} />,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
expect(container.querySelector('.MuiFormControlLabel-root')).not.toBeInTheDocument()
|
|
211
|
+
expect(container.querySelector('.MuiSwitch-root')).toBeInTheDocument()
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FormControlLabel, Switch, type SwitchProps } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import palette from '@/theme/palette'
|
|
4
|
+
|
|
5
|
+
export type RcSesSwitchProps = SwitchProps &
|
|
6
|
+
({ label: string; ariaLabel?: string } | { label?: undefined; ariaLabel: string })
|
|
7
|
+
|
|
8
|
+
const formControlLabelStyles = {
|
|
9
|
+
marginLeft: 0,
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
'& .MuiFormControlLabel-label': {
|
|
12
|
+
paddingLeft: '0.625rem',
|
|
13
|
+
},
|
|
14
|
+
'&.Mui-disabled .MuiFormControlLabel-label': {
|
|
15
|
+
color: palette.grey['500'],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function RcSesSwitch(props: RcSesSwitchProps) {
|
|
20
|
+
const { label, ariaLabel, disabled, ...switchProps } = props
|
|
21
|
+
|
|
22
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
23
|
+
if (event.key === 'Enter' && !disabled) {
|
|
24
|
+
event.preventDefault()
|
|
25
|
+
event.currentTarget.click()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const inputProps = {
|
|
30
|
+
...(label === undefined && { 'aria-label': ariaLabel }),
|
|
31
|
+
role: 'switch',
|
|
32
|
+
onKeyDown: handleKeyDown,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const switchEl = <Switch disabled={disabled} inputProps={inputProps} {...switchProps} />
|
|
36
|
+
|
|
37
|
+
return label ? (
|
|
38
|
+
<FormControlLabel
|
|
39
|
+
control={switchEl}
|
|
40
|
+
label={label}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
sx={formControlLabelStyles}
|
|
43
|
+
/>
|
|
44
|
+
) : (
|
|
45
|
+
switchEl
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default RcSesSwitch
|
|
@@ -135,7 +135,7 @@ describe('RcSesSearchInput', () => {
|
|
|
135
135
|
expect(onSearch).not.toHaveBeenCalled()
|
|
136
136
|
})
|
|
137
137
|
|
|
138
|
-
test('
|
|
138
|
+
test('calls onSearch on Enter when search button is enabled', () => {
|
|
139
139
|
const onSearch = vi.fn()
|
|
140
140
|
render(<TestWrapper onSearch={onSearch} defaultValue='hello' />)
|
|
141
141
|
|
|
@@ -143,7 +143,7 @@ describe('RcSesSearchInput', () => {
|
|
|
143
143
|
fireEvent.click(input)
|
|
144
144
|
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', charCode: 13 })
|
|
145
145
|
|
|
146
|
-
expect(onSearch).
|
|
146
|
+
expect(onSearch).toHaveBeenCalledWith('hello')
|
|
147
147
|
})
|
|
148
148
|
|
|
149
149
|
test('does not call onSearch when slotProps.field.onKeyDown calls preventDefault', () => {
|
|
@@ -200,4 +200,70 @@ describe('RcSesSearchInput', () => {
|
|
|
200
200
|
expect(fieldOnChange).toHaveBeenCalled()
|
|
201
201
|
})
|
|
202
202
|
})
|
|
203
|
+
|
|
204
|
+
describe('onSearch callback', () => {
|
|
205
|
+
test('calls onSearch when Enter is pressed', () => {
|
|
206
|
+
const onSearch = vi.fn()
|
|
207
|
+
render(
|
|
208
|
+
<TestWrapper onSearch={onSearch} defaultValue='query' showSearchButton={false} />,
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
const input = screen.getByRole('textbox')
|
|
212
|
+
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', charCode: 13 })
|
|
213
|
+
|
|
214
|
+
expect(onSearch).toHaveBeenCalledWith('query')
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
test('calls onSearch when search button is clicked', () => {
|
|
218
|
+
const onSearch = vi.fn()
|
|
219
|
+
render(<TestWrapper onSearch={onSearch} defaultValue='query' />)
|
|
220
|
+
|
|
221
|
+
const button = screen.getByRole('button', { name: 'searchButtonLabel' })
|
|
222
|
+
fireEvent.click(button)
|
|
223
|
+
|
|
224
|
+
expect(onSearch).toHaveBeenCalledWith('query')
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
test('does not call onSearch when value is empty', () => {
|
|
228
|
+
const onSearch = vi.fn()
|
|
229
|
+
render(<TestWrapper onSearch={onSearch} showSearchButton={false} />)
|
|
230
|
+
|
|
231
|
+
const input = screen.getByRole('textbox')
|
|
232
|
+
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', charCode: 13 })
|
|
233
|
+
|
|
234
|
+
expect(onSearch).not.toHaveBeenCalled()
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
test('does not call parent form onSubmit when nested in a form', () => {
|
|
238
|
+
const parentFormOnSubmit = vi.fn((e) => e.preventDefault())
|
|
239
|
+
const searchOnSearch = vi.fn()
|
|
240
|
+
|
|
241
|
+
const NestedFormWrapper = () => {
|
|
242
|
+
const { control } = useForm({ defaultValues: { search: 'query' } })
|
|
243
|
+
return (
|
|
244
|
+
<ThemeProvider theme={theme}>
|
|
245
|
+
<form onSubmit={parentFormOnSubmit}>
|
|
246
|
+
<RcSesSearchInput
|
|
247
|
+
id='search'
|
|
248
|
+
name='search'
|
|
249
|
+
control={control}
|
|
250
|
+
label='Search'
|
|
251
|
+
errors={undefined}
|
|
252
|
+
onSearch={searchOnSearch}
|
|
253
|
+
showSearchButton={false}
|
|
254
|
+
/>
|
|
255
|
+
</form>
|
|
256
|
+
</ThemeProvider>
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
render(<NestedFormWrapper />)
|
|
261
|
+
|
|
262
|
+
const input = screen.getByRole('textbox')
|
|
263
|
+
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', charCode: 13 })
|
|
264
|
+
|
|
265
|
+
expect(parentFormOnSubmit).not.toHaveBeenCalled()
|
|
266
|
+
expect(searchOnSearch).toHaveBeenCalledWith('query')
|
|
267
|
+
})
|
|
268
|
+
})
|
|
203
269
|
})
|
|
@@ -42,6 +42,16 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Search input component with react-hook-form integration.
|
|
47
|
+
*
|
|
48
|
+
* ⚠️ Warning: This component renders an inner `<form>` element and uses `stopPropagation()`
|
|
49
|
+
* to prevent submit events from bubbling to parent forms. If nested inside another form,
|
|
50
|
+
* React will log a `validateDOMNesting` warning in development mode — this is expected
|
|
51
|
+
* for client-side rendering and does not affect functionality. Note this is not SSR-safe:
|
|
52
|
+
* an HTML parser drops the nested `<form>` tag, so under SSR/hydration the Enter key
|
|
53
|
+
* would submit the parent form instead.
|
|
54
|
+
*/
|
|
45
55
|
const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref) => {
|
|
46
56
|
const [hasSearchAttempted, setHasSearchAttempted] = React.useState(false)
|
|
47
57
|
const internalInputRef = useRef<HTMLInputElement>(null)
|
|
@@ -115,32 +125,31 @@ const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref)
|
|
|
115
125
|
labelOnTop: slotProps?.wrapper?.labelOnTop ?? !sideLabel,
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
const shouldSearchOnEnter =
|
|
119
|
-
!shouldRenderSearchButton || !!mergedSearchButtonProps.disabled
|
|
120
|
-
|
|
121
128
|
const hasSearchValue = `${value ?? ''}`.trim().length > 0
|
|
122
129
|
const visibleErrors = hasSearchAttempted ? errors : undefined
|
|
123
130
|
|
|
124
|
-
const
|
|
131
|
+
const handleFormSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {
|
|
132
|
+
event.preventDefault()
|
|
133
|
+
event.stopPropagation()
|
|
125
134
|
setHasSearchAttempted(true)
|
|
126
|
-
mergedSearchButtonProps.onClick?.(event)
|
|
127
135
|
|
|
128
|
-
if (
|
|
136
|
+
if (hasSearchValue) {
|
|
129
137
|
onSearch(value ?? '')
|
|
138
|
+
} else {
|
|
139
|
+
onBlur()
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
|
|
133
143
|
const handleFieldKeyDown: NonNullable<TFieldProps['onKeyDown']> = (event) => {
|
|
134
144
|
slotProps?.field?.onKeyDown?.(event)
|
|
135
145
|
|
|
136
|
-
if (!event.defaultPrevented &&
|
|
137
|
-
setHasSearchAttempted(true)
|
|
146
|
+
if (!event.defaultPrevented && event.key === 'Enter') {
|
|
138
147
|
event.preventDefault()
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
148
|
+
const form = internalInputRef.current?.form
|
|
149
|
+
if (form?.requestSubmit) {
|
|
150
|
+
form.requestSubmit()
|
|
142
151
|
} else {
|
|
143
|
-
|
|
152
|
+
form?.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true }))
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
}
|
|
@@ -213,6 +222,8 @@ const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref)
|
|
|
213
222
|
{...mergedWrapperProps}
|
|
214
223
|
>
|
|
215
224
|
<Box
|
|
225
|
+
component='form'
|
|
226
|
+
onSubmit={handleFormSubmit}
|
|
216
227
|
sx={{
|
|
217
228
|
alignItems: 'stretch',
|
|
218
229
|
display: 'flex',
|
|
@@ -254,8 +265,8 @@ const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref)
|
|
|
254
265
|
|
|
255
266
|
{shouldRenderSearchButton && (
|
|
256
267
|
<RcSesButton
|
|
268
|
+
type='submit'
|
|
257
269
|
disabled={disabled || mergedSearchButtonProps.disabled || !hasSearchValue}
|
|
258
|
-
onClick={handleSearchClick}
|
|
259
270
|
sx={[
|
|
260
271
|
{
|
|
261
272
|
flexShrink: 0,
|
package/src/library/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import RcSesIconProps from '@/assets/IconProps'
|
|
|
6
6
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
7
7
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
8
8
|
import RcSesAlert from '@/components/common/Alert'
|
|
9
|
+
import RcSesBadge from '@/components/common/Badge'
|
|
9
10
|
import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
10
11
|
import RcSesButton from '@/components/common/Button'
|
|
11
12
|
import RcSesButtonWithPopover from '@/components/common/Button/ButtonWithPopover'
|
|
@@ -14,11 +15,13 @@ import DataPagination from '@/components/common/DataPagination'
|
|
|
14
15
|
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
15
16
|
import RcSesImageCard from '@/components/common/ImageCard'
|
|
16
17
|
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
18
|
+
import RcSesSegmentedControl from '@/components/common/SegmentedControl'
|
|
17
19
|
import RcSesSnackbar from '@/components/common/Snackbar'
|
|
18
20
|
import {
|
|
19
21
|
RcSesSnackbarProvider,
|
|
20
22
|
useSnackbar,
|
|
21
23
|
} from '@/components/common/Snackbar/SnackbarProvider'
|
|
24
|
+
import RcSesSwitch from '@/components/common/Switch'
|
|
22
25
|
import RcSesTab from '@/components/common/Tabs/Tab'
|
|
23
26
|
import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
|
|
24
27
|
import RcSesTabs from '@/components/common/Tabs/Tabs'
|
|
@@ -66,6 +69,7 @@ export { RcSesPalette, RcSesTheme }
|
|
|
66
69
|
export { RcSesAccordion, useAccordionController }
|
|
67
70
|
export {
|
|
68
71
|
RcSesAlert,
|
|
72
|
+
RcSesBadge,
|
|
69
73
|
RcSesBreadcrumbs,
|
|
70
74
|
RcSesButton,
|
|
71
75
|
RcSesButtonWithPopover,
|
|
@@ -79,7 +83,9 @@ export {
|
|
|
79
83
|
RcSesSnackbar,
|
|
80
84
|
RcSesSnackbarProvider,
|
|
81
85
|
RcSesModal,
|
|
86
|
+
RcSesSwitch,
|
|
82
87
|
}
|
|
88
|
+
export { RcSesSegmentedControl }
|
|
83
89
|
export { RcSesCheckbox, RcSesCheckboxFormControl, RcSesSimpleCheckbox }
|
|
84
90
|
export { useSnackbar }
|
|
85
91
|
export { RcSesDatepicker }
|
package/src/library/types.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
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 {
|
|
5
|
+
RcSesSegmentOption,
|
|
6
|
+
RcSesSegmentedControlProps,
|
|
7
|
+
} from '@/components/common/SegmentedControl'
|
|
8
|
+
import { RcSesSegmentButtonProps } from '@/components/common/SegmentedControl/components/SegmentButton'
|
|
4
9
|
import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControlLabel'
|
|
5
10
|
import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
|
|
6
11
|
import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
@@ -28,6 +33,9 @@ export type {
|
|
|
28
33
|
RcSesLoaderSize,
|
|
29
34
|
RcSesCardFormContainerProps,
|
|
30
35
|
RcSesCardProps,
|
|
36
|
+
RcSesSegmentedControlProps,
|
|
37
|
+
RcSesSegmentButtonProps,
|
|
38
|
+
RcSesSegmentOption,
|
|
31
39
|
ServiceWizardStepperProps,
|
|
32
40
|
SimpleCheckboxProps,
|
|
33
41
|
RcSesFormControlLabelProps,
|