@registrucentras/rc-ses-react-components 2.0.0-rc.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/assets/icons/ShoppingCartIcon.d.ts +3 -0
- package/dist/components/common/CardShell/index.d.ts +1 -1
- package/dist/components/common/CardShell/types.d.ts +10 -0
- package/dist/components/common/ListWithIcons/ListWithIcons.types.d.ts +4 -1
- package/dist/components/common/StepCard/StepCardFooter/index.d.ts +34 -0
- package/dist/components/common/StepCard/index.d.ts +3 -0
- package/dist/components/common/StepCard/types.d.ts +39 -0
- package/dist/components/common/TitleBlock/types.d.ts +1 -1
- package/dist/components/layout/ServiceFormContainer/CardFormContainer/index.d.ts +3 -0
- package/dist/components/loaders/LoadingSpinner/index.d.ts +1 -4
- package/dist/library/icons.d.ts +2 -1
- package/dist/library/index.d.ts +2 -1
- package/dist/library/types.d.ts +4 -3
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +2091 -1888
- package/dist/theme/cards.d.ts +12 -12
- package/dist/theme/light/MuiTypography.d.ts +14 -0
- package/dist/theme/palette.d.ts +124 -124
- package/dist/theme/spacing.d.ts +4 -0
- package/package.json +2 -1
- package/src/assets/icons/ShoppingCartIcon.tsx +16 -0
- package/src/components/common/Button/index.test.tsx +20 -11
- package/src/components/common/Button/index.tsx +8 -44
- package/src/components/common/CardShell/index.tsx +6 -2
- package/src/components/common/CardShell/types.ts +10 -0
- package/src/components/common/ListWithIcons/ListWithIcons.types.ts +22 -1
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +13 -4
- package/src/components/common/ListWithIcons/index.test.tsx +42 -0
- package/src/components/common/StepCard/StepCardFooter/index.test.tsx +162 -0
- package/src/components/common/StepCard/StepCardFooter/index.tsx +120 -0
- package/src/components/common/StepCard/index.test.tsx +120 -0
- package/src/components/common/StepCard/index.tsx +74 -0
- package/src/components/common/StepCard/types.ts +45 -0
- package/src/components/common/TitleBlock/types.ts +1 -1
- package/src/components/form/inputs/SearchableField.test.tsx +1 -1
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +3 -0
- package/src/components/loaders/LoadingSpinner/index.tsx +3 -26
- package/src/examples/ListWithPagination/index.tsx +2 -1
- package/src/i18n/namespaces/common/en.json +7 -0
- package/src/i18n/namespaces/common/lt.json +7 -0
- package/src/library/icons.ts +2 -0
- package/src/library/index.ts +2 -0
- package/src/library/types.ts +17 -2
- package/src/stories/atoms/Button.stories.tsx +202 -497
- package/src/stories/foundations/ThemedMuiComponents.stories.tsx +2 -2
- package/src/stories/molecules/CardShell.stories.tsx +36 -2
- package/src/stories/molecules/DatePicker.stories.tsx +1 -2
- package/src/stories/molecules/ListWithIcons.stories.tsx +26 -0
- package/src/stories/molecules/Popover.stories.tsx +1 -1
- package/src/stories/molecules/StepCard.stories.tsx +181 -0
- package/src/stories/molecules/TitleBlock.stories.tsx +2 -2
- package/src/stories/organisms/AdvancedListItem.stories.tsx +80 -0
- package/src/stories/organisms/CardFormContainer.stories.tsx +1 -1
- package/src/stories/organisms/Dialog.stories.tsx +1 -2
- package/src/theme/light/MuiButton.tsx +54 -0
- package/src/theme/light/MuiCard.tsx +9 -7
- package/src/theme/light/MuiTypography.tsx +17 -0
- package/src/theme/palette.tsx +7 -7
- package/src/theme/spacing.ts +5 -0
package/dist/theme/cards.d.ts
CHANGED
|
@@ -50,16 +50,16 @@ declare const footer: {
|
|
|
50
50
|
};
|
|
51
51
|
declare const themes: {
|
|
52
52
|
brand: {
|
|
53
|
-
backgroundColor:
|
|
54
|
-
borderColor:
|
|
53
|
+
backgroundColor: "#f3fbfe";
|
|
54
|
+
borderColor: "#b9e9fa";
|
|
55
55
|
};
|
|
56
56
|
default: {
|
|
57
|
-
backgroundColor:
|
|
58
|
-
borderColor:
|
|
57
|
+
backgroundColor: "#ffffff";
|
|
58
|
+
borderColor: "#c5cad1";
|
|
59
59
|
};
|
|
60
60
|
sunken: {
|
|
61
|
-
backgroundColor:
|
|
62
|
-
borderColor:
|
|
61
|
+
backgroundColor: "#f0f2f5";
|
|
62
|
+
borderColor: "#dce0e5";
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
export { borderWidth, card, footer, header, subcard, themes };
|
|
@@ -102,16 +102,16 @@ declare const _default: {
|
|
|
102
102
|
};
|
|
103
103
|
themes: {
|
|
104
104
|
brand: {
|
|
105
|
-
backgroundColor:
|
|
106
|
-
borderColor:
|
|
105
|
+
backgroundColor: "#f3fbfe";
|
|
106
|
+
borderColor: "#b9e9fa";
|
|
107
107
|
};
|
|
108
108
|
default: {
|
|
109
|
-
backgroundColor:
|
|
110
|
-
borderColor:
|
|
109
|
+
backgroundColor: "#ffffff";
|
|
110
|
+
borderColor: "#c5cad1";
|
|
111
111
|
};
|
|
112
112
|
sunken: {
|
|
113
|
-
backgroundColor:
|
|
114
|
-
borderColor:
|
|
113
|
+
backgroundColor: "#f0f2f5";
|
|
114
|
+
borderColor: "#dce0e5";
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
};
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { Components } from '@mui/material';
|
|
2
|
+
export declare const typography: {
|
|
3
|
+
bodyRegularMuted: {
|
|
4
|
+
color: "#8e959e";
|
|
5
|
+
fontSize: string;
|
|
6
|
+
fontWeight: number;
|
|
7
|
+
lineHeight: string;
|
|
8
|
+
};
|
|
9
|
+
priceEmphasis: {
|
|
10
|
+
color: "#1f2733";
|
|
11
|
+
fontSize: string;
|
|
12
|
+
fontWeight: number;
|
|
13
|
+
lineHeight: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
2
16
|
declare const MuiTypography: Components['MuiTypography'];
|
|
3
17
|
export default MuiTypography;
|
package/dist/theme/palette.d.ts
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
1
|
declare const primary: {
|
|
2
|
-
'50':
|
|
3
|
-
'100':
|
|
4
|
-
'200':
|
|
5
|
-
'300':
|
|
6
|
-
'400':
|
|
7
|
-
'500':
|
|
8
|
-
'600':
|
|
9
|
-
'700':
|
|
10
|
-
'800':
|
|
11
|
-
'900':
|
|
12
|
-
'950':
|
|
13
|
-
main:
|
|
2
|
+
readonly '50': "#f3fbfe";
|
|
3
|
+
readonly '100': "#dcf4fc";
|
|
4
|
+
readonly '200': "#b9e9fa";
|
|
5
|
+
readonly '300': "#88daf7";
|
|
6
|
+
readonly '400': "#50c9f3";
|
|
7
|
+
readonly '500': "#06a0d4";
|
|
8
|
+
readonly '600': "#0079ad";
|
|
9
|
+
readonly '700': "#0e6790";
|
|
10
|
+
readonly '800': "#155575";
|
|
11
|
+
readonly '900': "#164763";
|
|
12
|
+
readonly '950': "#082d44";
|
|
13
|
+
readonly main: "#06a0d4";
|
|
14
14
|
};
|
|
15
15
|
declare const secondary: {
|
|
16
|
-
'50':
|
|
17
|
-
'100':
|
|
18
|
-
'200':
|
|
19
|
-
'300':
|
|
20
|
-
'400':
|
|
21
|
-
'500':
|
|
22
|
-
'600':
|
|
23
|
-
'700':
|
|
24
|
-
'800':
|
|
25
|
-
'900':
|
|
26
|
-
'950':
|
|
27
|
-
main:
|
|
16
|
+
readonly '50': "#ecfdf6";
|
|
17
|
+
readonly '100': "#d1fae7";
|
|
18
|
+
readonly '200': "#a5f3d3";
|
|
19
|
+
readonly '300': "#6fe7bd";
|
|
20
|
+
readonly '400': "#05d091";
|
|
21
|
+
readonly '500': "#00c288";
|
|
22
|
+
readonly '600': "#00a879";
|
|
23
|
+
readonly '700': "#008561";
|
|
24
|
+
readonly '800': "#00664e";
|
|
25
|
+
readonly '900': "#004e3d";
|
|
26
|
+
readonly '950': "#002c24";
|
|
27
|
+
readonly main: "#00c288";
|
|
28
28
|
};
|
|
29
29
|
declare const grey: {
|
|
30
|
-
'50':
|
|
31
|
-
'100':
|
|
32
|
-
'200':
|
|
33
|
-
'300':
|
|
34
|
-
'400':
|
|
35
|
-
'500':
|
|
36
|
-
'600':
|
|
37
|
-
'700':
|
|
38
|
-
'800':
|
|
39
|
-
'900':
|
|
40
|
-
'950':
|
|
41
|
-
main:
|
|
30
|
+
readonly '50': "#f9fafb";
|
|
31
|
+
readonly '100': "#f0f2f5";
|
|
32
|
+
readonly '200': "#dce0e5";
|
|
33
|
+
readonly '300': "#c5cad1";
|
|
34
|
+
readonly '400': "#a9afb8";
|
|
35
|
+
readonly '500': "#8e959e";
|
|
36
|
+
readonly '600': "#6b747f";
|
|
37
|
+
readonly '700': "#4a5361";
|
|
38
|
+
readonly '800': "#29323d";
|
|
39
|
+
readonly '900': "#1f2733";
|
|
40
|
+
readonly '950': "#10161f";
|
|
41
|
+
readonly main: "#8e959e";
|
|
42
42
|
};
|
|
43
43
|
declare const warning: {
|
|
44
|
-
'50':
|
|
45
|
-
'100':
|
|
46
|
-
'200':
|
|
47
|
-
'300':
|
|
48
|
-
'400':
|
|
49
|
-
'500':
|
|
50
|
-
'600':
|
|
51
|
-
'700':
|
|
52
|
-
'800':
|
|
53
|
-
'900':
|
|
54
|
-
'950':
|
|
55
|
-
main:
|
|
44
|
+
readonly '50': "#fef9ef";
|
|
45
|
+
readonly '100': "#fdefcf";
|
|
46
|
+
readonly '200': "#fce09f";
|
|
47
|
+
readonly '300': "#fbd170";
|
|
48
|
+
readonly '400': "#fac240";
|
|
49
|
+
readonly '500': "#f9b311";
|
|
50
|
+
readonly '600': "#c78f0d";
|
|
51
|
+
readonly '700': "#956b0a";
|
|
52
|
+
readonly '800': "#634706";
|
|
53
|
+
readonly '900': "#4a3504";
|
|
54
|
+
readonly '950': "#312303";
|
|
55
|
+
readonly main: "#f9b311";
|
|
56
56
|
};
|
|
57
57
|
declare const error: {
|
|
58
|
-
'50':
|
|
59
|
-
'100':
|
|
60
|
-
'200':
|
|
61
|
-
'300':
|
|
62
|
-
'400':
|
|
63
|
-
'500':
|
|
64
|
-
'600':
|
|
65
|
-
'700':
|
|
66
|
-
'800':
|
|
67
|
-
'900':
|
|
68
|
-
'950':
|
|
69
|
-
main:
|
|
58
|
+
readonly '50': "#fef4f2";
|
|
59
|
+
readonly '100': "#fededa";
|
|
60
|
+
readonly '200': "#fdbdb5";
|
|
61
|
+
readonly '300': "#fc9c90";
|
|
62
|
+
readonly '400': "#fb7b6b";
|
|
63
|
+
readonly '500': "#fa5a46";
|
|
64
|
+
readonly '600': "#c84838";
|
|
65
|
+
readonly '700': "#96362a";
|
|
66
|
+
readonly '800': "#63231b";
|
|
67
|
+
readonly '900': "#4a1a14";
|
|
68
|
+
readonly '950': "#31110d";
|
|
69
|
+
readonly main: "#fa5a46";
|
|
70
70
|
};
|
|
71
71
|
declare const overlays: {
|
|
72
|
-
'200':
|
|
73
|
-
'300':
|
|
74
|
-
main:
|
|
72
|
+
readonly '200': "#ffffff14";
|
|
73
|
+
readonly '300': "#ffffff29";
|
|
74
|
+
readonly main: "#ffffff14";
|
|
75
75
|
};
|
|
76
76
|
declare const common: {
|
|
77
|
-
white:
|
|
77
|
+
readonly white: "#ffffff";
|
|
78
78
|
};
|
|
79
79
|
export { primary, secondary, grey, warning, error, overlays, common };
|
|
80
80
|
declare const _default: {
|
|
81
81
|
primary: {
|
|
82
|
-
'50':
|
|
83
|
-
'100':
|
|
84
|
-
'200':
|
|
85
|
-
'300':
|
|
86
|
-
'400':
|
|
87
|
-
'500':
|
|
88
|
-
'600':
|
|
89
|
-
'700':
|
|
90
|
-
'800':
|
|
91
|
-
'900':
|
|
92
|
-
'950':
|
|
93
|
-
main:
|
|
82
|
+
readonly '50': "#f3fbfe";
|
|
83
|
+
readonly '100': "#dcf4fc";
|
|
84
|
+
readonly '200': "#b9e9fa";
|
|
85
|
+
readonly '300': "#88daf7";
|
|
86
|
+
readonly '400': "#50c9f3";
|
|
87
|
+
readonly '500': "#06a0d4";
|
|
88
|
+
readonly '600': "#0079ad";
|
|
89
|
+
readonly '700': "#0e6790";
|
|
90
|
+
readonly '800': "#155575";
|
|
91
|
+
readonly '900': "#164763";
|
|
92
|
+
readonly '950': "#082d44";
|
|
93
|
+
readonly main: "#06a0d4";
|
|
94
94
|
};
|
|
95
95
|
secondary: {
|
|
96
|
-
'50':
|
|
97
|
-
'100':
|
|
98
|
-
'200':
|
|
99
|
-
'300':
|
|
100
|
-
'400':
|
|
101
|
-
'500':
|
|
102
|
-
'600':
|
|
103
|
-
'700':
|
|
104
|
-
'800':
|
|
105
|
-
'900':
|
|
106
|
-
'950':
|
|
107
|
-
main:
|
|
96
|
+
readonly '50': "#ecfdf6";
|
|
97
|
+
readonly '100': "#d1fae7";
|
|
98
|
+
readonly '200': "#a5f3d3";
|
|
99
|
+
readonly '300': "#6fe7bd";
|
|
100
|
+
readonly '400': "#05d091";
|
|
101
|
+
readonly '500': "#00c288";
|
|
102
|
+
readonly '600': "#00a879";
|
|
103
|
+
readonly '700': "#008561";
|
|
104
|
+
readonly '800': "#00664e";
|
|
105
|
+
readonly '900': "#004e3d";
|
|
106
|
+
readonly '950': "#002c24";
|
|
107
|
+
readonly main: "#00c288";
|
|
108
108
|
};
|
|
109
109
|
grey: {
|
|
110
|
-
'50':
|
|
111
|
-
'100':
|
|
112
|
-
'200':
|
|
113
|
-
'300':
|
|
114
|
-
'400':
|
|
115
|
-
'500':
|
|
116
|
-
'600':
|
|
117
|
-
'700':
|
|
118
|
-
'800':
|
|
119
|
-
'900':
|
|
120
|
-
'950':
|
|
121
|
-
main:
|
|
110
|
+
readonly '50': "#f9fafb";
|
|
111
|
+
readonly '100': "#f0f2f5";
|
|
112
|
+
readonly '200': "#dce0e5";
|
|
113
|
+
readonly '300': "#c5cad1";
|
|
114
|
+
readonly '400': "#a9afb8";
|
|
115
|
+
readonly '500': "#8e959e";
|
|
116
|
+
readonly '600': "#6b747f";
|
|
117
|
+
readonly '700': "#4a5361";
|
|
118
|
+
readonly '800': "#29323d";
|
|
119
|
+
readonly '900': "#1f2733";
|
|
120
|
+
readonly '950': "#10161f";
|
|
121
|
+
readonly main: "#8e959e";
|
|
122
122
|
};
|
|
123
123
|
warning: {
|
|
124
|
-
'50':
|
|
125
|
-
'100':
|
|
126
|
-
'200':
|
|
127
|
-
'300':
|
|
128
|
-
'400':
|
|
129
|
-
'500':
|
|
130
|
-
'600':
|
|
131
|
-
'700':
|
|
132
|
-
'800':
|
|
133
|
-
'900':
|
|
134
|
-
'950':
|
|
135
|
-
main:
|
|
124
|
+
readonly '50': "#fef9ef";
|
|
125
|
+
readonly '100': "#fdefcf";
|
|
126
|
+
readonly '200': "#fce09f";
|
|
127
|
+
readonly '300': "#fbd170";
|
|
128
|
+
readonly '400': "#fac240";
|
|
129
|
+
readonly '500': "#f9b311";
|
|
130
|
+
readonly '600': "#c78f0d";
|
|
131
|
+
readonly '700': "#956b0a";
|
|
132
|
+
readonly '800': "#634706";
|
|
133
|
+
readonly '900': "#4a3504";
|
|
134
|
+
readonly '950': "#312303";
|
|
135
|
+
readonly main: "#f9b311";
|
|
136
136
|
};
|
|
137
137
|
error: {
|
|
138
|
-
'50':
|
|
139
|
-
'100':
|
|
140
|
-
'200':
|
|
141
|
-
'300':
|
|
142
|
-
'400':
|
|
143
|
-
'500':
|
|
144
|
-
'600':
|
|
145
|
-
'700':
|
|
146
|
-
'800':
|
|
147
|
-
'900':
|
|
148
|
-
'950':
|
|
149
|
-
main:
|
|
138
|
+
readonly '50': "#fef4f2";
|
|
139
|
+
readonly '100': "#fededa";
|
|
140
|
+
readonly '200': "#fdbdb5";
|
|
141
|
+
readonly '300': "#fc9c90";
|
|
142
|
+
readonly '400': "#fb7b6b";
|
|
143
|
+
readonly '500': "#fa5a46";
|
|
144
|
+
readonly '600': "#c84838";
|
|
145
|
+
readonly '700': "#96362a";
|
|
146
|
+
readonly '800': "#63231b";
|
|
147
|
+
readonly '900': "#4a1a14";
|
|
148
|
+
readonly '950': "#31110d";
|
|
149
|
+
readonly main: "#fa5a46";
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
152
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@registrucentras/rc-ses-react-components",
|
|
3
3
|
"author": "VĮ REGISTRŲ CENTRAS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "RC SES React komponentų biblioteka",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"react-router-dom": "6.26.2",
|
|
118
118
|
"rollup-plugin-typescript2": "^0.37.0",
|
|
119
119
|
"storybook": "^10.5.5",
|
|
120
|
+
"storybook-addon-tag-badges": "^3.1.0",
|
|
120
121
|
"typescript": "^5.9.3",
|
|
121
122
|
"typescript-eslint": "^8.65.0",
|
|
122
123
|
"vite": "^7.3.6",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ShoppingCartIcon as PhosphorShoppingCartIcon } from '@phosphor-icons/react'
|
|
2
|
+
|
|
3
|
+
import IconProps from '../IconProps'
|
|
4
|
+
|
|
5
|
+
function ShoppingCartIcon({ className, size = 24, fillColor, ...rest }: IconProps) {
|
|
6
|
+
return (
|
|
7
|
+
<PhosphorShoppingCartIcon
|
|
8
|
+
{...rest}
|
|
9
|
+
className={className}
|
|
10
|
+
size={size}
|
|
11
|
+
color={fillColor}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ShoppingCartIcon
|
|
@@ -12,7 +12,7 @@ describe('Button Component', () => {
|
|
|
12
12
|
expect(spinner).toBeInTheDocument()
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
it('should
|
|
15
|
+
it('should mark the button as busy when loading', () => {
|
|
16
16
|
render(<Button loading>Save</Button>)
|
|
17
17
|
|
|
18
18
|
const button = screen.getByRole('button')
|
|
@@ -26,32 +26,40 @@ describe('Button Component', () => {
|
|
|
26
26
|
expect(button).toBeDisabled()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
it('should
|
|
29
|
+
it('should keep children in the DOM alongside the spinner when loading (label is visually hidden via CSS)', () => {
|
|
30
30
|
render(<Button loading>Save</Button>)
|
|
31
31
|
|
|
32
|
-
expect(screen.
|
|
32
|
+
expect(screen.getByText('Save')).toBeInTheDocument()
|
|
33
33
|
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
it('should
|
|
36
|
+
it('should hide startIcon when loadingPosition is "start"', () => {
|
|
37
37
|
render(
|
|
38
|
-
<Button
|
|
38
|
+
<Button
|
|
39
|
+
loading
|
|
40
|
+
loadingPosition='start'
|
|
41
|
+
startIcon={<span data-testid='start-icon'>+</span>}
|
|
42
|
+
>
|
|
39
43
|
Add
|
|
40
44
|
</Button>,
|
|
41
45
|
)
|
|
42
46
|
|
|
43
|
-
expect(screen.
|
|
47
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-loadingPositionStart')
|
|
44
48
|
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
|
45
49
|
})
|
|
46
50
|
|
|
47
|
-
it('should
|
|
51
|
+
it('should hide endIcon when loadingPosition is "end"', () => {
|
|
48
52
|
render(
|
|
49
|
-
<Button
|
|
53
|
+
<Button
|
|
54
|
+
loading
|
|
55
|
+
loadingPosition='end'
|
|
56
|
+
endIcon={<span data-testid='end-icon'>→</span>}
|
|
57
|
+
>
|
|
50
58
|
Next
|
|
51
59
|
</Button>,
|
|
52
60
|
)
|
|
53
61
|
|
|
54
|
-
expect(screen.
|
|
62
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-loadingPositionEnd')
|
|
55
63
|
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
|
56
64
|
})
|
|
57
65
|
|
|
@@ -136,20 +144,21 @@ describe('Button Component', () => {
|
|
|
136
144
|
})
|
|
137
145
|
|
|
138
146
|
describe('Icon Only Buttons', () => {
|
|
139
|
-
it('should
|
|
147
|
+
it('should render spinner when loading and iconOnly (icon visually hidden via CSS)', () => {
|
|
140
148
|
render(
|
|
141
149
|
<Button
|
|
142
150
|
loading
|
|
143
151
|
iconOnly
|
|
144
152
|
variant='contained'
|
|
153
|
+
aria-label='Add'
|
|
145
154
|
startIcon={<span data-testid='icon'>+</span>}
|
|
146
155
|
>
|
|
147
156
|
Add
|
|
148
157
|
</Button>,
|
|
149
158
|
)
|
|
150
159
|
|
|
151
|
-
expect(screen.queryByTestId('icon')).not.toBeInTheDocument()
|
|
152
160
|
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
|
161
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-loading')
|
|
153
162
|
})
|
|
154
163
|
})
|
|
155
164
|
|
|
@@ -3,7 +3,7 @@ import type { ButtonTypeMap } from '@mui/material/Button'
|
|
|
3
3
|
import type { ExtendButtonBase } from '@mui/material/ButtonBase'
|
|
4
4
|
import { useTranslation } from 'react-i18next'
|
|
5
5
|
|
|
6
|
-
import RcSesLoadingSpinner
|
|
6
|
+
import RcSesLoadingSpinner from '@/components/loaders/LoadingSpinner'
|
|
7
7
|
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
8
8
|
|
|
9
9
|
const defaultProps: Partial<MuiButtonProps> = {
|
|
@@ -18,67 +18,31 @@ const ICON_ONLY_SIZE_MAP = {
|
|
|
18
18
|
large: '3rem',
|
|
19
19
|
} as const
|
|
20
20
|
|
|
21
|
-
// MUI 6 added a native `loading` prop (`boolean | null`, alongside
|
|
22
|
-
// `loadingIndicator` and `loadingPosition`), so it no longer needs declaring
|
|
23
|
-
// here - re-declaring it as `boolean` conflicted with MUI's nullable type at
|
|
24
|
-
// every call site that spreads ButtonProps.
|
|
25
|
-
//
|
|
26
|
-
// Behaviour is unchanged: `loading` is still destructured out below and drives
|
|
27
|
-
// the custom RcSesLoadingSpinner, so it never reaches MuiButton and the native
|
|
28
|
-
// indicator stays inactive. Switching over to MUI's implementation is a
|
|
29
|
-
// breaking change, tracked as SAV-5916.
|
|
30
21
|
type Props = ButtonProps
|
|
31
22
|
|
|
32
23
|
function RcSesButtonComponent(props: Props) {
|
|
33
24
|
const { t } = useTranslation('common')
|
|
34
|
-
const {
|
|
35
|
-
children,
|
|
36
|
-
iconOnly,
|
|
37
|
-
loading = false,
|
|
38
|
-
size = 'medium',
|
|
39
|
-
sx,
|
|
40
|
-
variant,
|
|
41
|
-
...rest
|
|
42
|
-
} = props
|
|
25
|
+
const { children, iconOnly, size = 'medium', sx, variant, ...rest } = props
|
|
43
26
|
|
|
44
27
|
const currentVariant = variant ?? defaultProps.variant
|
|
45
28
|
const isIconOnly =
|
|
46
29
|
!!iconOnly && (currentVariant === 'contained' || currentVariant === 'outlined')
|
|
47
30
|
|
|
48
|
-
const showSpinnerInContent = loading && !isIconOnly && !rest.startIcon && !rest.endIcon
|
|
49
|
-
const showSpinnerAsIcon = loading && isIconOnly
|
|
50
|
-
|
|
51
|
-
const spinnerColor = getSpinnerColor(rest.color)
|
|
52
|
-
const spinner = <RcSesLoadingSpinner color={spinnerColor} size={size} />
|
|
53
|
-
|
|
54
|
-
const getIconDisplay = (icon: React.ReactNode) => {
|
|
55
|
-
if (showSpinnerAsIcon) return undefined
|
|
56
|
-
if (loading && !isIconOnly && icon) return spinner
|
|
57
|
-
return icon
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const displayIcon = getIconDisplay(rest.startIcon)
|
|
61
|
-
const displayEndIcon = getIconDisplay(rest.endIcon)
|
|
62
|
-
|
|
63
|
-
let displayContent = children
|
|
64
|
-
if (showSpinnerInContent || showSpinnerAsIcon) displayContent = spinner
|
|
65
|
-
|
|
66
31
|
return (
|
|
67
32
|
<MuiButton
|
|
68
33
|
{...defaultProps}
|
|
69
34
|
{...rest}
|
|
70
|
-
// TODO: use loading prop when MUI lib upgrade is done
|
|
71
|
-
disabled={loading || rest.disabled}
|
|
72
35
|
size={size}
|
|
73
36
|
variant={currentVariant}
|
|
74
|
-
aria-busy={loading || undefined}
|
|
37
|
+
aria-busy={rest.loading || undefined}
|
|
75
38
|
aria-label={
|
|
76
|
-
loading && rest['aria-label']
|
|
39
|
+
rest.loading && rest['aria-label']
|
|
77
40
|
? `${rest['aria-label']} – ${t('components.Button.loading')}`
|
|
78
41
|
: rest['aria-label']
|
|
79
42
|
}
|
|
80
|
-
|
|
81
|
-
|
|
43
|
+
loadingIndicator={
|
|
44
|
+
rest.loadingIndicator ?? <RcSesLoadingSpinner color='inherit' size={size} />
|
|
45
|
+
}
|
|
82
46
|
sx={[
|
|
83
47
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
84
48
|
isIconOnly
|
|
@@ -94,7 +58,7 @@ function RcSesButtonComponent(props: Props) {
|
|
|
94
58
|
: undefined,
|
|
95
59
|
]}
|
|
96
60
|
>
|
|
97
|
-
{
|
|
61
|
+
{children}
|
|
98
62
|
</MuiButton>
|
|
99
63
|
)
|
|
100
64
|
}
|
|
@@ -16,6 +16,8 @@ function RcSesCardShell({
|
|
|
16
16
|
theme = 'default',
|
|
17
17
|
fullHeight = false,
|
|
18
18
|
borderless = false,
|
|
19
|
+
contentGap,
|
|
20
|
+
footerGap,
|
|
19
21
|
header,
|
|
20
22
|
children,
|
|
21
23
|
footer,
|
|
@@ -28,7 +30,9 @@ function RcSesCardShell({
|
|
|
28
30
|
const hasContent = hasSlot(children)
|
|
29
31
|
const hasFooter = hasSlot(footer)
|
|
30
32
|
|
|
31
|
-
const
|
|
33
|
+
const resolvedContentGap = contentGap ?? cards[variant].gap
|
|
34
|
+
const resolvedFooterGap = footerGap ?? cards[variant].footerGap
|
|
35
|
+
const footerMt = hasHeader || hasContent ? resolvedFooterGap : 0
|
|
32
36
|
|
|
33
37
|
return (
|
|
34
38
|
<Box
|
|
@@ -75,7 +79,7 @@ function RcSesCardShell({
|
|
|
75
79
|
sx={{
|
|
76
80
|
flexGrow: fullHeight ? 1 : 0,
|
|
77
81
|
minWidth: 0,
|
|
78
|
-
mt: hasHeader ?
|
|
82
|
+
mt: hasHeader ? resolvedContentGap : 0,
|
|
79
83
|
width: '100%',
|
|
80
84
|
}}
|
|
81
85
|
>
|
|
@@ -17,6 +17,16 @@ export interface RcSesCardShellProps {
|
|
|
17
17
|
fullHeight?: boolean
|
|
18
18
|
/** Renders the shell without any border. */
|
|
19
19
|
borderless?: boolean
|
|
20
|
+
/**
|
|
21
|
+
* Overrides the `variant` preset's header-to-content gap (`cards[variant].gap`).
|
|
22
|
+
* Use when a composition needs a fixed spacing regardless of breakpoint.
|
|
23
|
+
*/
|
|
24
|
+
contentGap?: string
|
|
25
|
+
/**
|
|
26
|
+
* Overrides the `variant` preset's content-to-footer gap
|
|
27
|
+
* (`cards[variant].footerGap`).
|
|
28
|
+
*/
|
|
29
|
+
footerGap?: string
|
|
20
30
|
/** Header row, normally `RcSesTitleBlock`. The shell only provides the slot. */
|
|
21
31
|
header?: ReactNode
|
|
22
32
|
children?: ReactNode
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { ComponentType } from 'react'
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
common,
|
|
5
|
+
error,
|
|
6
|
+
grey,
|
|
7
|
+
overlays,
|
|
8
|
+
primary,
|
|
9
|
+
secondary,
|
|
10
|
+
warning,
|
|
11
|
+
} from '@/theme/palette'
|
|
12
|
+
|
|
13
|
+
export type ListWithIconsItemTone = 'default' | 'secondary' | 'muted' | 'link'
|
|
14
|
+
|
|
15
|
+
export type PaletteColor =
|
|
16
|
+
| (typeof primary)[keyof typeof primary]
|
|
17
|
+
| (typeof secondary)[keyof typeof secondary]
|
|
18
|
+
| (typeof grey)[keyof typeof grey]
|
|
19
|
+
| (typeof warning)[keyof typeof warning]
|
|
20
|
+
| (typeof error)[keyof typeof error]
|
|
21
|
+
| (typeof overlays)[keyof typeof overlays]
|
|
22
|
+
| (typeof common)[keyof typeof common]
|
|
23
|
+
|
|
3
24
|
export interface ListWithIconsItemData {
|
|
4
25
|
icon?: ComponentType<{ fillColor?: string; size?: number }>
|
|
5
26
|
text?: string
|
|
6
27
|
disabled?: boolean
|
|
7
28
|
tooltip?: string
|
|
8
|
-
textColor?:
|
|
29
|
+
textColor?: ListWithIconsItemTone | PaletteColor
|
|
9
30
|
}
|