@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,17 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { default as RcSesCardShell } from '../../../components/common/CardShell';
|
|
3
|
+
declare const meta: Meta<typeof RcSesCardShell>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RcSesCardShell>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const SubcardVariant: Story;
|
|
8
|
+
export declare const BrandTheme: Story;
|
|
9
|
+
export declare const SunkenTheme: Story;
|
|
10
|
+
export declare const HeaderComplete: Story;
|
|
11
|
+
export declare const Borderless: Story;
|
|
12
|
+
export declare const WithoutHeader: Story;
|
|
13
|
+
export declare const WithoutFooter: Story;
|
|
14
|
+
export declare const ContentOnly: Story;
|
|
15
|
+
export declare const FullHeight: Story;
|
|
16
|
+
export declare const MobileViewport: Story;
|
|
17
|
+
export declare const TabletViewport: Story;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { default as RcSesServiceLinks } from '../../../components/common/ServiceLinks';
|
|
3
|
+
declare const meta: Meta<typeof RcSesServiceLinks>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RcSesServiceLinks>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithoutDividers: Story;
|
|
8
|
+
export declare const WithDisabledItem: Story;
|
|
9
|
+
export declare const Loading: Story;
|
|
10
|
+
/**
|
|
11
|
+
* Items with `target='_blank'` open in a new tab. The shell automatically
|
|
12
|
+
* adds `rel='noopener noreferrer'` on those rows for safety; other rows get
|
|
13
|
+
* no `rel` attribute.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ExternalLinks: Story;
|
|
16
|
+
/**
|
|
17
|
+
* Passing a `linkComponent` renders every navigable row through it. The shell
|
|
18
|
+
* forwards `href`, `onClick`, and (when the item sets `target='_blank'`) also
|
|
19
|
+
* `target` and `rel='noopener noreferrer'`. Adapt a router `Link` with a
|
|
20
|
+
* one-line wrapper — as long as it renders a real `<a>` underneath,
|
|
21
|
+
* middle-click and "open in new tab" keep working.
|
|
22
|
+
*/
|
|
23
|
+
export declare const WithRouterLink: Story;
|
|
24
|
+
/**
|
|
25
|
+
* The intended composition: ServiceLinks placed inside a CardShell as the
|
|
26
|
+
* content slot, framed by a CardHeader and a CardFooter.
|
|
27
|
+
*/
|
|
28
|
+
export declare const InsideCardShell: Story;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { default as RcSesTitleBlock } from '../../../components/common/TitleBlock';
|
|
3
|
+
declare const meta: Meta<typeof RcSesTitleBlock>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RcSesTitleBlock>;
|
|
6
|
+
export declare const TitleBlock: Story;
|
|
7
|
+
export declare const WithPrimaryAction: Story;
|
|
8
|
+
export declare const WithLinkAction: Story;
|
|
9
|
+
export declare const WithPrimaryAndSecondaryActions: Story;
|
|
10
|
+
export declare const RowList: Story;
|
|
11
|
+
export declare const RowListWithIcons: Story;
|
|
12
|
+
export declare const RowListWithIconsAndTwoActions: Story;
|
|
13
|
+
export declare const HorizontalTitleBlockWithIconAndArrow: Story;
|
|
14
|
+
export declare const HorizontalTitleBlockWithArrowAndBrandCardShellTheme: Story;
|
|
15
|
+
export declare const HorizontalTitleBlockWithArrowAndSunkenCardShellTheme: Story;
|
|
16
|
+
export declare const ClickableHorizontalTitleBlockWithCardShellBase: Story;
|
|
17
|
+
export declare const VerticalTitleBlockWithCardShellBase: Story;
|
|
18
|
+
export declare const VerticalTitleBlock: Story;
|
|
19
|
+
export declare const MobileViewport: Story;
|
|
20
|
+
export declare const TabletViewport: Story;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { default as RcSesIconWithSquareBackground } from '../../../components/common/IconWithSquareBackground';
|
|
3
|
+
declare const meta: Meta<typeof RcSesIconWithSquareBackground>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const AllVariantsAndSizes: Story;
|
|
@@ -37,9 +37,116 @@ export declare const CalendarOpen: {
|
|
|
37
37
|
};
|
|
38
38
|
parameters: {
|
|
39
39
|
docs: {
|
|
40
|
+
story: {
|
|
41
|
+
inline: boolean;
|
|
42
|
+
iframeHeight: number;
|
|
43
|
+
};
|
|
40
44
|
description: {
|
|
41
45
|
story: string;
|
|
42
46
|
};
|
|
43
47
|
};
|
|
44
48
|
};
|
|
45
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Days past the 20th are out of range: they must read as greyed out, not merely
|
|
52
|
+
* be unclickable. Disabled weekends stay red.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CalendarWithDisabledDates: {
|
|
55
|
+
render: (args: any) => import("react").JSX.Element;
|
|
56
|
+
parameters: {
|
|
57
|
+
docs: {
|
|
58
|
+
story: {
|
|
59
|
+
inline: boolean;
|
|
60
|
+
iframeHeight: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
args: {
|
|
65
|
+
clearable: boolean;
|
|
66
|
+
label: string;
|
|
67
|
+
open: boolean;
|
|
68
|
+
rules: {
|
|
69
|
+
required: boolean;
|
|
70
|
+
};
|
|
71
|
+
datepickerProps: {
|
|
72
|
+
maxDate: Date;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A scattered rule rather than a range, so disabled days sit between selectable
|
|
78
|
+
* ones.
|
|
79
|
+
*/
|
|
80
|
+
export declare const CalendarWithDisabledRule: {
|
|
81
|
+
render: (args: any) => import("react").JSX.Element;
|
|
82
|
+
parameters: {
|
|
83
|
+
docs: {
|
|
84
|
+
story: {
|
|
85
|
+
inline: boolean;
|
|
86
|
+
iframeHeight: number;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
args: {
|
|
91
|
+
clearable: boolean;
|
|
92
|
+
label: string;
|
|
93
|
+
open: boolean;
|
|
94
|
+
rules: {
|
|
95
|
+
required: boolean;
|
|
96
|
+
};
|
|
97
|
+
datepickerProps: {
|
|
98
|
+
shouldDisableDate: (date: Date) => boolean;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Covers the `Mui-selected` day styling.
|
|
104
|
+
*/
|
|
105
|
+
export declare const CalendarWithValue: {
|
|
106
|
+
render: (args: any) => import("react").JSX.Element;
|
|
107
|
+
parameters: {
|
|
108
|
+
docs: {
|
|
109
|
+
story: {
|
|
110
|
+
inline: boolean;
|
|
111
|
+
iframeHeight: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
args: {
|
|
116
|
+
clearable: boolean;
|
|
117
|
+
label: string;
|
|
118
|
+
open: boolean;
|
|
119
|
+
rules: {
|
|
120
|
+
required: boolean;
|
|
121
|
+
};
|
|
122
|
+
value: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* The whole field disabled - a different state from a disabled day.
|
|
127
|
+
*/
|
|
128
|
+
export declare const Disabled: {
|
|
129
|
+
render: (args: any) => import("react").JSX.Element;
|
|
130
|
+
args: {
|
|
131
|
+
clearable: boolean;
|
|
132
|
+
disabled: boolean;
|
|
133
|
+
label: string;
|
|
134
|
+
rules: {
|
|
135
|
+
required: boolean;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The error state: input border and helper text.
|
|
141
|
+
*/
|
|
142
|
+
export declare const WithError: {
|
|
143
|
+
render: (args: any) => import("react").JSX.Element;
|
|
144
|
+
args: {
|
|
145
|
+
clearable: boolean;
|
|
146
|
+
error: string;
|
|
147
|
+
label: string;
|
|
148
|
+
rules: {
|
|
149
|
+
required: boolean;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { default as RcSesSideNavLayout } from '../../../components/common/SideNav/SideNavLayout';
|
|
3
|
+
declare const meta: Meta<typeof RcSesSideNavLayout>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RcSesSideNavLayout>;
|
|
6
|
+
export declare const Main: Story;
|
|
7
|
+
export declare const WithScrollSpy: Story;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card surface tokens - Figma `Cards/card/*` and `Cards/subcard/*`.
|
|
3
|
+
*
|
|
4
|
+
* The boxed surface lives here rather than in the component that draws it, so
|
|
5
|
+
* anything needing a boxed row reads the same values instead of copying them.
|
|
6
|
+
* `MuiCard` keeps its own radius until `RcSesCard` is deprecated.
|
|
7
|
+
*/
|
|
8
|
+
declare const borderWidth = "1px";
|
|
9
|
+
declare const card: {
|
|
10
|
+
borderRadius: string;
|
|
11
|
+
gap: {
|
|
12
|
+
xs: string;
|
|
13
|
+
md: string;
|
|
14
|
+
};
|
|
15
|
+
padding: {
|
|
16
|
+
xs: string;
|
|
17
|
+
md: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare const subcard: {
|
|
21
|
+
borderRadius: string;
|
|
22
|
+
gap: {
|
|
23
|
+
xs: string;
|
|
24
|
+
md: string;
|
|
25
|
+
};
|
|
26
|
+
padding: {
|
|
27
|
+
xs: string;
|
|
28
|
+
md: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Card header values. Two of them are departures from the type scale: the title
|
|
33
|
+
* is `h6` at weight 600 rather than 500, and the description is `body2` on a
|
|
34
|
+
* 1.25rem line. The three gaps follow the surrounding components - the row gap
|
|
35
|
+
* matches the card gap and the actions gap matches the footer - rather than a
|
|
36
|
+
* measured token. All six are pending confirmation against the DS.
|
|
37
|
+
*/
|
|
38
|
+
declare const header: {
|
|
39
|
+
actionsGap: string;
|
|
40
|
+
badgeGap: string;
|
|
41
|
+
descriptionLineHeight: string;
|
|
42
|
+
gap: string;
|
|
43
|
+
rowGap: string;
|
|
44
|
+
titleFontWeight: number;
|
|
45
|
+
};
|
|
46
|
+
declare const footer: {
|
|
47
|
+
gap: string;
|
|
48
|
+
};
|
|
49
|
+
declare const themes: {
|
|
50
|
+
brand: {
|
|
51
|
+
backgroundColor: string;
|
|
52
|
+
borderColor: string;
|
|
53
|
+
};
|
|
54
|
+
default: {
|
|
55
|
+
backgroundColor: string;
|
|
56
|
+
borderColor: string;
|
|
57
|
+
};
|
|
58
|
+
sunken: {
|
|
59
|
+
backgroundColor: string;
|
|
60
|
+
borderColor: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export { borderWidth, card, footer, header, subcard, themes };
|
|
64
|
+
declare const _default: {
|
|
65
|
+
borderWidth: string;
|
|
66
|
+
card: {
|
|
67
|
+
borderRadius: string;
|
|
68
|
+
gap: {
|
|
69
|
+
xs: string;
|
|
70
|
+
md: string;
|
|
71
|
+
};
|
|
72
|
+
padding: {
|
|
73
|
+
xs: string;
|
|
74
|
+
md: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
footer: {
|
|
78
|
+
gap: string;
|
|
79
|
+
};
|
|
80
|
+
header: {
|
|
81
|
+
actionsGap: string;
|
|
82
|
+
badgeGap: string;
|
|
83
|
+
descriptionLineHeight: string;
|
|
84
|
+
gap: string;
|
|
85
|
+
rowGap: string;
|
|
86
|
+
titleFontWeight: number;
|
|
87
|
+
};
|
|
88
|
+
subcard: {
|
|
89
|
+
borderRadius: string;
|
|
90
|
+
gap: {
|
|
91
|
+
xs: string;
|
|
92
|
+
md: string;
|
|
93
|
+
};
|
|
94
|
+
padding: {
|
|
95
|
+
xs: string;
|
|
96
|
+
md: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
themes: {
|
|
100
|
+
brand: {
|
|
101
|
+
backgroundColor: string;
|
|
102
|
+
borderColor: string;
|
|
103
|
+
};
|
|
104
|
+
default: {
|
|
105
|
+
backgroundColor: string;
|
|
106
|
+
borderColor: string;
|
|
107
|
+
};
|
|
108
|
+
sunken: {
|
|
109
|
+
backgroundColor: string;
|
|
110
|
+
borderColor: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PickerComponents } from '@mui/x-date-pickers/themeAugmentation';
|
|
2
|
+
/**
|
|
3
|
+
* x-date-pickers 9 gives the picker its own field components, which none of the
|
|
4
|
+
* `MuiInputBase` / `MuiOutlinedInput` slots reach. This mirrors them onto the
|
|
5
|
+
* picker slots - keep the two in step.
|
|
6
|
+
*/
|
|
7
|
+
declare const MuiPickersOutlinedInput: PickerComponents['MuiPickersOutlinedInput'];
|
|
8
|
+
export default MuiPickersOutlinedInput;
|
package/package.json
CHANGED
|
@@ -2,13 +2,14 @@ import { ArrowRightIcon as PhosphorArrowRightIcon } from '@phosphor-icons/react'
|
|
|
2
2
|
|
|
3
3
|
import IconProps from '../IconProps'
|
|
4
4
|
|
|
5
|
-
function ArrowRightIcon({ className, size = 24, fillColor, ...rest }: IconProps) {
|
|
5
|
+
function ArrowRightIcon({ className, size = 24, fillColor, weight, ...rest }: IconProps) {
|
|
6
6
|
return (
|
|
7
7
|
<PhosphorArrowRightIcon
|
|
8
8
|
{...rest}
|
|
9
9
|
className={className}
|
|
10
10
|
size={size}
|
|
11
11
|
color={fillColor}
|
|
12
|
+
weight={weight}
|
|
12
13
|
/>
|
|
13
14
|
)
|
|
14
15
|
}
|
|
@@ -62,6 +62,9 @@ const AdvancedListItem = ({
|
|
|
62
62
|
const isSelectable = leading.type === 'checkbox' || leading.type === 'radio'
|
|
63
63
|
const isClickable = (!!onClick || isSelectable) && !isDisabled
|
|
64
64
|
|
|
65
|
+
const effectiveState: AdvancedListItemState =
|
|
66
|
+
state === 'rest' && 'checked' in leading && leading.checked ? 'selected' : state
|
|
67
|
+
|
|
65
68
|
const hasInteractiveChild =
|
|
66
69
|
INTERACTIVE_LEADING_TYPES.has(leading.type) ||
|
|
67
70
|
INTERACTIVE_TRAILING_TYPES.has(trailing.type) ||
|
|
@@ -88,8 +91,8 @@ const AdvancedListItem = ({
|
|
|
88
91
|
const contentRef = useRef<HTMLDivElement>(null)
|
|
89
92
|
const prefersReducedMotion = usePrefersReducedMotion()
|
|
90
93
|
|
|
91
|
-
const borderColor = STATE_BORDER_COLOR[
|
|
92
|
-
const backgroundColor =
|
|
94
|
+
const borderColor = STATE_BORDER_COLOR[effectiveState]
|
|
95
|
+
const backgroundColor = effectiveState === 'selected' ? palette.primary[50] : undefined
|
|
93
96
|
const focusRingShadow = `0 0 0 ${FOCUS_RING_WIDTH} ${palette.primary.main}`
|
|
94
97
|
const transitionTiming = `${motion.duration.standard}ms ${motion.easing.standard}`
|
|
95
98
|
|
|
@@ -184,7 +187,6 @@ const AdvancedListItem = ({
|
|
|
184
187
|
sx={{
|
|
185
188
|
display: 'flex',
|
|
186
189
|
flexDirection: 'column',
|
|
187
|
-
gap: '0.75rem',
|
|
188
190
|
width: '100%',
|
|
189
191
|
boxSizing: 'border-box',
|
|
190
192
|
border: `${BORDER_WIDTH} solid`,
|
|
@@ -195,12 +197,12 @@ const AdvancedListItem = ({
|
|
|
195
197
|
opacity: isDisabled ? 0.6 : 1,
|
|
196
198
|
pointerEvents: isDisabled ? 'none' : 'auto',
|
|
197
199
|
cursor: isClickable ? 'pointer' : 'default',
|
|
198
|
-
boxShadow:
|
|
200
|
+
boxShadow: effectiveState === 'selected' ? focusRingShadow : 'none',
|
|
199
201
|
transition: prefersReducedMotion
|
|
200
202
|
? 'none'
|
|
201
203
|
: `border-color ${transitionTiming}, box-shadow ${transitionTiming}`,
|
|
202
204
|
'&:hover': isClickable
|
|
203
|
-
? { borderColor:
|
|
205
|
+
? { borderColor: effectiveState === 'rest' ? palette.grey[400] : borderColor }
|
|
204
206
|
: undefined,
|
|
205
207
|
'&:focus-visible, &:focus-within': !isDisabled
|
|
206
208
|
? { borderColor: palette.primary.main, boxShadow: focusRingShadow }
|
|
@@ -319,7 +321,7 @@ const AdvancedListItem = ({
|
|
|
319
321
|
ref={contentRef}
|
|
320
322
|
id={contentId}
|
|
321
323
|
sx={{
|
|
322
|
-
|
|
324
|
+
marginTop: '0.5rem',
|
|
323
325
|
backgroundColor: palette.grey[50],
|
|
324
326
|
borderRadius: BORDER_RADIUS,
|
|
325
327
|
padding: '0.75rem 1rem',
|
|
@@ -5,13 +5,12 @@ import {
|
|
|
5
5
|
Card as MuiCard,
|
|
6
6
|
Stack,
|
|
7
7
|
StackProps,
|
|
8
|
-
SxProps,
|
|
9
|
-
Theme,
|
|
10
8
|
Typography,
|
|
11
9
|
TypographyProps,
|
|
12
10
|
} from '@mui/material'
|
|
13
11
|
import { ReactNode } from 'react'
|
|
14
12
|
|
|
13
|
+
import normalizeSx from '@/components/utils/normalizeSx'
|
|
15
14
|
import palette from '@/theme/palette'
|
|
16
15
|
|
|
17
16
|
export type RcSesCardTestIds = {
|
|
@@ -51,27 +50,6 @@ export type RcSesCardProps = Omit<CardProps, 'children' | 'title'> & {
|
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
type SxEntry =
|
|
55
|
-
Extract<SxProps<Theme>, ReadonlyArray<unknown>> extends ReadonlyArray<infer T>
|
|
56
|
-
? T
|
|
57
|
-
: never
|
|
58
|
-
|
|
59
|
-
function isSxArray(sx: SxProps<Theme>): sx is ReadonlyArray<SxEntry> {
|
|
60
|
-
return Array.isArray(sx)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function normalizeSx(sx: SxProps<Theme> | undefined): SxEntry[] {
|
|
64
|
-
if (sx === undefined) {
|
|
65
|
-
return []
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (isSxArray(sx)) {
|
|
69
|
-
return [...sx]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return [sx]
|
|
73
|
-
}
|
|
74
|
-
|
|
75
53
|
function RcSesCard({
|
|
76
54
|
title,
|
|
77
55
|
description,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import '@testing-library/jest-dom'
|
|
3
|
+
import { render, screen } from '@testing-library/react'
|
|
4
|
+
import { type ReactElement } from 'react'
|
|
5
|
+
import { describe, expect, test } from 'vitest'
|
|
6
|
+
|
|
7
|
+
import theme from '@/theme/light'
|
|
8
|
+
|
|
9
|
+
import RcSesCardFooter from '.'
|
|
10
|
+
|
|
11
|
+
const renderCardFooter = (ui: ReactElement) =>
|
|
12
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
|
|
13
|
+
|
|
14
|
+
describe('RcSesCardFooter', () => {
|
|
15
|
+
test('renders its children', () => {
|
|
16
|
+
renderCardFooter(
|
|
17
|
+
<RcSesCardFooter>
|
|
18
|
+
<button type='button'>Atšaukti</button>
|
|
19
|
+
<button type='button'>Tęsti</button>
|
|
20
|
+
</RcSesCardFooter>,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
expect(screen.getByRole('button', { name: 'Atšaukti' })).toBeInTheDocument()
|
|
24
|
+
expect(screen.getByRole('button', { name: 'Tęsti' })).toBeInTheDocument()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('defaults to pushing the first and last child apart', () => {
|
|
28
|
+
renderCardFooter(
|
|
29
|
+
<RcSesCardFooter testIds={{ root: 'footer' }}>
|
|
30
|
+
<button type='button'>Tęsti</button>
|
|
31
|
+
</RcSesCardFooter>,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
expect(screen.getByTestId('footer')).toHaveStyle({
|
|
35
|
+
justifyContent: 'space-between',
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test.each([
|
|
40
|
+
['start', 'flex-start'],
|
|
41
|
+
['between', 'space-between'],
|
|
42
|
+
['end', 'flex-end'],
|
|
43
|
+
] as const)('align="%s" maps to justify-content %s', (align, expected) => {
|
|
44
|
+
renderCardFooter(
|
|
45
|
+
<RcSesCardFooter align={align} testIds={{ root: 'footer' }}>
|
|
46
|
+
<button type='button'>Tęsti</button>
|
|
47
|
+
</RcSesCardFooter>,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
expect(screen.getByTestId('footer')).toHaveStyle({ justifyContent: expected })
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Stack } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import cards from '@/theme/cards'
|
|
4
|
+
|
|
5
|
+
import { CardFooterAlign, RcSesCardFooterProps } from './types'
|
|
6
|
+
|
|
7
|
+
const justifyContent: Record<CardFooterAlign, string> = {
|
|
8
|
+
between: 'space-between',
|
|
9
|
+
end: 'flex-end',
|
|
10
|
+
start: 'flex-start',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function RcSesCardFooter({
|
|
14
|
+
children,
|
|
15
|
+
align = 'between',
|
|
16
|
+
stretchOnMobile = true,
|
|
17
|
+
className,
|
|
18
|
+
testIds,
|
|
19
|
+
}: RcSesCardFooterProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Stack
|
|
22
|
+
className={className}
|
|
23
|
+
data-testid={testIds?.root}
|
|
24
|
+
direction={{ xs: 'column', sm: 'row' }}
|
|
25
|
+
spacing={cards.footer.gap}
|
|
26
|
+
sx={{
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: justifyContent[align],
|
|
29
|
+
width: '100%',
|
|
30
|
+
...(stretchOnMobile ? { '& > *': { width: { xs: '100%', sm: 'auto' } } } : {}),
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</Stack>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default RcSesCardFooter
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type CardFooterAlign = 'start' | 'between' | 'end'
|
|
4
|
+
|
|
5
|
+
export type RcSesCardFooterTestIds = {
|
|
6
|
+
root?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type RcSesCardFooterProps = {
|
|
10
|
+
children?: ReactNode
|
|
11
|
+
/**
|
|
12
|
+
* Horizontal distribution of the row. `between` pushes the first and last
|
|
13
|
+
* child apart, which is the cancel/continue pattern; `end` is the single
|
|
14
|
+
* primary action; `start` is a lone link such as "Žiūrėti visas".
|
|
15
|
+
*/
|
|
16
|
+
align?: CardFooterAlign
|
|
17
|
+
/**
|
|
18
|
+
* Whether direct children stretch to the full width once the row stacks.
|
|
19
|
+
* Right for buttons, wrong for a text link, which is why it is a prop.
|
|
20
|
+
*/
|
|
21
|
+
stretchOnMobile?: boolean
|
|
22
|
+
className?: string
|
|
23
|
+
testIds?: RcSesCardFooterTestIds
|
|
24
|
+
}
|