@registrucentras/rc-ses-react-components 2.7.2 → 3.0.0-rc.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.
Files changed (289) hide show
  1. package/dist/assets/icons/phosphorIcons.d.ts +24 -0
  2. package/dist/components/common/Accordion/hooks/useAccordionController.d.ts +2 -1
  3. package/dist/components/common/Accordion/index.d.ts +18 -4
  4. package/dist/components/common/Accordion/types/AccordionControllerState.d.ts +1 -0
  5. package/dist/components/common/Card/index.d.ts +3 -0
  6. package/dist/components/common/CheckboxMark/index.d.ts +8 -0
  7. package/dist/components/common/DataPagination/components/ExpandButton.d.ts +7 -0
  8. package/dist/components/common/DataPagination/components/PaginationButton.d.ts +2 -1
  9. package/dist/components/common/DataPagination/index.d.ts +13 -3
  10. package/dist/components/common/DataPagination/paginationModel.d.ts +4 -0
  11. package/dist/components/common/Divider/index.d.ts +6 -0
  12. package/dist/components/common/EmptyState/index.d.ts +21 -0
  13. package/dist/components/common/IconWithSquareBackground/index.d.ts +2 -2
  14. package/dist/components/common/ImageCard/index.d.ts +5 -0
  15. package/dist/components/common/LinkTile/index.d.ts +11 -0
  16. package/dist/components/common/RadioMark/index.d.ts +8 -0
  17. package/dist/components/common/StepCard/StepCardFooter/index.d.ts +1 -1
  18. package/dist/components/common/TitleBlock/types.d.ts +4 -2
  19. package/dist/components/form/components/FormControlWrapper/index.d.ts +2 -1
  20. package/dist/components/form/inputs/Datepicker/RangeDatepicker.d.ts +23 -0
  21. package/dist/components/form/inputs/Datepicker/SingleDatepicker.d.ts +24 -0
  22. package/dist/components/form/inputs/Datepicker/components/CalendarViewsHeader.d.ts +18 -0
  23. package/dist/components/form/inputs/Datepicker/index.d.ts +10 -14
  24. package/dist/components/form/inputs/Datepicker/rangeModel.d.ts +4 -0
  25. package/dist/components/form/inputs/FileDropzone.d.ts +2 -2
  26. package/dist/components/form/inputs/RadioButtonGroup.d.ts +1 -0
  27. package/dist/components/form/inputs/Select/Select.styles.d.ts +84 -0
  28. package/dist/components/form/inputs/Select/components/OptionCheckbox.d.ts +2 -1
  29. package/dist/components/form/inputs/TextField.d.ts +27 -12
  30. package/dist/components/form/inputs/TextField.styles.d.ts +101 -0
  31. package/dist/components/layout/ServiceWizardStepper/stepperTokens.d.ts +5 -0
  32. package/dist/components/loaders/Loader/index.d.ts +12 -9
  33. package/dist/components/overlays/BottomSheet/index.d.ts +3 -2
  34. package/dist/components/overlays/Dialog/index.d.ts +1 -1
  35. package/dist/components/storybook/FileUploadTokenPreview.d.ts +4 -0
  36. package/dist/components/storybook/TabsTokenPreview.d.ts +3 -0
  37. package/dist/components/storybook/TokenDocs.d.ts +74 -0
  38. package/dist/library/index.d.ts +30 -1
  39. package/dist/registrucentras-rc-ses-react-components.cjs +2 -2
  40. package/dist/registrucentras-rc-ses-react-components.js +11144 -8374
  41. package/dist/theme/backdropTokens.d.ts +6 -0
  42. package/dist/theme/borderTokens.d.ts +33 -0
  43. package/dist/theme/cards.d.ts +42 -73
  44. package/dist/theme/colorTokens.d.ts +146 -0
  45. package/dist/theme/effectTokens.d.ts +9 -0
  46. package/dist/theme/layoutTokens.d.ts +12 -0
  47. package/dist/theme/light/MuiAccordion.d.ts +2 -2
  48. package/dist/theme/light/MuiAccordionSummary.d.ts +19 -0
  49. package/dist/theme/light/MuiButton.d.ts +7 -0
  50. package/dist/theme/light/MuiInputBase.d.ts +2 -0
  51. package/dist/theme/light/MuiPickerPopper.d.ts +3 -0
  52. package/dist/theme/light/MuiTypography.d.ts +0 -14
  53. package/dist/theme/palette.d.ts +8 -0
  54. package/dist/theme/sizeTokens.d.ts +20 -0
  55. package/dist/theme/spacingRoleBasedTokens.d.ts +38 -0
  56. package/dist/theme/spacingTokens.d.ts +97 -0
  57. package/dist/theme/tokenTheme.d.ts +13 -0
  58. package/dist/theme/typographyTokens.d.ts +104 -0
  59. package/package.json +2 -2
  60. package/src/assets/icons/phosphorIcons.ts +11 -0
  61. package/src/components/common/Accordion/hooks/useAccordionController.tsx +39 -7
  62. package/src/components/common/Accordion/index.test.tsx +132 -0
  63. package/src/components/common/Accordion/index.tsx +302 -25
  64. package/src/components/common/Accordion/types/AccordionControllerState.ts +1 -0
  65. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +3 -3
  66. package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +8 -3
  67. package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +3 -2
  68. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +3 -3
  69. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +23 -19
  70. package/src/components/common/AdvancedList/index.test.tsx +4 -2
  71. package/src/components/common/Alert/index.tsx +10 -6
  72. package/src/components/common/Badge/index.tsx +50 -37
  73. package/src/components/common/Button/index.tsx +12 -10
  74. package/src/components/common/Card/index.tsx +6 -1
  75. package/src/components/common/CardShell/index.test.tsx +16 -6
  76. package/src/components/common/CheckboxMark/index.tsx +86 -0
  77. package/src/components/common/DataPagination/components/DataPaginationSkeleton.tsx +9 -7
  78. package/src/components/common/DataPagination/components/ExpandButton.tsx +48 -0
  79. package/src/components/common/DataPagination/components/PaginationButton.tsx +48 -21
  80. package/src/components/common/DataPagination/index.test.tsx +229 -12
  81. package/src/components/common/DataPagination/index.tsx +135 -60
  82. package/src/components/common/DataPagination/paginationModel.ts +35 -0
  83. package/src/components/common/Divider/index.test.tsx +33 -0
  84. package/src/components/common/Divider/index.tsx +52 -0
  85. package/src/components/common/EmptyState/index.test.tsx +56 -0
  86. package/src/components/common/EmptyState/index.tsx +211 -0
  87. package/src/components/common/FilterChip/index.tsx +24 -19
  88. package/src/components/common/IconWithCircularBackground.tsx +24 -6
  89. package/src/components/common/IconWithSquareBackground/index.test.tsx +14 -2
  90. package/src/components/common/IconWithSquareBackground/index.tsx +36 -17
  91. package/src/components/common/ImageCard/index.test.tsx +16 -0
  92. package/src/components/common/ImageCard/index.tsx +54 -1
  93. package/src/components/common/LinkTile/index.test.tsx +57 -0
  94. package/src/components/common/LinkTile/index.tsx +136 -0
  95. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +39 -23
  96. package/src/components/common/ListWithIcons/index.test.tsx +20 -9
  97. package/src/components/common/ListWithIcons/index.tsx +6 -6
  98. package/src/components/common/Popover/index.tsx +11 -1
  99. package/src/components/common/RadioMark/index.tsx +76 -0
  100. package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +49 -25
  101. package/src/components/common/SegmentedControl/index.tsx +10 -6
  102. package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +7 -5
  103. package/src/components/common/SelectableCardList/index.test.tsx +8 -6
  104. package/src/components/common/SelectionMarks.test.tsx +92 -0
  105. package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +20 -11
  106. package/src/components/common/ServiceLinks/index.tsx +3 -3
  107. package/src/components/common/SideNav/SideNavLayout.tsx +6 -1
  108. package/src/components/common/SideNav/components/SideNavPill.tsx +24 -12
  109. package/src/components/common/SideNav/components/SideNavPillList.tsx +18 -12
  110. package/src/components/common/SideNav/components/SideNavRow.tsx +22 -15
  111. package/src/components/common/SideNav/index.tsx +10 -9
  112. package/src/components/common/Snackbar/config.ts +27 -8
  113. package/src/components/common/Snackbar/index.tsx +39 -16
  114. package/src/components/common/StepCard/StepCardFooter/index.tsx +28 -6
  115. package/src/components/common/StepCard/index.tsx +18 -6
  116. package/src/components/common/Switch/index.tsx +10 -4
  117. package/src/components/common/Tabs/TabPanel.tsx +6 -3
  118. package/src/components/common/Tabs/TabsWrapper.tsx +15 -7
  119. package/src/components/common/TitleBlock/index.test.tsx +14 -17
  120. package/src/components/common/TitleBlock/index.tsx +120 -15
  121. package/src/components/common/TitleBlock/types.ts +4 -2
  122. package/src/components/common/Tooltip/index.tsx +32 -3
  123. package/src/components/form/components/FormControlWrapper/index.tsx +43 -14
  124. package/src/components/form/inputs/CheckboxFormControl.tsx +25 -13
  125. package/src/components/form/inputs/Datepicker/RangeDatepicker.tsx +356 -0
  126. package/src/components/form/inputs/Datepicker/SingleDatepicker.tsx +207 -0
  127. package/src/components/form/inputs/Datepicker/components/CalendarViewsHeader.tsx +335 -0
  128. package/src/components/form/inputs/Datepicker/components/RcSesDatepickerCalendarHeader.tsx +22 -10
  129. package/src/components/form/inputs/Datepicker/index.test.tsx +23 -18
  130. package/src/components/form/inputs/Datepicker/index.tsx +20 -150
  131. package/src/components/form/inputs/Datepicker/rangeModel.test.ts +35 -0
  132. package/src/components/form/inputs/Datepicker/rangeModel.ts +25 -0
  133. package/src/components/form/inputs/FileDropzone.tsx +73 -46
  134. package/src/components/form/inputs/FileUpload.tsx +25 -16
  135. package/src/components/form/inputs/NumberStepper.tsx +36 -14
  136. package/src/components/form/inputs/PhoneInputFormControl/components/AutocompleteInput.tsx +10 -5
  137. package/src/components/form/inputs/PhoneInputFormControl/components/ListboxComponent.tsx +7 -1
  138. package/src/components/form/inputs/PhoneInputFormControl/components/PopperComponent.tsx +5 -2
  139. package/src/components/form/inputs/PhoneInputFormControl/components/RowComponent.tsx +9 -5
  140. package/src/components/form/inputs/PhoneInputFormControl/index.tsx +48 -24
  141. package/src/components/form/inputs/RadioButtonGroup.tsx +14 -6
  142. package/src/components/form/inputs/Select/Select.styles.ts +76 -0
  143. package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +6 -33
  144. package/src/components/form/inputs/Select/index.tsx +124 -86
  145. package/src/components/form/inputs/SimpleCheckbox.tsx +10 -3
  146. package/src/components/form/inputs/TextField.presets.test.tsx +284 -0
  147. package/src/components/form/inputs/TextField.styles.ts +96 -0
  148. package/src/components/form/inputs/TextField.test.tsx +153 -0
  149. package/src/components/form/inputs/TextField.tsx +315 -42
  150. package/src/components/layout/Footer/index.test.tsx +1 -1
  151. package/src/components/layout/Footer/index.tsx +17 -7
  152. package/src/components/layout/ServiceFormActions.tsx +5 -1
  153. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/index.tsx +3 -3
  154. package/src/components/layout/ServiceHeader.tsx +19 -19
  155. package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +10 -10
  156. package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +8 -5
  157. package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.tsx +22 -7
  158. package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.tsx +15 -11
  159. package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +28 -11
  160. package/src/components/layout/ServiceWizardStepper/stepperTokens.ts +8 -0
  161. package/src/components/loaders/FullPageLoader/index.test.tsx +18 -7
  162. package/src/components/loaders/FullPageLoader/index.tsx +14 -9
  163. package/src/components/loaders/Loader/index.tsx +48 -17
  164. package/src/components/overlays/BottomSheet/index.test.tsx +36 -3
  165. package/src/components/overlays/BottomSheet/index.tsx +54 -21
  166. package/src/components/overlays/Dialog/index.tsx +5 -23
  167. package/src/components/overlays/Drawer/index.tsx +29 -14
  168. package/src/components/overlays/Modal/index.tsx +46 -8
  169. package/src/components/storybook/FileUploadTokenPreview.tsx +68 -0
  170. package/src/components/storybook/TabsTokenPreview.tsx +58 -0
  171. package/src/components/storybook/TokenDocs.tsx +347 -0
  172. package/src/examples/MultipleStepForm/components/TermsAndConditionsForm.tsx +5 -1
  173. package/src/i18n/namespaces/input/en.json +48 -4
  174. package/src/i18n/namespaces/input/lt.json +48 -4
  175. package/src/library/index.ts +50 -0
  176. package/src/stories/atoms/Badge.stories.tsx +2 -1
  177. package/src/stories/atoms/Button.stories.tsx +124 -6
  178. package/src/stories/atoms/CheckboxMark.stories.tsx +79 -0
  179. package/src/stories/atoms/Divider.stories.tsx +129 -0
  180. package/src/stories/atoms/FilterChip.stories.tsx +9 -1
  181. package/src/stories/atoms/IconWithSquareBackground.stories.tsx +7 -7
  182. package/src/stories/atoms/Icons.stories.tsx +1 -1
  183. package/src/stories/atoms/NumberStepper.stories.tsx +44 -0
  184. package/src/stories/atoms/PhoneInput.stories.tsx +42 -0
  185. package/src/stories/atoms/RadioMark.stories.tsx +132 -0
  186. package/src/stories/atoms/Select.stories.tsx +139 -2
  187. package/src/stories/atoms/SimpleCheckbox.stories.tsx +74 -0
  188. package/src/stories/atoms/Switch.stories.tsx +46 -1
  189. package/src/stories/atoms/TextField.stories.tsx +508 -0
  190. package/src/stories/atoms/Tooltip.stories.tsx +5 -0
  191. package/src/stories/fixtures/foundations/Borders.stories.tsx +84 -0
  192. package/src/stories/fixtures/foundations/Effects.stories.tsx +204 -0
  193. package/src/stories/fixtures/foundations/Layout.stories.tsx +76 -0
  194. package/src/stories/fixtures/foundations/Sizes.stories.tsx +42 -0
  195. package/src/stories/fixtures/foundations/Spacing.stories.tsx +48 -0
  196. package/src/stories/fixtures/foundations/Typography.stories.tsx +49 -0
  197. package/src/stories/foundations/Borders.stories.tsx +179 -0
  198. package/src/stories/foundations/Colors.stories.tsx +253 -0
  199. package/src/stories/foundations/Effects.stories.tsx +116 -0
  200. package/src/stories/foundations/Layout.stories.tsx +177 -0
  201. package/src/stories/foundations/Sizes.stories.tsx +123 -0
  202. package/src/stories/foundations/Spacing.stories.tsx +159 -0
  203. package/src/stories/foundations/ThemeAdapter.stories.tsx +389 -0
  204. package/src/stories/foundations/Typography.stories.tsx +148 -0
  205. package/src/stories/molecules/Alert.stories.tsx +18 -0
  206. package/src/stories/molecules/Breadcrumbs.stories.tsx +51 -0
  207. package/src/stories/molecules/Card.stories.tsx +1 -1
  208. package/src/stories/molecules/CardShell.stories.tsx +1 -0
  209. package/src/stories/molecules/DatePicker.stories.tsx +133 -3
  210. package/src/stories/molecules/EmptyState.stories.tsx +106 -0
  211. package/src/stories/molecules/FormControlWrapper.stories.tsx +59 -0
  212. package/src/stories/molecules/LinkTile.stories.tsx +151 -0
  213. package/src/stories/molecules/ListWithIcons.stories.tsx +27 -2
  214. package/src/stories/molecules/RadioButtonGroup.stories.tsx +23 -0
  215. package/src/stories/molecules/SegmentedControl.stories.tsx +62 -1
  216. package/src/stories/molecules/Tabs.stories.tsx +4 -0
  217. package/src/stories/molecules/TitleBlock.stories.tsx +16 -16
  218. package/src/stories/organisms/Accordion.stories.tsx +132 -0
  219. package/src/stories/organisms/AdvancedListItemShell.stories.tsx +63 -23
  220. package/src/stories/organisms/BottomSheet.stories.tsx +48 -1
  221. package/src/stories/organisms/DataPagination.stories.tsx +127 -3
  222. package/src/stories/organisms/Dialog.stories.tsx +13 -0
  223. package/src/stories/organisms/FileDropzone.stories.tsx +6 -0
  224. package/src/stories/organisms/FileUpload.stories.tsx +4 -0
  225. package/src/stories/organisms/Footer.stories.tsx +20 -0
  226. package/src/stories/organisms/Modal.stories.tsx +53 -0
  227. package/src/stories/organisms/ServiceHeader.stories.tsx +25 -3
  228. package/src/stories/organisms/ServiceLinks.stories.tsx +1 -1
  229. package/src/stories/organisms/ServiceWizardStepper.stories.tsx +37 -1
  230. package/src/stories/organisms/SideNav.stories.tsx +8 -1
  231. package/src/theme/backdropTokens.test.ts +11 -0
  232. package/src/theme/backdropTokens.ts +11 -0
  233. package/src/theme/borderTokens.test.ts +59 -0
  234. package/src/theme/borderTokens.ts +36 -0
  235. package/src/theme/cards.ts +28 -28
  236. package/src/theme/colorTokens.test.ts +66 -0
  237. package/src/theme/colorTokens.ts +87 -0
  238. package/src/theme/effectTokens.test.ts +29 -0
  239. package/src/theme/effectTokens.ts +11 -0
  240. package/src/theme/layoutTokens.test.ts +42 -0
  241. package/src/theme/layoutTokens.ts +14 -0
  242. package/src/theme/light/MuiAccordion.tsx +30 -26
  243. package/src/theme/light/MuiAccordionDetails.ts +10 -5
  244. package/src/theme/light/MuiAccordionSummary.tsx +31 -17
  245. package/src/theme/light/MuiAlert.tsx +42 -65
  246. package/src/theme/light/MuiAutocomplete.ts +14 -7
  247. package/src/theme/light/MuiBreadcrumbs.tsx +17 -9
  248. package/src/theme/light/MuiButton.tsx +213 -204
  249. package/src/theme/light/MuiCard.tsx +5 -4
  250. package/src/theme/light/MuiCheckbox.ts +45 -14
  251. package/src/theme/light/MuiChip.tsx +3 -1
  252. package/src/theme/light/MuiDialog.ts +45 -6
  253. package/src/theme/light/MuiFormControl.ts +19 -9
  254. package/src/theme/light/MuiFormControlLabel.ts +16 -25
  255. package/src/theme/light/MuiFormGroup.ts +29 -26
  256. package/src/theme/light/MuiFormHelperText.ts +15 -4
  257. package/src/theme/light/MuiFormLabel.ts +20 -20
  258. package/src/theme/light/MuiInputBase.ts +49 -84
  259. package/src/theme/light/MuiOutlinedInput.ts +50 -6
  260. package/src/theme/light/MuiPagination.ts +21 -21
  261. package/src/theme/light/MuiPickerPopper.ts +17 -0
  262. package/src/theme/light/MuiPickersLayout.ts +63 -34
  263. package/src/theme/light/MuiPickersOutlinedInput.ts +38 -38
  264. package/src/theme/light/MuiPopover.ts +3 -1
  265. package/src/theme/light/MuiRadio.tsx +35 -52
  266. package/src/theme/light/MuiStepper.ts +21 -17
  267. package/src/theme/light/MuiSwitch.tsx +27 -23
  268. package/src/theme/light/MuiTab.tsx +27 -18
  269. package/src/theme/light/MuiTableCell.ts +4 -2
  270. package/src/theme/light/MuiTabs.tsx +11 -9
  271. package/src/theme/light/MuiTooltip.ts +2 -1
  272. package/src/theme/light/MuiTypography.tsx +0 -17
  273. package/src/theme/light/index.tsx +2 -0
  274. package/src/theme/light/themePalette.tsx +1 -0
  275. package/src/theme/palette.tsx +9 -0
  276. package/src/theme/sizeTokens.test.ts +37 -0
  277. package/src/theme/sizeTokens.ts +21 -0
  278. package/src/theme/spacingRoleBasedTokens.ts +41 -0
  279. package/src/theme/spacingTokens.test.ts +58 -0
  280. package/src/theme/spacingTokens.ts +114 -0
  281. package/src/theme/tokenTheme.test.tsx +402 -0
  282. package/src/theme/tokenTheme.ts +429 -0
  283. package/src/theme/tokens.css +476 -0
  284. package/src/theme/tokens.test.ts +174 -0
  285. package/src/theme/typographyTokens.test.ts +120 -0
  286. package/src/theme/typographyTokens.ts +119 -0
  287. package/dist/theme/spacing.d.ts +0 -4
  288. package/src/stories/foundations/Colors.mdx +0 -127
  289. package/src/theme/spacing.ts +0 -5
