@graphcommerce/magento-search 4.0.3 → 4.1.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/CHANGELOG.md +26 -0
- package/{CategorySearchResult → components/CategorySearchResult}/CategorySearchResult.graphql +0 -0
- package/{CategorySearchResult/index.tsx → components/CategorySearchResult/CategorySearchResult.tsx} +4 -4
- package/{NoSearchResults/index.tsx → components/NoSearchResults/NoSearchResults.tsx} +1 -1
- package/{SearchButton/index.tsx → components/SearchButton/SearchButton.tsx} +7 -3
- package/{SearchDivider/index.tsx → components/SearchDivider/SearchDivider.tsx} +1 -3
- package/{SearchForm/index.tsx → components/SearchForm/SearchForm.tsx} +4 -4
- package/components/SearchLink/SearchLink.tsx +69 -0
- package/index.ts +6 -14
- package/package.json +4 -3
- package/CategorySearchResult/chevron_right.svg +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1292](https://github.com/ho-nl/m2-pwa/pull/1292)
|
|
8
|
+
[`990df655b`](https://github.com/ho-nl/m2-pwa/commit/990df655b73b469718d6cb5837ee65dfe2ad6a1d)
|
|
9
|
+
Thanks [@paales](https://github.com/paales)! - `<SearchLink />` a more lightweight (less js)
|
|
10
|
+
alternative for `<SearchButton />`
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#1292](https://github.com/ho-nl/m2-pwa/pull/1292)
|
|
15
|
+
[`5a1ba9e66`](https://github.com/ho-nl/m2-pwa/commit/5a1ba9e664abbac89c4f5f71f7d6d6ed1aefa5c0)
|
|
16
|
+
Thanks [@paales](https://github.com/paales)! - Renamed SvgIcon to IconSvg to prevent collisions
|
|
17
|
+
with MUI
|
|
18
|
+
|
|
19
|
+
* [#1292](https://github.com/ho-nl/m2-pwa/pull/1292)
|
|
20
|
+
[`63f9b56eb`](https://github.com/ho-nl/m2-pwa/commit/63f9b56eb68ba790567ff1427e599fd2c3c8f1ee)
|
|
21
|
+
Thanks [@paales](https://github.com/paales)! - added responsive size to the Fab component
|
|
22
|
+
|
|
23
|
+
* Updated dependencies
|
|
24
|
+
[[`5a1ba9e66`](https://github.com/ho-nl/m2-pwa/commit/5a1ba9e664abbac89c4f5f71f7d6d6ed1aefa5c0),
|
|
25
|
+
[`990df655b`](https://github.com/ho-nl/m2-pwa/commit/990df655b73b469718d6cb5837ee65dfe2ad6a1d),
|
|
26
|
+
[`63f9b56eb`](https://github.com/ho-nl/m2-pwa/commit/63f9b56eb68ba790567ff1427e599fd2c3c8f1ee)]:
|
|
27
|
+
- @graphcommerce/next-ui@4.2.0
|
|
28
|
+
|
|
3
29
|
## 4.0.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/{CategorySearchResult → components/CategorySearchResult}/CategorySearchResult.graphql
RENAMED
|
File without changes
|
package/{CategorySearchResult/index.tsx → components/CategorySearchResult/CategorySearchResult.tsx}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Highlight, iconChevronRight,
|
|
1
|
+
import { Highlight, iconChevronRight, IconSvg, extendableComponent } from '@graphcommerce/next-ui'
|
|
2
2
|
import { Button, SxProps, Theme } from '@mui/material'
|
|
3
3
|
import PageLink from 'next/link'
|
|
4
4
|
import React from 'react'
|
|
@@ -13,17 +13,17 @@ const name = 'CategorySearchResult' as const
|
|
|
13
13
|
const parts = ['root'] as const
|
|
14
14
|
const { classes } = extendableComponent(name, parts)
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export function CategorySearchResult(props: CategorySearchResultProps) {
|
|
17
17
|
const { search = '', sx = [], ...catProps } = props
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<PageLink href={`/${catProps?.url_path ?? ''}`}>
|
|
20
|
+
<PageLink href={`/${catProps?.url_path ?? ''}`} passHref>
|
|
21
21
|
<Button
|
|
22
22
|
fullWidth
|
|
23
23
|
variant='contained'
|
|
24
24
|
className={classes.root}
|
|
25
25
|
disableElevation
|
|
26
|
-
endIcon={<
|
|
26
|
+
endIcon={<IconSvg src={iconChevronRight} size='small' />}
|
|
27
27
|
sx={[
|
|
28
28
|
(theme) => ({
|
|
29
29
|
background: theme.palette.background.default,
|
|
@@ -8,7 +8,7 @@ const name = 'NoSearchResults' as const
|
|
|
8
8
|
const parts = ['root'] as const
|
|
9
9
|
const { classes } = extendableComponent(name, parts)
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export function NoSearchResults(props: NoSearchResultsProps) {
|
|
12
12
|
const { search, sx = [] } = props
|
|
13
13
|
|
|
14
14
|
const term = `'${search}'`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iconSearch, responsiveVal,
|
|
1
|
+
import { iconSearch, responsiveVal, IconSvg, extendableComponent } from '@graphcommerce/next-ui'
|
|
2
2
|
import { Trans } from '@lingui/macro'
|
|
3
3
|
import { TextField, TextFieldProps } from '@mui/material'
|
|
4
4
|
|
|
@@ -9,7 +9,11 @@ const name = 'SearchButton' as const
|
|
|
9
9
|
const parts = ['root', 'inputRoot'] as const
|
|
10
10
|
const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated The use of `SearchButton` is not advised. It will import lots of things from
|
|
14
|
+
* `@mui/material`. Use the <SearchLink /> component instead.
|
|
15
|
+
*/
|
|
16
|
+
export function SearchButton(props: SearchButtonProps) {
|
|
13
17
|
const { InputProps, label, fullWidth = false, sx = [], ...textFieldProps } = props
|
|
14
18
|
const classes = withState({ fullWidth })
|
|
15
19
|
|
|
@@ -23,7 +27,7 @@ export default function SearchButton(props: SearchButtonProps) {
|
|
|
23
27
|
InputLabelProps={{ shrink: false }}
|
|
24
28
|
InputProps={{
|
|
25
29
|
readOnly: true,
|
|
26
|
-
endAdornment: <
|
|
30
|
+
endAdornment: <IconSvg src={iconSearch} size='medium' />,
|
|
27
31
|
classes: { root: classes.inputRoot },
|
|
28
32
|
...InputProps,
|
|
29
33
|
}}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { styled } from '@mui/material'
|
|
2
2
|
|
|
3
|
-
const SearchDivider = styled('div', { name: 'SearchDivider' })(({ theme }) => ({
|
|
3
|
+
export const SearchDivider = styled('div', { name: 'SearchDivider' })(({ theme }) => ({
|
|
4
4
|
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
5
5
|
width: '100%',
|
|
6
6
|
marginTop: theme.spacings.md,
|
|
7
7
|
marginBottom: theme.spacings.md,
|
|
8
8
|
}))
|
|
9
|
-
|
|
10
|
-
export default SearchDivider
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
FormRow,
|
|
3
3
|
iconClose,
|
|
4
4
|
iconSearch,
|
|
5
|
-
|
|
5
|
+
IconSvg,
|
|
6
6
|
extendableComponent,
|
|
7
7
|
} from '@graphcommerce/next-ui'
|
|
8
8
|
import { useForm, useFormAutoSubmit, useFormMuiRegister } from '@graphcommerce/react-hook-form'
|
|
@@ -23,7 +23,7 @@ const name = 'SearchForm' as const
|
|
|
23
23
|
const parts = ['root', 'totalProducts'] as const
|
|
24
24
|
const { classes } = extendableComponent(name, parts)
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export function SearchForm(props: SearchFormProps) {
|
|
27
27
|
const { totalResults = 0, search = '', urlHandle = 'search', textFieldProps, sx = [] } = props
|
|
28
28
|
const router = useRouter()
|
|
29
29
|
|
|
@@ -47,7 +47,7 @@ export default function SearchForm(props: SearchFormProps) {
|
|
|
47
47
|
|
|
48
48
|
const endAdornment = !watch('search') ? (
|
|
49
49
|
<IconButton size='small'>
|
|
50
|
-
<
|
|
50
|
+
<IconSvg src={iconSearch} />
|
|
51
51
|
</IconButton>
|
|
52
52
|
) : (
|
|
53
53
|
<>
|
|
@@ -65,7 +65,7 @@ export default function SearchForm(props: SearchFormProps) {
|
|
|
65
65
|
</Box>
|
|
66
66
|
)}
|
|
67
67
|
<IconButton onClick={handleReset} size='small'>
|
|
68
|
-
<
|
|
68
|
+
<IconSvg src={iconClose} />
|
|
69
69
|
</IconButton>
|
|
70
70
|
</>
|
|
71
71
|
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iconSearch,
|
|
3
|
+
responsiveVal,
|
|
4
|
+
IconSvg,
|
|
5
|
+
extendableComponent,
|
|
6
|
+
useFabSize,
|
|
7
|
+
} from '@graphcommerce/next-ui'
|
|
8
|
+
import { Link, LinkProps } from '@mui/material'
|
|
9
|
+
import PageLink from 'next/link'
|
|
10
|
+
import { SetRequired } from 'type-fest'
|
|
11
|
+
|
|
12
|
+
export type SearchLinknProps = SetRequired<LinkProps, 'href'>
|
|
13
|
+
|
|
14
|
+
const name = 'SearchLink' as const
|
|
15
|
+
const parts = ['root', 'text', 'svg'] as const
|
|
16
|
+
const { classes } = extendableComponent(name, parts)
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Usage:
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const MyComponent = () => <SearchLink href='/search' />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function SearchLink(props: SearchLinknProps) {
|
|
26
|
+
const { href, sx = [], children, ...linkProps } = props
|
|
27
|
+
|
|
28
|
+
const fabSize = useFabSize('responsive')
|
|
29
|
+
|
|
30
|
+
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 ?? <> </>}</div>
|
|
61
|
+
<IconSvg
|
|
62
|
+
src={iconSearch}
|
|
63
|
+
className={classes.svg}
|
|
64
|
+
sx={{ color: 'text.primary', fontSize: '1.4em' }}
|
|
65
|
+
/>
|
|
66
|
+
</Link>
|
|
67
|
+
</PageLink>
|
|
68
|
+
)
|
|
69
|
+
}
|
package/index.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export * from './
|
|
5
|
-
|
|
6
|
-
export { default as CategorySearchResult } from './CategorySearchResult'
|
|
7
|
-
export * from './CategorySearchResult'
|
|
8
|
-
|
|
9
|
-
export { default as SearchForm } from './SearchForm'
|
|
10
|
-
export * from './SearchForm'
|
|
11
|
-
|
|
12
|
-
export { default as SearchButton } from './SearchButton'
|
|
13
|
-
export * from './SearchButton'
|
|
14
|
-
|
|
1
|
+
export * from './components/SearchDivider/SearchDivider'
|
|
2
|
+
export * from './components/NoSearchResults/NoSearchResults'
|
|
3
|
+
export * from './components/CategorySearchResult/CategorySearchResult'
|
|
4
|
+
export * from './components/SearchForm/SearchForm'
|
|
5
|
+
export * from './components/SearchLink/SearchLink'
|
|
15
6
|
export * from './Search.gql'
|
|
7
|
+
export * from './components/SearchButton/SearchButton'
|
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.0
|
|
5
|
+
"version": "4.1.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@graphcommerce/graphql": "^3.0.3",
|
|
22
22
|
"@graphcommerce/image": "^3.1.0",
|
|
23
|
-
"@graphcommerce/next-ui": "^4.
|
|
24
|
-
"@graphcommerce/react-hook-form": "^3.0.3"
|
|
23
|
+
"@graphcommerce/next-ui": "^4.2.0",
|
|
24
|
+
"@graphcommerce/react-hook-form": "^3.0.3",
|
|
25
|
+
"type-fest": "^2.12.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@lingui/macro": "^3.13.2",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
-
<title>desktop_chevron_Right</title>
|
|
4
|
-
<g id="desktop_chevron_Right" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
-
<g id="chevron-right" transform="translate(16.500000, 16.000000) scale(-1, 1) translate(-16.500000, -16.000000) translate(13.000000, 9.000000)" stroke="#000000" stroke-width="1.6">
|
|
6
|
-
<polyline id="Path-2-Copy" points="7 0 0 7 7 14"></polyline>
|
|
7
|
-
</g>
|
|
8
|
-
</g>
|
|
9
|
-
</svg>
|