@graphcommerce/magento-search 3.0.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/CHANGELOG.md +135 -0
- package/CategorySearchResult/CategorySearchResult.gql.ts +4 -0
- package/CategorySearchResult/CategorySearchResult.graphql +6 -0
- package/CategorySearchResult/chevron_right.svg +9 -0
- package/CategorySearchResult/index.tsx +70 -0
- package/NoSearchResults/index.tsx +32 -0
- package/Search.gql.ts +16 -0
- package/Search.graphql +17 -0
- package/SearchButton/index.tsx +40 -0
- package/SearchDivider/index.tsx +14 -0
- package/SearchForm/index.tsx +93 -0
- package/index.ts +16 -0
- package/next-env.d.ts +4 -0
- package/package.json +33 -0
- package/tsconfig.json +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.0.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@3.0.0...@graphcommerce/magento-search@3.0.1) (2021-09-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @graphcommerce/magento-search
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 3.0.0 (2021-09-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **404-page:** prevent auto focus search form ([9e89ed3](https://github.com/ho-nl/m2-pwa/commit/9e89ed31ea192312641f46f01b69dc5f319331e8))
|
|
20
|
+
* add dependencies for searchbutton ([c8f9608](https://github.com/ho-nl/m2-pwa/commit/c8f960828daa77675c4f359e971690b227563445))
|
|
21
|
+
* **app-shell:** pages after app shell changes ([fb74510](https://github.com/ho-nl/m2-pwa/commit/fb74510121f6124009db72ad2ddebf6459c52a85))
|
|
22
|
+
* caption styles bugs ([f223918](https://github.com/ho-nl/m2-pwa/commit/f223918cc557a996b5f321fbf6910b4981646dcb))
|
|
23
|
+
* empty grid rows still have a gap ([7ba50c7](https://github.com/ho-nl/m2-pwa/commit/7ba50c740aa7ac5133b933b3e6a22fab853b55a6))
|
|
24
|
+
* ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
25
|
+
* **image:** make sure unoptimized images are preloaded correctly and remove preloads from lots of images ([fb2b4fc](https://github.com/ho-nl/m2-pwa/commit/fb2b4fcb5336ff880a9b32775847d7b6738ba1ea))
|
|
26
|
+
* implement next-ui barrel imports ([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
|
|
27
|
+
* make fab-menu more configurable ([f73d7ec](https://github.com/ho-nl/m2-pwa/commit/f73d7ecccfba7d5cd9eecdcdd65abb5393a9e7a9))
|
|
28
|
+
* no search results message ([2ecd6e3](https://github.com/ho-nl/m2-pwa/commit/2ecd6e36481e546dc78acfb46dfff08dcfdd8e6a))
|
|
29
|
+
* pagination & janky search form ([b4fb982](https://github.com/ho-nl/m2-pwa/commit/b4fb982980c92f3819bb563582979dd66893a733))
|
|
30
|
+
* readonly search field ([5524847](https://github.com/ho-nl/m2-pwa/commit/552484706520c14b7b3d1708daf8cc64b91f3fe7))
|
|
31
|
+
* rename NextButton to Button, change imports ([976adb0](https://github.com/ho-nl/m2-pwa/commit/976adb0bf906310d1efce888dcc9be1e28ce0f1b))
|
|
32
|
+
* search button on click type ([33a6a08](https://github.com/ho-nl/m2-pwa/commit/33a6a0826acf795750503b39bd0d224baa795a47))
|
|
33
|
+
* search not submitting after empying the field ([a15b5cf](https://github.com/ho-nl/m2-pwa/commit/a15b5cf94f4619e0087c8871a98617ab160f671a))
|
|
34
|
+
* search page routes ([4161179](https://github.com/ho-nl/m2-pwa/commit/4161179aaf2ecbc0fde0efbba891a7b85524e283))
|
|
35
|
+
* search results text ([33a496c](https://github.com/ho-nl/m2-pwa/commit/33a496c07fe6b5b0b05f3287dc86f6a32ca34b3b))
|
|
36
|
+
* **search-page:** hide menu and cart fabs when opened virtual keyboard mobile ([e728768](https://github.com/ho-nl/m2-pwa/commit/e7287680545f33079d0af47df1c6ea519b208978))
|
|
37
|
+
* since all links are of next/link we need to add passHref for custom components ([16fb931](https://github.com/ho-nl/m2-pwa/commit/16fb93100d367203ea79bb4f93357221253f2ecd))
|
|
38
|
+
* yarn workspace packages hot reload ([d03fc9f](https://github.com/ho-nl/m2-pwa/commit/d03fc9fdda3486476761786f2b56a934cc92befc))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* Add customer service icon and define MuiIconButton size ([eefcc52](https://github.com/ho-nl/m2-pwa/commit/eefcc52eeffa03b364464709e1860135127cc4b5))
|
|
44
|
+
* **app-shell:** now consistent ([fb5b506](https://github.com/ho-nl/m2-pwa/commit/fb5b5062729002b508e888a4962f1b2578e5199b))
|
|
45
|
+
* created stacked-pages package ([d86008e](https://github.com/ho-nl/m2-pwa/commit/d86008ee659ccb25b194a41d624b394a1ddbd088))
|
|
46
|
+
* full page ui desktop variant ([a70f301](https://github.com/ho-nl/m2-pwa/commit/a70f3013da36fa131f82fb44457b107fb7705df6))
|
|
47
|
+
* **graphql:** introduced new graphql package that holds all generated files ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
|
|
48
|
+
* **image:** introduced completely rewritten Image component ([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
|
|
49
|
+
* minimal page shell ([1693674](https://github.com/ho-nl/m2-pwa/commit/1693674631fc8438c60d9b74b73e607e08971a2d))
|
|
50
|
+
* next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
|
|
51
|
+
* **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
52
|
+
* renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
53
|
+
* search page ([c89291b](https://github.com/ho-nl/m2-pwa/commit/c89291b7a65c93cbdb5f131f061f7232fdce3b99))
|
|
54
|
+
* svgimage component ([f369605](https://github.com/ho-nl/m2-pwa/commit/f3696051e381a24c543fd24e199da5b17f9e124f))
|
|
55
|
+
* upgrade to node 14 ([d079a75](https://github.com/ho-nl/m2-pwa/commit/d079a751e9bfd8dc7f5009d2c9f31c336a0c96ab))
|
|
56
|
+
* upgraded to nextjs 11 ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## 2.0.8 (2020-10-28)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
* make sure themes extensions are found ([5aa18db](https://github.com/ho-nl/m2-pwa/commit/5aa18db514fd2e2f50681367e39523f8e742ece0))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Features
|
|
69
|
+
|
|
70
|
+
* split into packages ([2ee7fd6](https://github.com/ho-nl/m2-pwa/commit/2ee7fd6c0056f467d114f04d92c6c0ddf622d151))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### BREAKING CHANGES
|
|
74
|
+
|
|
75
|
+
* huge folder structure refactor, please read README to reinstall
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# Change Log
|
|
82
|
+
|
|
83
|
+
All notable changes to this project will be documented in this file. See
|
|
84
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
85
|
+
|
|
86
|
+
# [2.104.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@2.103.8...@graphcommerce/magento-search@2.104.0) (2021-08-27)
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
- **app-shell:** pages after app shell changes
|
|
91
|
+
([fb74510](https://github.com/ho-nl/m2-pwa/commit/fb74510121f6124009db72ad2ddebf6459c52a85))
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
- **app-shell:** now consistent
|
|
96
|
+
([fb5b506](https://github.com/ho-nl/m2-pwa/commit/fb5b5062729002b508e888a4962f1b2578e5199b))
|
|
97
|
+
|
|
98
|
+
## [2.103.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@2.103.5...@graphcommerce/magento-search@2.103.6) (2021-08-17)
|
|
99
|
+
|
|
100
|
+
### Bug Fixes
|
|
101
|
+
|
|
102
|
+
- **404-page:** prevent auto focus search form
|
|
103
|
+
([9e89ed3](https://github.com/ho-nl/m2-pwa/commit/9e89ed31ea192312641f46f01b69dc5f319331e8))
|
|
104
|
+
- **search-page:** hide menu and cart fabs when opened virtual keyboard mobile
|
|
105
|
+
([e728768](https://github.com/ho-nl/m2-pwa/commit/e7287680545f33079d0af47df1c6ea519b208978))
|
|
106
|
+
|
|
107
|
+
# [2.103.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@2.102.9...@graphcommerce/magento-search@2.103.0) (2021-08-12)
|
|
108
|
+
|
|
109
|
+
### Features
|
|
110
|
+
|
|
111
|
+
- upgraded to nextjs 11
|
|
112
|
+
([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
113
|
+
|
|
114
|
+
# [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@2.101.7...@graphcommerce/magento-search@2.102.0) (2021-07-26)
|
|
115
|
+
|
|
116
|
+
### Features
|
|
117
|
+
|
|
118
|
+
- **playwright:** added new playwright package to enable browser testing
|
|
119
|
+
([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
120
|
+
|
|
121
|
+
# [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-search@2.100.10...@graphcommerce/magento-search@2.101.0) (2021-07-20)
|
|
122
|
+
|
|
123
|
+
### Bug Fixes
|
|
124
|
+
|
|
125
|
+
- ignore md files from triggering version updates
|
|
126
|
+
([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
127
|
+
- search button on click type
|
|
128
|
+
([33a6a08](https://github.com/ho-nl/m2-pwa/commit/33a6a0826acf795750503b39bd0d224baa795a47))
|
|
129
|
+
|
|
130
|
+
### Features
|
|
131
|
+
|
|
132
|
+
- full page ui desktop variant
|
|
133
|
+
([a70f301](https://github.com/ho-nl/m2-pwa/commit/a70f3013da36fa131f82fb44457b107fb7705df6))
|
|
134
|
+
- minimal page shell
|
|
135
|
+
([1693674](https://github.com/ho-nl/m2-pwa/commit/1693674631fc8438c60d9b74b73e607e08971a2d))
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
export type CategorySearchResultFragment = { uid: string, url_path?: Types.Maybe<string>, name?: Types.Maybe<string>, breadcrumbs?: Types.Maybe<Array<Types.Maybe<{ category_uid: string, category_name?: Types.Maybe<string>, category_url_path?: Types.Maybe<string> }>>> };
|
|
@@ -0,0 +1,9 @@
|
|
|
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>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { makeStyles, Theme } from '@material-ui/core'
|
|
2
|
+
import { Button, Highlight, iconChevronRight, SvgImage, UseStyles } from '@graphcommerce/next-ui'
|
|
3
|
+
import PageLink from 'next/link'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import { CategorySearchResultFragment } from './CategorySearchResult.gql'
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles(
|
|
8
|
+
(theme: Theme) => ({
|
|
9
|
+
categoryButton: {
|
|
10
|
+
padding: `${theme.spacings.xs} 18px ${theme.spacings.xs} 14px`,
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
minWidth: '100%',
|
|
14
|
+
maxWidth: 'unset',
|
|
15
|
+
borderRadius: '0',
|
|
16
|
+
'&:not(&:last-child)': {
|
|
17
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
18
|
+
},
|
|
19
|
+
'&:focus': {
|
|
20
|
+
boxShadow: 'none',
|
|
21
|
+
},
|
|
22
|
+
'&:hover': {
|
|
23
|
+
background: theme.palette.background.highlight,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
totalProducts: {
|
|
27
|
+
minWidth: 'max-content',
|
|
28
|
+
paddingRight: 7,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
{
|
|
32
|
+
name: 'CategorySearchResult',
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export type CategorySearchResultProps = Omit<CategorySearchResultFragment, 'uid'> &
|
|
37
|
+
UseStyles<typeof useStyles> & { search?: string }
|
|
38
|
+
|
|
39
|
+
export default function CategorySearchResult(props: CategorySearchResultProps) {
|
|
40
|
+
const { search = '', ...catProps } = props
|
|
41
|
+
const classes = useStyles(props)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<PageLink href={`/${catProps?.url_path ?? ''}`}>
|
|
45
|
+
<Button
|
|
46
|
+
fullWidth
|
|
47
|
+
variant='contained'
|
|
48
|
+
className={classes.categoryButton}
|
|
49
|
+
disableElevation
|
|
50
|
+
endIcon={
|
|
51
|
+
<SvgImage src={iconChevronRight} alt='chevron right' size='small' loading='eager' />
|
|
52
|
+
}
|
|
53
|
+
>
|
|
54
|
+
<div>
|
|
55
|
+
{catProps?.breadcrumbs?.map((breadcrumb) => (
|
|
56
|
+
<React.Fragment key={breadcrumb?.category_url_path}>
|
|
57
|
+
<Highlight
|
|
58
|
+
key={breadcrumb?.category_url_path}
|
|
59
|
+
text={breadcrumb?.category_name ?? ''}
|
|
60
|
+
highlight={search}
|
|
61
|
+
/>
|
|
62
|
+
{' / '}
|
|
63
|
+
</React.Fragment>
|
|
64
|
+
))}
|
|
65
|
+
<Highlight text={catProps?.name ?? ''} highlight={search} />
|
|
66
|
+
</div>
|
|
67
|
+
</Button>
|
|
68
|
+
</PageLink>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { makeStyles, Theme, Typography } from '@material-ui/core'
|
|
2
|
+
import { UseStyles } from '@graphcommerce/next-ui'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const useStyles = makeStyles(
|
|
6
|
+
(theme: Theme) => ({
|
|
7
|
+
container: {
|
|
8
|
+
marginTop: theme.spacings.md,
|
|
9
|
+
marginBottom: theme.spacings.sm,
|
|
10
|
+
textAlign: 'center',
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
13
|
+
{
|
|
14
|
+
name: 'NoSearchResults',
|
|
15
|
+
},
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
export type NoSearchResultsProps = { search: string } & UseStyles<typeof useStyles>
|
|
19
|
+
|
|
20
|
+
export default function NoSearchResults(props: NoSearchResultsProps) {
|
|
21
|
+
const { search } = props
|
|
22
|
+
const classes = useStyles(props)
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className={classes.container}>
|
|
26
|
+
<Typography variant='h5' align='center'>
|
|
27
|
+
We couldn't find any results for {`'${search}'`}
|
|
28
|
+
</Typography>
|
|
29
|
+
<p>Try a different search</p>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
package/Search.gql.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
export const SearchDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Search"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}},"defaultValue":{"kind":"IntValue","value":"23"}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentPage"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}},"defaultValue":{"kind":"IntValue","value":"1"}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filters"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ProductAttributeFilterInput"}},"defaultValue":{"kind":"ObjectValue","fields":[]}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"sort"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ProductAttributeSortInput"}},"defaultValue":{"kind":"ObjectValue","fields":[]}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"search"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"defaultValue":{"kind":"StringValue","value":"","block":false}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"categories"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filters"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"name"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"match"},"value":{"kind":"Variable","name":{"kind":"Name","value":"search"}}}]}}]}},{"kind":"Argument","name":{"kind":"Name","value":"pageSize"},"value":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"url_path"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CategoryInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"breadcrumbs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"category_uid"}},{"kind":"Field","name":{"kind":"Name","value":"category_name"}},{"kind":"Field","name":{"kind":"Name","value":"category_url_path"}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"products"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"pageSize"},"value":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}}},{"kind":"Argument","name":{"kind":"Name","value":"currentPage"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentPage"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filters"}}},{"kind":"Argument","name":{"kind":"Name","value":"sort"},"value":{"kind":"Variable","name":{"kind":"Name","value":"sort"}}},{"kind":"Argument","name":{"kind":"Name","value":"search"},"value":{"kind":"Variable","name":{"kind":"Name","value":"search"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"total_count"}},{"kind":"Field","name":{"kind":"Name","value":"page_info"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"current_page"}},{"kind":"Field","name":{"kind":"Name","value":"total_pages"}}]}},{"kind":"Field","name":{"kind":"Name","value":"sort_fields"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"default"}},{"kind":"Field","name":{"kind":"Name","value":"options"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"url_key"}},{"kind":"Field","name":{"kind":"Name","value":"sku"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"small_image"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"price_range"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"maximum_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"regular_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"discount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount_off"}},{"kind":"Field","name":{"kind":"Name","value":"percent_off"}}]}},{"kind":"Field","name":{"kind":"Name","value":"final_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"minimum_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"regular_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"discount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount_off"}},{"kind":"Field","name":{"kind":"Name","value":"percent_off"}}]}},{"kind":"Field","name":{"kind":"Name","value":"final_price"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"rating_summary"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ConfigurableProduct"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"configurable_options"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attribute_code"}},{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"values"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"store_label"}},{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"swatch_data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TextSwatchData"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ColorSwatchData"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ImageSwatchData"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"thumbnail"}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"variants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"code"}}]}},{"kind":"Field","name":{"kind":"Name","value":"product"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uid"}},{"kind":"Field","name":{"kind":"Name","value":"sku"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"small_image"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}}]}}]}}]}},{"kind":"Field","alias":{"kind":"Name","value":"filters"},"name":{"kind":"Name","value":"products"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"search"},"value":{"kind":"Variable","name":{"kind":"Name","value":"search"}}},{"kind":"Argument","name":{"kind":"Name","value":"pageSize"},"value":{"kind":"Variable","name":{"kind":"Name","value":"pageSize"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"aggregations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"attribute_code"}},{"kind":"Field","name":{"kind":"Name","value":"options"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]}}]}}]} as unknown as DocumentNode<SearchQuery, SearchQueryVariables>;
|
|
7
|
+
export type SearchQueryVariables = Types.Exact<{
|
|
8
|
+
pageSize?: Types.Maybe<Types.Scalars['Int']>;
|
|
9
|
+
currentPage?: Types.Maybe<Types.Scalars['Int']>;
|
|
10
|
+
filters?: Types.Maybe<Types.ProductAttributeFilterInput>;
|
|
11
|
+
sort?: Types.Maybe<Types.ProductAttributeSortInput>;
|
|
12
|
+
search?: Types.Maybe<Types.Scalars['String']>;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type SearchQuery = { categories?: Types.Maybe<{ items?: Types.Maybe<Array<Types.Maybe<{ uid: string, url_path?: Types.Maybe<string>, name?: Types.Maybe<string>, breadcrumbs?: Types.Maybe<Array<Types.Maybe<{ category_uid: string, category_name?: Types.Maybe<string>, category_url_path?: Types.Maybe<string> }>>> }>>> }>, products?: Types.Maybe<{ total_count?: Types.Maybe<number>, page_info?: Types.Maybe<{ current_page?: Types.Maybe<number>, total_pages?: Types.Maybe<number> }>, sort_fields?: Types.Maybe<{ default?: Types.Maybe<string>, options?: Types.Maybe<Array<Types.Maybe<{ label?: Types.Maybe<string>, value?: Types.Maybe<string> }>>> }>, items?: Types.Maybe<Array<Types.Maybe<{ __typename: 'BundleProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } } | { __typename: 'ConfigurableProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, configurable_options?: Types.Maybe<Array<Types.Maybe<{ attribute_code?: Types.Maybe<string>, uid: string, label?: Types.Maybe<string>, values?: Types.Maybe<Array<Types.Maybe<{ store_label?: Types.Maybe<string>, uid?: Types.Maybe<string>, swatch_data?: Types.Maybe<{ __typename: 'ColorSwatchData', value?: Types.Maybe<string> } | { __typename: 'ImageSwatchData', value?: Types.Maybe<string>, thumbnail?: Types.Maybe<string> } | { __typename: 'TextSwatchData', value?: Types.Maybe<string> }> }>>> }>>>, variants?: Types.Maybe<Array<Types.Maybe<{ attributes?: Types.Maybe<Array<Types.Maybe<{ uid: string, code?: Types.Maybe<string> }>>>, product?: Types.Maybe<{ uid: string, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, small_image?: Types.Maybe<{ label?: Types.Maybe<string>, url?: Types.Maybe<string> }> }> }>>>, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } } | { __typename: 'DownloadableProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } } | { __typename: 'GroupedProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } } | { __typename: 'SimpleProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } } | { __typename: 'VirtualProduct', uid: string, url_key?: Types.Maybe<string>, sku?: Types.Maybe<string>, name?: Types.Maybe<string>, rating_summary: number, small_image?: Types.Maybe<{ url?: Types.Maybe<string>, label?: Types.Maybe<string> }>, price_range: { maximum_price?: Types.Maybe<{ regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, minimum_price: { regular_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, discount?: Types.Maybe<{ amount_off?: Types.Maybe<number>, percent_off?: Types.Maybe<number> }>, final_price: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } } } }>>> }>, filters?: Types.Maybe<{ aggregations?: Types.Maybe<Array<Types.Maybe<{ label?: Types.Maybe<string>, count?: Types.Maybe<number>, attribute_code: string, options?: Types.Maybe<Array<Types.Maybe<{ label?: Types.Maybe<string>, value: string, count?: Types.Maybe<number> }>>> }>>> }> };
|
package/Search.graphql
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
query Search(
|
|
2
|
+
$pageSize: Int = 23
|
|
3
|
+
$currentPage: Int = 1
|
|
4
|
+
$filters: ProductAttributeFilterInput = {}
|
|
5
|
+
$sort: ProductAttributeSortInput = {}
|
|
6
|
+
$search: String = ""
|
|
7
|
+
) {
|
|
8
|
+
categories(filters: { name: { match: $search } }, pageSize: $pageSize) {
|
|
9
|
+
items {
|
|
10
|
+
...CategorySearchResult
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
...ProductListQueryFragment
|
|
14
|
+
filters: products(search: $search, pageSize: $pageSize) {
|
|
15
|
+
...ProductListFilters
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { makeStyles, TextField, Theme } from '@material-ui/core'
|
|
2
|
+
import { UseStyles, SvgImage, iconSearch } from '@graphcommerce/next-ui'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const useStyles = makeStyles(
|
|
6
|
+
(theme: Theme) => ({
|
|
7
|
+
root: {
|
|
8
|
+
width: '100%',
|
|
9
|
+
'& fieldset': {
|
|
10
|
+
border: `2px solid rgba(0,0,0,0.1)`,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
inputRoot: {
|
|
14
|
+
...theme.typography.body2,
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
{ name: 'SearchButton' },
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
export type SearchButtonProps = UseStyles<typeof useStyles> & { onClick: () => void }
|
|
21
|
+
|
|
22
|
+
export default function SearchButton(props: SearchButtonProps) {
|
|
23
|
+
const { onClick } = props
|
|
24
|
+
const classes = useStyles(props)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<TextField
|
|
28
|
+
variant='outlined'
|
|
29
|
+
size='small'
|
|
30
|
+
classes={{ root: classes.root }}
|
|
31
|
+
InputProps={{
|
|
32
|
+
readOnly: true,
|
|
33
|
+
endAdornment: <SvgImage src={iconSearch} alt='Search' size='small' />,
|
|
34
|
+
classes: { root: classes.inputRoot },
|
|
35
|
+
}}
|
|
36
|
+
placeholder=''
|
|
37
|
+
onClick={onClick}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { styled } from '@material-ui/core'
|
|
2
|
+
|
|
3
|
+
const SearchDivider = styled('div')(
|
|
4
|
+
({ theme }) => ({
|
|
5
|
+
boxShadow: '0 5px 4px 0 rgb(3 3 3 / 3%)',
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: 16,
|
|
8
|
+
marginTop: theme.spacings.md,
|
|
9
|
+
marginBottom: theme.spacings.md,
|
|
10
|
+
}),
|
|
11
|
+
{ name: 'FormDivider' },
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export default SearchDivider
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { IconButton, makeStyles, TextField, Theme } from '@material-ui/core'
|
|
2
|
+
import { FormRow, UseStyles, SvgImage, iconClose, iconSearch } from '@graphcommerce/next-ui'
|
|
3
|
+
import { useForm, useFormAutoSubmit, useFormMuiRegister } from '@graphcommerce/react-hook-form'
|
|
4
|
+
import { useRouter } from 'next/router'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles(
|
|
8
|
+
(theme: Theme) => ({
|
|
9
|
+
totalProducts: {
|
|
10
|
+
minWidth: 'max-content',
|
|
11
|
+
color: theme.palette.grey[500],
|
|
12
|
+
paddingRight: 7,
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
name: 'SearchIndexPage',
|
|
17
|
+
},
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
export type SearchFormProps = {
|
|
21
|
+
totalResults?: number
|
|
22
|
+
search?: string
|
|
23
|
+
urlHandle?: string
|
|
24
|
+
autoFocus?: boolean
|
|
25
|
+
} & UseStyles<typeof useStyles>
|
|
26
|
+
|
|
27
|
+
export default function SearchForm(props: SearchFormProps) {
|
|
28
|
+
const { totalResults = 0, search = '', urlHandle = 'search', autoFocus = true } = props
|
|
29
|
+
const classes = useStyles(props)
|
|
30
|
+
const router = useRouter()
|
|
31
|
+
|
|
32
|
+
const form = useForm({ mode: 'onChange', defaultValues: { search } })
|
|
33
|
+
const { handleSubmit, formState, reset, watch, getValues } = form
|
|
34
|
+
|
|
35
|
+
const muiRegister = useFormMuiRegister(form)
|
|
36
|
+
|
|
37
|
+
const submit = handleSubmit((formData) => {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
39
|
+
router.replace(`/${urlHandle}/${formData.search}`)
|
|
40
|
+
reset(getValues())
|
|
41
|
+
})
|
|
42
|
+
useFormAutoSubmit({ form, submit })
|
|
43
|
+
|
|
44
|
+
const handleReset = () => {
|
|
45
|
+
reset({ search: '' })
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
47
|
+
router.replace(`/${urlHandle}`)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const endAdornment = !watch('search') ? (
|
|
51
|
+
<IconButton size='small'>
|
|
52
|
+
<SvgImage src={iconSearch} alt='search' size='small' />
|
|
53
|
+
</IconButton>
|
|
54
|
+
) : (
|
|
55
|
+
<>
|
|
56
|
+
{totalResults > 0 && (
|
|
57
|
+
<div className={classes.totalProducts}>
|
|
58
|
+
{totalResults} {totalResults > 1 ? 'results' : 'result'}
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
<IconButton onClick={handleReset} size='small'>
|
|
62
|
+
<SvgImage src={iconClose} alt='close' size='small' />
|
|
63
|
+
</IconButton>
|
|
64
|
+
</>
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<form
|
|
69
|
+
noValidate
|
|
70
|
+
onSubmit={submit}
|
|
71
|
+
onChange={() => {
|
|
72
|
+
if (watch('search') === '') {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
74
|
+
router.replace(`/search`)
|
|
75
|
+
}
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<FormRow>
|
|
79
|
+
<TextField
|
|
80
|
+
variant='outlined'
|
|
81
|
+
type='text'
|
|
82
|
+
autoFocus={autoFocus}
|
|
83
|
+
placeholder='Search'
|
|
84
|
+
defaultValue={search}
|
|
85
|
+
error={formState.isSubmitted && !!formState.errors.search}
|
|
86
|
+
helperText={formState.isSubmitted && formState.errors.search?.message}
|
|
87
|
+
{...muiRegister('search', { required: true, minLength: 2 })}
|
|
88
|
+
InputProps={{ endAdornment }}
|
|
89
|
+
/>
|
|
90
|
+
</FormRow>
|
|
91
|
+
</form>
|
|
92
|
+
)
|
|
93
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default as SearchDivider } from './SearchDivider'
|
|
2
|
+
export * from './SearchDivider'
|
|
3
|
+
|
|
4
|
+
export { default as NoSearchResults } from './NoSearchResults'
|
|
5
|
+
export * from './NoSearchResults'
|
|
6
|
+
|
|
7
|
+
export { default as CategorySearchResult } from './CategorySearchResult'
|
|
8
|
+
export * from './CategorySearchResult'
|
|
9
|
+
|
|
10
|
+
export { default as SearchForm } from './SearchForm'
|
|
11
|
+
export * from './SearchForm'
|
|
12
|
+
|
|
13
|
+
export { default as SearchButton } from './SearchButton'
|
|
14
|
+
export * from './SearchButton'
|
|
15
|
+
|
|
16
|
+
export * from './Search.gql'
|
package/next-env.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphcommerce/magento-search",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
6
|
+
"browserslist": [
|
|
7
|
+
"extends @graphcommerce/browserslist-config-pwa"
|
|
8
|
+
],
|
|
9
|
+
"eslintConfig": {
|
|
10
|
+
"extends": "@graphcommerce/eslint-config-pwa",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": "./tsconfig.json"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@graphcommerce/browserslist-config-pwa": "^3.0.1",
|
|
17
|
+
"@graphcommerce/eslint-config-pwa": "^3.0.1",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^3.0.1",
|
|
19
|
+
"@graphcommerce/typescript-config-pwa": "^3.0.1",
|
|
20
|
+
"@playwright/test": "^1.14.1"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@graphcommerce/graphql": "^2.103.1",
|
|
24
|
+
"@graphcommerce/image": "^2.104.1",
|
|
25
|
+
"@graphcommerce/next-ui": "^3.0.1",
|
|
26
|
+
"@graphcommerce/react-hook-form": "^2.102.1",
|
|
27
|
+
"@graphql-typed-document-node/core": "^3.1.0",
|
|
28
|
+
"@material-ui/core": "^4.12.3",
|
|
29
|
+
"next": "^11.1.2",
|
|
30
|
+
"react": "^17.0.2",
|
|
31
|
+
"react-dom": "^17.0.2"
|
|
32
|
+
}
|
|
33
|
+
}
|