@graphcommerce/magento-search 9.1.0-canary.26 → 9.1.0-canary.29
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 +10 -0
- package/graphql/fragments/CategorySearchFragment.graphql +6 -0
- package/graphql/queries/CategorySearch.graphql +5 -0
- package/hooks/useCategorySearch.ts +24 -0
- package/hooks/useCategorySearchVariables.ts +14 -0
- package/index.ts +18 -16
- package/package.json +12 -12
- package/utils/categoriesApplySearchDefaults.ts +14 -0
- package/CategorySearch.graphql +0 -7
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 9.1.0-canary.29
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [#2525](https://github.com/graphcommerce-org/graphcommerce/pull/2525) [`f9176ad`](https://github.com/graphcommerce-org/graphcommerce/commit/f9176adf3bf643ac00c865fc173a80056d8b8170) - Search Categories through algolia ([@paales](https://github.com/paales))
|
8
|
+
|
9
|
+
## 9.1.0-canary.28
|
10
|
+
|
11
|
+
## 9.1.0-canary.27
|
12
|
+
|
3
13
|
## 9.1.0-canary.26
|
4
14
|
|
5
15
|
## 9.1.0-canary.25
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
2
|
+
import { CategorySearchDocument } from '../graphql/queries/CategorySearch.gql'
|
3
|
+
import type { CategoriesApplySearchVariablesProps } from '../utils/categoriesApplySearchDefaults'
|
4
|
+
import { useCategorySearchVariables } from './useCategorySearchVariables'
|
5
|
+
|
6
|
+
export function useCategorySearch(props: CategoriesApplySearchVariablesProps) {
|
7
|
+
const { search } = props
|
8
|
+
const variables = useCategorySearchVariables(props)
|
9
|
+
const skip = !search || search.length < 3
|
10
|
+
|
11
|
+
const categories = useQuery(CategorySearchDocument, { variables, skip })
|
12
|
+
|
13
|
+
const categoryItems = (
|
14
|
+
categories.data?.categories?.items ??
|
15
|
+
categories.previousData?.categories?.items ??
|
16
|
+
[]
|
17
|
+
)
|
18
|
+
.filter((v) => !!v)
|
19
|
+
.filter((c) => (typeof c?.include_in_menu === 'boolean' ? c?.include_in_menu : true))
|
20
|
+
|
21
|
+
if (categories.error || categoryItems.length === 0 || skip) return null
|
22
|
+
|
23
|
+
return categoryItems
|
24
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
2
|
+
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
3
|
+
import type { CategorySearchQueryVariables } from '../graphql/queries/CategorySearch.gql'
|
4
|
+
import {
|
5
|
+
categoriesApplySearchDefaults,
|
6
|
+
type CategoriesApplySearchVariablesProps,
|
7
|
+
} from '../utils/categoriesApplySearchDefaults'
|
8
|
+
|
9
|
+
export function useCategorySearchVariables(
|
10
|
+
props: CategoriesApplySearchVariablesProps,
|
11
|
+
): CategorySearchQueryVariables {
|
12
|
+
const config = useQuery(StoreConfigDocument).data
|
13
|
+
return config ? categoriesApplySearchDefaults(props, config) : {}
|
14
|
+
}
|
package/index.ts
CHANGED
@@ -1,18 +1,3 @@
|
|
1
|
-
export * from './CategorySearch.gql'
|
2
|
-
export * from './components/CategorySearchResult/CategorySearchResult'
|
3
|
-
export * from './components/CategorySearchResult/CategorySearchResults'
|
4
|
-
export * from './components/CategorySearchResult/CategorySearchResult.gql'
|
5
|
-
export * from './components/NoSearchResults/NoSearchResults'
|
6
|
-
export * from './components/SearchButton/SearchButton'
|
7
|
-
export * from './components/SearchContext/SearchContext'
|
8
|
-
export * from './components/SearchDivider/SearchDivider'
|
9
|
-
export * from './components/SearchForm/SearchForm'
|
10
|
-
export * from './components/SearchLink/SearchLink'
|
11
|
-
export * from './components/SearchFab/SearchFab'
|
12
|
-
export * from './hooks/useProductList'
|
13
|
-
export * from './components/ProductFiltersPro/ProductFiltersProCategorySectionSearch'
|
14
|
-
export * from './components/ProductFiltersPro/ProductFiltersProSearchHeader'
|
15
|
-
|
16
1
|
export {
|
17
2
|
ProductListCount,
|
18
3
|
ProductListFilters,
|
@@ -24,5 +9,22 @@ export {
|
|
24
9
|
} from '@graphcommerce/magento-product'
|
25
10
|
|
26
11
|
export * from '@graphcommerce/magento-product/components/ProductFiltersPro'
|
27
|
-
export * from './
|
12
|
+
export * from './components/CategorySearchResult/CategorySearchResult'
|
13
|
+
export * from './components/CategorySearchResult/CategorySearchResult.gql'
|
14
|
+
export * from './components/CategorySearchResult/CategorySearchResults'
|
15
|
+
export * from './components/NoSearchResults/NoSearchResults'
|
16
|
+
export * from './components/ProductFiltersPro/ProductFiltersProCategorySectionSearch'
|
17
|
+
export * from './components/ProductFiltersPro/ProductFiltersProSearchHeader'
|
28
18
|
export * from './components/ProductFiltersPro/SearchField'
|
19
|
+
export * from './components/SearchButton/SearchButton'
|
20
|
+
export * from './components/SearchContext/SearchContext'
|
21
|
+
export * from './components/SearchDivider/SearchDivider'
|
22
|
+
export * from './components/SearchFab/SearchFab'
|
23
|
+
export * from './components/SearchForm/SearchForm'
|
24
|
+
export * from './components/SearchLink/SearchLink'
|
25
|
+
export * from './graphql/queries/CategorySearch.gql'
|
26
|
+
export * from './hooks/useCategorySearch'
|
27
|
+
export * from './hooks/useCategorySearchVariables'
|
28
|
+
export * from './hooks/useProductList'
|
29
|
+
export * from './utils/productListApplySearchDefaults'
|
30
|
+
export * from './utils/categoriesApplySearchDefaults'
|
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": "9.1.0-canary.
|
5
|
+
"version": "9.1.0-canary.29",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -12,17 +12,17 @@
|
|
12
12
|
}
|
13
13
|
},
|
14
14
|
"peerDependencies": {
|
15
|
-
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.
|
17
|
-
"@graphcommerce/framer-utils": "^9.1.0-canary.
|
18
|
-
"@graphcommerce/graphql": "^9.1.0-canary.
|
19
|
-
"@graphcommerce/image": "^9.1.0-canary.
|
20
|
-
"@graphcommerce/magento-product": "^9.1.0-canary.
|
21
|
-
"@graphcommerce/magento-store": "^9.1.0-canary.
|
22
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
23
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
24
|
-
"@graphcommerce/react-hook-form": "^9.1.0-canary.
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.29",
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.29",
|
17
|
+
"@graphcommerce/framer-utils": "^9.1.0-canary.29",
|
18
|
+
"@graphcommerce/graphql": "^9.1.0-canary.29",
|
19
|
+
"@graphcommerce/image": "^9.1.0-canary.29",
|
20
|
+
"@graphcommerce/magento-product": "^9.1.0-canary.29",
|
21
|
+
"@graphcommerce/magento-store": "^9.1.0-canary.29",
|
22
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.29",
|
23
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.29",
|
24
|
+
"@graphcommerce/react-hook-form": "^9.1.0-canary.29",
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.29",
|
26
26
|
"@lingui/core": "^4.2.1",
|
27
27
|
"@lingui/macro": "^4.2.1",
|
28
28
|
"@lingui/react": "^4.2.1",
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { StoreConfigQuery } from '@graphcommerce/magento-store'
|
2
|
+
import type { CategorySearchQueryVariables } from '../graphql/queries/CategorySearch.gql'
|
3
|
+
|
4
|
+
export type CategoriesApplySearchVariablesProps = {
|
5
|
+
search?: string | null
|
6
|
+
}
|
7
|
+
|
8
|
+
export function categoriesApplySearchDefaults(
|
9
|
+
props: CategoriesApplySearchVariablesProps,
|
10
|
+
conf: StoreConfigQuery,
|
11
|
+
): CategorySearchQueryVariables {
|
12
|
+
const { search } = props
|
13
|
+
return { filters: { name: { match: search } }, pageSize: 5 }
|
14
|
+
}
|