@graphcommerce/next-ui 9.0.0-canary.98 → 9.0.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 (189) hide show
  1. package/ActionCard/ActionCard.tsx +219 -203
  2. package/ActionCard/ActionCardAccordion.tsx +4 -2
  3. package/ActionCard/ActionCardLayout.tsx +3 -2
  4. package/ActionCard/ActionCardList.tsx +6 -5
  5. package/Blog/BlogAuthor/BlogAuthor.tsx +5 -4
  6. package/Blog/BlogContent/BlogContent.tsx +3 -2
  7. package/Blog/BlogHeader/BlogHeader.tsx +4 -3
  8. package/Blog/BlogList/BlogList.tsx +3 -3
  9. package/Blog/BlogListItem/BlogListItem.tsx +6 -5
  10. package/Blog/BlogTags/BlogTag.tsx +3 -2
  11. package/Blog/BlogTags/BlogTags.tsx +1 -1
  12. package/Breadcrumbs/Breadcrumbs.tsx +25 -19
  13. package/Breadcrumbs/BreadcrumbsList.tsx +3 -2
  14. package/Breadcrumbs/jsonLdBreadcrumb.tsx +1 -1
  15. package/Breadcrumbs/types.ts +1 -2
  16. package/Button/Button.tsx +2 -1
  17. package/Button/LinkOrButton.tsx +4 -2
  18. package/CHANGELOG.md +294 -1342
  19. package/ChipMenu/ChipMenu.tsx +3 -2
  20. package/Config.graphqls +28 -10
  21. package/Container/Container.tsx +90 -0
  22. package/ContainerWithHeader/ContainerWithHeader.tsx +2 -1
  23. package/Document/DocumentBodyEnd.tsx +1 -1
  24. package/Document/DocumentBodyStart.tsx +1 -1
  25. package/Document/DocumentHeadEnd.tsx +1 -1
  26. package/Document/DocumentHeadStart.tsx +1 -1
  27. package/Fab/Fab.tsx +15 -17
  28. package/FlagAvatar/FlagAvatar.tsx +2 -1
  29. package/Footer/Footer.tsx +14 -10
  30. package/Form/Form.tsx +2 -1
  31. package/Form/FormHeader.tsx +1 -1
  32. package/Form/FormRow.tsx +1 -1
  33. package/Form/InputCheckmark.tsx +2 -1
  34. package/FramerScroller/ItemScroller.tsx +5 -8
  35. package/FramerScroller/SidebarGallery.tsx +23 -30
  36. package/FramerScroller/SidebarSlider.tsx +8 -7
  37. package/FullPageMessage/FullPageMessage.tsx +2 -1
  38. package/IconHeader/IconHeader.tsx +5 -3
  39. package/IconSvg/IconSvg.tsx +8 -7
  40. package/Intl/DateTimeFormat/DateFormat.tsx +6 -4
  41. package/Intl/DateTimeFormat/DateTimeFormat.tsx +10 -14
  42. package/Intl/DateTimeFormat/TimeFormat.tsx +6 -4
  43. package/Intl/DateTimeFormat/index.ts +1 -0
  44. package/Intl/DateTimeFormat/useIntlDateTimeFormat.ts +13 -0
  45. package/Intl/DisplayNames/DisplayNames.tsx +5 -13
  46. package/Intl/DisplayNames/index.ts +1 -0
  47. package/Intl/DisplayNames/useIntlDisplayNames.ts +12 -0
  48. package/Intl/{ListFormat.tsx → ListFormat/ListFormat.tsx} +8 -13
  49. package/Intl/ListFormat/index.ts +2 -0
  50. package/Intl/ListFormat/useIntlListFormat.ts +15 -0
  51. package/Intl/NumberFormat/CurrencyFormat.tsx +4 -2
  52. package/Intl/NumberFormat/NumberFormat.tsx +15 -17
  53. package/Intl/NumberFormat/PercentFormat.tsx +6 -2
  54. package/Intl/NumberFormat/UnitFormat.tsx +5 -5
  55. package/Intl/NumberFormat/index.ts +1 -0
  56. package/Intl/NumberFormat/useIntlNumberFormat.ts +17 -0
  57. package/Intl/RelativeTimeFormat/RelativeTimeFormat.tsx +6 -13
  58. package/Intl/RelativeTimeFormat/RelativeToTimeFormat.tsx +4 -2
  59. package/Intl/RelativeTimeFormat/index.ts +1 -0
  60. package/Intl/RelativeTimeFormat/useIntlRelativeTimeFormat.ts +15 -0
  61. package/Intl/useIntlLocalesArgument.ts +16 -0
  62. package/Layout/components/LayoutHeader.tsx +7 -4
  63. package/Layout/components/LayoutHeaderBack.tsx +6 -4
  64. package/Layout/components/LayoutHeaderClose.tsx +1 -1
  65. package/Layout/components/LayoutHeaderContent.tsx +11 -12
  66. package/Layout/components/LayoutProvider.tsx +1 -1
  67. package/Layout/components/LayoutTitle.tsx +5 -3
  68. package/Layout/context/layoutContext.tsx +1 -1
  69. package/Layout/types.ts +1 -1
  70. package/LayoutDefault/components/LayoutDefault.tsx +12 -10
  71. package/LayoutOverlay/components/LayoutOverlay.tsx +3 -2
  72. package/LayoutOverlay/components/LayoutOverlayHeader.tsx +2 -1
  73. package/LayoutOverlay/test/LayoutOverlayDemo.tsx +4 -1
  74. package/LayoutParts/DesktopHeaderBadge.tsx +2 -1
  75. package/LayoutParts/DesktopNavBar.tsx +26 -22
  76. package/LayoutParts/DesktopNavBarItem.tsx +11 -7
  77. package/LayoutParts/Logo.tsx +5 -5
  78. package/LayoutParts/MenuFab.tsx +7 -13
  79. package/LayoutParts/MenuFabItem.tsx +6 -1
  80. package/LayoutParts/MenuFabSecondaryItem.tsx +11 -7
  81. package/LayoutParts/MobileTopRight.tsx +24 -0
  82. package/LayoutParts/PlaceholderFab.tsx +2 -1
  83. package/LayoutParts/StickyBelowHeader.tsx +2 -1
  84. package/LayoutParts/index.ts +1 -0
  85. package/LazyHydrate/LazyHydrate.tsx +18 -21
  86. package/MediaQuery/MediaQuery.tsx +111 -0
  87. package/MediaQuery/index.ts +1 -0
  88. package/Navigation/components/NavigationFab.tsx +3 -2
  89. package/Navigation/components/NavigationItem.tsx +3 -3
  90. package/Navigation/components/NavigationList.tsx +4 -3
  91. package/Navigation/components/NavigationOverlay.tsx +18 -11
  92. package/Navigation/components/NavigationProvider.tsx +9 -8
  93. package/Navigation/components/NavigationTitle.tsx +5 -5
  94. package/Navigation/hooks/useNavigation.ts +4 -2
  95. package/Overlay/components/Overlay.tsx +3 -2
  96. package/Overlay/components/OverlayBase.tsx +71 -30
  97. package/Overlay/components/OverlayContainer.tsx +2 -2
  98. package/Overlay/components/OverlayHeader.tsx +7 -4
  99. package/Overlay/components/OverlaySsr.tsx +2 -1
  100. package/Overlay/components/OverlayStickyBottom.tsx +2 -1
  101. package/Overlay/utils/variantsToScrollSnapType.ts +2 -2
  102. package/OverlayOrPopperChip/OverlayOrPopperChip.tsx +5 -12
  103. package/OverlayOrPopperChip/OverlayOrPopperPanel.tsx +3 -3
  104. package/OverlayOrPopperChip/OverlayPanel.tsx +13 -7
  105. package/OverlayOrPopperChip/OverlayPanelActions.tsx +2 -2
  106. package/OverlayOrPopperChip/PopperPanel.tsx +3 -2
  107. package/OverlayOrPopperChip/PopperPanelActions.tsx +2 -2
  108. package/OverlayOrPopperChip/types.ts +2 -2
  109. package/OverlayOrPopperChip/useHandleClickNotDrag.ts +3 -1
  110. package/Page/CssAndFramerMotionProvider.tsx +2 -1
  111. package/Page/types.ts +5 -5
  112. package/PageLoadIndicator/PageLoadIndicator.tsx +3 -2
  113. package/PageMeta/PageMeta.tsx +3 -2
  114. package/PageMeta/canonicalize.ts +7 -3
  115. package/Pagination/Pagination.tsx +4 -2
  116. package/Pagination/PaginationExtended.tsx +2 -9
  117. package/RenderType/RenderType.tsx +6 -0
  118. package/Row/ButtonLinkList/ButtonLinkList.tsx +4 -7
  119. package/Row/ButtonLinkList/ButtonLinkListItem.tsx +2 -1
  120. package/Row/ColumnOne/variant/VariantMessage.tsx +2 -4
  121. package/Row/ColumnOneBoxed/ColumnOneBoxed.tsx +4 -2
  122. package/Row/ColumnOneCentered/ColumnOneCentered.tsx +4 -2
  123. package/Row/ColumnThree/ColumnThree.tsx +6 -5
  124. package/Row/ColumnTwo/ColumnTwo.tsx +8 -7
  125. package/Row/ColumnTwoSpread/ColumnTwoSpread.tsx +7 -5
  126. package/Row/ColumnTwoWithTop/ColumnTwoWithTop.tsx +5 -4
  127. package/Row/ContentLinks/ContentLinks.tsx +4 -3
  128. package/Row/HeroBanner/HeroBanner.tsx +3 -2
  129. package/Row/IconBlocks/IconBlock.tsx +3 -2
  130. package/Row/IconBlocks/IconBlocks.tsx +3 -2
  131. package/Row/ImageText/ImageText.tsx +3 -2
  132. package/Row/ImageTextBoxed/ImageTextBoxed.tsx +4 -3
  133. package/Row/ParagraphWithSidebarSlide/ParagraphWithSidebarSlide.tsx +3 -2
  134. package/Row/Quote/Quote.tsx +1 -1
  135. package/Row/Row.tsx +2 -1
  136. package/Row/RowLinks/RowLinks.tsx +36 -34
  137. package/Row/RowLinks/variant/VariantImageLabelSwiper.tsx +6 -2
  138. package/Row/RowLinks/variant/VariantInline.tsx +6 -2
  139. package/Row/RowLinks/variant/VariantLogoSwiper.tsx +2 -1
  140. package/Row/RowLinks/variant/VariantUsps.tsx +2 -1
  141. package/Row/SpecialBanner/SpecialBanner.tsx +3 -2
  142. package/SectionContainer/SectionContainer.tsx +3 -2
  143. package/SectionHeader/SectionHeader.tsx +2 -1
  144. package/Separator/Separator.tsx +3 -2
  145. package/Snackbar/DismissibleSnackbar.tsx +1 -1
  146. package/Snackbar/ErrorSnackbar.tsx +1 -1
  147. package/Snackbar/MessageSnackbarImpl.tsx +7 -16
  148. package/StarRatingField/StarRatingField.tsx +3 -2
  149. package/Stepper/Stepper.tsx +3 -2
  150. package/Styles/__tests__/spreadVal.test.ts +4 -4
  151. package/Styles/extendableComponent.ts +4 -3
  152. package/Styles/withEmotionCache.tsx +2 -2
  153. package/Styles/withTheme.tsx +4 -1
  154. package/TextInputNumber/TextInputNumber.tsx +5 -8
  155. package/Theme/DarkLightModeThemeProvider.tsx +10 -7
  156. package/Theme/MuiButton.ts +2 -1
  157. package/Theme/MuiChip.ts +2 -1
  158. package/Theme/MuiFab.ts +2 -1
  159. package/Theme/MuiSlider.ts +3 -3
  160. package/Theme/MuiSnackbar.ts +1 -1
  161. package/Theme/NextLink.tsx +35 -15
  162. package/Theme/createTheme.ts +6 -0
  163. package/Theme/index.ts +1 -0
  164. package/Theme/themeDefaults.ts +10 -10
  165. package/Theme/useContainerSizing.ts +20 -0
  166. package/TimeAgo/TimeAgo.tsx +3 -3
  167. package/ToggleButton/ToggleButton.tsx +6 -4
  168. package/ToggleButtonGroup/ToggleButtonGroup.tsx +99 -94
  169. package/UspList/UspList.tsx +3 -2
  170. package/UspList/UspListItem.tsx +3 -2
  171. package/hooks/memoDeep.ts +3 -2
  172. package/hooks/useDateTimeFormat.ts +3 -1
  173. package/hooks/useMatchMedia.ts +2 -1
  174. package/hooks/useMemoDeep.ts +2 -1
  175. package/hooks/useNumberFormat.ts +3 -1
  176. package/index.ts +3 -1
  177. package/package.json +17 -18
  178. package/utils/cookie.ts +4 -3
  179. package/utils/robots.ts +1 -1
  180. package/utils/sitemap.ts +3 -2
  181. package/utils/sxx.ts +16 -0
  182. package/AnimatedRow/AnimatedRow.tsx +0 -23
  183. package/docs/building-components.mdx +0 -3
  184. package/docs/components/ComponentBasic.tsx +0 -26
  185. package/docs/components/ComponentChild.tsx +0 -49
  186. package/docs/components/ComponentChildVariant.tsx +0 -55
  187. package/docs/components/ComponentChildVariantExtendable.tsx +0 -63
  188. package/docs/components/ComponentStylable.tsx +0 -32
  189. package/docs/pages/building-components.tsx +0 -62
