@registrucentras/rc-ses-react-components 2.0.0-rc.2 → 2.0.0-rc.4
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/ArrowRightIcon.d.ts +1 -1
- package/dist/components/common/CardShell/CardFooter/index.d.ts +3 -0
- package/dist/components/common/CardShell/CardFooter/types.d.ts +21 -0
- package/dist/components/common/CardShell/index.d.ts +5 -0
- package/dist/components/common/CardShell/types.d.ts +26 -0
- package/dist/components/common/IconWithSquareBackground/index.d.ts +12 -0
- package/dist/components/common/ServiceLinks/ServiceLinkItem/index.d.ts +15 -0
- package/dist/components/common/ServiceLinks/index.d.ts +3 -0
- package/dist/components/common/ServiceLinks/types.d.ts +34 -0
- package/dist/components/common/SideNav/SideNav.types.d.ts +20 -0
- package/dist/components/common/SideNav/SideNavLayout.d.ts +4 -0
- package/dist/components/common/SideNav/components/SideNavPill.d.ts +9 -0
- package/dist/components/common/SideNav/components/SideNavPillList.d.ts +9 -0
- package/dist/components/common/SideNav/components/SideNavRow.d.ts +9 -0
- package/dist/components/common/SideNav/hooks/useSideNavScrollSpy.d.ts +12 -0
- package/dist/components/common/SideNav/index.d.ts +4 -0
- package/dist/components/common/TitleBlock/index.d.ts +3 -0
- package/dist/components/common/TitleBlock/types.d.ts +73 -0
- package/dist/components/utils/normalizeSx.d.ts +4 -0
- package/dist/library/index.d.ts +10 -1
- package/dist/library/types.d.ts +8 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +3535 -2563
- package/dist/stories/components/display/CardShell.stories.d.ts +17 -0
- package/dist/stories/components/display/SelectableCardList.stories.d.ts +1 -0
- package/dist/stories/components/display/ServiceLinks.stories.d.ts +28 -0
- package/dist/stories/components/display/TitleBlock.stories.d.ts +20 -0
- package/dist/stories/components/form/FormControlWrapper.stories.d.ts +1 -0
- package/dist/stories/components/icons/IconWithSquareBackground.stories.d.ts +7 -0
- package/dist/stories/components/inputs/DatePicker.stories.d.ts +107 -0
- package/dist/stories/components/navigation/SideNav.stories.d.ts +7 -0
- package/dist/theme/cards.d.ts +114 -0
- package/dist/theme/light/MuiPickersOutlinedInput.d.ts +8 -0
- package/package.json +1 -1
- package/src/assets/icons/ArrowRightIcon.tsx +2 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +8 -6
- package/src/components/common/Card/index.tsx +1 -23
- package/src/components/common/CardShell/CardFooter/index.test.tsx +52 -0
- package/src/components/common/CardShell/CardFooter/index.tsx +38 -0
- package/src/components/common/CardShell/CardFooter/types.ts +24 -0
- package/src/components/common/CardShell/index.test.tsx +137 -0
- package/src/components/common/CardShell/index.tsx +78 -0
- package/src/components/common/CardShell/types.ts +30 -0
- package/src/components/common/IconWithSquareBackground/index.test.tsx +55 -0
- package/src/components/common/IconWithSquareBackground/index.tsx +83 -0
- package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +177 -0
- package/src/components/common/ServiceLinks/index.test.tsx +166 -0
- package/src/components/common/ServiceLinks/index.tsx +66 -0
- package/src/components/common/ServiceLinks/types.ts +37 -0
- package/src/components/common/SideNav/SideNav.types.ts +24 -0
- package/src/components/common/SideNav/SideNavLayout.test.tsx +113 -0
- package/src/components/common/SideNav/SideNavLayout.tsx +67 -0
- package/src/components/common/SideNav/components/SideNavPill.tsx +62 -0
- package/src/components/common/SideNav/components/SideNavPillList.tsx +190 -0
- package/src/components/common/SideNav/components/SideNavRow.tsx +72 -0
- package/src/components/common/SideNav/hooks/useSideNavScrollSpy.test.ts +457 -0
- package/src/components/common/SideNav/hooks/useSideNavScrollSpy.ts +154 -0
- package/src/components/common/SideNav/index.test.tsx +99 -0
- package/src/components/common/SideNav/index.tsx +83 -0
- package/src/components/common/TitleBlock/index.test.tsx +366 -0
- package/src/components/common/TitleBlock/index.tsx +144 -0
- package/src/components/common/TitleBlock/types.ts +82 -0
- package/src/components/form/inputs/Datepicker/index.test.tsx +117 -0
- package/src/components/utils/normalizeSx.ts +24 -0
- package/src/i18n/namespaces/common/en.json +4 -0
- package/src/i18n/namespaces/common/lt.json +4 -0
- package/src/library/index.ts +12 -0
- package/src/library/types.ts +38 -0
- package/src/stories/components/display/CardShell.stories.tsx +263 -0
- package/src/stories/components/display/SelectableCardList.stories.tsx +33 -1
- package/src/stories/components/display/ServiceLinks.stories.tsx +154 -0
- package/src/stories/components/display/TitleBlock.stories.tsx +506 -0
- package/src/stories/components/form/FormControlWrapper.stories.tsx +23 -0
- package/src/stories/components/icons/IconWithSquareBackground.stories.tsx +60 -0
- package/src/stories/components/inputs/DatePicker.stories.tsx +105 -9
- package/src/stories/components/navigation/SideNav.stories.tsx +110 -0
- package/src/theme/cards.ts +60 -0
- package/src/theme/light/MuiButton.tsx +6 -0
- package/src/theme/light/MuiPickersLayout.ts +10 -1
- package/src/theme/light/MuiPickersOutlinedInput.ts +88 -0
- package/src/theme/light/index.tsx +2 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type TitleBlockHeadingLevel = 2 | 3 | 4 | 5 | 6
|
|
4
|
+
|
|
5
|
+
export type TitleBlockTitleVariant = 'h4' | 'h5' | 'h6'
|
|
6
|
+
|
|
7
|
+
export type TitleBlockOrientation = 'horizontal' | 'vertical'
|
|
8
|
+
|
|
9
|
+
export type RcSesTitleBlockTestIds = {
|
|
10
|
+
root?: string
|
|
11
|
+
icon?: string
|
|
12
|
+
heading?: string
|
|
13
|
+
badge?: string
|
|
14
|
+
description?: string
|
|
15
|
+
actions?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type RcSesTitleBlockBaseProps = {
|
|
19
|
+
title: ReactNode
|
|
20
|
+
headingLevel?: TitleBlockHeadingLevel
|
|
21
|
+
/**
|
|
22
|
+
* Visual size of the title, independent of `headingLevel`. The semantic tag
|
|
23
|
+
* (`headingLevel`) sets document structure; this sets the type scale.
|
|
24
|
+
* Defaults to `h6` (18px).
|
|
25
|
+
*/
|
|
26
|
+
titleVariant?: TitleBlockTitleVariant
|
|
27
|
+
/**
|
|
28
|
+
* Named tone applied to the title. Closed set so consumers cannot paint an
|
|
29
|
+
* arbitrary colour into the DS component.
|
|
30
|
+
* - `default` (default): `palette.grey[900]`, for non-branded rows.
|
|
31
|
+
* - `brand`: `palette.primary[700]`, for branded rows (catalogue tiles,
|
|
32
|
+
* card headers). Does not imply the row is clickable — use a link tone
|
|
33
|
+
* on the CTA, not the heading, if that signal is needed.
|
|
34
|
+
*/
|
|
35
|
+
titleTone?: 'default' | 'brand'
|
|
36
|
+
/**
|
|
37
|
+
* Decorative leading visual, `Icon-tile` once SAV-6476 lands. Rendered
|
|
38
|
+
* `aria-hidden`, so it never contributes to the heading's accessible name.
|
|
39
|
+
*/
|
|
40
|
+
icon?: ReactNode
|
|
41
|
+
/**
|
|
42
|
+
* Count rendered as a Neutral/Small `Badge` inside the heading, so it is
|
|
43
|
+
* announced together with the title. Intended for short section headings.
|
|
44
|
+
*/
|
|
45
|
+
count?: number
|
|
46
|
+
description?: ReactNode
|
|
47
|
+
/**
|
|
48
|
+
* DOM id assigned to the heading element. Lets a consumer point
|
|
49
|
+
* `aria-labelledby` at the row title from an external element (e.g. an
|
|
50
|
+
* action CTA in a card grid) without duplicating the title string.
|
|
51
|
+
*/
|
|
52
|
+
headingId?: string
|
|
53
|
+
className?: string
|
|
54
|
+
testIds?: RcSesTitleBlockTestIds
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Horizontal layout: icon on the left, text on the right, actions on the far
|
|
59
|
+
* right. Up to two trailing CTAs are allowed in the `actions` slot.
|
|
60
|
+
*/
|
|
61
|
+
export type RcSesTitleBlockHorizontalProps = RcSesTitleBlockBaseProps & {
|
|
62
|
+
orientation?: 'horizontal'
|
|
63
|
+
/**
|
|
64
|
+
* Up to two CTAs, rendered at the end of the header row. A trailing
|
|
65
|
+
* affordance such as the Category-tile chevron is not a CTA and will need
|
|
66
|
+
* its own slot.
|
|
67
|
+
*/
|
|
68
|
+
actions?: ReactNode
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Vertical layout: icon on top, text below. There is no header-level actions
|
|
73
|
+
* slot — put any CTA in the surrounding `CardShell`'s `footer` slot instead.
|
|
74
|
+
* Passing `actions` here is a compile error.
|
|
75
|
+
*/
|
|
76
|
+
export type RcSesTitleBlockVerticalProps = RcSesTitleBlockBaseProps & {
|
|
77
|
+
orientation: 'vertical'
|
|
78
|
+
actions?: never
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type RcSesTitleBlockProps =
|
|
82
|
+
RcSesTitleBlockHorizontalProps | RcSesTitleBlockVerticalProps
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'
|
|
4
|
+
import '@testing-library/jest-dom'
|
|
5
|
+
import { render, screen } from '@testing-library/react'
|
|
6
|
+
import { lt } from 'date-fns/locale/lt'
|
|
7
|
+
import { useForm } from 'react-hook-form'
|
|
8
|
+
import { describe, expect, test } from 'vitest'
|
|
9
|
+
|
|
10
|
+
import theme from '@/theme/light'
|
|
11
|
+
import palette, { common } from '@/theme/palette'
|
|
12
|
+
|
|
13
|
+
import RcSesDatepicker from '.'
|
|
14
|
+
|
|
15
|
+
// Pinned so the calendar does not follow the current date.
|
|
16
|
+
const REFERENCE = new Date(2026, 0, 15)
|
|
17
|
+
const MAX = new Date(2026, 0, 20)
|
|
18
|
+
|
|
19
|
+
type HarnessProps = {
|
|
20
|
+
/** Seeds the field, so a day renders as selected. */
|
|
21
|
+
value?: string | null
|
|
22
|
+
/** Bounds the calendar, so later days render as disabled. */
|
|
23
|
+
maxDate?: Date
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Harness({ value = null, maxDate }: HarnessProps) {
|
|
27
|
+
const {
|
|
28
|
+
control,
|
|
29
|
+
formState: { errors },
|
|
30
|
+
} = useForm<{ date: string | null }>({ defaultValues: { date: value } })
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ThemeProvider theme={theme}>
|
|
34
|
+
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={lt}>
|
|
35
|
+
<RcSesDatepicker
|
|
36
|
+
id='date'
|
|
37
|
+
name='date'
|
|
38
|
+
control={control}
|
|
39
|
+
label='Data'
|
|
40
|
+
errors={errors?.date}
|
|
41
|
+
slotProps={{
|
|
42
|
+
datepicker: { open: true, referenceDate: REFERENCE, maxDate },
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</LocalizationProvider>
|
|
46
|
+
</ThemeProvider>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const rgb = (hex: string) => {
|
|
51
|
+
const n = parseInt(hex.slice(1), 16)
|
|
52
|
+
// eslint-disable-next-line no-bitwise
|
|
53
|
+
return `rgb(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255})`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const dayColour = (label: string) =>
|
|
57
|
+
window.getComputedStyle(screen.getByRole('gridcell', { name: label })).color
|
|
58
|
+
|
|
59
|
+
describe('RcSesDatepicker calendar day colours', () => {
|
|
60
|
+
// Pinned here rather than left to the visual suite: a colour-only change on a
|
|
61
|
+
// few glyphs stays under its diff budget.
|
|
62
|
+
test('a selectable weekday uses the default day colour', () => {
|
|
63
|
+
render(<Harness maxDate={MAX} />)
|
|
64
|
+
|
|
65
|
+
expect(dayColour('19')).toBe(rgb(palette.grey['900']))
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('a disabled weekday is greyed out', () => {
|
|
69
|
+
render(<Harness maxDate={MAX} />)
|
|
70
|
+
|
|
71
|
+
expect(dayColour('21')).toBe(rgb(palette.grey['400']))
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// 1.x paints it white; v9 lost that to the theme's day colour.
|
|
75
|
+
test('the selected day is white on the blue fill', () => {
|
|
76
|
+
render(<Harness value='2026-01-15T00:00:00.000Z' />)
|
|
77
|
+
|
|
78
|
+
const selected = document.querySelector('.Mui-selected') as HTMLElement
|
|
79
|
+
const cs = window.getComputedStyle(selected)
|
|
80
|
+
|
|
81
|
+
expect(cs.backgroundColor).toBe(rgb(palette.primary['500']))
|
|
82
|
+
expect(cs.color).toBe(rgb(common.white))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('a disabled weekend day stays red, as in 1.x', () => {
|
|
86
|
+
render(<Harness maxDate={MAX} />)
|
|
87
|
+
|
|
88
|
+
expect(dayColour('24')).toBe(rgb(palette.error['600']))
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// The picker field is not a MUI OutlinedInput, so it needs its own overrides to
|
|
93
|
+
// match the other inputs.
|
|
94
|
+
describe('RcSesDatepicker field styling', () => {
|
|
95
|
+
test('the field keeps the shared input radius and background', () => {
|
|
96
|
+
render(<Harness />)
|
|
97
|
+
|
|
98
|
+
const field = document.querySelector('.MuiPickersInputBase-root') as HTMLElement
|
|
99
|
+
const cs = window.getComputedStyle(field)
|
|
100
|
+
|
|
101
|
+
expect(cs.borderRadius).toBe('0.5rem')
|
|
102
|
+
expect(cs.backgroundColor).toBe(rgb(common.white))
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('the value text matches a plain input', () => {
|
|
106
|
+
render(<Harness />)
|
|
107
|
+
|
|
108
|
+
const sections = document.querySelector(
|
|
109
|
+
'.MuiPickersInputBase-sectionsContainer',
|
|
110
|
+
) as HTMLElement
|
|
111
|
+
const cs = window.getComputedStyle(sections)
|
|
112
|
+
|
|
113
|
+
expect(cs.fontSize).toBe('0.9375rem')
|
|
114
|
+
expect(cs.height).toBe('1.125rem')
|
|
115
|
+
expect(cs.color).toBe(rgb(palette.grey['900']))
|
|
116
|
+
})
|
|
117
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
type SxEntry =
|
|
4
|
+
Extract<SxProps<Theme>, ReadonlyArray<unknown>> extends ReadonlyArray<infer T>
|
|
5
|
+
? T
|
|
6
|
+
: never
|
|
7
|
+
|
|
8
|
+
function isSxArray(sx: SxProps<Theme>): sx is ReadonlyArray<SxEntry> {
|
|
9
|
+
return Array.isArray(sx)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function normalizeSx(sx: SxProps<Theme> | undefined): SxEntry[] {
|
|
13
|
+
if (sx === undefined) {
|
|
14
|
+
return []
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (isSxArray(sx)) {
|
|
18
|
+
return [...sx]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [sx]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default normalizeSx
|
package/src/library/index.ts
CHANGED
|
@@ -13,11 +13,16 @@ import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
|
13
13
|
import RcSesButton from '@/components/common/Button'
|
|
14
14
|
import RcSesButtonWithPopover from '@/components/common/Button/ButtonWithPopover'
|
|
15
15
|
import RcSesCard from '@/components/common/Card'
|
|
16
|
+
import RcSesCardShell from '@/components/common/CardShell'
|
|
17
|
+
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
16
18
|
import DataPagination from '@/components/common/DataPagination'
|
|
17
19
|
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
20
|
+
import RcSesIconWithSquareBackground from '@/components/common/IconWithSquareBackground'
|
|
18
21
|
import RcSesImageCard from '@/components/common/ImageCard'
|
|
19
22
|
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
20
23
|
import RcSesSegmentedControl from '@/components/common/SegmentedControl'
|
|
24
|
+
import RcSesServiceLinks from '@/components/common/ServiceLinks'
|
|
25
|
+
import RcSesSideNavLayout from '@/components/common/SideNav/SideNavLayout'
|
|
21
26
|
import RcSesSnackbar from '@/components/common/Snackbar'
|
|
22
27
|
import {
|
|
23
28
|
RcSesSnackbarProvider,
|
|
@@ -28,6 +33,7 @@ import RcSesTab from '@/components/common/Tabs/Tab'
|
|
|
28
33
|
import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
|
|
29
34
|
import RcSesTabs from '@/components/common/Tabs/Tabs'
|
|
30
35
|
import RcSesTabsWrapper from '@/components/common/Tabs/TabsWrapper'
|
|
36
|
+
import RcSesTitleBlock from '@/components/common/TitleBlock'
|
|
31
37
|
import RcSesTooltip from '@/components/common/Tooltip'
|
|
32
38
|
import RcSesFormControlWrapper from '@/components/form/components/FormControlWrapper'
|
|
33
39
|
import RcSesCheckbox from '@/components/form/inputs/Checkbox'
|
|
@@ -81,6 +87,9 @@ export {
|
|
|
81
87
|
RcSesLoader,
|
|
82
88
|
RcSesLoadingSpinner,
|
|
83
89
|
RcSesCard,
|
|
90
|
+
RcSesCardShell,
|
|
91
|
+
RcSesTitleBlock,
|
|
92
|
+
RcSesCardFooter,
|
|
84
93
|
RcSesDialog,
|
|
85
94
|
RcSesFooter,
|
|
86
95
|
RcSesImageCard,
|
|
@@ -90,6 +99,7 @@ export {
|
|
|
90
99
|
RcSesSwitch,
|
|
91
100
|
}
|
|
92
101
|
export { RcSesSegmentedControl }
|
|
102
|
+
export { RcSesSideNavLayout }
|
|
93
103
|
export { RcSesCheckbox, RcSesCheckboxFormControl, RcSesSimpleCheckbox }
|
|
94
104
|
export { useSnackbar }
|
|
95
105
|
export { RcSesDatepicker }
|
|
@@ -106,6 +116,7 @@ export { RcSesTooltip }
|
|
|
106
116
|
export { RcSesTextField }
|
|
107
117
|
export { DataPagination }
|
|
108
118
|
export { ListWithIcons }
|
|
119
|
+
export { RcSesServiceLinks }
|
|
109
120
|
export { ServiceWizardStepper }
|
|
110
121
|
export { RcSesFormControlLabel }
|
|
111
122
|
export { SelectableCardList }
|
|
@@ -123,5 +134,6 @@ export {
|
|
|
123
134
|
|
|
124
135
|
export type { RcSesIconProps }
|
|
125
136
|
export { RcSesIconWithCircularBackground }
|
|
137
|
+
export { RcSesIconWithSquareBackground }
|
|
126
138
|
|
|
127
139
|
export * from './icons'
|
package/src/library/types.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { RcSesCardProps } from '@/components/common/Card'
|
|
2
|
+
import {
|
|
3
|
+
CardFooterAlign,
|
|
4
|
+
RcSesCardFooterProps,
|
|
5
|
+
RcSesCardFooterTestIds,
|
|
6
|
+
} from '@/components/common/CardShell/CardFooter/types'
|
|
7
|
+
import {
|
|
8
|
+
CardShellTheme,
|
|
9
|
+
CardShellVariant,
|
|
10
|
+
RcSesCardShellProps,
|
|
11
|
+
RcSesCardShellTestIds,
|
|
12
|
+
} from '@/components/common/CardShell/types'
|
|
2
13
|
import { ListWithIconsProps } from '@/components/common/ListWithIcons'
|
|
3
14
|
import { ListWithIconsItemData } from '@/components/common/ListWithIcons/ListWithIcons.types'
|
|
4
15
|
import {
|
|
@@ -6,6 +17,19 @@ import {
|
|
|
6
17
|
RcSesSegmentedControlProps,
|
|
7
18
|
} from '@/components/common/SegmentedControl'
|
|
8
19
|
import { RcSesSegmentButtonProps } from '@/components/common/SegmentedControl/components/SegmentButton'
|
|
20
|
+
import {
|
|
21
|
+
RcSesServiceLinkItem,
|
|
22
|
+
RcSesServiceLinksProps,
|
|
23
|
+
RcSesServiceLinksTestIds,
|
|
24
|
+
} from '@/components/common/ServiceLinks/types'
|
|
25
|
+
import { RcSesSideNavItem } from '@/components/common/SideNav'
|
|
26
|
+
import { RcSesSideNavLayoutProps } from '@/components/common/SideNav/SideNavLayout'
|
|
27
|
+
import {
|
|
28
|
+
RcSesTitleBlockProps,
|
|
29
|
+
RcSesTitleBlockTestIds,
|
|
30
|
+
TitleBlockHeadingLevel,
|
|
31
|
+
TitleBlockTitleVariant,
|
|
32
|
+
} from '@/components/common/TitleBlock/types'
|
|
9
33
|
import { RcSesTooltipProps } from '@/components/common/Tooltip'
|
|
10
34
|
import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControlLabel'
|
|
11
35
|
import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
|
|
@@ -25,6 +49,7 @@ import { ModalVariant, RcSesModalProps } from '@/components/overlays/Modal'
|
|
|
25
49
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
26
50
|
|
|
27
51
|
export type { ListWithIconsProps, ListWithIconsItemData }
|
|
52
|
+
export type { RcSesServiceLinksProps, RcSesServiceLinkItem, RcSesServiceLinksTestIds }
|
|
28
53
|
export type { ButtonProps }
|
|
29
54
|
|
|
30
55
|
export type {
|
|
@@ -34,6 +59,17 @@ export type {
|
|
|
34
59
|
RcSesLoaderSize,
|
|
35
60
|
RcSesCardFormContainerProps,
|
|
36
61
|
RcSesCardProps,
|
|
62
|
+
RcSesCardShellProps,
|
|
63
|
+
RcSesCardShellTestIds,
|
|
64
|
+
RcSesTitleBlockProps,
|
|
65
|
+
RcSesTitleBlockTestIds,
|
|
66
|
+
RcSesCardFooterProps,
|
|
67
|
+
RcSesCardFooterTestIds,
|
|
68
|
+
CardFooterAlign,
|
|
69
|
+
CardShellVariant,
|
|
70
|
+
CardShellTheme,
|
|
71
|
+
TitleBlockHeadingLevel,
|
|
72
|
+
TitleBlockTitleVariant,
|
|
37
73
|
RcSesSegmentedControlProps,
|
|
38
74
|
RcSesSegmentButtonProps,
|
|
39
75
|
RcSesSegmentOption,
|
|
@@ -43,6 +79,8 @@ export type {
|
|
|
43
79
|
RcSesLoadingSpinnerProps,
|
|
44
80
|
RcSesSpinnerColor,
|
|
45
81
|
RcSesTooltipProps,
|
|
82
|
+
RcSesSideNavItem,
|
|
83
|
+
RcSesSideNavLayoutProps,
|
|
46
84
|
}
|
|
47
85
|
export type { RcSesDialogProps, DialogSize }
|
|
48
86
|
export type { RcSesModalProps, ModalVariant }
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
+
|
|
4
|
+
import UserIcon from '@/assets/icons/UserIcon'
|
|
5
|
+
import RcSesButton from '@/components/common/Button'
|
|
6
|
+
import RcSesCardShell from '@/components/common/CardShell'
|
|
7
|
+
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
8
|
+
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
9
|
+
import RcSesTitleBlock from '@/components/common/TitleBlock'
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof RcSesCardShell> = {
|
|
12
|
+
title: 'components/display/CardShell',
|
|
13
|
+
component: RcSesCardShell,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
description: {
|
|
18
|
+
component:
|
|
19
|
+
'CardShell is a low-level building-block component for card structure and styling. It provides header, content, and footer slots with different variants (card, subcard) and themes (default, brand, sunken). Unlike a ready-to-use Card component, CardShell has no built-in content and serves as a foundation for building more complex cards.',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
viewport: {
|
|
23
|
+
options: {
|
|
24
|
+
mobile375: { name: 'Mobile 375', styles: { height: '900px', width: '375px' } },
|
|
25
|
+
tablet768: { name: 'Tablet 768', styles: { height: '900px', width: '768px' } },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
controls: {
|
|
29
|
+
include: [
|
|
30
|
+
'variant',
|
|
31
|
+
'theme',
|
|
32
|
+
'fullHeight',
|
|
33
|
+
'borderless',
|
|
34
|
+
'header',
|
|
35
|
+
'children',
|
|
36
|
+
'footer',
|
|
37
|
+
'testIds',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
argTypes: {
|
|
42
|
+
variant: {
|
|
43
|
+
control: 'select',
|
|
44
|
+
options: ['card', 'subcard'],
|
|
45
|
+
description: 'Visual variant of the card',
|
|
46
|
+
},
|
|
47
|
+
theme: {
|
|
48
|
+
control: 'select',
|
|
49
|
+
options: ['default', 'brand', 'sunken'],
|
|
50
|
+
description: 'Color theme of the card',
|
|
51
|
+
},
|
|
52
|
+
fullHeight: {
|
|
53
|
+
control: 'boolean',
|
|
54
|
+
description: 'Whether the card should take full height of its container',
|
|
55
|
+
},
|
|
56
|
+
borderless: {
|
|
57
|
+
control: 'boolean',
|
|
58
|
+
description: 'Renders the shell without any border',
|
|
59
|
+
},
|
|
60
|
+
header: {
|
|
61
|
+
control: false,
|
|
62
|
+
description: 'Header content (ReactNode)',
|
|
63
|
+
},
|
|
64
|
+
children: {
|
|
65
|
+
control: false,
|
|
66
|
+
description: 'Main content (ReactNode)',
|
|
67
|
+
},
|
|
68
|
+
footer: {
|
|
69
|
+
control: false,
|
|
70
|
+
description: 'Footer content (ReactNode)',
|
|
71
|
+
},
|
|
72
|
+
testIds: {
|
|
73
|
+
control: false,
|
|
74
|
+
description: 'Test IDs for the card elements',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default meta
|
|
80
|
+
|
|
81
|
+
type Story = StoryObj<typeof RcSesCardShell>
|
|
82
|
+
|
|
83
|
+
const SampleHeader = () => (
|
|
84
|
+
<RcSesTitleBlock
|
|
85
|
+
title='Kortelės antraštė'
|
|
86
|
+
description='Paaiškinimas apie šios kortelės turinį'
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const SampleContent = () => (
|
|
91
|
+
<Box
|
|
92
|
+
sx={{
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
color: 'text.primary',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
justifyContent: 'center',
|
|
97
|
+
minHeight: { xs: '9.625rem', md: '11.5rem' },
|
|
98
|
+
px: 3,
|
|
99
|
+
width: '100%',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<Typography align='center'>Turinys (Body slot)</Typography>
|
|
103
|
+
</Box>
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const SampleFooter = () => (
|
|
107
|
+
<RcSesCardFooter>
|
|
108
|
+
<RcSesButton color='grey' variant='outlined'>
|
|
109
|
+
Atšaukti
|
|
110
|
+
</RcSesButton>
|
|
111
|
+
<RcSesButton>Tęsti</RcSesButton>
|
|
112
|
+
</RcSesCardFooter>
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
export const Default: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
variant: 'card',
|
|
118
|
+
theme: 'default',
|
|
119
|
+
header: <SampleHeader />,
|
|
120
|
+
children: <SampleContent />,
|
|
121
|
+
footer: <SampleFooter />,
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const SubcardVariant: Story = {
|
|
126
|
+
args: {
|
|
127
|
+
variant: 'subcard',
|
|
128
|
+
theme: 'default',
|
|
129
|
+
header: <SampleHeader />,
|
|
130
|
+
children: <SampleContent />,
|
|
131
|
+
footer: <SampleFooter />,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const BrandTheme: Story = {
|
|
136
|
+
args: {
|
|
137
|
+
variant: 'card',
|
|
138
|
+
theme: 'brand',
|
|
139
|
+
header: <SampleHeader />,
|
|
140
|
+
children: <SampleContent />,
|
|
141
|
+
footer: <SampleFooter />,
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const SunkenTheme: Story = {
|
|
146
|
+
args: {
|
|
147
|
+
variant: 'card',
|
|
148
|
+
theme: 'sunken',
|
|
149
|
+
header: <SampleHeader />,
|
|
150
|
+
children: <SampleContent />,
|
|
151
|
+
footer: <SampleFooter />,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const HeaderComplete: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
variant: 'card',
|
|
158
|
+
theme: 'default',
|
|
159
|
+
header: (
|
|
160
|
+
<RcSesTitleBlock
|
|
161
|
+
actions={
|
|
162
|
+
<RcSesButton color='grey' variant='outlined'>
|
|
163
|
+
Redaguoti
|
|
164
|
+
</RcSesButton>
|
|
165
|
+
}
|
|
166
|
+
count={4}
|
|
167
|
+
description='Paaiškinimas apie šios kortelės turinį'
|
|
168
|
+
icon={<RcSesIconWithCircularBackground Icon={UserIcon} size='medium' />}
|
|
169
|
+
title='Pasirinktos teisės'
|
|
170
|
+
/>
|
|
171
|
+
),
|
|
172
|
+
children: <SampleContent />,
|
|
173
|
+
footer: <SampleFooter />,
|
|
174
|
+
},
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export const Borderless: Story = {
|
|
178
|
+
args: {
|
|
179
|
+
variant: 'card',
|
|
180
|
+
theme: 'brand',
|
|
181
|
+
borderless: true,
|
|
182
|
+
header: <SampleHeader />,
|
|
183
|
+
children: <SampleContent />,
|
|
184
|
+
footer: <SampleFooter />,
|
|
185
|
+
},
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const WithoutHeader: Story = {
|
|
189
|
+
args: {
|
|
190
|
+
variant: 'card',
|
|
191
|
+
theme: 'default',
|
|
192
|
+
children: <SampleContent />,
|
|
193
|
+
footer: <SampleFooter />,
|
|
194
|
+
},
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const WithoutFooter: Story = {
|
|
198
|
+
args: {
|
|
199
|
+
variant: 'card',
|
|
200
|
+
theme: 'default',
|
|
201
|
+
header: <SampleHeader />,
|
|
202
|
+
children: <SampleContent />,
|
|
203
|
+
},
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const ContentOnly: Story = {
|
|
207
|
+
args: {
|
|
208
|
+
variant: 'card',
|
|
209
|
+
theme: 'default',
|
|
210
|
+
children: <SampleContent />,
|
|
211
|
+
},
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export const FullHeight: Story = {
|
|
215
|
+
args: {
|
|
216
|
+
variant: 'card',
|
|
217
|
+
theme: 'default',
|
|
218
|
+
fullHeight: true,
|
|
219
|
+
header: <SampleHeader />,
|
|
220
|
+
children: (
|
|
221
|
+
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
222
|
+
<Typography align='center'>Pilno aukščio turinys</Typography>
|
|
223
|
+
</Box>
|
|
224
|
+
),
|
|
225
|
+
footer: <SampleFooter />,
|
|
226
|
+
},
|
|
227
|
+
decorators: [
|
|
228
|
+
(Story) => (
|
|
229
|
+
<Box sx={{ height: '500px' }}>
|
|
230
|
+
<Story />
|
|
231
|
+
</Box>
|
|
232
|
+
),
|
|
233
|
+
],
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const MobileViewport: Story = {
|
|
237
|
+
args: {
|
|
238
|
+
variant: 'card',
|
|
239
|
+
theme: 'default',
|
|
240
|
+
header: <SampleHeader />,
|
|
241
|
+
children: <SampleContent />,
|
|
242
|
+
footer: <SampleFooter />,
|
|
243
|
+
},
|
|
244
|
+
// Two separate mechanisms, deliberately: the tag sets Playwright's browser
|
|
245
|
+
// width for the baseline, the global sets the canvas iframe width for anyone
|
|
246
|
+
// reviewing in Storybook. Docs pages render stories inline at the container's
|
|
247
|
+
// width, where neither applies, so this one is kept out of the docs page
|
|
248
|
+
// rather than showing a desktop card under a mobile heading.
|
|
249
|
+
tags: ['viewport-375', '!autodocs'],
|
|
250
|
+
globals: { viewport: { value: 'mobile375' } },
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export const TabletViewport: Story = {
|
|
254
|
+
args: {
|
|
255
|
+
variant: 'card',
|
|
256
|
+
theme: 'default',
|
|
257
|
+
header: <SampleHeader />,
|
|
258
|
+
children: <SampleContent />,
|
|
259
|
+
footer: <SampleFooter />,
|
|
260
|
+
},
|
|
261
|
+
tags: ['viewport-768', '!autodocs'],
|
|
262
|
+
globals: { viewport: { value: 'tablet768' } },
|
|
263
|
+
}
|
|
@@ -9,6 +9,7 @@ import SelectableCardList, {
|
|
|
9
9
|
type SelectableCardListItemData,
|
|
10
10
|
type SelectableCardListProps,
|
|
11
11
|
} from '@/components/common/SelectableCardList'
|
|
12
|
+
import RcSesFormControlWrapper from '@/components/form/components/FormControlWrapper'
|
|
12
13
|
|
|
13
14
|
const getListItems = (index: number): ListWithIconsItemData[] => {
|
|
14
15
|
switch (index) {
|
|
@@ -61,8 +62,11 @@ const meta = {
|
|
|
61
62
|
parameters: {
|
|
62
63
|
docs: {
|
|
63
64
|
description: {
|
|
64
|
-
component:
|
|
65
|
+
component: [
|
|
65
66
|
'Paginates items client-side, showing 5 per page on desktop and 3 per page on mobile (below the `md` breakpoint). The page resets to 1 whenever the page size changes, e.g. when resizing across the breakpoint.',
|
|
67
|
+
'',
|
|
68
|
+
'The `error` prop is a data-loading failure state: whatever node it receives is rendered **instead of** the cards and the pagination. It is not meant for form validation messages - for those wrap the list in `RcSesFormControlWrapper` and pass `errors`, which keeps the cards visible and shows the message below them. Compare the `Error` and `ValidationError` stories.',
|
|
69
|
+
].join('\n'),
|
|
66
70
|
},
|
|
67
71
|
},
|
|
68
72
|
},
|
|
@@ -132,4 +136,32 @@ export const Error: Story = {
|
|
|
132
136
|
args: {
|
|
133
137
|
error: 'Unable to load selectable cards. Please try again.',
|
|
134
138
|
},
|
|
139
|
+
parameters: {
|
|
140
|
+
docs: {
|
|
141
|
+
description: {
|
|
142
|
+
story:
|
|
143
|
+
'Data-loading failure state. `items` is still populated here, yet the cards and the pagination are replaced by the `error` node - that is what this prop does. Use it when the list could not be fetched, not to report an invalid selection.',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const ValidationError: Story = {
|
|
150
|
+
render: (args) => (
|
|
151
|
+
<RcSesFormControlWrapper
|
|
152
|
+
label='Service option'
|
|
153
|
+
required
|
|
154
|
+
errors={{ type: 'required', message: 'Select one of the options' }}
|
|
155
|
+
>
|
|
156
|
+
<SelectableCardListStory {...args} onSelect={args.onSelect ?? (() => {})} />
|
|
157
|
+
</RcSesFormControlWrapper>
|
|
158
|
+
),
|
|
159
|
+
parameters: {
|
|
160
|
+
docs: {
|
|
161
|
+
description: {
|
|
162
|
+
story:
|
|
163
|
+
"The way to report an invalid selection: wrap the list in `RcSesFormControlWrapper` and pass the react-hook-form `fieldState.error` as `errors`. The cards stay selectable and the message renders below them. Leave the list's own `error` prop unset.",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
135
167
|
}
|