@graphcommerce/next-ui 4.4.0 → 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.
@@ -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 ? 'text.disabled' : color}
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,50 @@
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
+
19
+ ## 4.5.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [#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
24
+
25
+ - Updated dependencies [[`b610a6e40`](https://github.com/graphcommerce-org/graphcommerce/commit/b610a6e4049e8c9e8b5d2aeff31b8e1bfc24abe5)]:
26
+ - @graphcommerce/framer-next-pages@3.1.5
27
+ - @graphcommerce/framer-scroller@2.1.4
28
+ - @graphcommerce/image@3.1.3
29
+
30
+ ## 4.5.0
31
+
32
+ ### Minor Changes
33
+
34
+ - [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - Added a new <ErrorSnackbar /> component to more easily create an error snackbar.
35
+
36
+ ### Patch Changes
37
+
38
+ - [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - <FormDiv contained/> would throw an error that contained isn't a recognized prop
39
+
40
+ * [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
41
+
42
+ * Updated dependencies [[`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9)]:
43
+ - @graphcommerce/framer-next-pages@3.1.4
44
+ - @graphcommerce/framer-scroller@2.1.3
45
+ - @graphcommerce/framer-utils@3.1.1
46
+ - @graphcommerce/image@3.1.2
47
+
3
48
  ## 4.4.0
4
49
 
5
50
  ### Minor Changes
package/Form/Form.tsx CHANGED
@@ -31,7 +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
- export const FormDiv = styled('div')<FormStyleProps>(styles)
37
+ export const FormDiv = styled('div', {
38
+ shouldForwardProp: (prop) => prop !== 'contained' && prop !== 'sx',
39
+ })<FormStyleProps>(styles)
@@ -9,6 +9,7 @@ export type LayoutProviderProps = {
9
9
 
10
10
  export function LayoutProvider(props: LayoutProviderProps) {
11
11
  const { children, scroll } = props
12
+
12
13
  return (
13
14
  <layoutContext.Provider value={useMemo(() => ({ scroll }), [scroll])}>
14
15
  {children}
@@ -1,6 +1,4 @@
1
- import { ParsedUrlQuery } from 'querystring'
2
- import { useRouter } from 'next/router'
3
- import { useCallback } from 'react'
1
+ import { useUrlQuery } from '../../useUrlQuery/useUrlQuery'
4
2
  import { LayoutOverlay, LayoutOverlayProps } from '../components/LayoutOverlay'
5
3
 
6
4
  export type LayoutOverlayState = Omit<
@@ -8,31 +6,8 @@ export type LayoutOverlayState = Omit<
8
6
  'children' | 'sx' | 'sxBackdrop' | 'mdSpacingTop' | 'smSpacingTop'
9
7
  >
10
8
 
11
- function useQueryState<T extends ParsedUrlQuery>(builder: (query: T) => T) {
12
- const { query, replace } = useRouter()
13
- const queryState = builder(query as T)
14
-
15
- const setRouterQuery = (partialQuery: T) => {
16
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
17
- replace({ query: { ...queryState, ...partialQuery } }, undefined, { shallow: true })
18
- }
19
- return [queryState, setRouterQuery] as const
20
- }
21
-
22
9
  export function useLayoutState() {
23
- const [routerQuery, setRouterQuery] = useQueryState<LayoutOverlayState>(
24
- useCallback(
25
- ({ sizeMd, sizeSm, justifyMd, justifySm, variantMd, variantSm }) => ({
26
- sizeMd,
27
- sizeSm,
28
- justifyMd,
29
- justifySm,
30
- variantMd,
31
- variantSm,
32
- }),
33
- [],
34
- ),
35
- )
10
+ const [routerQuery, setRouterQuery] = useUrlQuery<LayoutOverlayState>()
36
11
 
37
12
  return [routerQuery, setRouterQuery] as const
38
13
  }
@@ -0,0 +1,24 @@
1
+ import { Trans } from '@lingui/macro'
2
+ import { Button } from '@mui/material'
3
+ import { MessageSnackbar } from './MessageSnackbar'
4
+ import { MessageSnackbarImplProps } from './MessageSnackbarImpl'
5
+
6
+ export type ErrorSnackbarProps = MessageSnackbarImplProps
7
+
8
+ export function ErrorSnackbar(props: ErrorSnackbarProps) {
9
+ const { action, ...passedProps } = props
10
+ return (
11
+ <MessageSnackbar
12
+ variant='pill'
13
+ severity='error'
14
+ {...passedProps}
15
+ action={
16
+ action ?? (
17
+ <Button size='medium' variant='pill' color='secondary'>
18
+ <Trans>Ok</Trans>
19
+ </Button>
20
+ )
21
+ }
22
+ />
23
+ )
24
+ }
@@ -42,7 +42,7 @@ export function TextInputNumber(props: TextInputNumberProps) {
42
42
  const classes = withState({})
43
43
 
44
44
  const ref = useRef<HTMLInputElement>(null)
45
- const forkRef = useForkRef<HTMLInputElement>(ref, inputRef as Ref<HTMLInputElement>)
45
+ const forkRef = useForkRef(ref, inputRef as Ref<HTMLInputElement>)
46
46
 
47
47
  const [direction, setDirection] = useState<'up' | 'down' | 'runUp' | 'runDown' | null>(null)
48
48
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -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
- aspectRatio: `4/3`,
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
- gridTemplateColumns: `repeat(auto-fill, minmax(60px, 1fr))`,
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/index.ts CHANGED
@@ -22,6 +22,7 @@ export * from './FullPageMessage/FullPageMessage'
22
22
  export * from './Highlight/Highlight'
23
23
  export * from './IconHeader/IconHeader'
24
24
  export * from './icons'
25
+ export * from './IconSvg'
25
26
  export * from './JsonLd/JsonLd'
26
27
  export * from './Layout'
27
28
  export * from './LayoutDefault'
@@ -37,15 +38,16 @@ export * from './SectionContainer/SectionContainer'
37
38
  export * from './SectionHeader/SectionHeader'
38
39
  export * from './Separator/Separator'
39
40
  export * from './Snackbar/MessageSnackbar'
41
+ export * from './Snackbar/ErrorSnackbar'
40
42
  export * from './Snackbar/MessageSnackbarImpl'
41
43
  export * from './StarRatingField/StarRatingField'
42
44
  export * from './Stepper/Stepper'
43
45
  export * from './Styles'
44
- export * from './IconSvg'
45
46
  export * from './TextInputNumber/TextInputNumber'
46
47
  export * from './Theme'
47
48
  export * from './TimeAgo/TimeAgo'
48
49
  export * from './ToggleButton/ToggleButton'
49
50
  export * from './ToggleButtonGroup/ToggleButtonGroup'
51
+ export * from './useUrlQuery/useUrlQuery'
50
52
  export * from './UspList/UspList'
51
53
  export * from './UspList/UspListItem'
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.4.0",
5
+ "version": "4.6.0",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -19,30 +19,30 @@
19
19
  "@emotion/react": "^11.8.2",
20
20
  "@emotion/server": "^11.4.0",
21
21
  "@emotion/styled": "^11.6.0",
22
- "@graphcommerce/framer-next-pages": "^3.1.3",
23
- "@graphcommerce/framer-scroller": "^2.1.2",
24
- "@graphcommerce/framer-utils": "^3.1.0",
25
- "@graphcommerce/image": "^3.1.1",
26
- "react-is": "^17.0.2",
22
+ "@graphcommerce/framer-next-pages": "3.1.5",
23
+ "@graphcommerce/framer-scroller": "2.1.5",
24
+ "@graphcommerce/framer-utils": "3.1.1",
25
+ "@graphcommerce/image": "3.1.4",
26
+ "react-is": "^18.0.0",
27
27
  "react-schemaorg": "^2.0.0",
28
- "schema-dts": "^1.1.0",
29
- "type-fest": "^2.12.0"
28
+ "schema-dts": "^1.1.0"
30
29
  },
31
30
  "peerDependencies": {
32
31
  "@lingui/macro": "^3.13.2",
33
32
  "@mui/lab": "^5.0.0-alpha.68",
34
- "@mui/material": "^5.4.1",
33
+ "@mui/material": "5.5.3",
35
34
  "framer-motion": "^6.2.4",
36
- "next": "^12.0.10",
35
+ "next": "12.1.2",
37
36
  "react": "^17.0.2",
38
37
  "react-dom": "^17.0.2"
39
38
  },
40
39
  "devDependencies": {
41
- "@graphcommerce/eslint-config-pwa": "^4.1.2",
42
- "@graphcommerce/prettier-config-pwa": "^4.0.4",
40
+ "@graphcommerce/eslint-config-pwa": "^4.1.4",
41
+ "@graphcommerce/prettier-config-pwa": "^4.0.5",
43
42
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
44
- "@playwright/test": "^1.19.2",
43
+ "@playwright/test": "^1.20.1",
45
44
  "@types/react-is": "^17.0.3",
46
- "typescript": "^4.6.2"
45
+ "type-fest": "2.12.1",
46
+ "typescript": "4.6.3"
47
47
  }
48
48
  }
@@ -0,0 +1,23 @@
1
+ import { useRouter } from 'next/router'
2
+ import { useCallback } from 'react'
3
+
4
+ export function useUrlQuery<T extends Record<string, string | null>>() {
5
+ const { query, replace } = useRouter()
6
+
7
+ const setRouterQuery = useCallback(
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
+
16
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
17
+ replace({ query: newQuery }, undefined, { shallow: true })
18
+ },
19
+ [replace],
20
+ )
21
+
22
+ return [query as T, setRouterQuery] as const
23
+ }