@@ -1,4 +1,5 @@
1
- import { RowLinks, RowLinksProps } from '../RowLinks'
1
+ import type { RowLinksProps } from '../RowLinks'
2
+ import { RowLinks } from '../RowLinks'
2
3
 
3
4
  export function VariantUsps(props: RowLinksProps) {
4
5
  const { sx = [], inlineTitle = true, ...rowLinksProps } = props
@@ -1,4 +1,5 @@
1
- import { Box, ContainerProps, Typography } from '@mui/material'
1
+ import type { ContainerProps } from '@mui/material'
2
+ import { Box, Typography } from '@mui/material'
2
3
  import { extendableComponent } from '../../Styles'
3
4
  import { breakpointVal } from '../../Styles/breakpointVal'
4
5
  import { responsiveVal } from '../../Styles/responsiveVal'
@@ -11,7 +12,7 @@ export type SpecialBannerProps = ContainerProps & {
11
12
  children: React.ReactNode
12
13
  }
13
14
 
14
- const name = 'SpecialBanner' as const
15
+ const name = 'SpecialBanner'
15
16
  const parts = ['root', 'wrapper', 'copy', 'asset', 'topic', 'links', 'textContainer'] as const
16
17
  const { classes } = extendableComponent(name, parts)
17
18
 
@@ -1,12 +1,13 @@
1
1
  import { Box } from '@mui/material'
2
- import { SectionHeader, SectionHeaderProps } from '../SectionHeader/SectionHeader'
2
+ import type { SectionHeaderProps } from '../SectionHeader/SectionHeader'
3
+ import { SectionHeader } from '../SectionHeader/SectionHeader'
3
4
  import { extendableComponent } from '../Styles'
4
5
 
5
6
  export type SectionContainerProps = SectionHeaderProps &
6
7
  OwnerState & { children?: React.ReactNode; className?: string }
7
8
 
8
9
  type OwnerState = { borderBottom?: boolean }
9
- const name = 'SectionContainer' as const
10
+ const name = 'SectionContainer'
10
11
  const parts = ['root'] as const
11
12
  const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
12
13
 
@@ -1,4 +1,5 @@
1
- import { Box, Typography, TypographyProps, SxProps, Theme } from '@mui/material'
1
+ import type { SxProps, Theme, TypographyProps } from '@mui/material'
2
+ import { Box, Typography } from '@mui/material'
2
3
  import React from 'react'
3
4
  import { extendableComponent } from '../Styles'
4
5
 
@@ -1,4 +1,5 @@
1
- import { Box, Typography, TypographyProps } from '@mui/material'
1
+ import type { TypographyProps } from '@mui/material'
2
+ import { Box, Typography } from '@mui/material'
2
3
  import React from 'react'
3
4
  import { extendableComponent } from '../Styles'
4
5
 
@@ -6,7 +7,7 @@ export type DividedLinksProps = {
6
7
  icon?: React.ReactNode
7
8
  } & Pick<TypographyProps, 'color' | 'sx'>
8
9
 
9
- const name = 'Separator' as const
10
+ const name = 'Separator'
10
11
  const parts = ['root'] as const
11
12
  const { classes } = extendableComponent(name, parts)
12
13
 
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react'
2
2
  import { MessageSnackbar } from './MessageSnackbar'
3
- import { MessageSnackbarProps } from './MessageSnackbarImpl'
3
+ import type { MessageSnackbarProps } from './MessageSnackbarImpl'
4
4
 
5
5
  export type DismissibleSnackbarProps = MessageSnackbarProps & {
6
6
  id: string
@@ -1,7 +1,7 @@
1
1
  import { Trans } from '@lingui/react'
2
2
  import { Button } from '@mui/material'
3
3
  import { MessageSnackbar } from './MessageSnackbar'
4
- import { MessageSnackbarProps } from './MessageSnackbarImpl'
4
+ import type { MessageSnackbarProps } from './MessageSnackbarImpl'
5
5
 
6
6
  export type ErrorSnackbarProps = MessageSnackbarProps
7
7
 
@@ -1,20 +1,11 @@
1
1
  import { i18n } from '@lingui/core'
2
- import {
3
- Fab,
4
- Snackbar,
5
- SnackbarContent,
6
- SnackbarProps,
7
- lighten,
8
- Box,
9
- SxProps,
10
- Theme,
11
- Portal,
12
- SvgIconProps,
13
- } from '@mui/material'
2
+ import type { SnackbarProps, SxProps, Theme } from '@mui/material'
3
+ import { Box, Fab, Portal, Snackbar, SnackbarContent, lighten } from '@mui/material'
14
4
  import React, { useEffect, useState } from 'react'
15
- import { IconSvg, IconSvgProps } from '../IconSvg'
16
- import { extendableComponent, breakpointVal } from '../Styles'
17
- import { iconClose, iconCheckmark, iconSadFace } from '../icons'
5
+ import type { IconSvgProps } from '../IconSvg'
6
+ import { IconSvg } from '../IconSvg'
7
+ import { breakpointVal, extendableComponent } from '../Styles'
8
+ import { iconCheckmark, iconClose, iconSadFace } from '../icons'
18
9
  import iconInfo from '../icons/info.svg'
19
10
 
20
11
  type Size = 'normal' | 'wide'
@@ -46,7 +37,7 @@ type OwnerState = {
46
37
  disableIcon?: boolean
47
38
  }
48
39
 
49
- const name = 'MessageSnackbarImpl' as const
40
+ const name = 'MessageSnackbarImpl'
50
41
  const parts = ['root', 'content', 'children', 'actionButton', 'close'] as const
51
42
  const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
52
43
 
@@ -1,4 +1,5 @@
1
- import { RatingProps, Rating } from '@mui/material'
1
+ import type { RatingProps } from '@mui/material'
2
+ import { Rating } from '@mui/material'
2
3
  import { IconSvg } from '../IconSvg'
3
4
  import { extendableComponent } from '../Styles'
4
5
  import { iconStar } from '../icons'
@@ -8,7 +9,7 @@ export type StarRatingFieldProps = {
8
9
  onChange?: (id: string, value: number) => void
9
10
  } & Omit<RatingProps, 'id' | 'onChange'>
10
11
 
11
- const name = 'StarRatingField' as const
12
+ const name = 'StarRatingField'
12
13
  const parts = ['root', 'startEmpty', 'starFull'] as const
13
14
  const { classes } = extendableComponent(name, parts)
14
15
 
@@ -1,4 +1,5 @@
1
- import { Box, SxProps, Theme } from '@mui/material'
1
+ import type { SxProps, Theme } from '@mui/material'
2
+ import { Box } from '@mui/material'
2
3
  import { extendableComponent } from '../Styles'
3
4
 
4
5
  export type StepperProps = {
@@ -7,7 +8,7 @@ export type StepperProps = {
7
8
  sx?: SxProps<Theme>
8
9
  }
9
10
 
10
- const name = 'Stepper' as const
11
+ const name = 'Stepper'
11
12
  const parts = ['root', 'step', 'activeStep'] as const
12
13
  const { classes } = extendableComponent(name, parts)
13
14
 
@@ -3,9 +3,9 @@ import { spreadLinear, spreadVal } from '../spreadVal'
3
3
  it('generates the right spreadVal', () => {
4
4
  const s = (val: unknown) => JSON.stringify(val)
5
5
 
6
- expect(s(spreadLinear(15, 18, 'xl'))).toMatchInlineSnapshot(`"[15,15.53,16.2,17.28,18]"`)
7
- expect(s(spreadLinear(15, 18))).toMatchInlineSnapshot(`"[15,16.31,18,18,18]"`)
6
+ expect(s(spreadLinear(15, 18, 'xl'))).toMatchInlineSnapshot('"[15,15.53,16.2,17.28,18]"')
7
+ expect(s(spreadLinear(15, 18))).toMatchInlineSnapshot('"[15,16.31,18,18,18]"')
8
8
 
9
- expect(s(spreadVal(15, 18, 'xl'))).toMatchInlineSnapshot(`"[15,15.09,15.48,16.73,18]"`)
10
- expect(s(spreadVal(15, 18))).toMatchInlineSnapshot(`"[15,15.57,18,18,18]"`)
9
+ expect(s(spreadVal(15, 18, 'xl'))).toMatchInlineSnapshot('"[15,15.09,15.48,16.73,18]"')
10
+ expect(s(spreadVal(15, 18))).toMatchInlineSnapshot('"[15,15.57,18,18,18]"')
11
11
  })
@@ -1,4 +1,5 @@
1
- import { capitalize, Interpolation, Theme } from '@mui/material'
1
+ import type { Interpolation, Theme } from '@mui/material'
2
+ import { capitalize } from '@mui/material'
2
3
 
3
4
  export type ExtendableComponent<StyleProps extends Record<string, unknown>> = {
4
5
  /**
@@ -15,7 +16,7 @@ export type ExtendableComponent<StyleProps extends Record<string, unknown>> = {
15
16
  variants?: { props: Partial<StyleProps>; style: Interpolation<{ theme: Theme }> }[]
16
17
  }
17
18
 
18
- export function slotClasses<Name extends string, ClassNames extends ReadonlyArray<string>>(
19
+ function slotClasses<Name extends string, ClassNames extends ReadonlyArray<string>>(
19
20
  name: Name,
20
21
  slotNames: ClassNames,
21
22
  ) {
@@ -25,7 +26,7 @@ export function slotClasses<Name extends string, ClassNames extends ReadonlyArra
25
26
  }
26
27
 
27
28
  /** Maps incoming classes to a selectors that can be used to extend the component */
28
- export const partselectorsMap = <O extends Record<string, string>>(
29
+ const partselectorsMap = <O extends Record<string, string>>(
29
30
  obj: O,
30
31
  ): {
31
32
  [P in keyof O]: `& .${O[P]}`
@@ -1,11 +1,11 @@
1
1
  import type { EmotionJSX } from '@emotion/react/types/jsx-namespace'
2
2
  import createEmotionServer from '@emotion/server/create-instance'
3
- import { AppType } from 'next/app'
3
+ import type { AppType } from 'next/app'
4
4
  // eslint-disable-next-line @next/next/no-document-import-in-page
5
5
  import type NextDocument from 'next/document'
6
6
  // eslint-disable-next-line @next/next/no-document-import-in-page
7
7
  import type { DocumentContext } from 'next/document'
8
- import { EmotionProviderProps } from './EmotionProvider'
8
+ import type { EmotionProviderProps } from './EmotionProvider'
9
9
  import { createEmotionCache } from './createEmotionCache'
10
10
 
11
11
  export type EmotionCacheProps = { emotionStyleTags: EmotionJSX.Element[] }
@@ -1,4 +1,5 @@
1
- import { SxProps, Theme, ThemeProvider } from '@mui/material'
1
+ import type { SxProps, Theme } from '@mui/material'
2
+ import { ThemeProvider } from '@mui/material'
2
3
  import React from 'react'
3
4
 
4
5
  type WithSx = { sx?: SxProps<Theme> }
@@ -34,6 +35,8 @@ type WithSx = { sx?: SxProps<Theme> }
34
35
  * Layout: withTheme(LayoutFull, darkTheme),
35
36
  * } as PageOptions
36
37
  * ```
38
+ *
39
+ * @public
37
40
  */
38
41
  export function withTheme<T>(
39
42
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,16 +1,13 @@
1
1
  import { i18n } from '@lingui/core'
2
+ import type { IconButtonProps, SxProps, TextFieldProps, Theme } from '@mui/material'
2
3
  import {
3
- IconButtonProps,
4
- SxProps,
5
4
  Box,
6
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
+ Fab, // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
6
  TextField,
8
- TextFieldProps,
9
7
  useForkRef,
10
- Theme,
11
- Fab,
12
8
  } from '@mui/material'
13
- import { ChangeEvent, Ref, useCallback, useEffect, useRef, useState } from 'react'
9
+ import type { ChangeEvent, Ref } from 'react'
10
+ import { useCallback, useEffect, useRef, useState } from 'react'
14
11
  import { IconSvg } from '../IconSvg'
15
12
  import { extendableComponent } from '../Styles'
16
13
  import { responsiveVal } from '../Styles/responsiveVal'
@@ -28,7 +25,7 @@ export type TextInputNumberProps = Omit<TextFieldProps, 'type'> & {
28
25
  }
29
26
 
30
27
  type OwnerState = { size?: 'small' | 'medium' }
31
- const name = 'TextInputNumber' as const
28
+ const name = 'TextInputNumber'
32
29
  const parts = ['quantity', 'quantityInput', 'button'] as const
33
30
  const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
34
31
 
@@ -1,19 +1,17 @@
1
1
  import { Trans } from '@lingui/react'
2
+ import type { FabProps, ListItemButtonProps, Theme } from '@mui/material'
2
3
  import {
3
- Theme,
4
- ThemeProvider,
5
- useMediaQuery,
6
4
  Fab,
7
- FabProps,
8
5
  ListItemButton,
9
6
  ListItemIcon,
10
7
  ListItemText,
11
- ListItemButtonProps,
8
+ ThemeProvider, // eslint-disable-next-line @typescript-eslint/no-restricted-imports
9
+ useMediaQuery,
12
10
  } from '@mui/material'
13
11
  import { useRouter } from 'next/router'
14
12
  import { createContext, useContext, useEffect, useMemo, useState } from 'react'
15
- import { IconSvg } from '../IconSvg'
16
13
  import { iconMoon, iconSun } from '../icons'
14
+ import { IconSvg } from '../IconSvg'
17
15
  import { getCssFlag, setCssFlag } from '../utils/cssFlags'
18
16
 
19
17
  type Mode = 'dark' | 'light'
@@ -27,10 +25,11 @@ type ColorModeContext = {
27
25
  toggle: () => void
28
26
  }
29
27
 
28
+ /** @public */
30
29
  export const colorModeContext = createContext(undefined as unknown as ColorModeContext)
31
30
  colorModeContext.displayName = 'ColorModeContext'
32
31
 
33
- type ThemeProviderProps = {
32
+ export type ThemeProviderProps = {
34
33
  children: React.ReactNode
35
34
  ssrMode?: Mode
36
35
  listenToBrowser?: boolean
@@ -93,10 +92,12 @@ export function DarkLightModeThemeProvider(props: ThemeProviderProps) {
93
92
  )
94
93
  }
95
94
 
95
+ /** @public */
96
96
  export function useColorMode() {
97
97
  return useContext(colorModeContext)
98
98
  }
99
99
 
100
+ /** @public */
100
101
  export function DarkLightModeToggleFab(props: Omit<FabProps, 'onClick'>) {
101
102
  const { currentMode, isSingleMode, toggle } = useColorMode()
102
103
 
@@ -115,6 +116,8 @@ export function DarkLightModeToggleFab(props: Omit<FabProps, 'onClick'>) {
115
116
  * A button that switches between light and dark mode
116
117
  *
117
118
  * To disable this functionality
119
+ *
120
+ * @public
118
121
  */
119
122
  export function DarkLightModeMenuSecondaryItem(props: ListItemButtonProps) {
120
123
  const { sx = [] } = props
@@ -1,4 +1,5 @@
1
- import { ComponentsVariants, Theme, alpha, darken, lighten } from '@mui/material'
1
+ import type { ComponentsVariants, Theme } from '@mui/material'
2
+ import { alpha, darken, lighten } from '@mui/material'
2
3
  import { responsiveVal } from '../Styles/responsiveVal'
3
4
 
4
5
  declare module '@mui/material/Button/Button' {
package/Theme/MuiChip.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ComponentsVariants, Theme, darken } from '@mui/material'
1
+ import type { ComponentsVariants, Theme } from '@mui/material'
2
+ import { darken } from '@mui/material'
2
3
  import { responsiveVal } from '../Styles'
3
4
 
4
5
  declare module '@mui/material/Chip/Chip' {
package/Theme/MuiFab.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ComponentsVariants, FabProps, Theme, useTheme } from '@mui/material'
1
+ import type { ComponentsVariants, FabProps, Theme } from '@mui/material'
2
+ import { useTheme } from '@mui/material'
2
3
  import { responsiveVal } from '../Styles'
3
4
 
4
5
  type FabSize = NonNullable<FabProps['size']>
@@ -1,4 +1,4 @@
1
- import { ComponentsVariants, Theme } from '@mui/material'
1
+ import type { ComponentsVariants, Theme } from '@mui/material'
2
2
 
3
3
  declare module '@mui/material/Slider/Slider' {
4
4
  interface SliderPropsSizeOverrides {
@@ -36,8 +36,8 @@ export const MuiSlider: SliderVariants = [
36
36
  {
37
37
  props: { size: 'large' },
38
38
  style: {
39
- maxWidth: `calc(100% - 28px)`,
40
- margin: `0 auto`,
39
+ maxWidth: 'calc(100% - 28px)',
40
+ margin: '0 auto',
41
41
  display: 'block',
42
42
  '& .MuiSlider-rail': {
43
43
  height: 4,
@@ -1,4 +1,4 @@
1
- import { ComponentsVariants, Theme } from '@mui/material'
1
+ import type { ComponentsVariants, Theme } from '@mui/material'
2
2
 
3
3
  type SnackbarVariants = NonNullable<ComponentsVariants<Theme>['MuiSnackbar']>
4
4
 
@@ -1,15 +1,21 @@
1
- import Link, { LinkProps as NextLinkProps } from 'next/link'
1
+ import type { LinkProps as NextLinkProps } from 'next/link'
2
+ import Link from 'next/link'
3
+ import { useRouter } from 'next/router'
2
4
  import React, { forwardRef } from 'react'
5
+ import { useStorefrontConfig } from '../hooks/useStorefrontConfig'
3
6
 
4
- type LinkProps = Omit<NextLinkProps, 'legacyBehavior' | 'passHref' | 'as'>
5
- type AnchorWithoutLinkProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps>
6
- type LinkProppies = AnchorWithoutLinkProps & Partial<LinkProps> & { relative?: boolean }
7
+ export type NextLinkPropsBase = Omit<NextLinkProps, 'legacyBehavior' | 'passHref' | 'as'>
8
+ export type AnchorWithoutLinkProps = Omit<
9
+ React.AnchorHTMLAttributes<HTMLAnchorElement>,
10
+ keyof NextLinkPropsBase
11
+ >
12
+ export type LinkProps = AnchorWithoutLinkProps & Partial<NextLinkPropsBase> & { relative?: boolean }
7
13
 
8
14
  /**
9
15
  * This is a wrapper around the Next.js Link component which can be used with MUI's Link component
10
16
  * or any ButtonBase derivative.
11
17
  *
12
- * By default you can use the the props provided by the Link or Button component, but you to pass
18
+ * By default you can use the props provided by the Link or Button component, but you can pass
13
19
  * any next/link specific props like `prefetch`, `replace`, `scroll`, `shallow`
14
20
  *
15
21
  * ```typescript
@@ -20,22 +26,36 @@ type LinkProppies = AnchorWithoutLinkProps & Partial<LinkProps> & { relative?: b
20
26
  * )
21
27
  * ```
22
28
  */
23
- export const NextLink = forwardRef<HTMLAnchorElement, LinkProppies>((props, ref) => {
24
- let { href, target, relative, ...rest } = props
29
+ export const NextLink = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
30
+ let { href, target, relative, locale, ...rest } = props
31
+
32
+ const router = useRouter()
33
+ const canonicalBaseUrl =
34
+ useStorefrontConfig().canonicalBaseUrl ?? import.meta.graphCommerce.canonicalBaseUrl
25
35
 
26
36
  // The href is optional in a MUI link, but required in a Next.js link
27
- // eslint-disable-next-line jsx-a11y/anchor-has-content
28
- if (!href) return <a {...rest} ref={ref} />
37
+ // When the href is not a string, we pass it through directly
38
+ if (!href || typeof href !== 'string') return <Link href={href ?? ''} {...rest} ref={ref} />
39
+
40
+ const isFullUrl = href.includes(':') || href.startsWith('//')
29
41
 
30
- const hrefString = href.toString()
31
- const isExternal = hrefString.includes(':') || hrefString.startsWith('//')
32
- const isHash = hrefString.startsWith('#')
42
+ /**
43
+ * When an internal link is provided and it is on the same domain, extract the locale
44
+ * from the URL and make the URL relative without the locale. Prevents Next.js prefixing
45
+ * again with the current locale.
46
+ */
47
+ if (!locale && isFullUrl && href.startsWith(canonicalBaseUrl)) {
48
+ const url = new URL(href)
49
+ locale = router.locales?.find((l) => url.pathname.startsWith(`/${l}/`))
50
+ href = locale ? url.pathname.replace(`/${locale}/`, '/') : url.pathname
51
+ }
33
52
 
53
+ const isExternal = isFullUrl && !href.startsWith(canonicalBaseUrl)
34
54
  if (isExternal) target = target || '_blank'
35
- target = typeof target === 'undefined' && isExternal ? '_blank' : target
36
55
 
37
56
  // Relative URL's cause more pain than they're worth
38
- if (!isExternal && !isHash && !hrefString.startsWith('/') && !relative) href = `/${href}`
57
+ const isHash = href.startsWith('#')
58
+ if (!isExternal && !isHash && !href.startsWith('/') && !relative) href = `/${href}`
39
59
 
40
- return <Link href={href} {...rest} target={target} ref={ref} />
60
+ return <Link href={href} {...rest} target={target} ref={ref} locale={locale} />
41
61
  })
@@ -1,3 +1,5 @@
1
+ import { Breakpoint } from '@mui/material'
2
+
1
3
  export {}
2
4
 
3
5
  declare module '@mui/material/styles/createPalette' {
@@ -26,6 +28,8 @@ declare module '@mui/material/styles/createTheme' {
26
28
  headerHeightMd: string
27
29
  appBarHeightMd: string
28
30
  appBarInnerHeightMd: string
31
+ containerSizingShell: false | Breakpoint | undefined
32
+ containerSizingContent: false | Breakpoint | undefined
29
33
  }
30
34
 
31
35
  // todo: should be cleaned up to be compatible with the default mui-styles
@@ -50,6 +54,8 @@ declare module '@mui/material/styles/createTheme' {
50
54
  headerHeightMd: string
51
55
  appBarHeightMd: string
52
56
  appBarInnerHeightMd: string
57
+ containerSizingShell: false | Breakpoint | undefined
58
+ containerSizingContent: false | Breakpoint | undefined
53
59
  }
54
60
 
55
61
  // todo: should be cleaned up to be compatible with the default mui-styles
package/Theme/index.ts CHANGED
@@ -6,3 +6,4 @@ export * from './MuiSlider'
6
6
  export * from './MuiSnackbar'
7
7
  export * from './themeDefaults'
8
8
  export * from './NextLink'
9
+ export * from './useContainerSizing'
@@ -1,4 +1,4 @@
1
- import { Shadows } from '@mui/material/styles/shadows'
1
+ import type { Shadows } from '@mui/material/styles/shadows'
2
2
  import { spreadVal } from '../Styles/spreadVal'
3
3
  import { breakpoints } from './breakpoints'
4
4
 
@@ -6,22 +6,22 @@ import { breakpoints } from './breakpoints'
6
6
 
7
7
  const shadows: Shadows = [
8
8
  /* 0 */ 'none',
9
- /* 1 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 1.4px 1.8px -1.5px hsl(0deg 0% 0% / 0.09)`,
10
- /* 2 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 2.6px 3.3px -1.5px hsl(0deg 0% 0% / 0.09)`,
11
- /* 3 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 3.8px 4.8px -1.5px hsl(0deg 0% 0% / 0.09)`,
12
- /* 4 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.04),0px 1.7px 2.2px -0.7px hsl(0deg 0% 0% / 0.06),0px 5px 6.4px -1.5px hsl(0deg 0% 0% / 0.08)`,
9
+ /* 1 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 1.4px 1.8px -1.5px hsl(0deg 0% 0% / 0.09)',
10
+ /* 2 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 2.6px 3.3px -1.5px hsl(0deg 0% 0% / 0.09)',
11
+ /* 3 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 3.8px 4.8px -1.5px hsl(0deg 0% 0% / 0.09)',
12
+ /* 4 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.04),0px 1.7px 2.2px -0.7px hsl(0deg 0% 0% / 0.06),0px 5px 6.4px -1.5px hsl(0deg 0% 0% / 0.08)',
13
13
  /* 5 */ 'none',
14
- /* 6 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.04),0px 2.3px 2.9px -0.7px hsl(0deg 0% 0% / 0.06),0px 7.6px 9.7px -1.5px hsl(0deg 0% 0% / 0.08)`,
14
+ /* 6 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.04),0px 2.3px 2.9px -0.7px hsl(0deg 0% 0% / 0.06),0px 7.6px 9.7px -1.5px hsl(0deg 0% 0% / 0.08)',
15
15
  /* 7 */ 'none',
16
- /* 8 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 2.9px 3.7px -0.7px hsl(0deg 0% 0% / 0.07),0px 10px 12.8px -1.5px hsl(0deg 0% 0% / 0.1)`,
16
+ /* 8 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 2.9px 3.7px -0.7px hsl(0deg 0% 0% / 0.07),0px 10px 12.8px -1.5px hsl(0deg 0% 0% / 0.1)',
17
17
  /* 9 */ 'none',
18
18
  /* 10 */ 'none',
19
19
  /* 11 */ 'none',
20
- /* 12 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 4.2px 5.4px -0.7px hsl(0deg 0% 0% / 0.09),0px 15px 19.1px -1.5px hsl(0deg 0% 0% / 0.11)`,
20
+ /* 12 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.06),0px 4.2px 5.4px -0.7px hsl(0deg 0% 0% / 0.09),0px 15px 19.1px -1.5px hsl(0deg 0% 0% / 0.11)',
21
21
  /* 13 */ 'none',
22
22
  /* 14 */ 'none',
23
23
  /* 15 */ 'none',
24
- /* 16 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 3.5px 4.5px -0.5px hsl(0deg 0% 0% / 0.07),0px 8.6px 11px -1px hsl(0deg 0% 0% / 0.08),0px 20px 25.5px -1.5px hsl(0deg 0% 0% / 0.1)`,
24
+ /* 16 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 3.5px 4.5px -0.5px hsl(0deg 0% 0% / 0.07),0px 8.6px 11px -1px hsl(0deg 0% 0% / 0.08),0px 20px 25.5px -1.5px hsl(0deg 0% 0% / 0.1)',
25
25
  /* 17 */ 'none',
26
26
  /* 18 */ 'none',
27
27
  /* 19 */ 'none',
@@ -29,7 +29,7 @@ const shadows: Shadows = [
29
29
  /* 21 */ 'none',
30
30
  /* 22 */ 'none',
31
31
  /* 23 */ 'none',
32
- /* 24 */ `0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 3.9px 5px -0.4px hsl(0deg 0% 0% / 0.07),0px 8.1px 10.3px -0.7px hsl(0deg 0% 0% / 0.08),0px 15.8px 20.1px -1.1px hsl(0deg 0% 0% / 0.1),0px 30px 38.3px -1.5px hsl(0deg 0% 0% / 0.11)`,
32
+ /* 24 */ '0px 0px 1.5px hsl(0deg 0% 0% / 0.15),0px 0.5px 0.6px hsl(0deg 0% 0% / 0.05),0px 3.9px 5px -0.4px hsl(0deg 0% 0% / 0.07),0px 8.1px 10.3px -0.7px hsl(0deg 0% 0% / 0.08),0px 15.8px 20.1px -1.1px hsl(0deg 0% 0% / 0.1),0px 30px 38.3px -1.5px hsl(0deg 0% 0% / 0.11)',
33
33
  ]
34
34
 
35
35
  export const themeBaseDefaults = {
@@ -0,0 +1,20 @@
1
+ import type { Theme } from '@mui/material'
2
+ import { useTheme } from '@mui/material'
3
+
4
+ function containerSizing(variant: ContainerSizingVariant, theme: Theme) {
5
+ const breakpoint =
6
+ variant === 'shell'
7
+ ? theme.appShell.containerSizingShell
8
+ : theme.appShell.containerSizingContent
9
+
10
+ return {
11
+ breakpoint,
12
+ value: breakpoint ? `${theme.breakpoints.values[breakpoint]}px` : '100%',
13
+ }
14
+ }
15
+
16
+ export type ContainerSizingVariant = 'shell' | 'content'
17
+ export function useContainerSizing(variant: ContainerSizingVariant) {
18
+ const theme = useTheme()
19
+ return containerSizing(variant, theme)
20
+ }
@@ -2,14 +2,14 @@ import { useLocale } from '../hooks/useLocale'
2
2
 
3
3
  export type TimeAgoProps = {
4
4
  date: Date
5
- /**
6
- * @deprecated No longer used
7
- */
5
+ /** @deprecated No longer used */
6
+ // eslint-disable-next-line react/no-unused-prop-types
8
7
  locale?: string
9
8
  }
10
9
 
11
10
  /**
12
11
  * @deprecated Use <RelativeToTimeFormat /> instead.
12
+ * @public
13
13
  */
14
14
  export function TimeAgo(props: TimeAgoProps) {
15
15
  const { date } = props
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { alpha, Button, ButtonProps } from '@mui/material'
3
- import React, { FormEvent } from 'react'
2
+ import type { ButtonProps } from '@mui/material'
3
+ import { Button, alpha } from '@mui/material'
4
+ import type { FormEvent } from 'react'
5
+ import React from 'react'
4
6
  import { extendableComponent } from '../Styles'
5
7
  import { breakpointVal } from '../Styles/breakpointVal'
6
8
 
@@ -12,7 +14,7 @@ export type ToggleButtonProps = Omit<ButtonProps, 'onClick' | 'onChange'> & {
12
14
 
13
15
  type OwnerState = Pick<ButtonProps, 'size' | 'disabled'> & { selected?: boolean }
14
16
 
15
- const compName = 'ToggleButton' as const
17
+ const compName = 'ToggleButton'
16
18
  const parts = ['root', 'button', 'helperText'] as const
17
19
  const { withState } = extendableComponent<OwnerState, typeof compName, typeof parts>(
18
20
  compName,
@@ -93,7 +95,7 @@ export const ToggleButton = React.forwardRef<any, ToggleButtonProps>((props, ref
93
95
  theme.shape.borderRadius * 1.5,
94
96
  theme.breakpoints.values,
95
97
  ),
96
- padding: `8px 12px`,
98
+ padding: '8px 12px',
97
99
  },
98
100
  }),
99
101
  ...(Array.isArray(sx) ? sx : [sx]),