@graphcommerce/next-ui 9.0.0-canary.99 → 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.
- package/ActionCard/ActionCard.tsx +219 -203
- package/ActionCard/ActionCardAccordion.tsx +4 -2
- package/ActionCard/ActionCardLayout.tsx +3 -2
- package/ActionCard/ActionCardList.tsx +6 -5
- package/Blog/BlogAuthor/BlogAuthor.tsx +5 -4
- package/Blog/BlogContent/BlogContent.tsx +3 -2
- package/Blog/BlogHeader/BlogHeader.tsx +4 -3
- package/Blog/BlogList/BlogList.tsx +3 -3
- package/Blog/BlogListItem/BlogListItem.tsx +6 -5
- package/Blog/BlogTags/BlogTag.tsx +3 -2
- package/Blog/BlogTags/BlogTags.tsx +1 -1
- package/Breadcrumbs/Breadcrumbs.tsx +25 -19
- package/Breadcrumbs/BreadcrumbsList.tsx +3 -2
- package/Breadcrumbs/jsonLdBreadcrumb.tsx +1 -1
- package/Breadcrumbs/types.ts +1 -2
- package/Button/Button.tsx +2 -1
- package/Button/LinkOrButton.tsx +4 -2
- package/CHANGELOG.md +294 -1344
- package/ChipMenu/ChipMenu.tsx +3 -2
- package/Config.graphqls +28 -10
- package/Container/Container.tsx +90 -0
- package/ContainerWithHeader/ContainerWithHeader.tsx +2 -1
- package/Document/DocumentBodyEnd.tsx +1 -1
- package/Document/DocumentBodyStart.tsx +1 -1
- package/Document/DocumentHeadEnd.tsx +1 -1
- package/Document/DocumentHeadStart.tsx +1 -1
- package/Fab/Fab.tsx +15 -17
- package/FlagAvatar/FlagAvatar.tsx +2 -1
- package/Footer/Footer.tsx +14 -10
- package/Form/Form.tsx +2 -1
- package/Form/FormHeader.tsx +1 -1
- package/Form/FormRow.tsx +1 -1
- package/Form/InputCheckmark.tsx +2 -1
- package/FramerScroller/ItemScroller.tsx +5 -8
- package/FramerScroller/SidebarGallery.tsx +23 -30
- package/FramerScroller/SidebarSlider.tsx +8 -7
- package/FullPageMessage/FullPageMessage.tsx +2 -1
- package/IconHeader/IconHeader.tsx +5 -3
- package/IconSvg/IconSvg.tsx +8 -7
- package/Intl/DateTimeFormat/DateFormat.tsx +6 -4
- package/Intl/DateTimeFormat/DateTimeFormat.tsx +10 -14
- package/Intl/DateTimeFormat/TimeFormat.tsx +6 -4
- package/Intl/DateTimeFormat/index.ts +1 -0
- package/Intl/DateTimeFormat/useIntlDateTimeFormat.ts +13 -0
- package/Intl/DisplayNames/DisplayNames.tsx +5 -13
- package/Intl/DisplayNames/index.ts +1 -0
- package/Intl/DisplayNames/useIntlDisplayNames.ts +12 -0
- package/Intl/{ListFormat.tsx → ListFormat/ListFormat.tsx} +8 -13
- package/Intl/ListFormat/index.ts +2 -0
- package/Intl/ListFormat/useIntlListFormat.ts +15 -0
- package/Intl/NumberFormat/CurrencyFormat.tsx +4 -2
- package/Intl/NumberFormat/NumberFormat.tsx +15 -17
- package/Intl/NumberFormat/PercentFormat.tsx +6 -2
- package/Intl/NumberFormat/UnitFormat.tsx +5 -5
- package/Intl/NumberFormat/index.ts +1 -0
- package/Intl/NumberFormat/useIntlNumberFormat.ts +17 -0
- package/Intl/RelativeTimeFormat/RelativeTimeFormat.tsx +6 -13
- package/Intl/RelativeTimeFormat/RelativeToTimeFormat.tsx +4 -2
- package/Intl/RelativeTimeFormat/index.ts +1 -0
- package/Intl/RelativeTimeFormat/useIntlRelativeTimeFormat.ts +15 -0
- package/Intl/useIntlLocalesArgument.ts +16 -0
- package/Layout/components/LayoutHeader.tsx +7 -4
- package/Layout/components/LayoutHeaderBack.tsx +6 -4
- package/Layout/components/LayoutHeaderClose.tsx +1 -1
- package/Layout/components/LayoutHeaderContent.tsx +11 -12
- package/Layout/components/LayoutProvider.tsx +1 -1
- package/Layout/components/LayoutTitle.tsx +5 -3
- package/Layout/context/layoutContext.tsx +1 -1
- package/Layout/types.ts +1 -1
- package/LayoutDefault/components/LayoutDefault.tsx +12 -10
- package/LayoutOverlay/components/LayoutOverlay.tsx +3 -2
- package/LayoutOverlay/components/LayoutOverlayHeader.tsx +2 -1
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +4 -1
- package/LayoutParts/DesktopHeaderBadge.tsx +2 -1
- package/LayoutParts/DesktopNavBar.tsx +26 -22
- package/LayoutParts/DesktopNavBarItem.tsx +11 -7
- package/LayoutParts/Logo.tsx +5 -5
- package/LayoutParts/MenuFab.tsx +7 -13
- package/LayoutParts/MenuFabItem.tsx +6 -1
- package/LayoutParts/MenuFabSecondaryItem.tsx +11 -7
- package/LayoutParts/MobileTopRight.tsx +24 -0
- package/LayoutParts/PlaceholderFab.tsx +2 -1
- package/LayoutParts/StickyBelowHeader.tsx +2 -1
- package/LayoutParts/index.ts +1 -0
- package/LazyHydrate/LazyHydrate.tsx +18 -21
- package/MediaQuery/MediaQuery.tsx +111 -0
- package/MediaQuery/index.ts +1 -0
- package/Navigation/components/NavigationFab.tsx +3 -2
- package/Navigation/components/NavigationItem.tsx +3 -3
- package/Navigation/components/NavigationList.tsx +4 -3
- package/Navigation/components/NavigationOverlay.tsx +18 -11
- package/Navigation/components/NavigationProvider.tsx +9 -8
- package/Navigation/components/NavigationTitle.tsx +5 -5
- package/Navigation/hooks/useNavigation.ts +4 -2
- package/Overlay/components/Overlay.tsx +3 -2
- package/Overlay/components/OverlayBase.tsx +71 -30
- package/Overlay/components/OverlayContainer.tsx +2 -2
- package/Overlay/components/OverlayHeader.tsx +7 -4
- package/Overlay/components/OverlaySsr.tsx +2 -1
- package/Overlay/components/OverlayStickyBottom.tsx +2 -1
- package/Overlay/utils/variantsToScrollSnapType.ts +2 -2
- package/OverlayOrPopperChip/OverlayOrPopperChip.tsx +5 -12
- package/OverlayOrPopperChip/OverlayOrPopperPanel.tsx +3 -3
- package/OverlayOrPopperChip/OverlayPanel.tsx +13 -7
- package/OverlayOrPopperChip/OverlayPanelActions.tsx +2 -2
- package/OverlayOrPopperChip/PopperPanel.tsx +3 -2
- package/OverlayOrPopperChip/PopperPanelActions.tsx +2 -2
- package/OverlayOrPopperChip/types.ts +2 -2
- package/OverlayOrPopperChip/useHandleClickNotDrag.ts +3 -1
- package/Page/CssAndFramerMotionProvider.tsx +2 -1
- package/Page/types.ts +5 -5
- package/PageLoadIndicator/PageLoadIndicator.tsx +3 -2
- package/PageMeta/PageMeta.tsx +3 -2
- package/PageMeta/canonicalize.ts +7 -3
- package/Pagination/Pagination.tsx +4 -2
- package/Pagination/PaginationExtended.tsx +2 -9
- package/RenderType/RenderType.tsx +6 -0
- package/Row/ButtonLinkList/ButtonLinkList.tsx +4 -7
- package/Row/ButtonLinkList/ButtonLinkListItem.tsx +2 -1
- package/Row/ColumnOne/variant/VariantMessage.tsx +2 -4
- package/Row/ColumnOneBoxed/ColumnOneBoxed.tsx +4 -2
- package/Row/ColumnOneCentered/ColumnOneCentered.tsx +4 -2
- package/Row/ColumnThree/ColumnThree.tsx +6 -5
- package/Row/ColumnTwo/ColumnTwo.tsx +8 -7
- package/Row/ColumnTwoSpread/ColumnTwoSpread.tsx +7 -5
- package/Row/ColumnTwoWithTop/ColumnTwoWithTop.tsx +5 -4
- package/Row/ContentLinks/ContentLinks.tsx +4 -3
- package/Row/HeroBanner/HeroBanner.tsx +3 -2
- package/Row/IconBlocks/IconBlock.tsx +3 -2
- package/Row/IconBlocks/IconBlocks.tsx +3 -2
- package/Row/ImageText/ImageText.tsx +3 -2
- package/Row/ImageTextBoxed/ImageTextBoxed.tsx +4 -3
- package/Row/ParagraphWithSidebarSlide/ParagraphWithSidebarSlide.tsx +3 -2
- package/Row/Quote/Quote.tsx +1 -1
- package/Row/Row.tsx +2 -1
- package/Row/RowLinks/RowLinks.tsx +36 -34
- package/Row/RowLinks/variant/VariantImageLabelSwiper.tsx +6 -2
- package/Row/RowLinks/variant/VariantInline.tsx +6 -2
- package/Row/RowLinks/variant/VariantLogoSwiper.tsx +2 -1
- package/Row/RowLinks/variant/VariantUsps.tsx +2 -1
- package/Row/SpecialBanner/SpecialBanner.tsx +3 -2
- package/SectionContainer/SectionContainer.tsx +3 -2
- package/SectionHeader/SectionHeader.tsx +2 -1
- package/Separator/Separator.tsx +3 -2
- package/Snackbar/DismissibleSnackbar.tsx +1 -1
- package/Snackbar/ErrorSnackbar.tsx +1 -1
- package/Snackbar/MessageSnackbarImpl.tsx +7 -16
- package/StarRatingField/StarRatingField.tsx +3 -2
- package/Stepper/Stepper.tsx +3 -2
- package/Styles/__tests__/spreadVal.test.ts +4 -4
- package/Styles/extendableComponent.ts +4 -3
- package/Styles/withEmotionCache.tsx +2 -2
- package/Styles/withTheme.tsx +4 -1
- package/TextInputNumber/TextInputNumber.tsx +5 -8
- package/Theme/DarkLightModeThemeProvider.tsx +10 -7
- package/Theme/MuiButton.ts +2 -1
- package/Theme/MuiChip.ts +2 -1
- package/Theme/MuiFab.ts +2 -1
- package/Theme/MuiSlider.ts +3 -3
- package/Theme/MuiSnackbar.ts +1 -1
- package/Theme/NextLink.tsx +35 -15
- package/Theme/createTheme.ts +6 -0
- package/Theme/index.ts +1 -0
- package/Theme/themeDefaults.ts +10 -10
- package/Theme/useContainerSizing.ts +20 -0
- package/TimeAgo/TimeAgo.tsx +3 -3
- package/ToggleButton/ToggleButton.tsx +6 -4
- package/ToggleButtonGroup/ToggleButtonGroup.tsx +99 -94
- package/UspList/UspList.tsx +3 -2
- package/UspList/UspListItem.tsx +3 -2
- package/hooks/memoDeep.ts +3 -2
- package/hooks/useDateTimeFormat.ts +3 -1
- package/hooks/useMatchMedia.ts +2 -1
- package/hooks/useMemoDeep.ts +2 -1
- package/hooks/useNumberFormat.ts +3 -1
- package/index.ts +3 -1
- package/package.json +17 -18
- package/utils/cookie.ts +4 -3
- package/utils/robots.ts +1 -1
- package/utils/sitemap.ts +3 -2
- package/utils/sxx.ts +16 -0
- package/AnimatedRow/AnimatedRow.tsx +0 -23
- package/docs/building-components.mdx +0 -3
- package/docs/components/ComponentBasic.tsx +0 -26
- package/docs/components/ComponentChild.tsx +0 -49
- package/docs/components/ComponentChildVariant.tsx +0 -55
- package/docs/components/ComponentChildVariantExtendable.tsx +0 -63
- package/docs/components/ComponentStylable.tsx +0 -32
- package/docs/pages/building-components.tsx +0 -62
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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'
|
|
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 {
|
|
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'
|
|
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 {
|
|
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
|
|
package/Separator/Separator.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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'
|
|
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
|
-
|
|
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 {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
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'
|
|
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
|
|
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'
|
|
12
|
+
const name = 'StarRatingField'
|
|
12
13
|
const parts = ['root', 'startEmpty', 'starFull'] as const
|
|
13
14
|
const { classes } = extendableComponent(name, parts)
|
|
14
15
|
|
package/Stepper/Stepper.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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'
|
|
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(
|
|
7
|
-
expect(s(spreadLinear(15, 18))).toMatchInlineSnapshot(
|
|
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(
|
|
10
|
-
expect(s(spreadVal(15, 18))).toMatchInlineSnapshot(
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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[] }
|
package/Styles/withTheme.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { SxProps, Theme
|
|
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
|
|
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'
|
|
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
|
-
|
|
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
|
package/Theme/MuiButton.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ComponentsVariants, Theme
|
|
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
package/Theme/MuiFab.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ComponentsVariants, FabProps, Theme
|
|
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']>
|
package/Theme/MuiSlider.ts
CHANGED
|
@@ -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:
|
|
40
|
-
margin:
|
|
39
|
+
maxWidth: 'calc(100% - 28px)',
|
|
40
|
+
margin: '0 auto',
|
|
41
41
|
display: 'block',
|
|
42
42
|
'& .MuiSlider-rail': {
|
|
43
43
|
height: 4,
|
package/Theme/MuiSnackbar.ts
CHANGED
package/Theme/NextLink.tsx
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import
|
|
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
|
|
5
|
-
type AnchorWithoutLinkProps = Omit<
|
|
6
|
-
|
|
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
|
|
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,
|
|
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
|
-
//
|
|
28
|
-
if (!href) return <
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
})
|
package/Theme/createTheme.ts
CHANGED
|
@@ -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
package/Theme/themeDefaults.ts
CHANGED
|
@@ -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 */
|
|
10
|
-
/* 2 */
|
|
11
|
-
/* 3 */
|
|
12
|
-
/* 4 */
|
|
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 */
|
|
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 */
|
|
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 */
|
|
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 */
|
|
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 */
|
|
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
|
+
}
|
package/TimeAgo/TimeAgo.tsx
CHANGED
|
@@ -2,14 +2,14 @@ import { useLocale } from '../hooks/useLocale'
|
|
|
2
2
|
|
|
3
3
|
export type TimeAgoProps = {
|
|
4
4
|
date: Date
|
|
5
|
-
/**
|
|
6
|
-
|
|
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 {
|
|
3
|
-
import
|
|
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'
|
|
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:
|
|
98
|
+
padding: '8px 12px',
|
|
97
99
|
},
|
|
98
100
|
}),
|
|
99
101
|
...(Array.isArray(sx) ? sx : [sx]),
|