@registrucentras/rc-ses-react-components 2.0.0-rc.7 → 2.0.0-rc.8
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/components/common/Accordion/hooks/useAccordionController.d.ts +2 -2
- package/dist/components/common/Accordion/types/AccordionControllerState.d.ts +2 -2
- package/dist/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.d.ts +2 -2
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.d.ts +2 -2
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.d.ts +2 -2
- package/dist/components/common/Badge/index.d.ts +2 -2
- package/dist/components/common/Breadcrumbs/index.d.ts +4 -4
- package/dist/components/common/Card/index.d.ts +2 -2
- package/dist/components/common/CardShell/CardFooter/index.d.ts +1 -1
- package/dist/components/common/CardShell/CardFooter/types.d.ts +4 -9
- package/dist/components/common/CardShell/types.d.ts +4 -4
- package/dist/components/common/IconWithCircularBackground.d.ts +2 -2
- package/dist/components/common/IconWithSquareBackground/index.d.ts +2 -2
- package/dist/components/common/ImageCard/index.d.ts +2 -2
- package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +2 -2
- package/dist/components/common/SelectableCardList/index.d.ts +2 -2
- package/dist/components/common/ServiceLinks/types.d.ts +6 -6
- package/dist/components/common/SideNav/SideNav.types.d.ts +7 -5
- package/dist/components/common/SideNav/SideNavLayout.d.ts +1 -1
- package/dist/components/common/SideNav/components/SideNavPill.d.ts +2 -2
- package/dist/components/common/SideNav/components/SideNavPillList.d.ts +2 -2
- package/dist/components/common/SideNav/components/SideNavRow.d.ts +4 -3
- package/dist/components/common/SideNav/hooks/useKeepActiveItemInView.d.ts +19 -0
- package/dist/components/common/SideNav/hooks/useSideNavScrollSpy.d.ts +2 -2
- package/dist/components/common/SideNav/index.d.ts +2 -2
- package/dist/components/common/Tabs/TabPanel.d.ts +2 -2
- package/dist/components/common/Tabs/TabsWrapper.d.ts +2 -2
- package/dist/components/common/TitleBlock/types.d.ts +4 -4
- package/dist/components/form/components/FormControlWrapper/components/FieldSuffix.d.ts +2 -2
- package/dist/components/form/components/FormControlWrapper/index.d.ts +2 -2
- package/dist/components/form/inputs/RadioButtonGroup.d.ts +3 -3
- package/dist/components/form/inputs/SearchableField.d.ts +2 -2
- package/dist/components/form/inputs/Select/Select.types.d.ts +2 -2
- package/dist/components/layout/Footer/index.d.ts +2 -2
- package/dist/components/layout/ServiceFormActions.d.ts +2 -2
- package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.d.ts +2 -2
- package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/index.d.ts +2 -2
- package/dist/components/layout/ServiceHeader.d.ts +2 -2
- package/dist/components/layout/ServicePage.d.ts +2 -2
- package/dist/components/utils/normalizeSx.d.ts +1 -1
- package/dist/library/types.d.ts +2 -2
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +1631 -1589
- package/dist/types/assets/IconProps.d.ts +2 -2
- package/dist/types/cards/CardServiceProps.d.ts +2 -2
- package/dist/types/common/QuickLinkType.d.ts +2 -2
- package/dist/types/inputs/InputIconProps.d.ts +2 -2
- package/dist/types/lists/ListNewsItemType.d.ts +2 -2
- package/dist/types/lists/ListServicesItemType.d.ts +3 -3
- package/package.json +2 -1
- package/src/components/common/Accordion/hooks/useAccordionController.tsx +1 -1
- package/src/components/common/Accordion/index.tsx +1 -4
- package/src/components/common/Accordion/types/AccordionControllerState.ts +1 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.ts +1 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +1 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +1 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +2 -2
- package/src/components/common/Badge/index.tsx +3 -3
- package/src/components/common/Breadcrumbs/index.tsx +5 -2
- package/src/components/common/Card/index.tsx +1 -1
- package/src/components/common/CardShell/CardFooter/index.tsx +6 -13
- package/src/components/common/CardShell/CardFooter/types.ts +2 -7
- package/src/components/common/CardShell/types.ts +2 -2
- package/src/components/common/IconWithCircularBackground.tsx +7 -8
- package/src/components/common/IconWithSquareBackground/index.tsx +7 -8
- package/src/components/common/ImageCard/index.tsx +1 -1
- package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +18 -19
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +1 -1
- package/src/components/common/SelectableCardList/index.tsx +1 -1
- package/src/components/common/ServiceLinks/types.ts +3 -3
- package/src/components/common/SideNav/SideNav.types.ts +11 -3
- package/src/components/common/SideNav/SideNavLayout.tsx +3 -0
- package/src/components/common/SideNav/components/SideNavPill.tsx +1 -1
- package/src/components/common/SideNav/components/SideNavPillList.tsx +8 -23
- package/src/components/common/SideNav/components/SideNavRow.tsx +6 -2
- package/src/components/common/SideNav/hooks/useKeepActiveItemInView.test.ts +258 -0
- package/src/components/common/SideNav/hooks/useKeepActiveItemInView.ts +80 -0
- package/src/components/common/SideNav/hooks/useSideNavScrollSpy.test.ts +9 -2
- package/src/components/common/SideNav/hooks/useSideNavScrollSpy.ts +4 -3
- package/src/components/common/SideNav/index.test.tsx +51 -0
- package/src/components/common/SideNav/index.tsx +47 -12
- package/src/components/common/Snackbar/index.test.tsx +40 -0
- package/src/components/common/Snackbar/index.tsx +9 -3
- package/src/components/common/Tabs/TabPanel.tsx +1 -1
- package/src/components/common/Tabs/TabsWrapper.tsx +1 -1
- package/src/components/common/TitleBlock/index.test.tsx +9 -7
- package/src/components/common/TitleBlock/index.tsx +13 -9
- package/src/components/common/TitleBlock/types.ts +2 -2
- package/src/components/form/components/FormControlWrapper/components/FieldSuffix.tsx +1 -1
- package/src/components/form/components/FormControlWrapper/index.tsx +1 -1
- package/src/components/form/inputs/Datepicker/index.test.tsx +1 -1
- package/src/components/form/inputs/FileDropzone.tsx +1 -4
- package/src/components/form/inputs/NumberStepper.test.tsx +83 -0
- package/src/components/form/inputs/NumberStepper.tsx +7 -8
- package/src/components/form/inputs/RadioButtonGroup.test.tsx +1 -1
- package/src/components/form/inputs/RadioButtonGroup.tsx +2 -2
- package/src/components/form/inputs/SearchInput/index.tsx +1 -1
- package/src/components/form/inputs/SearchableField.test.tsx +2 -2
- package/src/components/form/inputs/SearchableField.tsx +1 -1
- package/src/components/form/inputs/Select/Select.types.ts +1 -1
- package/src/components/form/inputs/Select/index.test.tsx +3 -3
- package/src/components/layout/Footer/index.tsx +1 -1
- package/src/components/layout/ServiceFormActions.tsx +1 -1
- package/src/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.tsx +1 -1
- package/src/components/layout/ServiceFormContainer/AccordionFormContainer/index.tsx +1 -1
- package/src/components/layout/ServiceHeader.tsx +1 -1
- package/src/components/layout/ServicePage.tsx +1 -1
- package/src/components/utils/normalizeSx.ts +2 -4
- package/src/examples/ListWithPagination/index.tsx +0 -2
- package/src/examples/MultipleStepForm/components/AdditionalServicesForm.tsx +1 -1
- package/src/examples/MultipleStepForm/components/ServiceIssuanceForm.tsx +1 -1
- package/src/examples/MultipleStepForm/components/TermsAndConditionsForm.tsx +1 -1
- package/src/examples/MultipleStepForm/types/MultiStepFormModel.ts +1 -1
- package/src/examples/SingleStepForm/components/ObjectIdentifierSearchModal.tsx +2 -2
- package/src/examples/SingleStepForm/types/SingleStepFormModel.ts +1 -1
- package/src/library/types.ts +2 -1
- package/src/stories/atoms/Button.stories.tsx +9 -14
- package/src/stories/atoms/Checkbox.stories.tsx +1 -1
- package/src/stories/atoms/Icons.stories.tsx +1 -1
- package/src/stories/atoms/NumberStepper.stories.tsx +1 -1
- package/src/stories/atoms/PhoneInput.stories.tsx +1 -1
- package/src/stories/atoms/Select.stories.tsx +7 -9
- package/src/stories/atoms/Switch.stories.tsx +1 -1
- package/src/stories/molecules/Alert.stories.tsx +2 -2
- package/src/stories/molecules/CardShell.stories.tsx +4 -4
- package/src/stories/molecules/CheckboxFormControl.stories.tsx +13 -21
- package/src/stories/molecules/RadioButtonGroup.stories.tsx +1 -1
- package/src/stories/molecules/Snackbar.stories.tsx +2 -2
- package/src/stories/molecules/TitleBlock.stories.tsx +40 -1
- package/src/stories/organisms/AdvancedList.stories.tsx +4 -4
- package/src/stories/organisms/FileDropzone.stories.tsx +1 -1
- package/src/stories/organisms/FileUpload.stories.tsx +1 -1
- package/src/stories/organisms/SideNav.stories.tsx +36 -3
- package/src/stubs/Component.tsx +4 -4
- package/src/types/assets/IconProps.tsx +1 -1
- package/src/types/cards/CardServiceProps.tsx +1 -1
- package/src/types/common/QuickLinkType.tsx +1 -1
- package/src/types/inputs/InputIconProps.tsx +1 -1
- package/src/types/lists/ListNewsItemType.tsx +1 -1
- package/src/types/lists/ListServicesItemType.tsx +2 -2
- package/src/vite-env.d.ts +2 -2
- package/dist/stories/atoms/Badge.stories.d.ts +0 -9
- package/dist/stories/atoms/Button.stories.d.ts +0 -107
- package/dist/stories/atoms/Checkbox.stories.d.ts +0 -21
- package/dist/stories/atoms/IconWithCircularBackground.stories.d.ts +0 -6
- package/dist/stories/atoms/IconWithSquareBackground.stories.d.ts +0 -7
- package/dist/stories/atoms/Icons.stories.d.ts +0 -7
- package/dist/stories/atoms/Loader.stories.d.ts +0 -36
- package/dist/stories/atoms/LoadingSpinner.stories.d.ts +0 -62
- package/dist/stories/atoms/Logo.stories.d.ts +0 -12
- package/dist/stories/atoms/NumberStepper.stories.d.ts +0 -6
- package/dist/stories/atoms/PhoneInput.stories.d.ts +0 -10
- package/dist/stories/atoms/SearchInput.stories.d.ts +0 -11
- package/dist/stories/atoms/Select.stories.d.ts +0 -7
- package/dist/stories/atoms/SimpleCheckbox.stories.d.ts +0 -19
- package/dist/stories/atoms/Switch.stories.d.ts +0 -17
- package/dist/stories/atoms/Tab.stories.d.ts +0 -8
- package/dist/stories/atoms/TextField.stories.d.ts +0 -6
- package/dist/stories/atoms/Tooltip.stories.d.ts +0 -48
- package/dist/stories/foundations/ThemedMuiComponents.stories.d.ts +0 -25
- package/dist/stories/molecules/Alert.stories.d.ts +0 -14
- package/dist/stories/molecules/Breadcrumbs.stories.d.ts +0 -6
- package/dist/stories/molecules/ButtonWithPopover.stories.d.ts +0 -7
- package/dist/stories/molecules/Card.stories.d.ts +0 -8
- package/dist/stories/molecules/CardShell.stories.d.ts +0 -18
- package/dist/stories/molecules/CheckboxFormControl.stories.d.ts +0 -9
- package/dist/stories/molecules/DatePicker.stories.d.ts +0 -152
- package/dist/stories/molecules/FormControlWrapper.stories.d.ts +0 -7
- package/dist/stories/molecules/ImageCard.stories.d.ts +0 -8
- package/dist/stories/molecules/ListWithIcons.stories.d.ts +0 -34
- package/dist/stories/molecules/PhoneInputFormControl.stories.d.ts +0 -6
- package/dist/stories/molecules/Popover.stories.d.ts +0 -12
- package/dist/stories/molecules/RadioButtonGroup.stories.d.ts +0 -6
- package/dist/stories/molecules/SearchableField.stories.d.ts +0 -6
- package/dist/stories/molecules/SegmentedControl.stories.d.ts +0 -202
- package/dist/stories/molecules/Snackbar.stories.d.ts +0 -143
- package/dist/stories/molecules/TabPanel.stories.d.ts +0 -7
- package/dist/stories/molecules/Tabs.stories.d.ts +0 -7
- package/dist/stories/molecules/TabsWrapper.stories.d.ts +0 -6
- package/dist/stories/molecules/TitleBlock.stories.d.ts +0 -22
- package/dist/stories/organisms/Accordion.stories.d.ts +0 -18
- package/dist/stories/organisms/AdvancedList.stories.d.ts +0 -33
- package/dist/stories/organisms/AdvancedListItem.stories.d.ts +0 -33
- package/dist/stories/organisms/CardFormContainer.stories.d.ts +0 -7
- package/dist/stories/organisms/DataPagination.stories.d.ts +0 -47
- package/dist/stories/organisms/Dialog.stories.d.ts +0 -15
- package/dist/stories/organisms/FileDropzone.stories.d.ts +0 -6
- package/dist/stories/organisms/FileUpload.stories.d.ts +0 -18
- package/dist/stories/organisms/Footer.stories.d.ts +0 -6
- package/dist/stories/organisms/FullPageLoader.stories.d.ts +0 -37
- package/dist/stories/organisms/Modal.stories.d.ts +0 -10
- package/dist/stories/organisms/SelectableCardList.stories.d.ts +0 -37
- package/dist/stories/organisms/ServiceFormActions.stories.d.ts +0 -6
- package/dist/stories/organisms/ServiceFormContainer.stories.d.ts +0 -15
- package/dist/stories/organisms/ServiceHeader.stories.d.ts +0 -7
- package/dist/stories/organisms/ServiceLinks.stories.d.ts +0 -28
- package/dist/stories/organisms/ServiceWizardStepper.stories.d.ts +0 -7
- package/dist/stories/organisms/SideNav.stories.d.ts +0 -7
- package/dist/stories/templates/ServicePage.stories.d.ts +0 -6
|
@@ -4,7 +4,7 @@ import RcSesBadge from '@/components/common/Badge'
|
|
|
4
4
|
import cards from '@/theme/cards'
|
|
5
5
|
import palette from '@/theme/palette'
|
|
6
6
|
|
|
7
|
-
import { RcSesTitleBlockProps } from './types'
|
|
7
|
+
import { RcSesTitleBlockProps, TitleBlockHeadingLevel } from './types'
|
|
8
8
|
|
|
9
9
|
function RcSesTitleBlock({
|
|
10
10
|
title,
|
|
@@ -20,7 +20,10 @@ function RcSesTitleBlock({
|
|
|
20
20
|
className,
|
|
21
21
|
testIds,
|
|
22
22
|
}: RcSesTitleBlockProps) {
|
|
23
|
-
|
|
23
|
+
// Annotated rather than asserted: a template literal expression widens to
|
|
24
|
+
// `string` without a contextual type, and JSX cannot resolve an intrinsic
|
|
25
|
+
// element from that.
|
|
26
|
+
const HeadingTag: `h${TitleBlockHeadingLevel}` = `h${headingLevel}`
|
|
24
27
|
const hasCount = count !== undefined && count !== null
|
|
25
28
|
const hasDescription = description !== undefined && description !== null
|
|
26
29
|
const isVertical = orientation === 'vertical'
|
|
@@ -103,11 +106,15 @@ function RcSesTitleBlock({
|
|
|
103
106
|
const actionsSlot = actions ? (
|
|
104
107
|
<Stack
|
|
105
108
|
data-testid={testIds?.actions}
|
|
106
|
-
direction=
|
|
109
|
+
direction='row'
|
|
107
110
|
spacing={cards.header.actionsGap}
|
|
111
|
+
// Flex gap instead of sibling margin, so wrapped rows get the vertical
|
|
112
|
+
// gap and the first action of each row has no stray left margin.
|
|
113
|
+
useFlexGap
|
|
108
114
|
sx={{
|
|
109
|
-
alignItems:
|
|
115
|
+
alignItems: 'center',
|
|
110
116
|
flexShrink: 0,
|
|
117
|
+
flexWrap: 'wrap',
|
|
111
118
|
}}
|
|
112
119
|
>
|
|
113
120
|
{actions}
|
|
@@ -125,10 +132,7 @@ function RcSesTitleBlock({
|
|
|
125
132
|
// leaving a sibling-selector margin above the title.
|
|
126
133
|
useFlexGap
|
|
127
134
|
sx={{
|
|
128
|
-
alignItems:
|
|
129
|
-
isVertical || hasDescription
|
|
130
|
-
? 'flex-start'
|
|
131
|
-
: { xs: 'flex-start', sm: 'center' },
|
|
135
|
+
alignItems: isVertical ? 'flex-start' : { xs: 'flex-start', sm: 'center' },
|
|
132
136
|
width: '100%',
|
|
133
137
|
}}
|
|
134
138
|
>
|
|
@@ -145,7 +149,7 @@ function RcSesTitleBlock({
|
|
|
145
149
|
direction='row'
|
|
146
150
|
spacing={cards.header.rowGap}
|
|
147
151
|
sx={{
|
|
148
|
-
alignItems:
|
|
152
|
+
alignItems: 'center',
|
|
149
153
|
flex: 1,
|
|
150
154
|
minWidth: 0,
|
|
151
155
|
width: '100%',
|
|
@@ -6,7 +6,7 @@ export type TitleBlockTitleVariant = 'h4' | 'h5' | 'h6' | 'body1'
|
|
|
6
6
|
|
|
7
7
|
export type TitleBlockOrientation = 'horizontal' | 'vertical'
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export interface RcSesTitleBlockTestIds {
|
|
10
10
|
root?: string
|
|
11
11
|
icon?: string
|
|
12
12
|
heading?: string
|
|
@@ -15,7 +15,7 @@ export type RcSesTitleBlockTestIds = {
|
|
|
15
15
|
actions?: string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export interface RcSesTitleBlockBaseProps {
|
|
19
19
|
title: ReactNode
|
|
20
20
|
headingLevel?: TitleBlockHeadingLevel
|
|
21
21
|
/**
|
|
@@ -8,7 +8,7 @@ import theme from '@/theme/light'
|
|
|
8
8
|
import FieldSuffix from './components/FieldSuffix'
|
|
9
9
|
import { formControlDesktopLabelWidth } from './const/FormControlLayoutVariables'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface Props {
|
|
12
12
|
children: React.ReactNode
|
|
13
13
|
className?: string
|
|
14
14
|
description?: React.ReactNode
|
|
@@ -16,7 +16,7 @@ import RcSesDatepicker from '.'
|
|
|
16
16
|
const REFERENCE = new Date(2026, 0, 15)
|
|
17
17
|
const MAX = new Date(2026, 0, 20)
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface HarnessProps {
|
|
20
20
|
/** Seeds the field, so a day renders as selected. */
|
|
21
21
|
value?: string | null
|
|
22
22
|
/** Bounds the calendar, so later days render as disabled. */
|
|
@@ -70,10 +70,7 @@ function RcSesFileDropzone(props: Props) {
|
|
|
70
70
|
|
|
71
71
|
const hasValidFileSelection = value && Array.isArray(value) && value.length > 0
|
|
72
72
|
|
|
73
|
-
const onRemoveFile = (
|
|
74
|
-
e: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
75
|
-
index: number,
|
|
76
|
-
) => {
|
|
73
|
+
const onRemoveFile = (e: React.MouseEvent<HTMLButtonElement>, index: number) => {
|
|
77
74
|
e.preventDefault()
|
|
78
75
|
e.stopPropagation()
|
|
79
76
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import { useForm } from 'react-hook-form'
|
|
4
|
+
|
|
5
|
+
import theme from '@/theme/light'
|
|
6
|
+
|
|
7
|
+
import RcSesNumberStepper from './NumberStepper'
|
|
8
|
+
|
|
9
|
+
interface TestWrapperProps {
|
|
10
|
+
defaultValue?: number
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
max?: number
|
|
13
|
+
min?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TestWrapper = ({ defaultValue = 5, disabled, max, min }: TestWrapperProps) => {
|
|
17
|
+
const { control } = useForm({ defaultValues: { quantity: defaultValue } })
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ThemeProvider theme={theme}>
|
|
21
|
+
<RcSesNumberStepper
|
|
22
|
+
id='quantity'
|
|
23
|
+
name='quantity'
|
|
24
|
+
control={control}
|
|
25
|
+
label='Kiekis'
|
|
26
|
+
displayStepperControls
|
|
27
|
+
disabled={disabled}
|
|
28
|
+
rules={{ min, max }}
|
|
29
|
+
/>
|
|
30
|
+
</ThemeProvider>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const subtractButton = () => screen.getByRole('button', { name: 'Atimti' })
|
|
35
|
+
const addButton = () => screen.getByRole('button', { name: 'Pridėti' })
|
|
36
|
+
|
|
37
|
+
describe('RcSesNumberStepper', () => {
|
|
38
|
+
test('enables both controls when the value sits between min and max', () => {
|
|
39
|
+
render(<TestWrapper defaultValue={5} min={0} max={10} />)
|
|
40
|
+
|
|
41
|
+
expect(subtractButton()).toBeEnabled()
|
|
42
|
+
expect(addButton()).toBeEnabled()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('disables subtract on the first render when the value is already at min', () => {
|
|
46
|
+
render(<TestWrapper defaultValue={0} min={0} max={10} />)
|
|
47
|
+
|
|
48
|
+
expect(subtractButton()).toBeDisabled()
|
|
49
|
+
expect(addButton()).toBeEnabled()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('disables add on the first render when the value is already at max', () => {
|
|
53
|
+
render(<TestWrapper defaultValue={10} min={0} max={10} />)
|
|
54
|
+
|
|
55
|
+
expect(subtractButton()).toBeEnabled()
|
|
56
|
+
expect(addButton()).toBeDisabled()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('disables both controls when the field is disabled', () => {
|
|
60
|
+
render(<TestWrapper defaultValue={5} disabled min={0} max={10} />)
|
|
61
|
+
|
|
62
|
+
expect(subtractButton()).toBeDisabled()
|
|
63
|
+
expect(addButton()).toBeDisabled()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test('leaves both controls enabled when no min or max is set', () => {
|
|
67
|
+
render(<TestWrapper defaultValue={0} />)
|
|
68
|
+
|
|
69
|
+
expect(subtractButton()).toBeEnabled()
|
|
70
|
+
expect(addButton()).toBeEnabled()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('re-evaluates the controls as the value reaches a bound', () => {
|
|
74
|
+
render(<TestWrapper defaultValue={9} min={0} max={10} />)
|
|
75
|
+
|
|
76
|
+
expect(addButton()).toBeEnabled()
|
|
77
|
+
|
|
78
|
+
fireEvent.click(addButton())
|
|
79
|
+
|
|
80
|
+
expect(addButton()).toBeDisabled()
|
|
81
|
+
expect(subtractButton()).toBeEnabled()
|
|
82
|
+
})
|
|
83
|
+
})
|
|
@@ -51,7 +51,7 @@ const NumberInput = styled(OutlinedInput)({
|
|
|
51
51
|
},
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
interface ArrowButtonProps {
|
|
55
55
|
ariaLabel: string
|
|
56
56
|
direction: 'plus' | 'minus'
|
|
57
57
|
disabled: boolean
|
|
@@ -110,8 +110,6 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
110
110
|
function RcSesNumberStepper(props: Props) {
|
|
111
111
|
const { t } = useTranslation('input', { keyPrefix: 'components.RcSesNumberStepper' })
|
|
112
112
|
|
|
113
|
-
const [buttonState, setButtonState] = React.useState<[boolean, boolean]>([true, true])
|
|
114
|
-
|
|
115
113
|
const {
|
|
116
114
|
control,
|
|
117
115
|
displayStepperControls,
|
|
@@ -138,20 +136,21 @@ function RcSesNumberStepper(props: Props) {
|
|
|
138
136
|
...slotProps?.controller,
|
|
139
137
|
})
|
|
140
138
|
|
|
141
|
-
|
|
139
|
+
// [subtractDisabled, addDisabled] - derived from the current value and the
|
|
140
|
+
// controller rules, so the buttons render with the right state on first paint.
|
|
141
|
+
const buttonState = useMemo<[boolean, boolean]>(() => {
|
|
142
142
|
if (disabled) {
|
|
143
|
-
|
|
144
|
-
return
|
|
143
|
+
return [true, true]
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
return [
|
|
148
147
|
Number.isInteger(rules?.min)
|
|
149
148
|
? parseInt(rules?.min as string, 10) >= parseInt((value ?? 0) as string, 10)
|
|
150
149
|
: false,
|
|
151
150
|
Number.isInteger(rules?.max)
|
|
152
151
|
? parseInt(rules?.max as string, 10) <= parseInt((value ?? 0) as string, 10)
|
|
153
152
|
: false,
|
|
154
|
-
]
|
|
153
|
+
]
|
|
155
154
|
}, [disabled, rules?.max, rules?.min, value])
|
|
156
155
|
|
|
157
156
|
const handleInputOnChange = (
|
|
@@ -15,7 +15,7 @@ import RcSesFormControlWrapper, {
|
|
|
15
15
|
RcSesFormControlWrapperProps,
|
|
16
16
|
} from '../components/FormControlWrapper'
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export interface RadioOption {
|
|
19
19
|
label: string
|
|
20
20
|
value: string
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
35
35
|
id?: string
|
|
36
36
|
className?: string
|
|
37
37
|
hideNativeRadio?: boolean
|
|
38
|
-
options:
|
|
38
|
+
options: RadioOption[]
|
|
39
39
|
variant?: 'flat' | 'outlined' | 'filled'
|
|
40
40
|
slotProps?: {
|
|
41
41
|
controller?: Partial<Omit<TControllerProps, ImmediateControllerProps>>
|
|
@@ -62,7 +62,7 @@ const RcSesSearchInput = React.forwardRef<HTMLInputElement, Props>((props, ref)
|
|
|
62
62
|
if (typeof ref === 'function') {
|
|
63
63
|
ref(el)
|
|
64
64
|
} else if (ref) {
|
|
65
|
-
|
|
65
|
+
ref.current = el
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
[ref],
|
|
@@ -25,7 +25,7 @@ vi.mock('react-i18next', () => ({
|
|
|
25
25
|
* the runtime breaks. These tests pin the behaviour so the migration is verifiable.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
interface ModalProps {
|
|
29
29
|
open: boolean
|
|
30
30
|
onSubmit: (value: string) => void
|
|
31
31
|
onClose: () => void
|
|
@@ -58,7 +58,7 @@ const TestWrapper = ({ defaultValue = '' }: { defaultValue?: string }) => {
|
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const getField = () => screen.getByRole('textbox')
|
|
61
|
+
const getField = () => screen.getByRole<HTMLInputElement>('textbox')
|
|
62
62
|
|
|
63
63
|
describe('RcSesSearchableField', () => {
|
|
64
64
|
it('should render the field with the value from the form', () => {
|
|
@@ -7,7 +7,7 @@ import theme from '@/theme/light'
|
|
|
7
7
|
|
|
8
8
|
import RcSesSelect from '.'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface TestWrapperProps {
|
|
11
11
|
defaultValue?: string | null
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -22,13 +22,13 @@ const options = [
|
|
|
22
22
|
},
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
interface UnregisterTestWrapperProps {
|
|
26
26
|
shouldUnregister?: boolean
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const UnregisterTestWrapper = ({ shouldUnregister }: UnregisterTestWrapperProps) => {
|
|
30
30
|
const { control, getValues } = useForm({
|
|
31
|
-
defaultValues: { selection: 'short-option'
|
|
31
|
+
defaultValues: { selection: 'short-option' },
|
|
32
32
|
})
|
|
33
33
|
const [mounted, setMounted] = useState(true)
|
|
34
34
|
const [formValues, setFormValues] = useState('')
|
|
@@ -5,7 +5,7 @@ import ExpandChevronsIcon from '@/assets/icons/ExpandChevronsIcon'
|
|
|
5
5
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
6
6
|
import Button from '@/components/common/Button'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface Props {
|
|
9
9
|
controller: ReturnType<typeof useAccordionController>
|
|
10
10
|
}
|
|
11
11
|
function AccordionCollapseControls({ controller }: Props) {
|
|
@@ -9,7 +9,7 @@ import ServiceWizardStepper from '../../ServiceWizardStepper'
|
|
|
9
9
|
import AccordionCollapseControls from './components/AccordionCollapseControls'
|
|
10
10
|
import mapAccordionStateToSteps from './utils'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
interface Props {
|
|
13
13
|
accordionController: ReturnType<typeof useAccordionController>
|
|
14
14
|
children: React.ReactNode
|
|
15
15
|
showAccordionCollapseControls?: boolean
|
|
@@ -5,7 +5,7 @@ import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
|
5
5
|
import theme from '@/theme/light'
|
|
6
6
|
import { common } from '@/theme/palette'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface Props {
|
|
9
9
|
breadcrumbsProps: React.ComponentProps<typeof RcSesBreadcrumbs>
|
|
10
10
|
children?: React.ReactNode
|
|
11
11
|
title: string
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SxProps, Theme } from '@mui/material'
|
|
2
2
|
|
|
3
3
|
type SxEntry =
|
|
4
|
-
Extract<SxProps<Theme>,
|
|
5
|
-
? T
|
|
6
|
-
: never
|
|
4
|
+
Extract<SxProps<Theme>, readonly unknown[]> extends readonly (infer T)[] ? T : never
|
|
7
5
|
|
|
8
|
-
function isSxArray(sx: SxProps<Theme>): sx is
|
|
6
|
+
function isSxArray(sx: SxProps<Theme>): sx is readonly SxEntry[] {
|
|
9
7
|
return Array.isArray(sx)
|
|
10
8
|
}
|
|
11
9
|
|
|
@@ -58,8 +58,6 @@ function ListWithPagination() {
|
|
|
58
58
|
const [selectedItemId, setSelectedItemId] = useState<string | null>(null)
|
|
59
59
|
|
|
60
60
|
useEffect(() => {
|
|
61
|
-
setIsLoading(true)
|
|
62
|
-
|
|
63
61
|
const timer = setTimeout(() => {
|
|
64
62
|
setData(mapToSelectableItems(mockApiData))
|
|
65
63
|
setIsLoading(false)
|
|
@@ -4,7 +4,7 @@ import RcSesAlert from '@/components/common/Alert'
|
|
|
4
4
|
import RcSesRadioButtonGroup from '@/components/form/inputs/RadioButtonGroup'
|
|
5
5
|
import RcSesSelect from '@/components/form/inputs/Select'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface FormModel {
|
|
8
8
|
issuanceMethod: string
|
|
9
9
|
rcBranch: string
|
|
10
10
|
}
|
|
@@ -19,7 +19,7 @@ import { useForm } from 'react-hook-form'
|
|
|
19
19
|
|
|
20
20
|
import RcSesTextField from '@/components/form/inputs/TextField'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
interface FormModel {
|
|
23
23
|
city: string
|
|
24
24
|
street: string
|
|
25
25
|
addressNo: string
|
|
@@ -27,7 +27,7 @@ type FormModel = {
|
|
|
27
27
|
aptNo: string
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
interface Props {
|
|
31
31
|
open: boolean
|
|
32
32
|
onSubmit: (value: string) => void
|
|
33
33
|
onClose: () => void
|
package/src/library/types.ts
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
RcSesServiceLinksProps,
|
|
23
23
|
RcSesServiceLinksTestIds,
|
|
24
24
|
} from '@/components/common/ServiceLinks/types'
|
|
25
|
-
import { RcSesSideNavItem } from '@/components/common/SideNav'
|
|
25
|
+
import { RcSesSideNavItem, RcSesSideNavOverflow } from '@/components/common/SideNav'
|
|
26
26
|
import { RcSesSideNavLayoutProps } from '@/components/common/SideNav/SideNavLayout'
|
|
27
27
|
import {
|
|
28
28
|
RcSesTitleBlockProps,
|
|
@@ -81,6 +81,7 @@ export type {
|
|
|
81
81
|
RcSesTooltipProps,
|
|
82
82
|
RcSesSideNavItem,
|
|
83
83
|
RcSesSideNavLayoutProps,
|
|
84
|
+
RcSesSideNavOverflow,
|
|
84
85
|
}
|
|
85
86
|
export type { RcSesDialogProps, DialogSize }
|
|
86
87
|
export type { RcSesModalProps, ModalVariant }
|
|
@@ -6,12 +6,7 @@ import Button from '@/components/common/Button'
|
|
|
6
6
|
import { grey } from '@/theme/palette'
|
|
7
7
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
8
8
|
|
|
9
|
-
const variantOptions:
|
|
10
|
-
'contained',
|
|
11
|
-
'outlined',
|
|
12
|
-
'link',
|
|
13
|
-
'text',
|
|
14
|
-
]
|
|
9
|
+
const variantOptions: ButtonProps['variant'][] = ['contained', 'outlined', 'link', 'text']
|
|
15
10
|
const colorOptions = [
|
|
16
11
|
'primary',
|
|
17
12
|
'secondary',
|
|
@@ -249,7 +244,7 @@ export const ErrorOutlined: Story = {
|
|
|
249
244
|
export const LightOutlined: Story = {
|
|
250
245
|
args: {
|
|
251
246
|
variant: 'outlined',
|
|
252
|
-
color: 'light'
|
|
247
|
+
color: 'light',
|
|
253
248
|
children: 'Light Button',
|
|
254
249
|
},
|
|
255
250
|
decorators: [
|
|
@@ -273,7 +268,7 @@ export const LightOutlined: Story = {
|
|
|
273
268
|
export const LightOutlinedWithIcon: Story = {
|
|
274
269
|
args: {
|
|
275
270
|
variant: 'outlined',
|
|
276
|
-
color: 'light'
|
|
271
|
+
color: 'light',
|
|
277
272
|
startIcon: <PlusBoldIcon />,
|
|
278
273
|
children: 'Light Button with Icon',
|
|
279
274
|
},
|
|
@@ -298,7 +293,7 @@ export const LightOutlinedWithIcon: Story = {
|
|
|
298
293
|
export const LightOutlinedDisabled: Story = {
|
|
299
294
|
args: {
|
|
300
295
|
variant: 'outlined',
|
|
301
|
-
color: 'light'
|
|
296
|
+
color: 'light',
|
|
302
297
|
children: 'Light Button Disabled',
|
|
303
298
|
disabled: true,
|
|
304
299
|
},
|
|
@@ -324,7 +319,7 @@ export const GhostOutlinedIconOnly: Story = {
|
|
|
324
319
|
args: {
|
|
325
320
|
'aria-label': 'Close',
|
|
326
321
|
children: <PlusBoldIcon />,
|
|
327
|
-
color: 'ghost'
|
|
322
|
+
color: 'ghost',
|
|
328
323
|
iconOnly: true,
|
|
329
324
|
variant: 'outlined',
|
|
330
325
|
},
|
|
@@ -350,7 +345,7 @@ export const GhostOutlinedIconOnlyDisabled: Story = {
|
|
|
350
345
|
args: {
|
|
351
346
|
'aria-label': 'Close',
|
|
352
347
|
children: <PlusBoldIcon />,
|
|
353
|
-
color: 'ghost'
|
|
348
|
+
color: 'ghost',
|
|
354
349
|
disabled: true,
|
|
355
350
|
iconOnly: true,
|
|
356
351
|
variant: 'outlined',
|
|
@@ -491,7 +486,7 @@ export const ErrorOutlinedLoading: Story = {
|
|
|
491
486
|
export const LightOutlinedLoading: Story = {
|
|
492
487
|
args: {
|
|
493
488
|
variant: 'outlined',
|
|
494
|
-
color: 'light'
|
|
489
|
+
color: 'light',
|
|
495
490
|
children: 'Light Button',
|
|
496
491
|
loading: true,
|
|
497
492
|
},
|
|
@@ -516,7 +511,7 @@ export const LightOutlinedLoading: Story = {
|
|
|
516
511
|
export const LightOutlinedWithIconLoading: Story = {
|
|
517
512
|
args: {
|
|
518
513
|
variant: 'outlined',
|
|
519
|
-
color: 'light'
|
|
514
|
+
color: 'light',
|
|
520
515
|
startIcon: <PlusBoldIcon />,
|
|
521
516
|
children: 'Light Button with Icon',
|
|
522
517
|
loading: true,
|
|
@@ -543,7 +538,7 @@ export const GhostOutlinedIconOnlyLoading: Story = {
|
|
|
543
538
|
args: {
|
|
544
539
|
'aria-label': 'Close',
|
|
545
540
|
children: <PlusBoldIcon />,
|
|
546
|
-
color: 'ghost'
|
|
541
|
+
color: 'ghost',
|
|
547
542
|
iconOnly: true,
|
|
548
543
|
variant: 'outlined',
|
|
549
544
|
loading: true,
|
|
@@ -7,7 +7,7 @@ import FieldView from '@/components/storybook/FieldView'
|
|
|
7
7
|
import Fields from '@/components/storybook/Fields'
|
|
8
8
|
import PreviewTitle from '@/components/storybook/PreviewTitle'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface FormModel {
|
|
11
11
|
countable: number
|
|
12
12
|
countable2: number
|
|
13
13
|
countable3: number
|
|
@@ -7,7 +7,7 @@ import FieldView from '@/components/storybook/FieldView'
|
|
|
7
7
|
import Fields from '@/components/storybook/Fields'
|
|
8
8
|
import PreviewTitle from '@/components/storybook/PreviewTitle'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface FormModel {
|
|
11
11
|
phone: string
|
|
12
12
|
phoneDisabled: string
|
|
13
13
|
phoneError: string
|