@graphcommerce/next-ui 4.5.1 → 4.6.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/Button/LinkOrButton.tsx +9 -2
- package/CHANGELOG.md +16 -0
- package/Form/Form.tsx +2 -2
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +1 -14
- package/ToggleButton/ToggleButton.tsx +6 -2
- package/ToggleButtonGroup/ToggleButtonGroup.tsx +6 -2
- package/package.json +3 -3
- package/useUrlQuery/useUrlQuery.tsx +12 -8
package/Button/LinkOrButton.tsx
CHANGED
|
@@ -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,17 @@ 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 && ((theme)=>({
|
|
87
|
+
opacity: theme.palette.action.disabledOpacity,
|
|
88
|
+
pointerEvents: 'none'
|
|
89
|
+
})),
|
|
83
90
|
...(Array.isArray(linkSx) ? linkSx : [linkSx]),
|
|
84
91
|
]}
|
|
85
92
|
>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#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.
|
|
12
|
+
|
|
13
|
+
* [#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
|
|
14
|
+
|
|
15
|
+
* Updated dependencies [[`0e425e85e`](https://github.com/graphcommerce-org/graphcommerce/commit/0e425e85ee8fed280349317ee0440c7bceea5823)]:
|
|
16
|
+
- @graphcommerce/image@3.1.4
|
|
17
|
+
- @graphcommerce/framer-scroller@2.1.5
|
|
18
|
+
|
|
3
19
|
## 4.5.1
|
|
4
20
|
|
|
5
21
|
### Patch 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,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
|
}
|
|
@@ -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.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@emotion/server": "^11.4.0",
|
|
21
21
|
"@emotion/styled": "^11.6.0",
|
|
22
22
|
"@graphcommerce/framer-next-pages": "3.1.5",
|
|
23
|
-
"@graphcommerce/framer-scroller": "2.1.
|
|
23
|
+
"@graphcommerce/framer-scroller": "2.1.5",
|
|
24
24
|
"@graphcommerce/framer-utils": "3.1.1",
|
|
25
|
-
"@graphcommerce/image": "3.1.
|
|
25
|
+
"@graphcommerce/image": "3.1.4",
|
|
26
26
|
"react-is": "^18.0.0",
|
|
27
27
|
"react-schemaorg": "^2.0.0",
|
|
28
28
|
"schema-dts": "^1.1.0"
|
|
@@ -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
|
}
|