@graphcommerce/magento-search 4.1.7 → 4.1.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1451](https://github.com/graphcommerce-org/graphcommerce/pull/1451) [`f698ff85d`](https://github.com/graphcommerce-org/graphcommerce/commit/f698ff85df6bb0922288471bb3c81856091b8061) Thanks [@paales](https://github.com/paales)! - Removed all occurences of @lingui/macro and moved to @lingui/macro / @lingui/core in preparation to move to swc.
8
+
9
+ Since we've removed @lingui/macro, all occurences need to be replaced with @lingui/core and @lingui/react.
10
+
11
+ All occurences of `<Trans>` and `t` need to be replaced:
12
+
13
+ ```tsx
14
+ import { Trans, t } from '@lingui/macro'
15
+
16
+ function MyComponent() {
17
+ const foo = 'bar'
18
+ return (
19
+ <div aria-label={t`Account ${foo}`}>
20
+ <Trans>My Translation {foo}</Trans>
21
+ </div>
22
+ )
23
+ }
24
+ ```
25
+
26
+ Needs to be replaced with:
27
+
28
+ ```tsx
29
+ import { Trans } from '@lingui/react'
30
+ import { i18n } from '@lingui/core'
31
+
32
+ function MyComponent() {
33
+ const foo = 'bar'
34
+ return (
35
+ <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
36
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
37
+ </div>
38
+ )
39
+ }
40
+ ```
41
+
42
+ [More examples for Trans](https://lingui.js.org/ref/macro.html#examples-of-jsx-macros) and [more examples for `t`](https://lingui.js.org/ref/macro.html#examples-of-js-macros)
43
+
44
+ - Updated dependencies [[`50188e378`](https://github.com/graphcommerce-org/graphcommerce/commit/50188e378b4c77561ebc600958ea11cd114fa61a), [`f698ff85d`](https://github.com/graphcommerce-org/graphcommerce/commit/f698ff85df6bb0922288471bb3c81856091b8061)]:
45
+ - @graphcommerce/react-hook-form@3.1.3
46
+ - @graphcommerce/next-ui@4.7.2
47
+ - @graphcommerce/graphql@3.1.3
48
+
49
+ ## 4.1.9
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [[`25ef6cf08`](https://github.com/graphcommerce-org/graphcommerce/commit/25ef6cf08c278105307d6f604b7135d637e9046c), [`80e30bb77`](https://github.com/graphcommerce-org/graphcommerce/commit/80e30bb77015755fbc00a7935d590f80c1c1c18c)]:
54
+ - @graphcommerce/graphql@3.1.2
55
+ - @graphcommerce/next-ui@4.7.1
56
+
57
+ ## 4.1.8
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [[`f3d06dd83`](https://github.com/graphcommerce-org/graphcommerce/commit/f3d06dd836c9a76412b419d4d2c79bbd0ee92e04)]:
62
+ - @graphcommerce/next-ui@4.7.0
63
+
3
64
  ## 4.1.7
4
65
 
5
66
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { extendableComponent } from '@graphcommerce/next-ui'
2
- import { Trans } from '@lingui/macro'
2
+ import { Trans } from '@lingui/react'
3
3
  import { Box, SxProps, Theme, Typography } from '@mui/material'
4
4
 
5
5
  export type NoSearchResultsProps = { search: string; sx?: SxProps<Theme> }
@@ -26,10 +26,10 @@ export function NoSearchResults(props: NoSearchResultsProps) {
26
26
  ]}
27
27
  >
28
28
  <Typography variant='h5' align='center'>
29
- <Trans>We couldn&apos;t find any results for {term}</Trans>
29
+ <Trans id="We couldn't find any results for {term}" values={{ term }} />
30
30
  </Typography>
31
31
  <p>
32
- <Trans>Try a different search</Trans>
32
+ <Trans id='Try a different search' />
33
33
  </p>
34
34
  </Box>
35
35
  )
@@ -1,5 +1,5 @@
1
1
  import { iconSearch, responsiveVal, IconSvg, extendableComponent } from '@graphcommerce/next-ui'
2
- import { Trans } from '@lingui/macro'
2
+ import { Trans } from '@lingui/react'
3
3
  import { TextField, TextFieldProps } from '@mui/material'
4
4
 
5
5
  export type SearchButtonProps = TextFieldProps
@@ -22,7 +22,7 @@ export function SearchButton(props: SearchButtonProps) {
22
22
  variant='outlined'
23
23
  size='small'
24
24
  className={classes.root}
25
- label={label ?? <Trans>Search...</Trans>}
25
+ label={label ?? <Trans id='Search...' />}
26
26
  id='search-input'
27
27
  InputLabelProps={{ shrink: false }}
28
28
  InputProps={{
@@ -6,7 +6,8 @@ import {
6
6
  extendableComponent,
7
7
  } from '@graphcommerce/next-ui'
8
8
  import { useForm, useFormAutoSubmit, useFormMuiRegister } from '@graphcommerce/react-hook-form'
9
- import { t, Trans } from '@lingui/macro'
9
+ import { i18n } from '@lingui/core'
10
+ import { Trans } from '@lingui/react'
10
11
  import { Box, IconButton, SxProps, TextField, TextFieldProps, Theme } from '@mui/material'
11
12
  import { useRouter } from 'next/router'
12
13
 
@@ -60,8 +61,8 @@ export function SearchForm(props: SearchFormProps) {
60
61
  paddingRight: '7px',
61
62
  })}
62
63
  >
63
- {totalResults === 1 && <Trans>{totalResults} result</Trans>}
64
- {totalResults > 1 && <Trans>{totalResults} results</Trans>}
64
+ {totalResults === 1 && <Trans id='{totalResults} result' values={{ totalResults }} />}
65
+ {totalResults > 1 && <Trans id='{totalResults} results' values={{ totalResults }} />}
65
66
  </Box>
66
67
  )}
67
68
  <IconButton onClick={handleReset} size='small'>
@@ -88,7 +89,7 @@ export function SearchForm(props: SearchFormProps) {
88
89
  <TextField
89
90
  variant='outlined'
90
91
  type='text'
91
- placeholder={t`Search`}
92
+ placeholder={i18n._(/* i18n */ `Search`)}
92
93
  defaultValue={search}
93
94
  error={formState.isSubmitted && !!formState.errors.search}
94
95
  helperText={formState.isSubmitted && formState.errors.search?.message}
@@ -7,6 +7,7 @@ import {
7
7
  } from '@graphcommerce/next-ui'
8
8
  import { Link, LinkProps } from '@mui/material'
9
9
  import PageLink from 'next/link'
10
+ import { useRouter } from 'next/router'
10
11
  import type { SetRequired } from 'type-fest'
11
12
 
12
13
  export type SearchLinkProps = SetRequired<Pick<LinkProps, 'href' | 'sx' | 'children'>, 'href'>
@@ -24,46 +25,50 @@ const { classes } = extendableComponent(name, parts)
24
25
  */
25
26
  export function SearchLink(props: SearchLinkProps) {
26
27
  const { href, sx = [], children, ...linkProps } = props
28
+ const router = useRouter()
27
29
 
28
30
  const fabSize = useFabSize('responsive')
29
31
 
30
32
  return (
31
- <PageLink href={href} passHref>
32
- <Link
33
- className={classes.root}
34
- underline='none'
35
- sx={[
36
- (theme) => ({
37
- justifySelf: 'center',
38
- // @todo make abstract, this is the size of a responsive Fab minus the icon size, divided by 2.
39
- marginRight: `calc(${fabSize} / 4)`,
40
- width: responsiveVal(64, 172),
41
- borderRadius: 2,
42
- typography: 'body2',
43
- display: 'flex',
44
- alignItems: 'center',
45
- justifyContent: 'space-between',
46
- gap: theme.spacings.xs,
47
- color: 'text.secondary',
48
- border: 1,
49
- borderColor: 'divider',
50
- py: 1,
51
- px: 1.5,
52
- '&:hover': {
53
- borderColor: 'text.secondary',
54
- },
55
- }),
56
- ...(Array.isArray(sx) ? sx : [sx]),
57
- ]}
58
- {...linkProps}
59
- >
60
- <div className={classes.text}>{children ?? <>&nbsp;</>}</div>
61
- <IconSvg
62
- src={iconSearch}
63
- className={classes.svg}
64
- sx={{ color: 'text.primary', fontSize: '1.4em' }}
65
- />
66
- </Link>
67
- </PageLink>
33
+ <Link
34
+ component='button'
35
+ className={classes.root}
36
+ underline='none'
37
+ onClick={(e) => {
38
+ e.preventDefault()
39
+ return router.push(href)
40
+ }}
41
+ sx={[
42
+ (theme) => ({
43
+ justifySelf: 'center',
44
+ // @todo make abstract, this is the size of a responsive Fab minus the icon size, divided by 2.
45
+ marginRight: `calc(${fabSize} / 4)`,
46
+ width: responsiveVal(64, 172),
47
+ borderRadius: 2,
48
+ typography: 'body2',
49
+ display: 'flex',
50
+ alignItems: 'center',
51
+ justifyContent: 'space-between',
52
+ gap: theme.spacings.xs,
53
+ color: 'text.secondary',
54
+ border: 1,
55
+ borderColor: 'divider',
56
+ py: 1,
57
+ px: 1.5,
58
+ '&:hover': {
59
+ borderColor: 'text.secondary',
60
+ },
61
+ }),
62
+ ...(Array.isArray(sx) ? sx : [sx]),
63
+ ]}
64
+ {...linkProps}
65
+ >
66
+ <div className={classes.text}>{children ?? <>&nbsp;</>}</div>
67
+ <IconSvg
68
+ src={iconSearch}
69
+ className={classes.svg}
70
+ sx={{ color: 'text.primary', fontSize: '1.4em' }}
71
+ />
72
+ </Link>
68
73
  )
69
74
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-search",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.1.7",
5
+ "version": "4.1.10",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,20 +12,21 @@
12
12
  }
13
13
  },
14
14
  "devDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^4.1.6",
15
+ "@graphcommerce/eslint-config-pwa": "^4.1.7",
16
16
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
17
- "@graphcommerce/typescript-config-pwa": "^4.0.2",
17
+ "@graphcommerce/typescript-config-pwa": "^4.0.3",
18
18
  "@playwright/test": "^1.21.1",
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/graphql": "3.1.1",
22
+ "@graphcommerce/graphql": "3.1.3",
23
23
  "@graphcommerce/image": "3.1.5",
24
- "@graphcommerce/next-ui": "4.6.2",
25
- "@graphcommerce/react-hook-form": "3.1.2"
24
+ "@graphcommerce/next-ui": "4.7.2",
25
+ "@graphcommerce/react-hook-form": "3.1.3"
26
26
  },
27
27
  "peerDependencies": {
28
- "@lingui/macro": "^3.13.2",
28
+ "@lingui/react": "^3.13.2",
29
+ "@lingui/core": "^3.13.2",
29
30
  "@mui/material": "5.5.3",
30
31
  "next": "12.1.2",
31
32
  "react": "^17.0.2",