@graphcommerce/next-ui 4.5.0 → 4.6.1
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/Button/LinkOrButton.tsx +11 -3
- package/CHANGELOG.md +43 -0
- package/Form/Form.tsx +2 -2
- package/LayoutOverlay/components/LayoutOverlay.tsx +1 -1
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +1 -14
- package/Theme/themeDefaults.ts +1 -2
- package/ToggleButton/ToggleButton.tsx +6 -2
- package/ToggleButtonGroup/ToggleButtonGroup.tsx +6 -2
- package/package.json +12 -12
- package/useUrlQuery/useUrlQuery.tsx +12 -8
package/Button/LinkOrButton.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Link, LinkProps, useForkRef } from '@mui/material'
|
|
2
2
|
import React, { useRef } from 'react'
|
|
3
|
-
import { ConditionalExcept } from 'type-fest'
|
|
3
|
+
import type { ConditionalExcept } from 'type-fest'
|
|
4
4
|
import { Button, ButtonProps } from './Button'
|
|
5
5
|
|
|
6
6
|
type OmitNever<T extends Record<string, unknown>> = {
|
|
@@ -14,6 +14,7 @@ export type LinkOrButtonProps = {
|
|
|
14
14
|
button?: ButtonProps
|
|
15
15
|
link?: LinkProps
|
|
16
16
|
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
17
|
+
disabled?: boolean
|
|
17
18
|
} & SharedProperties<
|
|
18
19
|
Omit<ButtonProps, 'sx'>,
|
|
19
20
|
Omit<LinkProps, 'color' | 'sx'> & Pick<ButtonProps, 'endIcon' | 'startIcon' | 'color' | 'loading'>
|
|
@@ -29,6 +30,7 @@ export const LinkOrButton = React.forwardRef<
|
|
|
29
30
|
breakpoint = 'md',
|
|
30
31
|
button,
|
|
31
32
|
link,
|
|
33
|
+
disabled,
|
|
32
34
|
|
|
33
35
|
// Shared props
|
|
34
36
|
loading,
|
|
@@ -54,6 +56,7 @@ export const LinkOrButton = React.forwardRef<
|
|
|
54
56
|
ref={buttonRef}
|
|
55
57
|
color={color}
|
|
56
58
|
loading={loading}
|
|
59
|
+
disabled={disabled}
|
|
57
60
|
sx={[
|
|
58
61
|
{
|
|
59
62
|
display: {
|
|
@@ -73,13 +76,18 @@ export const LinkOrButton = React.forwardRef<
|
|
|
73
76
|
variant='body2'
|
|
74
77
|
{...sharedProps}
|
|
75
78
|
{...link}
|
|
76
|
-
color={loading ? '
|
|
77
|
-
aria-disabled={loading}
|
|
79
|
+
color={loading || disabled ? 'action.disabled' : color}
|
|
80
|
+
aria-disabled={loading || disabled}
|
|
78
81
|
sx={[
|
|
79
82
|
{
|
|
80
83
|
display: { xs: 'inline-flex', [breakpoint]: 'none' },
|
|
81
84
|
alignItems: 'center',
|
|
82
85
|
},
|
|
86
|
+
!!disabled &&
|
|
87
|
+
((theme) => ({
|
|
88
|
+
opacity: theme.palette.action.disabledOpacity,
|
|
89
|
+
pointerEvents: 'none',
|
|
90
|
+
})),
|
|
83
91
|
...(Array.isArray(linkSx) ? linkSx : [linkSx]),
|
|
84
92
|
]}
|
|
85
93
|
>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`fb277d8e1`](https://github.com/graphcommerce-org/graphcommerce/commit/fb277d8e1e3612c5e9cf890a30d19cfd1ff70542) Thanks [@paales](https://github.com/paales)! - Now using [@graphql-yoga](https://github.com/dotansimha/graphql-yoga) for GraphQL which has full support for [envelop](https://www.envelop.dev/) plugins.
|
|
8
|
+
|
|
9
|
+
* [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`fb277d8e1`](https://github.com/graphcommerce-org/graphcommerce/commit/fb277d8e1e3612c5e9cf890a30d19cfd1ff70542) Thanks [@paales](https://github.com/paales)! - Added a new @graphcommerce/cli package to generate the mesh so it can be generated _inside_ the @graphcommerce/graphql-mesh package to allow for better future extensibility.
|
|
10
|
+
|
|
11
|
+
- [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4) Thanks [@paales](https://github.com/paales)! - Updated dependencies
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4)]:
|
|
14
|
+
- @graphcommerce/framer-next-pages@3.1.6
|
|
15
|
+
- @graphcommerce/framer-scroller@2.1.6
|
|
16
|
+
- @graphcommerce/framer-utils@3.1.2
|
|
17
|
+
- @graphcommerce/image@3.1.5
|
|
18
|
+
|
|
19
|
+
## 4.6.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- [#1386](https://github.com/graphcommerce-org/graphcommerce/pull/1386) [`3c801f45c`](https://github.com/graphcommerce-org/graphcommerce/commit/3c801f45c7df55131acf30ae2fe0d2344830d480) Thanks [@FrankHarland](https://github.com/FrankHarland)! - feat: add disabled support to LinkOrButton component
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#1388](https://github.com/graphcommerce-org/graphcommerce/pull/1388) [`3192fab82`](https://github.com/graphcommerce-org/graphcommerce/commit/3192fab82560e2211dfcacadc3b0b305260527d8) Thanks [@mikekeehnen](https://github.com/mikekeehnen)! - ConfigurableOptions size=small didn't render correctly when label were to large. The buttons will now just wrap instead of trying to be on a grid when the size=small.
|
|
28
|
+
|
|
29
|
+
* [#1385](https://github.com/graphcommerce-org/graphcommerce/pull/1385) [`8a354d1cd`](https://github.com/graphcommerce-org/graphcommerce/commit/8a354d1cd4757497ddfc9b1969a0addbc8ff616b) Thanks [@NickdeK](https://github.com/NickdeK)! - Prevent sx prop from being passed to form element
|
|
30
|
+
|
|
31
|
+
* Updated dependencies [[`0e425e85e`](https://github.com/graphcommerce-org/graphcommerce/commit/0e425e85ee8fed280349317ee0440c7bceea5823)]:
|
|
32
|
+
- @graphcommerce/image@3.1.4
|
|
33
|
+
- @graphcommerce/framer-scroller@2.1.5
|
|
34
|
+
|
|
35
|
+
## 4.5.1
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [#1378](https://github.com/graphcommerce-org/graphcommerce/pull/1378) [`b610a6e40`](https://github.com/graphcommerce-org/graphcommerce/commit/b610a6e4049e8c9e8b5d2aeff31b8e1bfc24abe5) Thanks [@paales](https://github.com/paales)! - Pin all versions internally so we can’t end up in an unfixable state for the user
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`b610a6e40`](https://github.com/graphcommerce-org/graphcommerce/commit/b610a6e4049e8c9e8b5d2aeff31b8e1bfc24abe5)]:
|
|
42
|
+
- @graphcommerce/framer-next-pages@3.1.5
|
|
43
|
+
- @graphcommerce/framer-scroller@2.1.4
|
|
44
|
+
- @graphcommerce/image@3.1.3
|
|
45
|
+
|
|
3
46
|
## 4.5.0
|
|
4
47
|
|
|
5
48
|
### Minor Changes
|
package/Form/Form.tsx
CHANGED
|
@@ -31,9 +31,9 @@ const styles = ({ theme, contained = false, background }: { theme: Theme } & For
|
|
|
31
31
|
])
|
|
32
32
|
|
|
33
33
|
export const Form = styled('form', {
|
|
34
|
-
shouldForwardProp: (prop) => prop !== 'contained',
|
|
34
|
+
shouldForwardProp: (prop) => prop !== 'contained' && prop !== 'sx',
|
|
35
35
|
})<FormStyleProps>(styles)
|
|
36
36
|
|
|
37
37
|
export const FormDiv = styled('div', {
|
|
38
|
-
shouldForwardProp: (prop) => prop !== 'contained',
|
|
38
|
+
shouldForwardProp: (prop) => prop !== 'contained' && prop !== 'sx',
|
|
39
39
|
})<FormStyleProps>(styles)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScrollerProvider, ScrollSnapType } from '@graphcommerce/framer-scroller'
|
|
2
|
-
import { SetOptional } from 'type-fest'
|
|
2
|
+
import type { SetOptional } from 'type-fest'
|
|
3
3
|
import { LayoutOverlayBase, LayoutOverlayBaseProps } from './LayoutOverlayBase'
|
|
4
4
|
|
|
5
5
|
export type { LayoutOverlayVariant } from './LayoutOverlayBase'
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useCallback } from 'react'
|
|
2
1
|
import { useUrlQuery } from '../../useUrlQuery/useUrlQuery'
|
|
3
2
|
import { LayoutOverlay, LayoutOverlayProps } from '../components/LayoutOverlay'
|
|
4
3
|
|
|
@@ -8,19 +7,7 @@ export type LayoutOverlayState = Omit<
|
|
|
8
7
|
>
|
|
9
8
|
|
|
10
9
|
export function useLayoutState() {
|
|
11
|
-
const [routerQuery, setRouterQuery] = useUrlQuery<LayoutOverlayState>(
|
|
12
|
-
useCallback(
|
|
13
|
-
({ sizeMd, sizeSm, justifyMd, justifySm, variantMd, variantSm }) => ({
|
|
14
|
-
sizeMd,
|
|
15
|
-
sizeSm,
|
|
16
|
-
justifyMd,
|
|
17
|
-
justifySm,
|
|
18
|
-
variantMd,
|
|
19
|
-
variantSm,
|
|
20
|
-
}),
|
|
21
|
-
[],
|
|
22
|
-
),
|
|
23
|
-
)
|
|
10
|
+
const [routerQuery, setRouterQuery] = useUrlQuery<LayoutOverlayState>()
|
|
24
11
|
|
|
25
12
|
return [routerQuery, setRouterQuery] as const
|
|
26
13
|
}
|
package/Theme/themeDefaults.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BreakpointsOptions, experimental_sx, SxProps, Theme } from '@mui/material'
|
|
2
2
|
import { Shadows } from '@mui/material/styles/shadows'
|
|
3
|
-
|
|
4
|
-
import { SetRequired } from 'type-fest'
|
|
3
|
+
import type { SetRequired } from 'type-fest'
|
|
5
4
|
|
|
6
5
|
// https://material.io/design/environment/elevation.html#default-elevations
|
|
7
6
|
|
|
@@ -60,7 +60,6 @@ export const ToggleButton = React.forwardRef<any, ToggleButtonProps>((props, ref
|
|
|
60
60
|
classes={classes}
|
|
61
61
|
sx={[
|
|
62
62
|
(theme) => ({
|
|
63
|
-
borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
|
|
64
63
|
border: 1,
|
|
65
64
|
borderColor: 'divider',
|
|
66
65
|
bgcolor: 'background.paper',
|
|
@@ -76,10 +75,15 @@ export const ToggleButton = React.forwardRef<any, ToggleButtonProps>((props, ref
|
|
|
76
75
|
}`,
|
|
77
76
|
},
|
|
78
77
|
':not(&.sizeSmall)': {
|
|
78
|
+
borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
|
|
79
79
|
padding: `${theme.spacings.xxs} ${theme.spacings.xs}`,
|
|
80
80
|
},
|
|
81
81
|
'&.sizeSmall': {
|
|
82
|
-
|
|
82
|
+
borderRadius: responsiveVal(
|
|
83
|
+
theme.shape.borderRadius * 1,
|
|
84
|
+
theme.shape.borderRadius * 1.5,
|
|
85
|
+
),
|
|
86
|
+
padding: `8px 12px`,
|
|
83
87
|
},
|
|
84
88
|
}),
|
|
85
89
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
@@ -63,19 +63,23 @@ const ToggleButtonGroup = React.forwardRef<HTMLDivElement, ToggleButtonGroupProp
|
|
|
63
63
|
className={`${classes.root} ${className ?? ''}`}
|
|
64
64
|
sx={[
|
|
65
65
|
(theme) => ({
|
|
66
|
-
display: 'grid',
|
|
67
66
|
rowGap: theme.spacings.xxs,
|
|
68
67
|
columnGap: theme.spacings.xs,
|
|
69
68
|
'&.orientationVertical': {
|
|
70
69
|
gridAutoFlow: 'column',
|
|
71
70
|
},
|
|
72
71
|
'&.sizeSmall.orientationHorizontal': {
|
|
73
|
-
|
|
72
|
+
display: 'flex',
|
|
73
|
+
flexWrap: 'wrap',
|
|
74
|
+
rowGap: '8px',
|
|
75
|
+
columnGap: '8px',
|
|
74
76
|
},
|
|
75
77
|
'&.sizeMedium.orientationHorizontal': {
|
|
78
|
+
display: 'grid',
|
|
76
79
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
77
80
|
},
|
|
78
81
|
'&.sizeLarge.orientationHorizontal': {
|
|
82
|
+
display: 'grid',
|
|
79
83
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
80
84
|
},
|
|
81
85
|
}),
|
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": "4.
|
|
5
|
+
"version": "4.6.1",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@emotion/babel-preset-css-prop": "^11.2.0",
|
|
18
18
|
"@emotion/cache": "^11.7.1",
|
|
19
|
-
"@emotion/react": "^11.
|
|
19
|
+
"@emotion/react": "^11.9.0",
|
|
20
20
|
"@emotion/server": "^11.4.0",
|
|
21
21
|
"@emotion/styled": "^11.6.0",
|
|
22
|
-
"@graphcommerce/framer-next-pages": "
|
|
23
|
-
"@graphcommerce/framer-scroller": "
|
|
24
|
-
"@graphcommerce/framer-utils": "
|
|
25
|
-
"@graphcommerce/image": "
|
|
22
|
+
"@graphcommerce/framer-next-pages": "3.1.6",
|
|
23
|
+
"@graphcommerce/framer-scroller": "2.1.6",
|
|
24
|
+
"@graphcommerce/framer-utils": "3.1.2",
|
|
25
|
+
"@graphcommerce/image": "3.1.5",
|
|
26
26
|
"react-is": "^18.0.0",
|
|
27
27
|
"react-schemaorg": "^2.0.0",
|
|
28
28
|
"schema-dts": "^1.1.0"
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@lingui/macro": "^3.13.2",
|
|
32
32
|
"@mui/lab": "^5.0.0-alpha.68",
|
|
33
|
-
"@mui/material": "
|
|
33
|
+
"@mui/material": "5.5.3",
|
|
34
34
|
"framer-motion": "^6.2.4",
|
|
35
|
-
"next": "
|
|
35
|
+
"next": "12.1.2",
|
|
36
36
|
"react": "^17.0.2",
|
|
37
37
|
"react-dom": "^17.0.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
41
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
40
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.5",
|
|
41
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
42
42
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
43
|
-
"@playwright/test": "^1.
|
|
43
|
+
"@playwright/test": "^1.21.1",
|
|
44
44
|
"@types/react-is": "^17.0.3",
|
|
45
|
-
"type-fest": "2.12.
|
|
45
|
+
"type-fest": "^2.12.2",
|
|
46
46
|
"typescript": "4.6.3"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { ParsedUrlQuery } from 'querystring'
|
|
2
1
|
import { useRouter } from 'next/router'
|
|
3
2
|
import { useCallback } from 'react'
|
|
4
3
|
|
|
5
|
-
export function useUrlQuery<T extends
|
|
4
|
+
export function useUrlQuery<T extends Record<string, string | null>>() {
|
|
6
5
|
const { query, replace } = useRouter()
|
|
7
|
-
const queryState = builder(query as T)
|
|
8
6
|
|
|
9
7
|
const setRouterQuery = useCallback(
|
|
10
|
-
(
|
|
11
|
-
|
|
8
|
+
(incomming: T) => {
|
|
9
|
+
const current = Object.fromEntries(new URLSearchParams(window.location.search).entries())
|
|
10
|
+
const newQuery = Object.fromEntries(
|
|
11
|
+
Object.entries({ ...current, ...incomming }).filter(([, value]) => value !== null),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
if (JSON.stringify(current) === JSON.stringify(newQuery)) return
|
|
15
|
+
|
|
12
16
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
13
|
-
replace({ query:
|
|
17
|
+
replace({ query: newQuery }, undefined, { shallow: true })
|
|
14
18
|
},
|
|
15
|
-
[
|
|
19
|
+
[replace],
|
|
16
20
|
)
|
|
17
21
|
|
|
18
|
-
return [
|
|
22
|
+
return [query as T, setRouterQuery] as const
|
|
19
23
|
}
|