@registrucentras/rc-ses-react-components 2.0.0-rc.3 → 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/index.d.ts +1 -1
- package/dist/components/common/CardShell/types.d.ts +3 -1
- 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 +8 -2
- package/dist/library/types.d.ts +6 -2
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +3412 -2728
- package/dist/stories/components/display/CardShell.stories.d.ts +1 -1
- 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/navigation/SideNav.stories.d.ts +7 -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/index.tsx +4 -1
- package/src/components/common/CardShell/types.ts +3 -1
- 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/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 +8 -2
- package/src/library/types.ts +20 -8
- package/src/stories/components/display/CardShell.stories.tsx +14 -12
- 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/navigation/SideNav.stories.tsx +110 -0
- package/src/theme/cards.ts +1 -1
- package/src/theme/light/MuiButton.tsx +6 -0
- package/dist/components/common/CardShell/CardHeader/index.d.ts +0 -3
- package/dist/components/common/CardShell/CardHeader/types.d.ts +0 -33
- package/src/components/common/CardShell/CardHeader/index.test.tsx +0 -207
- package/src/components/common/CardShell/CardHeader/index.tsx +0 -104
- package/src/components/common/CardShell/CardHeader/types.ts +0 -36
|
@@ -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,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
|
@@ -15,12 +15,14 @@ import RcSesButtonWithPopover from '@/components/common/Button/ButtonWithPopover
|
|
|
15
15
|
import RcSesCard from '@/components/common/Card'
|
|
16
16
|
import RcSesCardShell from '@/components/common/CardShell'
|
|
17
17
|
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
18
|
-
import RcSesCardHeader from '@/components/common/CardShell/CardHeader'
|
|
19
18
|
import DataPagination from '@/components/common/DataPagination'
|
|
20
19
|
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
20
|
+
import RcSesIconWithSquareBackground from '@/components/common/IconWithSquareBackground'
|
|
21
21
|
import RcSesImageCard from '@/components/common/ImageCard'
|
|
22
22
|
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
23
23
|
import RcSesSegmentedControl from '@/components/common/SegmentedControl'
|
|
24
|
+
import RcSesServiceLinks from '@/components/common/ServiceLinks'
|
|
25
|
+
import RcSesSideNavLayout from '@/components/common/SideNav/SideNavLayout'
|
|
24
26
|
import RcSesSnackbar from '@/components/common/Snackbar'
|
|
25
27
|
import {
|
|
26
28
|
RcSesSnackbarProvider,
|
|
@@ -31,6 +33,7 @@ import RcSesTab from '@/components/common/Tabs/Tab'
|
|
|
31
33
|
import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
|
|
32
34
|
import RcSesTabs from '@/components/common/Tabs/Tabs'
|
|
33
35
|
import RcSesTabsWrapper from '@/components/common/Tabs/TabsWrapper'
|
|
36
|
+
import RcSesTitleBlock from '@/components/common/TitleBlock'
|
|
34
37
|
import RcSesTooltip from '@/components/common/Tooltip'
|
|
35
38
|
import RcSesFormControlWrapper from '@/components/form/components/FormControlWrapper'
|
|
36
39
|
import RcSesCheckbox from '@/components/form/inputs/Checkbox'
|
|
@@ -85,7 +88,7 @@ export {
|
|
|
85
88
|
RcSesLoadingSpinner,
|
|
86
89
|
RcSesCard,
|
|
87
90
|
RcSesCardShell,
|
|
88
|
-
|
|
91
|
+
RcSesTitleBlock,
|
|
89
92
|
RcSesCardFooter,
|
|
90
93
|
RcSesDialog,
|
|
91
94
|
RcSesFooter,
|
|
@@ -96,6 +99,7 @@ export {
|
|
|
96
99
|
RcSesSwitch,
|
|
97
100
|
}
|
|
98
101
|
export { RcSesSegmentedControl }
|
|
102
|
+
export { RcSesSideNavLayout }
|
|
99
103
|
export { RcSesCheckbox, RcSesCheckboxFormControl, RcSesSimpleCheckbox }
|
|
100
104
|
export { useSnackbar }
|
|
101
105
|
export { RcSesDatepicker }
|
|
@@ -112,6 +116,7 @@ export { RcSesTooltip }
|
|
|
112
116
|
export { RcSesTextField }
|
|
113
117
|
export { DataPagination }
|
|
114
118
|
export { ListWithIcons }
|
|
119
|
+
export { RcSesServiceLinks }
|
|
115
120
|
export { ServiceWizardStepper }
|
|
116
121
|
export { RcSesFormControlLabel }
|
|
117
122
|
export { SelectableCardList }
|
|
@@ -129,5 +134,6 @@ export {
|
|
|
129
134
|
|
|
130
135
|
export type { RcSesIconProps }
|
|
131
136
|
export { RcSesIconWithCircularBackground }
|
|
137
|
+
export { RcSesIconWithSquareBackground }
|
|
132
138
|
|
|
133
139
|
export * from './icons'
|
package/src/library/types.ts
CHANGED
|
@@ -4,11 +4,6 @@ import {
|
|
|
4
4
|
RcSesCardFooterProps,
|
|
5
5
|
RcSesCardFooterTestIds,
|
|
6
6
|
} from '@/components/common/CardShell/CardFooter/types'
|
|
7
|
-
import {
|
|
8
|
-
CardHeadingLevel,
|
|
9
|
-
RcSesCardHeaderProps,
|
|
10
|
-
RcSesCardHeaderTestIds,
|
|
11
|
-
} from '@/components/common/CardShell/CardHeader/types'
|
|
12
7
|
import {
|
|
13
8
|
CardShellTheme,
|
|
14
9
|
CardShellVariant,
|
|
@@ -22,6 +17,19 @@ import {
|
|
|
22
17
|
RcSesSegmentedControlProps,
|
|
23
18
|
} from '@/components/common/SegmentedControl'
|
|
24
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'
|
|
25
33
|
import { RcSesTooltipProps } from '@/components/common/Tooltip'
|
|
26
34
|
import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControlLabel'
|
|
27
35
|
import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
|
|
@@ -41,6 +49,7 @@ import { ModalVariant, RcSesModalProps } from '@/components/overlays/Modal'
|
|
|
41
49
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
42
50
|
|
|
43
51
|
export type { ListWithIconsProps, ListWithIconsItemData }
|
|
52
|
+
export type { RcSesServiceLinksProps, RcSesServiceLinkItem, RcSesServiceLinksTestIds }
|
|
44
53
|
export type { ButtonProps }
|
|
45
54
|
|
|
46
55
|
export type {
|
|
@@ -52,14 +61,15 @@ export type {
|
|
|
52
61
|
RcSesCardProps,
|
|
53
62
|
RcSesCardShellProps,
|
|
54
63
|
RcSesCardShellTestIds,
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
RcSesTitleBlockProps,
|
|
65
|
+
RcSesTitleBlockTestIds,
|
|
57
66
|
RcSesCardFooterProps,
|
|
58
67
|
RcSesCardFooterTestIds,
|
|
59
68
|
CardFooterAlign,
|
|
60
69
|
CardShellVariant,
|
|
61
70
|
CardShellTheme,
|
|
62
|
-
|
|
71
|
+
TitleBlockHeadingLevel,
|
|
72
|
+
TitleBlockTitleVariant,
|
|
63
73
|
RcSesSegmentedControlProps,
|
|
64
74
|
RcSesSegmentButtonProps,
|
|
65
75
|
RcSesSegmentOption,
|
|
@@ -69,6 +79,8 @@ export type {
|
|
|
69
79
|
RcSesLoadingSpinnerProps,
|
|
70
80
|
RcSesSpinnerColor,
|
|
71
81
|
RcSesTooltipProps,
|
|
82
|
+
RcSesSideNavItem,
|
|
83
|
+
RcSesSideNavLayoutProps,
|
|
72
84
|
}
|
|
73
85
|
export type { RcSesDialogProps, DialogSize }
|
|
74
86
|
export type { RcSesModalProps, ModalVariant }
|
|
@@ -5,8 +5,8 @@ import UserIcon from '@/assets/icons/UserIcon'
|
|
|
5
5
|
import RcSesButton from '@/components/common/Button'
|
|
6
6
|
import RcSesCardShell from '@/components/common/CardShell'
|
|
7
7
|
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
8
|
-
import RcSesCardHeader from '@/components/common/CardShell/CardHeader'
|
|
9
8
|
import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
|
|
9
|
+
import RcSesTitleBlock from '@/components/common/TitleBlock'
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof RcSesCardShell> = {
|
|
12
12
|
title: 'components/display/CardShell',
|
|
@@ -30,6 +30,7 @@ const meta: Meta<typeof RcSesCardShell> = {
|
|
|
30
30
|
'variant',
|
|
31
31
|
'theme',
|
|
32
32
|
'fullHeight',
|
|
33
|
+
'borderless',
|
|
33
34
|
'header',
|
|
34
35
|
'children',
|
|
35
36
|
'footer',
|
|
@@ -52,6 +53,10 @@ const meta: Meta<typeof RcSesCardShell> = {
|
|
|
52
53
|
control: 'boolean',
|
|
53
54
|
description: 'Whether the card should take full height of its container',
|
|
54
55
|
},
|
|
56
|
+
borderless: {
|
|
57
|
+
control: 'boolean',
|
|
58
|
+
description: 'Renders the shell without any border',
|
|
59
|
+
},
|
|
55
60
|
header: {
|
|
56
61
|
control: false,
|
|
57
62
|
description: 'Header content (ReactNode)',
|
|
@@ -76,7 +81,7 @@ export default meta
|
|
|
76
81
|
type Story = StoryObj<typeof RcSesCardShell>
|
|
77
82
|
|
|
78
83
|
const SampleHeader = () => (
|
|
79
|
-
<
|
|
84
|
+
<RcSesTitleBlock
|
|
80
85
|
title='Kortelės antraštė'
|
|
81
86
|
description='Paaiškinimas apie šios kortelės turinį'
|
|
82
87
|
/>
|
|
@@ -152,7 +157,7 @@ export const HeaderComplete: Story = {
|
|
|
152
157
|
variant: 'card',
|
|
153
158
|
theme: 'default',
|
|
154
159
|
header: (
|
|
155
|
-
<
|
|
160
|
+
<RcSesTitleBlock
|
|
156
161
|
actions={
|
|
157
162
|
<RcSesButton color='grey' variant='outlined'>
|
|
158
163
|
Redaguoti
|
|
@@ -169,26 +174,23 @@ export const HeaderComplete: Story = {
|
|
|
169
174
|
},
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
export const
|
|
177
|
+
export const Borderless: Story = {
|
|
173
178
|
args: {
|
|
174
179
|
variant: 'card',
|
|
175
|
-
theme: '
|
|
180
|
+
theme: 'brand',
|
|
181
|
+
borderless: true,
|
|
182
|
+
header: <SampleHeader />,
|
|
176
183
|
children: <SampleContent />,
|
|
177
184
|
footer: <SampleFooter />,
|
|
178
185
|
},
|
|
179
186
|
}
|
|
180
187
|
|
|
181
|
-
export const
|
|
188
|
+
export const WithoutHeader: Story = {
|
|
182
189
|
args: {
|
|
183
190
|
variant: 'card',
|
|
184
191
|
theme: 'default',
|
|
185
|
-
header: <SampleHeader />,
|
|
186
192
|
children: <SampleContent />,
|
|
187
|
-
footer:
|
|
188
|
-
<RcSesCardFooter align='start' stretchOnMobile={false}>
|
|
189
|
-
<RcSesButton variant='link'>Žiūrėti visas</RcSesButton>
|
|
190
|
-
</RcSesCardFooter>
|
|
191
|
-
),
|
|
193
|
+
footer: <SampleFooter />,
|
|
192
194
|
},
|
|
193
195
|
}
|
|
194
196
|
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { BriefcaseIcon } from '@phosphor-icons/react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
+
|
|
4
|
+
import RcSesButton from '@/components/common/Button'
|
|
5
|
+
import RcSesCardShell from '@/components/common/CardShell'
|
|
6
|
+
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
7
|
+
import RcSesIconWithSquareBackground from '@/components/common/IconWithSquareBackground'
|
|
8
|
+
import RcSesServiceLinks from '@/components/common/ServiceLinks'
|
|
9
|
+
import {
|
|
10
|
+
RcSesServiceLinkItem,
|
|
11
|
+
RcSesServiceLinksProps,
|
|
12
|
+
} from '@/components/common/ServiceLinks/types'
|
|
13
|
+
import RcSesTitleBlock from '@/components/common/TitleBlock'
|
|
14
|
+
|
|
15
|
+
const baseItems: RcSesServiceLinkItem[] = [
|
|
16
|
+
{ label: 'Juridinių asmenų registro (JAR) išrašas', href: '#jar' },
|
|
17
|
+
{ label: 'Juridinio asmens steigimas', href: '#steigimas' },
|
|
18
|
+
{ label: 'Dalyvių sąrašo teikimas (JADIS)', href: '#jadis' },
|
|
19
|
+
{ label: 'Įmonių ir organizacijų dokumentų kopijos', href: '#kopijos' },
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
const meta: Meta<typeof RcSesServiceLinks> = {
|
|
23
|
+
title: 'components/display/ServiceLinks',
|
|
24
|
+
component: RcSesServiceLinks,
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
parameters: {
|
|
27
|
+
docs: {
|
|
28
|
+
description: {
|
|
29
|
+
component:
|
|
30
|
+
'ServiceLinks is a standalone, vertical list of navigational service links, each row pairing a label with a trailing arrow. It carries no card shell of its own and is intended to be placed inside a CardShell content, could be together with a CardHeader and CardFooter.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
viewport: {
|
|
34
|
+
options: {
|
|
35
|
+
mobile375: { name: 'Mobile 375', styles: { height: '900px', width: '375px' } },
|
|
36
|
+
tablet768: { name: 'Tablet 768', styles: { height: '900px', width: '768px' } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
argTypes: {
|
|
41
|
+
items: { control: false },
|
|
42
|
+
dividers: { control: 'boolean' },
|
|
43
|
+
isLoading: { control: 'boolean' },
|
|
44
|
+
skeletonCount: { control: 'number' },
|
|
45
|
+
linkComponent: { control: false },
|
|
46
|
+
testIds: { control: false },
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default meta
|
|
51
|
+
|
|
52
|
+
type Story = StoryObj<typeof RcSesServiceLinks>
|
|
53
|
+
|
|
54
|
+
export const Default: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
items: baseItems,
|
|
57
|
+
dividers: true,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const WithoutDividers: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
items: baseItems,
|
|
64
|
+
dividers: false,
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const WithDisabledItem: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
items: [...baseItems.slice(0, 3), { label: 'Netrukus (neaktyvus)', disabled: true }],
|
|
71
|
+
dividers: true,
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Loading: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
items: [],
|
|
78
|
+
isLoading: true,
|
|
79
|
+
skeletonCount: 4,
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Items with `target='_blank'` open in a new tab. The shell automatically
|
|
85
|
+
* adds `rel='noopener noreferrer'` on those rows for safety; other rows get
|
|
86
|
+
* no `rel` attribute.
|
|
87
|
+
*/
|
|
88
|
+
export const ExternalLinks: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
items: [
|
|
91
|
+
{ label: 'Vidinė nuoroda', href: '#internal' },
|
|
92
|
+
{
|
|
93
|
+
label: 'Išorinė nuoroda (naujame lange)',
|
|
94
|
+
href: 'https://example.com',
|
|
95
|
+
target: '_blank',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
dividers: true,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Passing a `linkComponent` renders every navigable row through it. The shell
|
|
104
|
+
* forwards `href`, `onClick`, and (when the item sets `target='_blank'`) also
|
|
105
|
+
* `target` and `rel='noopener noreferrer'`. Adapt a router `Link` with a
|
|
106
|
+
* one-line wrapper — as long as it renders a real `<a>` underneath,
|
|
107
|
+
* middle-click and "open in new tab" keep working.
|
|
108
|
+
*/
|
|
109
|
+
export const WithRouterLink: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
items: baseItems,
|
|
112
|
+
dividers: true,
|
|
113
|
+
linkComponent: ({ href, children, ...rest }: React.ComponentProps<'a'>) => (
|
|
114
|
+
// Stand-in for a router `Link`; a real adapter would forward `href`
|
|
115
|
+
// as `to`, e.g. `<RouterLink to={href!} {...rest}>{children}</RouterLink>`.
|
|
116
|
+
<a href={href} {...rest} data-router-link>
|
|
117
|
+
{children}
|
|
118
|
+
</a>
|
|
119
|
+
),
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The intended composition: ServiceLinks placed inside a CardShell as the
|
|
125
|
+
* content slot, framed by a CardHeader and a CardFooter.
|
|
126
|
+
*/
|
|
127
|
+
export const InsideCardShell: Story = {
|
|
128
|
+
render: (args: RcSesServiceLinksProps) => (
|
|
129
|
+
<RcSesCardShell
|
|
130
|
+
theme='brand'
|
|
131
|
+
borderless
|
|
132
|
+
header={
|
|
133
|
+
<RcSesTitleBlock
|
|
134
|
+
icon={<RcSesIconWithSquareBackground Icon={BriefcaseIcon} variant='solid' />}
|
|
135
|
+
title='Įmonėms ir organizacijoms'
|
|
136
|
+
titleVariant='h5'
|
|
137
|
+
/>
|
|
138
|
+
}
|
|
139
|
+
footer={
|
|
140
|
+
<RcSesCardFooter align='start'>
|
|
141
|
+
<RcSesButton variant='contained' color='primary'>
|
|
142
|
+
Žiūrėti visas
|
|
143
|
+
</RcSesButton>
|
|
144
|
+
</RcSesCardFooter>
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
<RcSesServiceLinks {...args} />
|
|
148
|
+
</RcSesCardShell>
|
|
149
|
+
),
|
|
150
|
+
args: {
|
|
151
|
+
items: baseItems,
|
|
152
|
+
dividers: true,
|
|
153
|
+
},
|
|
154
|
+
}
|