@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.
- 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 -1342
- 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,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import {
|
|
2
|
+
import type { ToggleButtonGroupProps as ToggleButtonGroupPropsBase } from '@mui/material'
|
|
3
|
+
import { Box } from '@mui/material'
|
|
3
4
|
import React from 'react'
|
|
4
5
|
import { isFragment } from 'react-is'
|
|
5
6
|
import { extendableComponent } from '../Styles'
|
|
@@ -12,112 +13,116 @@ function isValueSelected(value: string, candidate: string | string[]) {
|
|
|
12
13
|
|
|
13
14
|
type OwnerState = Pick<ToggleButtonGroupPropsBase, 'orientation' | 'size'>
|
|
14
15
|
|
|
15
|
-
const name = 'ToggleButtonGroup'
|
|
16
|
+
const name = 'ToggleButtonGroup'
|
|
16
17
|
const parts = ['root', 'button'] as const
|
|
17
18
|
const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
|
|
18
19
|
|
|
19
20
|
export type ToggleButtonGroupProps = ToggleButtonGroupPropsBase & { required?: boolean }
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
/** @deprecated @public */
|
|
23
|
+
export const ToggleButtonGroup = React.forwardRef<HTMLDivElement, ToggleButtonGroupProps>(
|
|
24
|
+
(props, ref) => {
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
exclusive = false,
|
|
29
|
+
required = false,
|
|
30
|
+
onChange,
|
|
31
|
+
orientation = 'horizontal',
|
|
32
|
+
value,
|
|
33
|
+
size = 'large',
|
|
34
|
+
sx = [],
|
|
35
|
+
...other
|
|
36
|
+
} = props
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
const classes = withState({ orientation, size })
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
const handleChange = (
|
|
41
|
+
event: React.MouseEvent<HTMLElement, MouseEvent>,
|
|
42
|
+
buttonValue: unknown,
|
|
43
|
+
) => {
|
|
44
|
+
if (!onChange) return
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
const index = Boolean(value) && (value.indexOf(buttonValue) as number)
|
|
47
|
+
let newValue: string[]
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
if (value && index && index >= 0) {
|
|
50
|
+
newValue = value.slice()
|
|
51
|
+
newValue.splice(index, 1)
|
|
52
|
+
} else {
|
|
53
|
+
newValue = value ? [...value, buttonValue] : [buttonValue]
|
|
54
|
+
}
|
|
55
|
+
onChange(event, newValue)
|
|
48
56
|
}
|
|
49
|
-
onChange(event, newValue)
|
|
50
|
-
}
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const handleExclusiveChange = (
|
|
59
|
+
event: React.MouseEvent<HTMLElement, MouseEvent>,
|
|
60
|
+
buttonValue: unknown,
|
|
61
|
+
) => {
|
|
62
|
+
if (!onChange || value === buttonValue) return
|
|
63
|
+
if (required) onChange(event, buttonValue)
|
|
64
|
+
else onChange(event, value === buttonValue ? null : buttonValue)
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
return (
|
|
68
|
+
<Box
|
|
69
|
+
role='group'
|
|
70
|
+
className={`${classes.root} ${className ?? ''}`}
|
|
71
|
+
sx={[
|
|
72
|
+
(theme) => ({
|
|
73
|
+
rowGap: theme.spacings.xxs,
|
|
74
|
+
columnGap: theme.spacings.xs,
|
|
75
|
+
'&.orientationVertical': {
|
|
76
|
+
gridAutoFlow: 'column',
|
|
77
|
+
},
|
|
78
|
+
'&.sizeSmall.orientationHorizontal': {
|
|
79
|
+
display: 'flex',
|
|
80
|
+
flexWrap: 'wrap',
|
|
81
|
+
rowGap: '8px',
|
|
82
|
+
columnGap: '8px',
|
|
83
|
+
},
|
|
84
|
+
'&.sizeMedium.orientationHorizontal': {
|
|
85
|
+
display: 'grid',
|
|
86
|
+
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
87
|
+
},
|
|
88
|
+
'&.sizeLarge.orientationHorizontal': {
|
|
89
|
+
display: 'grid',
|
|
90
|
+
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
94
|
+
]}
|
|
95
|
+
ref={ref}
|
|
96
|
+
{...other}
|
|
97
|
+
>
|
|
98
|
+
{React.Children.map(children, (child) => {
|
|
99
|
+
if (!React.isValidElement(child)) return null
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
102
|
+
if (isFragment(child)) {
|
|
103
|
+
console.error(
|
|
104
|
+
[
|
|
105
|
+
"@graphcommerce/next-ui: The ToggleButtonGroup component doesn't accept a Fragment as a child.",
|
|
106
|
+
'Consider providing an array instead.',
|
|
107
|
+
].join('\n'),
|
|
108
|
+
)
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
|
-
}
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
className: `${classes.button} ${child.props.className ?? ''}`,
|
|
109
|
-
onChange: exclusive ? handleExclusiveChange : handleChange,
|
|
110
|
-
selected:
|
|
112
|
+
return React.cloneElement(child, {
|
|
111
113
|
// @ts-ignore
|
|
112
|
-
child.props.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
className: `${classes.button} ${child.props.className ?? ''}`,
|
|
115
|
+
onChange: exclusive ? handleExclusiveChange : handleChange,
|
|
116
|
+
selected:
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
child.props.selected === undefined
|
|
119
|
+
? // @ts-ignore
|
|
120
|
+
isValueSelected(child.props.value as string, value as string | string[])
|
|
121
|
+
: // @ts-ignore
|
|
122
|
+
child.props.selected,
|
|
123
|
+
})
|
|
124
|
+
})}
|
|
125
|
+
</Box>
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
)
|
package/UspList/UspList.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 UspListProps = OwnerState & {
|
|
@@ -7,7 +8,7 @@ export type UspListProps = OwnerState & {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
type OwnerState = { size?: 'small' | 'medium' }
|
|
10
|
-
const name = 'UspList'
|
|
11
|
+
const name = 'UspList'
|
|
11
12
|
const parts = ['root'] as const
|
|
12
13
|
const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
|
|
13
14
|
|
package/UspList/UspListItem.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
|
import { responsiveVal } from '../Styles/responsiveVal'
|
|
4
5
|
|
|
@@ -9,7 +10,7 @@ export type UspListItemProps = {
|
|
|
9
10
|
} & OwnerState
|
|
10
11
|
|
|
11
12
|
type OwnerState = { size?: 'small' | 'medium' }
|
|
12
|
-
const name = 'UspListItem'
|
|
13
|
+
const name = 'UspListItem'
|
|
13
14
|
const parts = ['root', 'icon', 'text'] as const
|
|
14
15
|
const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
|
|
15
16
|
|
package/hooks/memoDeep.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import { equal } from '@wry/equality'
|
|
3
|
-
import { FunctionComponent,
|
|
3
|
+
import type { FunctionComponent, NamedExoticComponent } from 'react'
|
|
4
|
+
import { memo } from 'react'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* This is a deep comparison version of React's `memo` function.
|
|
@@ -23,7 +24,7 @@ export function memoDeep<P extends object>(
|
|
|
23
24
|
|
|
24
25
|
if (ms < 0.2) return result
|
|
25
26
|
|
|
26
|
-
console.
|
|
27
|
+
console.warn('memoDeep took more than 0.2ms', {
|
|
27
28
|
result,
|
|
28
29
|
ms,
|
|
29
30
|
Component,
|
|
@@ -2,7 +2,9 @@ import { useMemo } from 'react'
|
|
|
2
2
|
import { useLocale } from './useLocale'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated
|
|
5
|
+
* @deprecated Use <DateFormat/>, <TimeFormat/> or <DateTimeFormat/> or useIntlDateTimeFormat()
|
|
6
|
+
* instead
|
|
7
|
+
* @public
|
|
6
8
|
*/
|
|
7
9
|
export function useDateTimeFormat(props?: Intl.DateTimeFormatOptions) {
|
|
8
10
|
const locale = useLocale()
|
package/hooks/useMatchMedia.ts
CHANGED
package/hooks/useMemoDeep.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import { equal } from '@wry/equality'
|
|
3
|
-
import { DependencyList
|
|
3
|
+
import type { DependencyList } from 'react'
|
|
4
|
+
import { useMemo, useRef } from 'react'
|
|
4
5
|
|
|
5
6
|
export function useMemoDeep<T>(factory: () => T, deps: DependencyList | undefined): T {
|
|
6
7
|
const ref = useRef<DependencyList | undefined>(undefined)
|
package/hooks/useNumberFormat.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { useMemo } from 'react'
|
|
|
2
2
|
import { useLocale } from './useLocale'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated
|
|
5
|
+
* @deprecated Use <NumberFormat />, <PercentFormat /> or <UnitFormat /> or useIntlNumberFormat()
|
|
6
|
+
* instead
|
|
7
|
+
* @public
|
|
6
8
|
*/
|
|
7
9
|
export function useNumberFormat(props?: Intl.NumberFormatOptions) {
|
|
8
10
|
const locale = useLocale()
|
package/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './ActionCard'
|
|
2
|
-
export * from './AnimatedRow/AnimatedRow'
|
|
3
2
|
export * from './Blog/BlogAuthor/BlogAuthor'
|
|
4
3
|
export * from './Blog/BlogContent/BlogContent'
|
|
5
4
|
export * from './Blog/BlogHeader/BlogHeader'
|
|
@@ -34,6 +33,7 @@ export * from './LayoutDefault'
|
|
|
34
33
|
export * from './LayoutOverlay'
|
|
35
34
|
export * from './LayoutParts'
|
|
36
35
|
export * from './LazyHydrate'
|
|
36
|
+
export * from './MediaQuery'
|
|
37
37
|
export * from './Navigation'
|
|
38
38
|
export * from './Overlay'
|
|
39
39
|
export * from './OverlayOrPopperChip'
|
|
@@ -68,3 +68,5 @@ export * from './utils/normalizeLocale'
|
|
|
68
68
|
export * from './utils/robots'
|
|
69
69
|
export * from './utils/sitemap'
|
|
70
70
|
export * from './utils/storefrontConfig'
|
|
71
|
+
export * from './utils/sxx'
|
|
72
|
+
export * from './Container/Container'
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0
|
|
5
|
+
"version": "9.0.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,34 +12,33 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"@emotion/react": "^11.11.4",
|
|
17
|
-
"@emotion/server": "^11.11.0",
|
|
18
|
-
"@emotion/styled": "^11.11.5",
|
|
19
|
-
"cookie": "^0.6.0",
|
|
20
|
-
"next-sitemap": "4.2.3",
|
|
15
|
+
"cookie": "^1.0.2",
|
|
21
16
|
"react-is": "^18.3.1"
|
|
22
17
|
},
|
|
23
18
|
"devDependencies": {
|
|
24
|
-
"@types/
|
|
25
|
-
"
|
|
26
|
-
"typescript": "5.5.3"
|
|
19
|
+
"@types/react-is": "^18.3.1",
|
|
20
|
+
"typescript": "5.7.2"
|
|
27
21
|
},
|
|
28
22
|
"peerDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@graphcommerce/
|
|
34
|
-
"@graphcommerce/
|
|
35
|
-
"@graphcommerce/
|
|
23
|
+
"@emotion/cache": "^11",
|
|
24
|
+
"@emotion/react": "^11",
|
|
25
|
+
"@emotion/server": "^11",
|
|
26
|
+
"@emotion/styled": "^11",
|
|
27
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0",
|
|
28
|
+
"@graphcommerce/framer-next-pages": "^9.0.0",
|
|
29
|
+
"@graphcommerce/framer-scroller": "^9.0.0",
|
|
30
|
+
"@graphcommerce/framer-utils": "^9.0.0",
|
|
31
|
+
"@graphcommerce/image": "^9.0.0",
|
|
32
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0",
|
|
33
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0",
|
|
36
34
|
"@lingui/core": "^4.2.1",
|
|
37
35
|
"@lingui/macro": "^4.2.1",
|
|
38
36
|
"@lingui/react": "^4.2.1",
|
|
39
37
|
"@mui/lab": "^5.0.0-alpha.68",
|
|
40
38
|
"@mui/material": "^5.10.16",
|
|
41
|
-
"framer-motion": "^
|
|
39
|
+
"framer-motion": "^11.0.0",
|
|
42
40
|
"next": "*",
|
|
41
|
+
"next-sitemap": "4.2.3",
|
|
43
42
|
"react": "^18.2.0",
|
|
44
43
|
"react-dom": "^18.2.0"
|
|
45
44
|
}
|
package/utils/cookie.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SerializeOptions } from 'cookie'
|
|
2
|
+
import { parse, serialize } from 'cookie'
|
|
2
3
|
|
|
3
4
|
/** Read a cookie */
|
|
4
5
|
export function cookie(name: string): string | undefined
|
|
5
6
|
/** Set a cookie */
|
|
6
|
-
export function cookie(name: string, value: string, options?:
|
|
7
|
+
export function cookie(name: string, value: string, options?: SerializeOptions): void
|
|
7
8
|
/** Delete a cookie */
|
|
8
9
|
export function cookie(name: string, value: null): void
|
|
9
10
|
/** Function to handle the three different cases */
|
|
10
|
-
export function cookie(name: string, value?: string | null, options?:
|
|
11
|
+
export function cookie(name: string, value?: string | null, options?: SerializeOptions) {
|
|
11
12
|
if (typeof window === 'undefined') {
|
|
12
13
|
return undefined
|
|
13
14
|
}
|
package/utils/robots.ts
CHANGED
package/utils/sitemap.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GetServerSidePropsContext, GetStaticPathsResult } from 'next'
|
|
2
|
-
import {
|
|
1
|
+
import type { GetServerSidePropsContext, GetStaticPathsResult } from 'next'
|
|
2
|
+
import type { ISitemapField } from 'next-sitemap'
|
|
3
|
+
import { getServerSideSitemapLegacy } from 'next-sitemap'
|
|
3
4
|
import { canonicalize } from '../PageMeta/canonicalize'
|
|
4
5
|
|
|
5
6
|
export function excludeSitemap(excludes: string[]) {
|
package/utils/sxx.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Concat an array of SxProps into a single SxProps.
|
|
5
|
+
*
|
|
6
|
+
* Each item in the array can be an array of Sx it's self:
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* sxx({ position: 'absolute', right: 0, top: 0 }, props.sx)
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export const sxx = (...sxPropsArray: (SxProps<Theme> | undefined)[]): SxProps<Theme> =>
|
|
13
|
+
sxPropsArray
|
|
14
|
+
.filter((v) => v !== undefined)
|
|
15
|
+
.map((sx) => (Array.isArray(sx) ? sx : [sx]))
|
|
16
|
+
.flat(1)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { styled, SxProps, Theme } from '@mui/material'
|
|
2
|
-
import { HTMLMotionProps, m } from 'framer-motion'
|
|
3
|
-
import { ReactHTML } from 'react'
|
|
4
|
-
|
|
5
|
-
export type AnimatedRowProps = Omit<
|
|
6
|
-
ReactHTML['div'] & HTMLMotionProps<'div'>,
|
|
7
|
-
'initial' | 'animate' | 'exit' | 'transition'
|
|
8
|
-
> & { sx?: SxProps<Theme> }
|
|
9
|
-
|
|
10
|
-
const StyledDiv = styled(m.div)({})
|
|
11
|
-
|
|
12
|
-
/** @deprecated Should be replaced with Box component */
|
|
13
|
-
export function AnimatedRow(props: AnimatedRowProps) {
|
|
14
|
-
return (
|
|
15
|
-
<StyledDiv
|
|
16
|
-
{...props}
|
|
17
|
-
initial={{ opacity: 0, height: 'auto' }}
|
|
18
|
-
animate={{ opacity: 1, height: 'auto' }}
|
|
19
|
-
exit={{ opacity: 0, height: 0 }}
|
|
20
|
-
transition={{ type: 'tween' }}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { styled } from '@mui/material'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
// ---- Root component ----
|
|
5
|
-
|
|
6
|
-
// We're creating a new styled('div') component and apply our styles to it.
|
|
7
|
-
const Root = styled('div')(({ theme }) => ({
|
|
8
|
-
padding: '3px',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
color: theme.palette.text.primary,
|
|
11
|
-
}))
|
|
12
|
-
|
|
13
|
-
// ---- MyComponent component ----
|
|
14
|
-
|
|
15
|
-
// Props of the component we are writing
|
|
16
|
-
export type MyComponentProps = { children: React.ReactNode }
|
|
17
|
-
|
|
18
|
-
export function MyComponent(props: MyComponentProps) {
|
|
19
|
-
const { children } = props
|
|
20
|
-
return (
|
|
21
|
-
<Root as='span'>
|
|
22
|
-
My Component
|
|
23
|
-
{children}
|
|
24
|
-
</Root>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { extendableComponent } from '@graphcommerce/next-ui'
|
|
3
|
-
import { styled } from '@mui/material'
|
|
4
|
-
import { ComponentProps } from 'react'
|
|
5
|
-
|
|
6
|
-
// ---- Setup ----
|
|
7
|
-
|
|
8
|
-
// To be able to select children from the consuming side, we define the classes.
|
|
9
|
-
// Minimal utility to convert the classes to selectors. Hover over `selectors` to see what it means.
|
|
10
|
-
const componentName = 'MyComponent' as const
|
|
11
|
-
const { classes, selectors } = extendableComponent(componentName, ['root', 'child'] as const)
|
|
12
|
-
|
|
13
|
-
// ---- Root component ----
|
|
14
|
-
|
|
15
|
-
// We're creating a new styled('div') component and apply our styles to it.
|
|
16
|
-
const Root = styled('div', {
|
|
17
|
-
name: componentName,
|
|
18
|
-
target: classes.root,
|
|
19
|
-
})(({ theme }) => ({
|
|
20
|
-
display: 'flex',
|
|
21
|
-
color: theme.palette.text.primary,
|
|
22
|
-
}))
|
|
23
|
-
|
|
24
|
-
// ---- Child component ----
|
|
25
|
-
|
|
26
|
-
const Child = styled('div', {
|
|
27
|
-
name: componentName,
|
|
28
|
-
target: classes.child,
|
|
29
|
-
})(({ theme }) => ({
|
|
30
|
-
backgroundColor: theme.palette.primary.main,
|
|
31
|
-
width: 100,
|
|
32
|
-
height: 100,
|
|
33
|
-
}))
|
|
34
|
-
|
|
35
|
-
// ---- MyComponent component ----
|
|
36
|
-
|
|
37
|
-
// Props of the component we are writing
|
|
38
|
-
export type MyComponentProps = Pick<ComponentProps<typeof Root>, 'sx' | 'children'>
|
|
39
|
-
|
|
40
|
-
export function MyComponent(props: MyComponentProps) {
|
|
41
|
-
const { sx, children } = props
|
|
42
|
-
return (
|
|
43
|
-
<Root as='span' sx={sx}>
|
|
44
|
-
My Component
|
|
45
|
-
<Child>{children}</Child>
|
|
46
|
-
</Root>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
MyComponent.selectors = selectors
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { extendableComponent } from '@graphcommerce/next-ui'
|
|
3
|
-
import { styled } from '@mui/material'
|
|
4
|
-
import { ComponentProps } from 'react'
|
|
5
|
-
|
|
6
|
-
// ---- Setup ----
|
|
7
|
-
|
|
8
|
-
// To be able to select children from the consuming side, we define the classes.
|
|
9
|
-
// Minimal utility to convert the classes to selectors. Hover over `selectors` to see what it means.
|
|
10
|
-
const componentName = 'MyComponent' as const
|
|
11
|
-
const { classes, selectors } = extendableComponent(componentName, ['root', 'child'] as const)
|
|
12
|
-
|
|
13
|
-
// Props that are used in our styled elements to render different CSS
|
|
14
|
-
type MyComponentStyleProps = { variant?: 'cool' | 'supercool' }
|
|
15
|
-
|
|
16
|
-
// ---- Root component ----
|
|
17
|
-
|
|
18
|
-
// We're creating a new styled('div') component and apply our styles to it.
|
|
19
|
-
const Root = styled('div', {
|
|
20
|
-
name: componentName,
|
|
21
|
-
target: classes.root,
|
|
22
|
-
})<MyComponentStyleProps>(({ theme }) => ({
|
|
23
|
-
// Styles are added
|
|
24
|
-
display: 'flex',
|
|
25
|
-
color: theme.palette.text.primary,
|
|
26
|
-
}))
|
|
27
|
-
|
|
28
|
-
// ---- Child component ----
|
|
29
|
-
|
|
30
|
-
const Child = styled('div', {
|
|
31
|
-
name: componentName,
|
|
32
|
-
target: classes.child, // Mandatory for children, adds a class name `MyComponent-child` so it can be styled from the outside.
|
|
33
|
-
})<MyComponentStyleProps>(({ theme, variant }) => ({
|
|
34
|
-
backgroundColor: theme.palette.primary.main,
|
|
35
|
-
width: 100,
|
|
36
|
-
height: 100,
|
|
37
|
-
fontSize: variant === 'supercool' ? 'large' : 'normal',
|
|
38
|
-
}))
|
|
39
|
-
|
|
40
|
-
// ---- MyComponent component ----
|
|
41
|
-
|
|
42
|
-
// Props of the component we are writing
|
|
43
|
-
export type MyComponentProps = Pick<ComponentProps<typeof Root>, 'sx' | 'children'> &
|
|
44
|
-
MyComponentStyleProps
|
|
45
|
-
|
|
46
|
-
export function MyComponent(props: MyComponentProps) {
|
|
47
|
-
const { sx, children, variant } = props
|
|
48
|
-
return (
|
|
49
|
-
<Root as='span' sx={sx} variant={variant}>
|
|
50
|
-
My Component <Child variant={variant}>{children}</Child>
|
|
51
|
-
</Root>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
MyComponent.selectors = selectors
|