@graphcommerce/magento-category 4.1.20 → 4.1.23

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,39 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`18054c441`](https://github.com/graphcommerce-org/graphcommerce/commit/18054c441962ba750bed3acc39ab46c8d3a341ce), [`c5c539c44`](https://github.com/graphcommerce-org/graphcommerce/commit/c5c539c44eeac524cd62ce649e132d2e00333794), [`6f69bc54c`](https://github.com/graphcommerce-org/graphcommerce/commit/6f69bc54c6e0224452817c532ae58d9c332b61ea), [`21886d6fa`](https://github.com/graphcommerce-org/graphcommerce/commit/21886d6fa64a48d9e932bfaf8d138c9b13c36e43), [`b4936e961`](https://github.com/graphcommerce-org/graphcommerce/commit/b4936e96175fe80717895822e245274db05638bd)]:
8
+ - @graphcommerce/graphql@3.4.1
9
+ - @graphcommerce/next-ui@4.13.1
10
+ - @graphcommerce/framer-scroller@2.1.23
11
+ - @graphcommerce/magento-product@4.4.15
12
+ - @graphcommerce/magento-store@4.2.17
13
+
14
+ ## 4.1.22
15
+
16
+ ### Patch Changes
17
+
18
+ - [#1522](https://github.com/graphcommerce-org/graphcommerce/pull/1522) [`8d8fda262`](https://github.com/graphcommerce-org/graphcommerce/commit/8d8fda2623e561cb43441110c67ffa34b692668a) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Introducing a new Navigation component that builds on the existing navigation component and tries to address the 'mega menu' question where there are tons of categories that need to be navigated quickly.
19
+
20
+ - Updated dependencies [[`8d8fda262`](https://github.com/graphcommerce-org/graphcommerce/commit/8d8fda2623e561cb43441110c67ffa34b692668a), [`d41cff721`](https://github.com/graphcommerce-org/graphcommerce/commit/d41cff7211230561ceeb7786cf75790efd6377cd), [`cefa7b365`](https://github.com/graphcommerce-org/graphcommerce/commit/cefa7b3652b55108d2178927e3c5d98a111cf373), [`584b683a2`](https://github.com/graphcommerce-org/graphcommerce/commit/584b683a2aedcdf5067644c8dcc0e63a5b9e894c)]:
21
+ - @graphcommerce/next-ui@4.13.0
22
+ - @graphcommerce/magento-store@4.2.16
23
+ - @graphcommerce/framer-scroller@2.1.22
24
+ - @graphcommerce/magento-product@4.4.14
25
+
26
+ ## 4.1.21
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`5f927ebdc`](https://github.com/graphcommerce-org/graphcommerce/commit/5f927ebdc6f0331833e02b96e4f169bfe475ac6b), [`c756f42e5`](https://github.com/graphcommerce-org/graphcommerce/commit/c756f42e503761a497e4a5a7a02d02141df231c3)]:
31
+ - @graphcommerce/graphql@3.4.0
32
+ - @graphcommerce/next-ui@4.12.0
33
+ - @graphcommerce/magento-product@4.4.13
34
+ - @graphcommerce/magento-store@4.2.15
35
+ - @graphcommerce/framer-scroller@2.1.21
36
+
3
37
  ## 4.1.20
4
38
 
5
39
  ### Patch Changes
@@ -0,0 +1,38 @@
1
+ import { NavigationNode, NavigationNodeButton, NavigationNodeHref } from '@graphcommerce/next-ui'
2
+ import { MenuQueryFragment } from '../queries/MenuQueryFragment.gql'
3
+
4
+ function nonNullable<T>(value: T): value is NonNullable<T> {
5
+ return value !== null && value !== undefined
6
+ }
7
+
8
+ type Item = NonNullable<NonNullable<MenuQueryFragment['menu']>['items']>[0]
9
+
10
+ function categoryToNav(props: Item | null | undefined): NavigationNode | undefined {
11
+ if (!props) return undefined
12
+ const { uid, children, include_in_menu, name, url_path } = props
13
+
14
+ if (!uid || include_in_menu !== 1 || !url_path || !name) return undefined
15
+
16
+ // If we've got children we make a button that navigates to childitems.
17
+ if (children && children.length > 0) {
18
+ return {
19
+ name,
20
+ id: uid,
21
+ childItems: [
22
+ { name: `All ${name}`, href: `/${url_path}` },
23
+ ...children.map(categoryToNav).filter(nonNullable),
24
+ ],
25
+ } as NavigationNodeButton
26
+ }
27
+
28
+ // If we've got no children we make a href.
29
+ return { name, id: uid, href: `/${url_path}` } as NavigationNodeHref
30
+ }
31
+
32
+ /**
33
+ * Converts the Magento GraphQL category tree to a NavigationNode tree, which can be used in the
34
+ * Navigation component.
35
+ */
36
+ export function useMagentoMenuToNavigation(menu: MenuQueryFragment['menu']) {
37
+ return (menu?.items ?? []).map(categoryToNav).filter(nonNullable)
38
+ }
package/index.ts CHANGED
@@ -3,5 +3,5 @@ export * from './components/CategoryDescription/CategoryDescription'
3
3
  export * from './components/CategoryHeroNav/CategoryHeroNav'
4
4
  export * from './components/CategoryHeroNav/CategoryHeroNavTitle'
5
5
  export * from './components/CategoryMeta/CategoryMeta'
6
-
6
+ export * from './hooks/useMagentoMenuToNavigation'
7
7
  export * from './queries/getCategoryStaticPaths'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-category",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.1.20",
5
+ "version": "4.1.23",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,19 +12,19 @@
12
12
  }
13
13
  },
14
14
  "devDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^4.1.8",
15
+ "@graphcommerce/eslint-config-pwa": "^4.1.9",
16
16
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
17
- "@graphcommerce/typescript-config-pwa": "^4.0.3",
17
+ "@graphcommerce/typescript-config-pwa": "^4.0.4",
18
18
  "@playwright/test": "^1.21.1",
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/framer-scroller": "2.1.20",
23
- "@graphcommerce/graphql": "3.3.0",
22
+ "@graphcommerce/framer-scroller": "2.1.23",
23
+ "@graphcommerce/graphql": "3.4.1",
24
24
  "@graphcommerce/image": "3.1.7",
25
- "@graphcommerce/magento-product": "4.4.12",
26
- "@graphcommerce/magento-store": "4.2.14",
27
- "@graphcommerce/next-ui": "4.11.2"
25
+ "@graphcommerce/magento-product": "4.4.15",
26
+ "@graphcommerce/magento-store": "4.2.17",
27
+ "@graphcommerce/next-ui": "4.13.1"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@lingui/react": "^3.13.2",
@@ -1,10 +1,15 @@
1
1
  fragment MenuQueryFragment on Query {
2
2
  menu: categories(filters: { parent_category_uid: { eq: $rootCategory } }) {
3
3
  items {
4
- uid
5
- name
6
- url_path
7
- include_in_menu
4
+ ...NavigationItem
5
+ children {
6
+ uid
7
+ ...NavigationItem
8
+ children {
9
+ uid
10
+ ...NavigationItem
11
+ }
12
+ }
8
13
  }
9
14
  }
10
15
  }
@@ -0,0 +1,7 @@
1
+ fragment NavigationItem on CategoryTree {
2
+ uid
3
+ include_in_menu
4
+ name
5
+ url_path
6
+ children_count
7
+ }