@graphcommerce/hygraph-ui 9.0.4-canary.8 → 9.1.0-canary.15

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,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.1.0-canary.15
4
+
5
+ ## 9.0.4-canary.14
6
+
7
+ ## 9.0.4-canary.13
8
+
9
+ ## 9.0.4-canary.12
10
+
11
+ ## 9.0.4-canary.11
12
+
13
+ ## 9.0.4-canary.10
14
+
15
+ ### Patch Changes
16
+
17
+ - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`cf9eafb`](https://github.com/graphcommerce-org/graphcommerce/commit/cf9eafb9d71991852510f632c692679810b9e76f) - Prepare the RichTex for embed and code-block ([@paales](https://github.com/paales))
18
+
19
+ - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`2085f0b`](https://github.com/graphcommerce-org/graphcommerce/commit/2085f0b30dfadd9ab589fde962f59e87b3f30b34) - Forward `<Asset unoptimized />` component to `<Image />` ([@paales](https://github.com/paales))
20
+
21
+ ## 9.0.4-canary.9
22
+
3
23
  ## 9.0.4-canary.8
4
24
 
5
25
  ## 9.0.4-canary.7
@@ -22,7 +22,7 @@ export type AssetProps = {
22
22
  } & Omit<ImageProps, 'src' | 'width' | 'height' | 'alt' | 'sx'>
23
23
 
24
24
  export const Asset = memo<AssetProps>((props) => {
25
- const { asset, sx = [], ...imgProps } = props
25
+ const { asset, sx = [], unoptimized = false, ...imgProps } = props
26
26
 
27
27
  if (isImage(asset)) {
28
28
  const { url, height, mimeType, size, width, alt, ...assetProps } = asset
@@ -34,7 +34,7 @@ export const Asset = memo<AssetProps>((props) => {
34
34
  alt={alt ?? undefined}
35
35
  {...imgProps}
36
36
  {...assetProps}
37
- unoptimized={mimeType === 'image/svg+xml'}
37
+ unoptimized={typeof unoptimized === 'boolean' ? unoptimized : mimeType === 'image/svg+xml'}
38
38
  sx={[...(Array.isArray(sx) ? sx : [sx])]}
39
39
  />
40
40
  )
@@ -56,10 +56,11 @@ function RenderText({
56
56
  last,
57
57
  ...textProps
58
58
  }: TextNode & AdditionalProps) {
59
- let type: 'bold' | 'italic' | 'underlined' | undefined
59
+ let type: 'bold' | 'italic' | 'underlined' | 'code' | undefined
60
60
 
61
61
  if (textProps.bold) type = 'bold'
62
62
  if (textProps.italic) type = 'italic'
63
+ if (textProps.code) type = 'code'
63
64
  if (textProps.underlined) type = 'underlined'
64
65
 
65
66
  const sx = useRenderProps({ first, last, sxRenderer }, type)
@@ -98,7 +99,7 @@ function RenderNode(node: ElementOrTextNode & AdditionalProps) {
98
99
  return null
99
100
  }
100
101
 
101
- function RenderChildren({
102
+ export function RenderChildren({
102
103
  childNodes,
103
104
  noMargin,
104
105
  ...props
@@ -55,4 +55,14 @@ export const defaultRenderers: Renderers = {
55
55
  italic: (props) => <Box component='em' fontStyle='italic' {...props} />,
56
56
  underlined: (props) => <Box component='span' {...props} />,
57
57
  class: (props) => <Box component='div' {...props} />,
58
+ 'code-block': (props) => (
59
+ <Box component='pre'>
60
+ <Box component='code' {...props} />
61
+ </Box>
62
+ ),
63
+ embed: ({ id, nodeId, nodeType, children, isInline, ...props }) => (
64
+ <Box component={isInline ? 'span' : 'div'} {...props}>
65
+ {id} {nodeId} {nodeType} {children}
66
+ </Box>
67
+ ),
58
68
  }
@@ -21,6 +21,7 @@ type BaseElementTypes =
21
21
  | 'table_row'
22
22
  | 'table_cell'
23
23
  | 'code'
24
+ | 'code-block'
24
25
  | 'bold'
25
26
  | 'italic'
26
27
  | 'underlined'
@@ -80,6 +81,15 @@ type IframeElement = {
80
81
  height?: number
81
82
  }
82
83
 
84
+ type EmbedElement = {
85
+ type: 'embed'
86
+ children: ElementOrTextNode[]
87
+ id: string
88
+ nodeId: string
89
+ nodeType: string
90
+ isInline?: boolean
91
+ }
92
+
83
93
  export type ElementNode =
84
94
  | SimpleElement
85
95
  | LinkElement
@@ -87,6 +97,8 @@ export type ElementNode =
87
97
  | VideoElement
88
98
  | IframeElement
89
99
  | ClassElement
100
+ | EmbedElement
101
+
90
102
  export type ElementOrTextNode = ElementNode | TextNode
91
103
 
92
104
  type RendererBase = { sx?: SxProps<Theme>; children?: React.ReactNode }
@@ -102,6 +114,7 @@ export type Renderers = {
102
114
  video: Renderer<VideoElement>
103
115
  iframe: Renderer<IframeElement>
104
116
  class: Renderer<ClassElement>
117
+ embed: Renderer<EmbedElement>
105
118
  }
106
119
 
107
120
  export type SxRenderer = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/hygraph-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.4-canary.8",
5
+ "version": "9.1.0-canary.15",
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/ecommerce-ui": "^9.0.4-canary.8",
16
- "@graphcommerce/eslint-config-pwa": "^9.0.4-canary.8",
17
- "@graphcommerce/graphql": "^9.0.4-canary.8",
18
- "@graphcommerce/image": "^9.0.4-canary.8",
19
- "@graphcommerce/next-ui": "^9.0.4-canary.8",
20
- "@graphcommerce/prettier-config-pwa": "^9.0.4-canary.8",
21
- "@graphcommerce/typescript-config-pwa": "^9.0.4-canary.8",
15
+ "@graphcommerce/ecommerce-ui": "^9.1.0-canary.15",
16
+ "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.15",
17
+ "@graphcommerce/graphql": "^9.1.0-canary.15",
18
+ "@graphcommerce/image": "^9.1.0-canary.15",
19
+ "@graphcommerce/next-ui": "^9.1.0-canary.15",
20
+ "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.15",
21
+ "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.15",
22
22
  "@mui/material": "^5.10.16",
23
23
  "next": "*",
24
24
  "react": "^18.2.0",