@graphcommerce/hygraph-dynamic-rows 8.0.0-canary.80 → 8.0.0-canary.82

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,9 @@
1
1
  # @graphcommerce/hygraph-dynamic-rows
2
2
 
3
+ ## 8.0.0-canary.82
4
+
5
+ ## 8.0.0-canary.81
6
+
3
7
  ## 8.0.0-canary.80
4
8
 
5
9
  ## 8.0.0-canary.79
@@ -16,4 +16,15 @@ fragment DynamicRow on DynamicRow @injectable {
16
16
  ...RowQuote
17
17
  ...RowLinks
18
18
  }
19
+
20
+ rows {
21
+ __typename
22
+ ... on Node {
23
+ id
24
+ }
25
+
26
+ ...RowColumnOne
27
+ ...RowQuote
28
+ ...RowLinks
29
+ }
19
30
  }
@@ -120,22 +120,24 @@ export async function hygraphDynamicRows(
120
120
  const [pageResult, dynamicResult] = await Promise.all([pageQuery, dynamicRows])
121
121
 
122
122
  // Create a copy of the content array.
123
- const content = [...(pageResult.data.pages[0]?.content ?? [])]
123
+ const content = pageResult.data.pages[0]?.content ?? []
124
124
 
125
125
  dynamicResult?.data.dynamicRows.forEach((dynamicRow) => {
126
- const { placement, target, row } = dynamicRow
127
- if (!row) return
126
+ const { placement, target, rows, row } = dynamicRow
127
+ if (!rows && !row) return
128
+
129
+ const rowsToMerge = rows.length > 0 ? rows : [row]
128
130
 
129
131
  if (!target) {
130
- if (placement === 'BEFORE') content.unshift(row)
131
- else content.push(row)
132
+ if (placement === 'BEFORE') content.unshift(...rowsToMerge)
133
+ else content.push(...rowsToMerge)
132
134
  return
133
135
  }
134
136
 
135
137
  const targetIdx = content.findIndex((c) => c.id === target.id)
136
- if (placement === 'BEFORE') content.splice(targetIdx, 0, row)
137
- if (placement === 'AFTER') content.splice(targetIdx + 1, 0, row)
138
- if (placement === 'REPLACE') content.splice(targetIdx, 1, row)
138
+ if (placement === 'BEFORE') content.splice(targetIdx, 0, ...rowsToMerge)
139
+ if (placement === 'AFTER') content.splice(targetIdx + 1, 0, ...rowsToMerge)
140
+ if (placement === 'REPLACE') content.splice(targetIdx, 1, ...rowsToMerge)
139
141
  })
140
142
 
141
143
  if (!content.length) return pageResult
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/hygraph-dynamic-rows",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.0-canary.80",
5
+ "version": "8.0.0-canary.82",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,13 +12,13 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.80",
16
- "@graphcommerce/graphcms-ui": "^8.0.0-canary.80",
17
- "@graphcommerce/graphql": "^8.0.0-canary.80",
18
- "@graphcommerce/image": "^8.0.0-canary.80",
19
- "@graphcommerce/next-ui": "^8.0.0-canary.80",
20
- "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.80",
21
- "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.80",
15
+ "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.82",
16
+ "@graphcommerce/graphcms-ui": "^8.0.0-canary.82",
17
+ "@graphcommerce/graphql": "^8.0.0-canary.82",
18
+ "@graphcommerce/image": "^8.0.0-canary.82",
19
+ "@graphcommerce/next-ui": "^8.0.0-canary.82",
20
+ "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.82",
21
+ "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.82",
22
22
  "@mui/material": "^5.10.16",
23
23
  "next": "*",
24
24
  "react": "^18.2.0",