@@ -0,0 +1,402 @@
1
+ import { Box, ThemeProvider, Typography, useTheme } from '@mui/material'
2
+ import { alpha, createTheme, decomposeColor } from '@mui/material/styles'
3
+ import { render, screen } from '@testing-library/react'
4
+ import { describe, expect, test } from 'vitest'
5
+
6
+ import Button from '@/components/common/Button'
7
+ import FullPageLoader from '@/components/loaders/FullPageLoader'
8
+ import legacyTheme from '@/theme/light'
9
+ import { createRcSesTokenTheme } from '@/theme/tokenTheme'
10
+ import { typographyRoleVariants } from '@/theme/typographyTokens'
11
+
12
+ const tokenTheme = createRcSesTokenTheme()
13
+
14
+ function css(theme = tokenTheme) {
15
+ return JSON.stringify(theme.generateStyleSheets?.())
16
+ }
17
+
18
+ function Probe() {
19
+ const theme = useTheme()
20
+ return (
21
+ <output data-testid='theme-probe' data-spacing={theme.spacing(-1, 0.5, 'auto')}>
22
+ {theme.vars?.palette.primary.main}
23
+ </output>
24
+ )
25
+ }
26
+
27
+ describe('native token theme adapter', () => {
28
+ test('preserves the existing theme, public palette and theme extension API', () => {
29
+ expect(legacyTheme.vars).toBeUndefined()
30
+ expect(legacyTheme.spacing(1)).toBe('8px')
31
+ expect(
32
+ createTheme(legacyTheme, { shape: { borderRadius: 6 } }).shape.borderRadius,
33
+ ).toBe(6)
34
+ expect(tokenTheme.palette.primary.main).toBe(legacyTheme.palette.primary.main)
35
+ expect(decomposeColor(tokenTheme.palette.primary.main)).toEqual(
36
+ decomposeColor(legacyTheme.palette.primary.main),
37
+ )
38
+ expect(alpha(tokenTheme.palette.common.white, 0.72)).toBe(
39
+ alpha(legacyTheme.palette.common.white, 0.72),
40
+ )
41
+ expect(tokenTheme.colorSchemes?.dark).toBeUndefined()
42
+ })
43
+
44
+ test('native MUI CSS declarations point to semantic colors, primitives and shape', () => {
45
+ expect(tokenTheme.vars?.palette.primary.main).toBe(
46
+ 'var(--rc-mui-palette-primary-main, #06a0d4)',
47
+ )
48
+ expect(css()).toContain('var(--rc-color-control-selected, #06a0d4)')
49
+ expect(css()).toContain('var(--rc-color-text-default, #1f2733)')
50
+ expect(css()).toContain('var(--rc-color-neutrals-300, #c5cad1)')
51
+ expect(css()).toContain('var(--rc-radius-4, 4px)')
52
+ expect(tokenTheme.vars?.shape.borderRadius).toBe(
53
+ 'var(--rc-mui-shape-borderRadius, 4px)',
54
+ )
55
+ })
56
+
57
+ test('effect roles bind by component while numeric shadows and consumer overrides are preserved', () => {
58
+ expect(tokenTheme.shadows).toEqual(legacyTheme.shadows)
59
+ expect(tokenTheme.components?.MuiPopover?.styleOverrides?.paper).toMatchObject({
60
+ boxShadow: `var(--rc-elevation-md, ${legacyTheme.shadows[8]})`,
61
+ })
62
+ expect(tokenTheme.components?.MuiDialog?.styleOverrides?.paper).toMatchObject({
63
+ boxShadow: `var(--rc-elevation-lg, ${legacyTheme.shadows[24]})`,
64
+ })
65
+ expect(tokenTheme.components?.MuiSnackbarContent?.styleOverrides?.root).toMatchObject(
66
+ {
67
+ boxShadow: `var(--rc-elevation-lg, ${legacyTheme.shadows[6]})`,
68
+ },
69
+ )
70
+ expect(tokenTheme.components?.MuiPopover?.defaultProps).toEqual(
71
+ legacyTheme.components?.MuiPopover?.defaultProps,
72
+ )
73
+ expect(tokenTheme.components?.MuiDialog?.styleOverrides?.root).toEqual(
74
+ legacyTheme.components?.MuiDialog?.styleOverrides?.root,
75
+ )
76
+ const customShadows = [...legacyTheme.shadows] as typeof legacyTheme.shadows
77
+ customShadows[8] = 'none'
78
+ expect(
79
+ createRcSesTokenTheme({ shadows: customShadows }).components?.MuiPopover
80
+ ?.styleOverrides?.paper,
81
+ ).toMatchObject({
82
+ boxShadow: 'var(--rc-elevation-md, none)',
83
+ })
84
+ const customized = createRcSesTokenTheme({
85
+ shadows: customShadows,
86
+ components: {
87
+ MuiAutocomplete: { styleOverrides: { paper: { boxShadow: 'none' } } },
88
+ MuiPopover: { styleOverrides: { paper: { boxShadow: 'none' } } },
89
+ MuiDialog: { styleOverrides: { paper: { boxShadow: 'none' } } },
90
+ MuiSnackbarContent: { styleOverrides: { root: { boxShadow: 'none' } } },
91
+ },
92
+ })
93
+ expect(customized.shadows).toEqual(customShadows)
94
+ expect(customized.components?.MuiAutocomplete?.styleOverrides?.paper).toMatchObject({
95
+ boxShadow: 'none',
96
+ })
97
+ expect(customized.components?.MuiPopover?.styleOverrides?.paper).toMatchObject({
98
+ boxShadow: 'none',
99
+ })
100
+ expect(customized.components?.MuiDialog?.styleOverrides?.paper).toMatchObject({
101
+ boxShadow: 'none',
102
+ })
103
+ expect(customized.components?.MuiSnackbarContent?.styleOverrides?.root).toMatchObject(
104
+ { boxShadow: 'none' },
105
+ )
106
+ })
107
+
108
+ test('spacing supports MUI defaults, negatives, fractions, multiple arguments and strings', () => {
109
+ expect(tokenTheme.spacing()).toBe('var(--rc-space-8, 8px)')
110
+ expect(tokenTheme.spacing(2)).toBe('var(--rc-space-16, 16px)')
111
+ expect(tokenTheme.spacing(-1, 0.5, 'auto', 0)).toBe(
112
+ 'calc(-1 * var(--rc-space-8, 8px)) var(--rc-space-4, 4px) auto 0px',
113
+ )
114
+ expect(tokenTheme.spacing(1.75)).toBe('calc(var(--rc-space-8, 8px) * 1.75)')
115
+ expect(tokenTheme.spacing(20)).toBe('calc(var(--rc-space-8, 8px) * 20)')
116
+ })
117
+
118
+ test('typography dimensions come only from theme.typography for mapped variants', () => {
119
+ expect(tokenTheme.typography.h1.fontSize).toBe(
120
+ 'var(--rc-typography-font-size-heading-h1, var(--rc-mui-h1-fallback-fontSize, 1.5rem))',
121
+ )
122
+ expect(
123
+ tokenTheme.typography.h1[
124
+ legacyTheme.breakpoints.up('md') as keyof typeof tokenTheme.typography.h1
125
+ ],
126
+ ).toEqual({
127
+ '--rc-mui-h1-fallback-fontSize': '2.25rem',
128
+ '--rc-mui-h1-fallback-lineHeight': '3rem',
129
+ })
130
+ expect(tokenTheme.components?.MuiTypography?.styleOverrides?.h2).toEqual({
131
+ fontWeight: '500',
132
+ })
133
+ expect(legacyTheme.components?.MuiTypography?.styleOverrides?.h2).toMatchObject({
134
+ fontSize: '2rem',
135
+ lineHeight: '2.75rem',
136
+ })
137
+ })
138
+
139
+ test('legacy component configuration is preserved without general tokenization', () => {
140
+ Object.entries(legacyTheme.components ?? {}).forEach(([name, component]) => {
141
+ if (
142
+ ![
143
+ 'MuiTypography',
144
+ 'MuiButton',
145
+ 'MuiCard',
146
+ 'MuiInputBase',
147
+ 'MuiOutlinedInput',
148
+ 'MuiAutocomplete',
149
+ 'MuiPickersOutlinedInput',
150
+ 'MuiPopover',
151
+ 'MuiDialog',
152
+ 'MuiSnackbarContent',
153
+ ].includes(name)
154
+ ) {
155
+ expect(
156
+ tokenTheme.components?.[name as keyof typeof tokenTheme.components],
157
+ name,
158
+ ).toEqual(component)
159
+ }
160
+ })
161
+ })
162
+
163
+ test('explicit Borders roles preserve other component styles and consumer radius overrides', () => {
164
+ expect(tokenTheme.components?.MuiAutocomplete?.styleOverrides?.root).toMatchObject({
165
+ '.MuiOutlinedInput-root': {
166
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
167
+ '.MuiOutlinedInput-notchedOutline': {
168
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
169
+ },
170
+ '&.Mui-focused': {
171
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
172
+ '.MuiOutlinedInput-notchedOutline': {
173
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
174
+ },
175
+ },
176
+ '.MuiAutocomplete-input': { padding: '.25rem .1875rem' },
177
+ },
178
+ })
179
+ expect(tokenTheme.components?.MuiAutocomplete?.styleOverrides?.paper).toEqual({
180
+ ...(legacyTheme.components?.MuiAutocomplete?.styleOverrides?.paper as object),
181
+ boxShadow: 'var(--rc-elevation-md, 0px 4px 16px 0px rgba(0, 0, 0, 0.08))',
182
+ })
183
+ expect(tokenTheme.components?.MuiButton?.styleOverrides?.root).toMatchObject({
184
+ borderRadius: 'var(--rc-radius-button, 0.5rem)',
185
+ height:
186
+ 'calc(var(--rc-typography-line-height-button-regular) + var(--rc-space-button-padding-y-regular) * 2)',
187
+ })
188
+ expect(tokenTheme.components?.MuiCard?.styleOverrides?.root).toMatchObject({
189
+ borderRadius: 'var(--rc-radius-card, 1rem)',
190
+ borderStyle: 'solid',
191
+ })
192
+ expect(tokenTheme.components?.MuiInputBase?.styleOverrides?.root).toMatchObject({
193
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
194
+ '&.Mui-focused': {
195
+ '.MuiOutlinedInput-notchedOutline': {
196
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
197
+ },
198
+ '&.Mui-error': {
199
+ '.MuiOutlinedInput-notchedOutline': {
200
+ borderRadius: 'var(--rc-radius-input, 0.5rem)',
201
+ },
202
+ },
203
+ },
204
+ })
205
+ expect(tokenTheme.components?.MuiInputBase?.styleOverrides?.input).toMatchObject({
206
+ padding: 'var(--rc-space-input-padding-y, 0.625rem) var(--rc-space-12, 0.75rem)',
207
+ })
208
+ const customized = createRcSesTokenTheme({
209
+ components: {
210
+ MuiButton: { styleOverrides: { root: { borderRadius: '3px' } } },
211
+ MuiAutocomplete: {
212
+ styleOverrides: { root: { '.MuiOutlinedInput-root': { borderRadius: '3px' } } },
213
+ },
214
+ },
215
+ })
216
+ expect(customized.components?.MuiAutocomplete?.styleOverrides?.root).toMatchObject({
217
+ '.MuiOutlinedInput-root': { borderRadius: '3px' },
218
+ })
219
+ expect(customized.components?.MuiButton?.styleOverrides?.root).toMatchObject({
220
+ borderRadius: '3px',
221
+ })
222
+ expect(legacyTheme.components?.MuiButton?.styleOverrides?.root).toMatchObject({
223
+ borderRadius: 'var(--rc-radius-button)',
224
+ })
225
+ })
226
+
227
+ test('explicit consumer overrides retain precedence', () => {
228
+ const customized = createRcSesTokenTheme({
229
+ palette: { primary: { main: '#123456' } },
230
+ spacing: 10,
231
+ shape: { borderRadius: 6 },
232
+ typography: { h2: { fontSize: '3rem', fontWeight: 700 } },
233
+ components: {
234
+ MuiCard: { styleOverrides: { root: { borderColor: 'rebeccapurple' } } },
235
+ MuiTypography: { styleOverrides: { h2: { fontWeight: 400 } } },
236
+ },
237
+ })
238
+ expect(customized.spacing(2)).toBe('calc(2 * var(--rc-mui-spacing, 10px))')
239
+ expect(customized.typography.h2.fontSize).toBe('3rem')
240
+ expect(customized.components?.MuiTypography?.styleOverrides?.h2).toMatchObject({
241
+ fontWeight: 400,
242
+ })
243
+ expect(css(customized)).toContain('"--rc-mui-palette-primary-main":"#123456"')
244
+ expect(css(customized)).toContain('"--rc-mui-shape-borderRadius":"6px"')
245
+ expect(customized.components?.MuiCard?.styleOverrides?.root).toMatchObject({
246
+ borderColor: 'rebeccapurple',
247
+ })
248
+ })
249
+
250
+ test('consumer component literals and callbacks are not tokenized', () => {
251
+ const callback = () => ({ borderColor: '#c5cad1', padding: '1rem' })
252
+ const customized = createRcSesTokenTheme({
253
+ components: {
254
+ MuiCard: {
255
+ styleOverrides: { root: { borderColor: '#c5cad1', padding: '1rem' } },
256
+ variants: [
257
+ { props: { variant: 'outlined' }, style: { backgroundColor: '#06a0d4' } },
258
+ ],
259
+ },
260
+ MuiCardHeader: { styleOverrides: { root: callback } },
261
+ },
262
+ })
263
+ expect(customized.components?.MuiCard?.styleOverrides?.root).toMatchObject({
264
+ borderColor: '#c5cad1',
265
+ padding: '1rem',
266
+ })
267
+ expect(customized.components?.MuiCard?.variants?.[0].style).toEqual({
268
+ backgroundColor: '#06a0d4',
269
+ })
270
+ expect(customized.components?.MuiCardHeader?.styleOverrides?.root).toBe(callback)
271
+ })
272
+
273
+ test('typography customizes individual properties without disabling responsive dimensions', () => {
274
+ const customized = createRcSesTokenTheme({
275
+ typography: { h2: { fontWeight: 700 }, h1: { fontSize: '3rem' } },
276
+ })
277
+ expect(customized.typography.h2.fontSize).toBe(tokenTheme.typography.h2.fontSize)
278
+ expect(customized.typography.h2.lineHeight).toBe(tokenTheme.typography.h2.lineHeight)
279
+ expect(customized.typography.h2.fontWeight).toBe(700)
280
+ expect(customized.components?.MuiTypography?.styleOverrides?.h2).toEqual({})
281
+ expect(
282
+ customized.typography.h1[
283
+ legacyTheme.breakpoints.up('md') as keyof typeof customized.typography.h1
284
+ ],
285
+ ).toEqual({
286
+ '--rc-mui-h1-fallback-fontSize': '2.25rem',
287
+ '--rc-mui-h1-fallback-lineHeight': '3rem',
288
+ })
289
+ const sized = createRcSesTokenTheme({
290
+ typography: { h2: { fontSize: '3rem', lineHeight: '4rem' } },
291
+ })
292
+ expect(sized.typography.h2.fontSize).toBe('3rem')
293
+ expect(sized.typography.h2.lineHeight).toBe('4rem')
294
+ })
295
+
296
+ test('function typography input is resolved against the consumer palette', () => {
297
+ const customized = createRcSesTokenTheme({
298
+ palette: { primary: { main: '#123456' } },
299
+ typography: (palette) => ({ h2: { color: palette.primary.main, fontWeight: 700 } }),
300
+ })
301
+ expect(customized.typography.h2.color).toBe('#123456')
302
+ expect(customized.typography.h2.fontWeight).toBe(700)
303
+ expect(customized.typography.h2.fontSize).toBe(tokenTheme.typography.h2.fontSize)
304
+ expect(customized.typography.h2.lineHeight).toBe(tokenTheme.typography.h2.lineHeight)
305
+ })
306
+
307
+ test('all 14 DS roles resolve through theme styles without inventing font attributes', () => {
308
+ expect(Object.keys(typographyRoleVariants)).toHaveLength(14)
309
+ Object.entries(typographyRoleVariants).forEach(([role, variant]) => {
310
+ const style = tokenTheme.typography[variant]
311
+ expect(style.fontSize).toContain(`var(--rc-typography-font-size-${role}`)
312
+ expect(style.lineHeight).toContain(`var(--rc-typography-line-height-${role}`)
313
+ })
314
+ ;(['headingCardTitle', 'bodyLarge', 'buttonCompact'] as const).forEach((variant) => {
315
+ expect(tokenTheme.typography[variant]).not.toHaveProperty('fontFamily')
316
+ expect(tokenTheme.typography[variant]).not.toHaveProperty('fontWeight')
317
+ expect(legacyTheme.typography[variant]).toBeUndefined()
318
+ })
319
+ expect(tokenTheme.typography.fontFamily).toBe(legacyTheme.typography.fontFamily)
320
+ // MUI fills inherited attributes when creating a theme (legacy h1 omits family).
321
+ const normalizedLegacy = createTheme(legacyTheme)
322
+ Object.keys(normalizedLegacy.typography).forEach((variant) => {
323
+ const before =
324
+ normalizedLegacy.typography[variant as keyof typeof normalizedLegacy.typography]
325
+ const after = tokenTheme.typography[variant as keyof typeof tokenTheme.typography]
326
+ if (typeof before === 'object' && before && typeof after === 'object' && after) {
327
+ expect(after.fontFamily).toBe(before.fontFamily)
328
+ if (variant !== 'h5') expect(after.fontWeight).toBe(before.fontWeight)
329
+ }
330
+ })
331
+ })
332
+
333
+ test('h5 uses the Figma SemiBold weight unless the consumer overrides it', () => {
334
+ expect(tokenTheme.typography.h5.fontWeight).toBe(600)
335
+ expect(tokenTheme.components?.MuiTypography?.styleOverrides?.h5).not.toHaveProperty(
336
+ 'fontWeight',
337
+ )
338
+ expect(legacyTheme.components?.MuiTypography?.styleOverrides?.h5).toMatchObject({
339
+ fontWeight: '500',
340
+ })
341
+ render(
342
+ <ThemeProvider theme={tokenTheme}>
343
+ <Typography variant='h5'>Section heading</Typography>
344
+ </ThemeProvider>,
345
+ )
346
+ expect(screen.getByText('Section heading')).toHaveStyle({ fontWeight: '600' })
347
+ expect(
348
+ createRcSesTokenTheme({ typography: { h5: { fontWeight: 700 } } }).typography.h5
349
+ .fontWeight,
350
+ ).toBe(700)
351
+ })
352
+
353
+ test('named styles support typed consumer overrides and keep unmodified dimensions responsive', () => {
354
+ const customized = createRcSesTokenTheme({
355
+ typography: { headingCardTitle: { fontSize: '3rem', fontWeight: 600 } },
356
+ })
357
+ expect(customized.typography.headingCardTitle.fontSize).toBe('3rem')
358
+ expect(customized.typography.headingCardTitle.fontWeight).toBe(600)
359
+ expect(customized.typography.headingCardTitle.lineHeight).toBe(
360
+ tokenTheme.typography.headingCardTitle.lineHeight,
361
+ )
362
+ render(
363
+ <ThemeProvider theme={customized}>
364
+ <Typography variant='headingCardTitle'>Named title</Typography>
365
+ </ThemeProvider>,
366
+ )
367
+ expect(screen.getByText('Named title')).toHaveStyle({
368
+ fontSize: '3rem',
369
+ fontWeight: '600',
370
+ })
371
+ })
372
+
373
+ test('h6 has no inferred token role and keeps its existing overrides', () => {
374
+ expect(tokenTheme.typography.h6).toEqual(legacyTheme.typography.h6)
375
+ expect(tokenTheme.components?.MuiTypography?.styleOverrides?.h6).toEqual(
376
+ legacyTheme.components?.MuiTypography?.styleOverrides?.h6,
377
+ )
378
+ })
379
+
380
+ test('ThemeProvider resolves the native theme and existing JS color consumers still render', () => {
381
+ render(
382
+ <ThemeProvider theme={tokenTheme}>
383
+ <Probe />
384
+ <Box sx={{ p: 2, borderRadius: 2, color: 'text.primary' }}>
385
+ <Typography variant='h2'>Token heading</Typography>
386
+ <Button>Continue</Button>
387
+ </Box>
388
+ <FullPageLoader showLabel={false} />
389
+ </ThemeProvider>,
390
+ )
391
+ expect(screen.getByTestId('theme-probe')).toHaveTextContent(
392
+ 'var(--rc-mui-palette-primary-main)',
393
+ )
394
+ expect(screen.getByTestId('theme-probe')).toHaveAttribute(
395
+ 'data-spacing',
396
+ tokenTheme.spacing(-1, 0.5, 'auto'),
397
+ )
398
+ expect(
399
+ screen.getByRole('button', { name: 'Continue', hidden: true }),
400
+ ).toBeInTheDocument()
401
+ })
402
+ })