@graphcommerce/next-ui 9.0.0-canary.73 → 9.0.0-canary.75

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,7 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.75
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2348](https://github.com/graphcommerce-org/graphcommerce/pull/2348) [`61b66ef`](https://github.com/graphcommerce-org/graphcommerce/commit/61b66efeab9b377c8daa322015d4b55cdf3db4c1) - Added a new OverlayHeader component to be used in combination with the Overlay component. ([@JoshuaS98](https://github.com/JoshuaS98))
8
+
9
+ ## 9.0.0-canary.74
10
+
3
11
  ## 9.0.0-canary.73
4
12
 
13
+ ### Patch Changes
14
+
15
+ - [`4c24225`](https://github.com/graphcommerce-org/graphcommerce/commit/4c24225f9f998cd40e71da06528eb9323e9b6752) - Created a new `memoDeep` function that is a deep compare variant of `React.memo`. Performance seems to be pretty good, but should only be used as a result of a profiling session. ([@paales](https://github.com/paales))
16
+
5
17
  ## 9.0.0-canary.72
6
18
 
7
19
  ## 9.0.0-canary.71
@@ -6,18 +6,24 @@ import { IconSvg, useIconSvgSize } from '../../IconSvg'
6
6
  import { useFabSize } from '../../Theme'
7
7
  import { iconClose } from '../../icons'
8
8
 
9
+ type LayoutHeaderCloseProps = {
10
+ onClose?: () => void
11
+ }
12
+
9
13
  export function useShowClose() {
10
14
  const { overlayGroup } = usePageContext()
11
15
  return !!overlayGroup
12
16
  }
13
17
 
14
- export function LayoutHeaderClose() {
18
+ export function LayoutHeaderClose(props: LayoutHeaderCloseProps) {
19
+ const { onClose } = props
15
20
  const { closeSteps } = usePageContext()
16
21
  const [disabled, setDisabled] = useState(false)
17
22
  const go = useGo(closeSteps * -1)
18
23
  const onClick = () => {
19
24
  setDisabled(true)
20
- go()
25
+
26
+ return onClose ? onClose() : go()
21
27
  }
22
28
 
23
29
  const fabSize = useFabSize('responsive')
@@ -0,0 +1,27 @@
1
+ import { LayoutHeaderProps, LayoutTitle, TitleProps } from '../../Layout'
2
+ import { LayoutHeaderClose } from '../../Layout/components/LayoutHeaderClose'
3
+ import { LayoutOverlayHeader } from '../../LayoutOverlay/components/LayoutOverlayHeader'
4
+
5
+ type OverlayHeaderProps = Omit<LayoutHeaderProps, 'hideBackButton' | 'switchPoint'> &
6
+ Pick<TitleProps, 'icon'> & { onClose: () => void }
7
+
8
+ export const OverlayHeader = (props: OverlayHeaderProps) => {
9
+ const { children, onClose, sx = [], icon, primary, secondary, ...rest } = props
10
+
11
+ return (
12
+ <LayoutOverlayHeader
13
+ noAlign
14
+ sx={[{ '&.noAlign': { mb: 0 } }, ...(Array.isArray(sx) ? sx : [sx])]}
15
+ switchPoint={-10000}
16
+ size='small'
17
+ hideBackButton
18
+ primary={primary ?? <LayoutHeaderClose onClose={onClose} />}
19
+ secondary={primary ? <LayoutHeaderClose onClose={onClose} /> : secondary}
20
+ {...rest}
21
+ >
22
+ <LayoutTitle size='small' component='span' icon={icon}>
23
+ {children}
24
+ </LayoutTitle>
25
+ </LayoutOverlayHeader>
26
+ )
27
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './OverlayBase'
2
2
  export * from './Overlay'
3
3
  export * from './OverlayStickyBottom'
4
+ export * from './OverlayHeader'
package/hooks/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from './useStorefrontConfig'
7
7
  export * from './useUrlQuery'
8
8
  export * from './useIsSsr'
9
9
  export * from './useLocale'
10
+ export * from './memoDeep'
@@ -0,0 +1,38 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { equal } from '@wry/equality'
3
+ import { FunctionComponent, memo, NamedExoticComponent } from 'react'
4
+
5
+ /**
6
+ * This is a deep comparison version of React's `memo` function.
7
+ *
8
+ * This method isn't too expensive to run, but will be rerun every time a parent component is rendered.
9
+ *
10
+ * This should probably only be used as the result of a performance profiling session.
11
+ */
12
+ export function memoDeep<P extends object>(
13
+ Component: FunctionComponent<P>,
14
+ measure: boolean = false,
15
+ ): NamedExoticComponent<P> {
16
+ return memo(
17
+ Component,
18
+ process.env.NODE_ENV === 'development' && measure
19
+ ? (prevProps, nextProps) => {
20
+ const start = performance.now()
21
+ const result = equal(prevProps, nextProps)
22
+ const ms = performance.now() - start
23
+
24
+ if (ms < 0.2) return result
25
+
26
+ console.log(`memoDeep took more than 0.2ms`, {
27
+ result,
28
+ ms,
29
+ Component,
30
+ prevProps,
31
+ nextProps,
32
+ })
33
+
34
+ return result
35
+ }
36
+ : equal,
37
+ )
38
+ }
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": "9.0.0-canary.73",
5
+ "version": "9.0.0-canary.75",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -26,13 +26,13 @@
26
26
  "typescript": "5.5.3"
27
27
  },
28
28
  "peerDependencies": {
29
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.73",
30
- "@graphcommerce/framer-next-pages": "^9.0.0-canary.73",
31
- "@graphcommerce/framer-scroller": "^9.0.0-canary.73",
32
- "@graphcommerce/framer-utils": "^9.0.0-canary.73",
33
- "@graphcommerce/image": "^9.0.0-canary.73",
34
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.73",
35
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.73",
29
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.75",
30
+ "@graphcommerce/framer-next-pages": "^9.0.0-canary.75",
31
+ "@graphcommerce/framer-scroller": "^9.0.0-canary.75",
32
+ "@graphcommerce/framer-utils": "^9.0.0-canary.75",
33
+ "@graphcommerce/image": "^9.0.0-canary.75",
34
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.75",
35
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.75",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",
package/server.ts CHANGED
@@ -6,3 +6,4 @@ export * from './utils/sitemap'
6
6
  export * from './utils/storefrontConfig'
7
7
  export * from './PageMeta/canonicalize'
8
8
  export * from './Document'
9
+ export * from './utils/cookie'