@graphcommerce/next-ui 8.0.0-canary.40 → 8.0.0-canary.69

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,12 +1,85 @@
1
1
  # Change Log
2
2
 
3
- ## 8.0.0-canary.40
3
+ ## 8.0.0-canary.69
4
+
5
+ ## 7.1.0-canary.68
6
+
7
+ ## 7.1.0-canary.67
4
8
 
5
9
  ### Patch Changes
6
10
 
7
- - [#2077](https://github.com/graphcommerce-org/graphcommerce/pull/2077) [`727d1004d`](https://github.com/graphcommerce-org/graphcommerce/commit/727d1004dfcb7dddf6e35b6b157a34491bb05cc6) - Fixed ItemScroller component className. Changed from SidebarSlider to ItemScroller ([@bramvanderholst](https://github.com/bramvanderholst))
11
+ - [#2108](https://github.com/graphcommerce-org/graphcommerce/pull/2108) [`7fc4bb9`](https://github.com/graphcommerce-org/graphcommerce/commit/7fc4bb925c59da46961c9656a2a67b37a9c2d652) - Removed the 'NoSSR' functionality from `<WaitForQueries/>` component as it slows down rendering. The 'feature' was necessary for the following use case: When hydrating a component that was server rendered and was living inside a `<Suspense />` component. It would cause an hydration error and this was the workaround. With useSuspenseQuery and React 18, this problem will not occur.
12
+ ([@StefanAngenent](https://github.com/StefanAngenent))
13
+
14
+ ## 7.1.0-canary.66
15
+
16
+ ## 7.1.0-canary.65
17
+
18
+ ## 7.1.0-canary.64
19
+
20
+ ## 7.1.0-canary.63
21
+
22
+ ## 7.1.0-canary.62
23
+
24
+ ## 7.1.0-canary.61
25
+
26
+ ### Patch Changes
27
+
28
+ - [#2125](https://github.com/graphcommerce-org/graphcommerce/pull/2125) [`5224ee500`](https://github.com/graphcommerce-org/graphcommerce/commit/5224ee5001c94a19f226fa36106e76739319297c) - If there is an open menu in an overlay, pressing the escape button now closes the menu instead of the overlay. ([@Jessevdpoel](https://github.com/Jessevdpoel))
29
+
30
+ ## 7.1.0-canary.60
31
+
32
+ ## 7.1.0-canary.59
33
+
34
+ ## 7.1.0-canary.58
35
+
36
+ ### Patch Changes
37
+
38
+ - [#2121](https://github.com/graphcommerce-org/graphcommerce/pull/2121) [`a5da6ffc8`](https://github.com/graphcommerce-org/graphcommerce/commit/a5da6ffc8be359e93c7bde986134f7162aae13b9) - Change the critical css injection location to be in the head instead of `<style>` tags in the body. It has a number of negative consequences, such as the famous "flash of unstyled content" (FOUC) and the re-paint and re-layout required. ([@paales](https://github.com/paales))
39
+
40
+ ## 7.1.0-canary.57
41
+
42
+ ## 7.1.0-canary.56
43
+
44
+ ### Patch Changes
8
45
 
9
- ## 7.1.0-canary.39
46
+ - [#2123](https://github.com/graphcommerce-org/graphcommerce/pull/2123) [`8ad60f255`](https://github.com/graphcommerce-org/graphcommerce/commit/8ad60f255b747858c35dd6b6cf5c90147d960082) - Fixed schema-dts dependency issue ([@bramvanderholst](https://github.com/bramvanderholst))
47
+
48
+ ## 7.1.0-canary.55
49
+
50
+ ### Patch Changes
51
+
52
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`da2135744`](https://github.com/graphcommerce-org/graphcommerce/commit/da2135744dddfa0d211c59589090ebb1977c38c9) - Added info icon for Snackbar when severity is set to info ([@bramvanderholst](https://github.com/bramvanderholst))
53
+
54
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`d608830ce`](https://github.com/graphcommerce-org/graphcommerce/commit/d608830ce77f85ff725cc106b9fc55a22012c74c) - Added ‘disableBackdropClick’ prop to MessageSnackbar to allow page interaction without closing the snackbar ([@bramvanderholst](https://github.com/bramvanderholst))
55
+
56
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`94e1ae811`](https://github.com/graphcommerce-org/graphcommerce/commit/94e1ae811fe9eb0051863e8be91c6399ddcdf22f) - Added DismissibleSnackbar component to allow messages to be shown only once ([@bramvanderholst](https://github.com/bramvanderholst))
57
+
58
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`53947d39f`](https://github.com/graphcommerce-org/graphcommerce/commit/53947d39f2f3ee578c14903c96a2b356d99d9475) - Implemented Message variant for RowColumnOne to show an important message which, after dismissing, will not show again ([@bramvanderholst](https://github.com/bramvanderholst))
59
+
60
+ ## 7.1.0-canary.54
61
+
62
+ ## 7.1.0-canary.53
63
+
64
+ ## 7.1.0-canary.52
65
+
66
+ ## 7.1.0-canary.51
67
+
68
+ ## 7.1.0-canary.50
69
+
70
+ ## 7.1.0-canary.49
71
+
72
+ ## 7.1.0-canary.48
73
+
74
+ ## 7.1.0-canary.47
75
+
76
+ ## 7.1.0-canary.46
77
+
78
+ ## 7.1.0-canary.45
79
+
80
+ ### Patch Changes
81
+
82
+ - [#2077](https://github.com/graphcommerce-org/graphcommerce/pull/2077) [`727d1004d`](https://github.com/graphcommerce-org/graphcommerce/commit/727d1004dfcb7dddf6e35b6b157a34491bb05cc6) - Fixed ItemScroller component className. Changed from SidebarSlider to ItemScroller ([@bramvanderholst](https://github.com/bramvanderholst))
10
83
 
11
84
  ## 7.1.0-canary.38
12
85
 
@@ -1516,31 +1589,31 @@
1516
1589
  All occurences of `<Trans>` and `t` need to be replaced:
1517
1590
 
1518
1591
  ```tsx
1519
- import { Trans, t } from '@lingui/macro'
1592
+ import { Trans, t } from "@lingui/macro";
1520
1593
 
1521
1594
  function MyComponent() {
1522
- const foo = 'bar'
1595
+ const foo = "bar";
1523
1596
  return (
1524
1597
  <div aria-label={t`Account ${foo}`}>
1525
1598
  <Trans>My Translation {foo}</Trans>
1526
1599
  </div>
1527
- )
1600
+ );
1528
1601
  }
1529
1602
  ```
1530
1603
 
1531
1604
  Needs to be replaced with:
1532
1605
 
1533
1606
  ```tsx
1534
- import { Trans } from '@lingui/react'
1535
- import { i18n } from '@lingui/core'
1607
+ import { Trans } from "@lingui/react";
1608
+ import { i18n } from "@lingui/core";
1536
1609
 
1537
1610
  function MyComponent() {
1538
- const foo = 'bar'
1611
+ const foo = "bar";
1539
1612
  return (
1540
1613
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1541
- <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1614
+ <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1542
1615
  </div>
1543
- )
1616
+ );
1544
1617
  }
1545
1618
  ```
1546
1619
 
package/JsonLd/JsonLd.tsx CHANGED
@@ -1,8 +1,6 @@
1
1
  import Head from 'next/head'
2
2
  import { safeJsonLdReplacer } from './safeJsonLdReplacer'
3
3
 
4
- export * as SchemaDts from 'schema-dts'
5
-
6
4
  export function JsonLd<T extends { '@type': string }>(props: {
7
5
  item: T & { '@context': 'https://schema.org' }
8
6
  }) {
@@ -311,7 +311,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
311
311
  const handleEscape = (e: KeyboardEvent | Event) => {
312
312
  if (active && (e as KeyboardEvent)?.key === 'Escape') closeOverlay()
313
313
  }
314
- useDomEvent(windowRef, 'keyup', handleEscape, { passive: true })
314
+ useDomEvent(windowRef, 'keydown', handleEscape, { passive: true })
315
315
 
316
316
  const dragging = useMotionValue(false)
317
317
  const scrollerElementRef = scrollerRef as React.RefObject<HTMLElement>
@@ -1,2 +1,3 @@
1
1
  export * from './OverlayBase'
2
2
  export * from './Overlay'
3
+ export * from './OverlayStickyBottom'
@@ -1,9 +1,8 @@
1
1
  import { GlobalStyles } from '@mui/material'
2
2
  import { LazyMotion } from 'framer-motion'
3
+ import { EmotionProvider, EmotionProviderProps } from '../Styles/EmotionProvider'
3
4
 
4
- export type GraphCommerceProviderProps = {
5
- children: React.ReactNode
6
- }
5
+ export type CssAndFramerMotionProviderProps = EmotionProviderProps
7
6
 
8
7
  /**
9
8
  * For [@emotion/core](https://emotion.sh/docs/introduction) and
@@ -12,22 +11,25 @@ export type GraphCommerceProviderProps = {
12
11
  * - Wrapps the app to lazily load framer-motion.
13
12
  * - Wrapps the app to have Emotion CSS styles
14
13
  */
15
- export function CssAndFramerMotionProvider({ children }: GraphCommerceProviderProps) {
14
+ export function CssAndFramerMotionProvider(props: CssAndFramerMotionProviderProps) {
15
+ const { children, emotionCache } = props
16
16
  return (
17
- <LazyMotion features={async () => (await import('./framerFeatures')).default} strict>
18
- {children}
19
- <GlobalStyles
20
- styles={{
21
- ':root': {
22
- '--client-size-y': '100vh',
23
- '--client-size-x': '100vw',
24
- '@supports(height: 100dvh)': {
25
- '--client-size-y': '100dvh',
26
- '--client-size-x': '100dvw',
17
+ <EmotionProvider emotionCache={emotionCache}>
18
+ <LazyMotion features={async () => (await import('./framerFeatures')).default} strict>
19
+ {children}
20
+ <GlobalStyles
21
+ styles={{
22
+ ':root': {
23
+ '--client-size-y': '100vh',
24
+ '--client-size-x': '100vw',
25
+ '@supports(height: 100dvh)': {
26
+ '--client-size-y': '100dvh',
27
+ '--client-size-x': '100dvw',
28
+ },
27
29
  },
28
- },
29
- }}
30
- />
31
- </LazyMotion>
30
+ }}
31
+ />
32
+ </LazyMotion>
33
+ </EmotionProvider>
32
34
  )
33
35
  }
@@ -0,0 +1,12 @@
1
+ import {
2
+ DismissibleSnackbar,
3
+ DismissibleSnackbarProps,
4
+ } from '../../../Snackbar/DismissibleSnackbar'
5
+
6
+ export type VariantMessageProps = DismissibleSnackbarProps
7
+
8
+ export function VariantMessage(props: VariantMessageProps) {
9
+ const { ...rest } = props
10
+
11
+ return <DismissibleSnackbar variant='pill' severity='info' disableBackdropClick {...rest} />
12
+ }
@@ -0,0 +1 @@
1
+ export * from './VariantMessage'
package/Row/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Row'
2
2
  export * from './ButtonLinkList'
3
3
  export * from './ColumnOne/ColumnOne'
4
+ export * from './ColumnOne/variant'
4
5
  export * from './ColumnOneBoxed/ColumnOneBoxed'
5
6
  export * from './ColumnOneCentered/ColumnOneCentered'
6
7
  export * from './ColumnThree/ColumnThree'
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { MessageSnackbar } from './MessageSnackbar'
3
+ import { MessageSnackbarProps } from './MessageSnackbarImpl'
4
+
5
+ export type DismissibleSnackbarProps = MessageSnackbarProps & {
6
+ id: string
7
+ storageType?: 'localStorage' | 'sessionStorage'
8
+ }
9
+ export function DismissibleSnackbar(props: DismissibleSnackbarProps) {
10
+ const { storageType = 'localStorage', id, onClose, ...rest } = props
11
+ const messageId = `DismissibleSnackbar_${id}`
12
+ const [open, setOpen] = useState(false)
13
+
14
+ useEffect(() => {
15
+ setOpen(!globalThis[storageType]?.getItem(messageId))
16
+ }, [messageId, storageType])
17
+
18
+ return (
19
+ <MessageSnackbar
20
+ {...rest}
21
+ open={open}
22
+ onClose={() => {
23
+ globalThis[storageType]?.setItem(messageId, `${Date.now()}`)
24
+ onClose?.()
25
+ }}
26
+ />
27
+ )
28
+ }
@@ -14,6 +14,7 @@ import React, { useEffect, useState } from 'react'
14
14
  import { IconSvg } from '../IconSvg'
15
15
  import { extendableComponent, breakpointVal } from '../Styles'
16
16
  import { iconClose, iconCheckmark, iconSadFace } from '../icons'
17
+ import iconInfo from '../icons/info.svg'
17
18
 
18
19
  type Size = 'normal' | 'wide'
19
20
  type Variant = 'contained' | 'pill'
@@ -34,6 +35,10 @@ type OwnerState = {
34
35
  size?: Size
35
36
  severity?: 'success' | 'info' | 'warning' | 'error'
36
37
  variant?: Variant
38
+ /**
39
+ * Setting this to true allows interaction with the rest of the page without closing the Snackbar
40
+ */
41
+ disableBackdropClick?: boolean
37
42
  }
38
43
 
39
44
  const name = 'MessageSnackbarImpl' as const
@@ -56,6 +61,7 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
56
61
  onClose,
57
62
  severity = 'info',
58
63
  sx,
64
+ disableBackdropClick,
59
65
  ...snackbarProps
60
66
  } = props
61
67
 
@@ -65,7 +71,11 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
65
71
  setShowSnackbar(!!open)
66
72
  }, [open])
67
73
 
68
- const hideSnackbar = () => {
74
+ const hideSnackbar = (event: React.SyntheticEvent | Event, reason?: string) => {
75
+ if (disableBackdropClick && reason === 'clickaway') {
76
+ return
77
+ }
78
+
69
79
  setShowSnackbar(false)
70
80
  onClose?.()
71
81
  }
@@ -80,6 +90,7 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
80
90
  }
81
91
 
82
92
  let icon = iconCheckmark
93
+ if (severity === 'info') icon = iconInfo
83
94
  if (severity === 'error') icon = iconSadFace
84
95
 
85
96
  return (
@@ -91,7 +102,13 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
91
102
  open={showSnackbar}
92
103
  autoHideDuration={autoHide ? 5000 : null}
93
104
  className={classes.root}
94
- sx={sx}
105
+ sx={[
106
+ {
107
+ pointerEvents: 'none',
108
+ '& > *': { pointerEvents: 'auto' },
109
+ },
110
+ ...(Array.isArray(sx) ? sx : [sx]),
111
+ ]}
95
112
  onClose={hideSnackbar}
96
113
  >
97
114
  <SnackbarContent
@@ -1,14 +1,14 @@
1
- import createCache from '@emotion/cache'
2
1
  import type { EmotionCache } from '@emotion/cache'
3
2
  import { CacheProvider } from '@emotion/react'
3
+ import { createEmotionCache } from './createEmotionCache'
4
4
 
5
- let muiCache: EmotionCache | undefined
6
- export const createMuiCache = () => {
7
- muiCache = createCache({ key: 'mui' })
8
- return muiCache
9
- }
5
+ export type EmotionProviderProps = { children?: React.ReactNode; emotionCache?: EmotionCache }
6
+
7
+ const clientSideEmotionCache = createEmotionCache()
10
8
 
11
9
  /** Provider that is supposed to be used in your `pages/_app.tsx` */
12
- export function EmotionProvider({ children }: { children: React.ReactNode }) {
13
- return <CacheProvider value={muiCache ?? createMuiCache()}>{children}</CacheProvider>
10
+ export function EmotionProvider(props: EmotionProviderProps) {
11
+ const { children, emotionCache = clientSideEmotionCache } = props
12
+
13
+ return <CacheProvider value={emotionCache}>{children}</CacheProvider>
14
14
  }
@@ -0,0 +1,14 @@
1
+ import createCache from '@emotion/cache'
2
+
3
+ export const createEmotionCache = () => {
4
+ let insertionPoint: HTMLElement | undefined
5
+
6
+ if (typeof window !== 'undefined') {
7
+ const emotionInsertionPoint = document.querySelector<HTMLMetaElement>(
8
+ 'meta[name="emotion-insertion-point"]',
9
+ )
10
+ insertionPoint = emotionInsertionPoint ?? undefined
11
+ }
12
+
13
+ return createCache({ key: 'mui-style', insertionPoint })
14
+ }
@@ -1,36 +1,46 @@
1
1
  import type { EmotionJSX } from '@emotion/react/types/jsx-namespace'
2
2
  import createEmotionServer from '@emotion/server/create-instance'
3
3
  // eslint-disable-next-line @next/next/no-document-import-in-page
4
+ import { AppType } from 'next/app'
4
5
  import type NextDocument from 'next/document'
5
6
  // eslint-disable-next-line @next/next/no-document-import-in-page
6
7
  import type { DocumentContext, DocumentInitialProps } from 'next/document'
7
- import { createMuiCache } from './EmotionProvider'
8
+ import { EmotionProviderProps } from './EmotionProvider'
9
+ import { createEmotionCache } from './createEmotionCache'
8
10
 
9
11
  export type EmotionCacheProps = { emotionStyleTags: EmotionJSX.Element[] }
10
12
 
11
13
  export function withEmotionCache(Document: typeof NextDocument): typeof NextDocument {
12
14
  return class DocumentWithEmotionCache extends Document {
13
15
  static async getInitialProps(ctx: DocumentContext) {
14
- const emotionServer = createEmotionServer(createMuiCache())
15
- const initialProps = await Document.getInitialProps(ctx)
16
+ const cache = createEmotionCache()
17
+ const emotionServer = createEmotionServer(cache)
18
+
19
+ const originalRenderPage = ctx.renderPage
20
+ ctx.renderPage = () =>
21
+ originalRenderPage({
22
+ enhanceApp:
23
+ (App: React.ComponentType<React.ComponentProps<AppType> & EmotionProviderProps>) =>
24
+ (props) => <App emotionCache={cache} {...props} />,
25
+ })
16
26
 
17
- const emotionStyleTags = emotionServer
18
- .extractCriticalToChunks(initialProps.html)
19
- .styles.filter(({ css }) => css !== '')
20
- .map((style) => (
21
- <style
22
- data-emotion={`${style.key} ${style.ids.join(' ')}`}
23
- key={style.key}
24
- // eslint-disable-next-line react/no-danger
25
- dangerouslySetInnerHTML={{ __html: style.css }}
26
- />
27
- ))
27
+ const initialProps = await Document.getInitialProps(ctx)
28
+ // This is important. It prevents Emotion to render invalid HTML.
29
+ // See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153
30
+ const emotionStyles = emotionServer.extractCriticalToChunks(initialProps.html)
31
+ const emotionStyleTags = emotionStyles.styles.map((style) => (
32
+ <style
33
+ data-emotion={`${style.key} ${style.ids.join(' ')}`}
34
+ key={style.key}
35
+ // eslint-disable-next-line react/no-danger
36
+ dangerouslySetInnerHTML={{ __html: style.css }}
37
+ />
38
+ ))
28
39
 
29
- const props: DocumentInitialProps & EmotionCacheProps = {
40
+ return {
30
41
  ...initialProps,
31
42
  emotionStyleTags,
32
43
  }
33
- return props
34
44
  }
35
45
  }
36
46
  }
@@ -22,8 +22,10 @@ export const MuiSnackbar: SnackbarVariants = [
22
22
  },
23
23
  },
24
24
  '&.MuiSnackbar-anchorOriginBottomCenter': {
25
- left: 0,
26
- right: 0,
25
+ [theme.breakpoints.up('md')]: {
26
+ left: theme.page.horizontal,
27
+ right: theme.page.horizontal,
28
+ },
27
29
  transform: 'unset',
28
30
  },
29
31
  }),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.0-canary.40",
5
+ "version": "8.0.0-canary.69",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -20,19 +20,19 @@
20
20
  "react-is": "^18.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/cookie": "^0.5.4",
23
+ "@types/cookie": "^0.6.0",
24
24
  "@types/react-is": "^18.2.4",
25
25
  "schema-dts": "^1.1.2",
26
- "typescript": "5.2.2"
26
+ "typescript": "5.3.3"
27
27
  },
28
28
  "peerDependencies": {
29
- "@graphcommerce/eslint-config-pwa": "8.0.0-canary.40",
30
- "@graphcommerce/framer-next-pages": "8.0.0-canary.40",
31
- "@graphcommerce/framer-scroller": "8.0.0-canary.40",
32
- "@graphcommerce/framer-utils": "8.0.0-canary.40",
33
- "@graphcommerce/image": "8.0.0-canary.40",
34
- "@graphcommerce/prettier-config-pwa": "8.0.0-canary.40",
35
- "@graphcommerce/typescript-config-pwa": "8.0.0-canary.40",
29
+ "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.69",
30
+ "@graphcommerce/framer-next-pages": "^8.0.0-canary.69",
31
+ "@graphcommerce/framer-scroller": "^8.0.0-canary.69",
32
+ "@graphcommerce/framer-utils": "^8.0.0-canary.69",
33
+ "@graphcommerce/image": "^8.0.0-canary.69",
34
+ "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.69",
35
+ "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.69",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",