@graphcommerce/next-ui 8.1.0-canary.2 → 8.1.0-canary.5
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/ActionCard/ActionCardListForm.tsx +41 -33
- package/CHANGELOG.md +124 -1
- package/FramerScroller/SidebarGallery.tsx +5 -8
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +1 -0
- package/LazyHydrate/LazyHydrate.tsx +17 -7
- package/Navigation/components/NavigationOverlay.tsx +1 -0
- package/Overlay/components/OverlayBase.tsx +5 -3
- package/Overlay/components/OverlaySsr.tsx +1 -0
- package/Styles/createEmotionCache.ts +1 -1
- package/TimeAgo/TimeAgo.tsx +8 -2
- package/hooks/index.ts +2 -0
- package/hooks/useDateTimeFormat.ts +4 -6
- package/hooks/useLocale.ts +7 -0
- package/hooks/useMatchMedia.ts +20 -1
- package/hooks/useNumberFormat.ts +3 -8
- package/hooks/useSsr.ts +11 -0
- package/package.json +9 -9
- package/types.d.ts +0 -6
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Controller,
|
|
4
|
+
ControllerProps,
|
|
5
|
+
FieldValues,
|
|
6
|
+
useController,
|
|
7
|
+
} from '@graphcommerce/react-hook-form'
|
|
3
8
|
import React, { MouseEventHandler } from 'react'
|
|
4
9
|
import { ActionCardProps } from './ActionCard'
|
|
5
10
|
import { ActionCardList, ActionCardListProps } from './ActionCardList'
|
|
@@ -43,38 +48,41 @@ export function ActionCardListForm<
|
|
|
43
48
|
: selectValues === itemValue
|
|
44
49
|
}
|
|
45
50
|
|
|
51
|
+
const {
|
|
52
|
+
field: { onChange, value, ref },
|
|
53
|
+
fieldState,
|
|
54
|
+
formState,
|
|
55
|
+
} = useController({
|
|
56
|
+
...props,
|
|
57
|
+
control,
|
|
58
|
+
name,
|
|
59
|
+
defaultValue,
|
|
60
|
+
rules: { required: errorMessage || required, ...rules },
|
|
61
|
+
})
|
|
62
|
+
|
|
46
63
|
return (
|
|
47
|
-
<
|
|
48
|
-
{...
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
onReset={(e) => {
|
|
71
|
-
e.preventDefault()
|
|
72
|
-
onChange(null)
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
))}
|
|
76
|
-
</ActionCardList>
|
|
77
|
-
)}
|
|
78
|
-
/>
|
|
64
|
+
<ActionCardList
|
|
65
|
+
{...other}
|
|
66
|
+
multiple={multiple}
|
|
67
|
+
required={required}
|
|
68
|
+
value={value}
|
|
69
|
+
ref={ref}
|
|
70
|
+
onChange={(_, incomming) => onChange(incomming)}
|
|
71
|
+
error={formState.isSubmitted && !!fieldState.error}
|
|
72
|
+
errorMessage={fieldState.error?.message}
|
|
73
|
+
>
|
|
74
|
+
{items.map((item) => (
|
|
75
|
+
<RenderItem
|
|
76
|
+
{...item}
|
|
77
|
+
key={item.value ?? ''}
|
|
78
|
+
value={item.value}
|
|
79
|
+
selected={onSelect(item.value, value)}
|
|
80
|
+
onReset={(e) => {
|
|
81
|
+
e.preventDefault()
|
|
82
|
+
onChange(null)
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
))}
|
|
86
|
+
</ActionCardList>
|
|
79
87
|
)
|
|
80
88
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,129 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 8.1.0-canary.
|
|
3
|
+
## 8.1.0-canary.5
|
|
4
|
+
|
|
5
|
+
## 8.0.6-canary.4
|
|
6
|
+
|
|
7
|
+
## 8.0.6-canary.3
|
|
8
|
+
|
|
9
|
+
## 8.0.6-canary.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Added useIsSSR hook that will properly resolve when the page is rendered on the server and on first render, but will return false when a component is rendered on the client directly.
|
|
14
|
+
([@FrankHarland](https://github.com/FrankHarland))
|
|
15
|
+
|
|
16
|
+
- [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
|
|
17
|
+
([@FrankHarland](https://github.com/FrankHarland))
|
|
18
|
+
|
|
19
|
+
## 8.0.6-canary.1
|
|
20
|
+
|
|
21
|
+
## 8.0.6-canary.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#2196](https://github.com/graphcommerce-org/graphcommerce/pull/2196) [`84c50e4`](https://github.com/graphcommerce-org/graphcommerce/commit/84c50e49a1a7f154d4a8f4045c37e773e20283ad) - Allow Lingui to use linguiLocale with country identifiers like `en-us`, it would always load `en` in this case. Introced a new `useLocale` hook to use the correct locale string to use in Intl methods.
|
|
26
|
+
([@paales](https://github.com/paales))
|
|
27
|
+
|
|
28
|
+
## 8.0.5
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [#2236](https://github.com/graphcommerce-org/graphcommerce/pull/2236) [`85fb916`](https://github.com/graphcommerce-org/graphcommerce/commit/85fb916e5ec2a1456a93a59bf92a5f414fee8595) - Solve issue where the inert prop wouldnt be properly forwarded
|
|
33
|
+
([@paales](https://github.com/paales))
|
|
34
|
+
|
|
35
|
+
- [#2235](https://github.com/graphcommerce-org/graphcommerce/pull/2235) [`de99691`](https://github.com/graphcommerce-org/graphcommerce/commit/de9969155e271cc2535147479b80b602a1b9c335) - The Lazyhydrate component to accepts any BoxProps. Replaced `<section>` with a `<Box>` so it doesn't hold symantic meaning.
|
|
36
|
+
|
|
37
|
+
Please note: If you've used child selectors to style the section, please make sure you update your styles. ([@carlocarels90](https://github.com/carlocarels90))
|
|
38
|
+
|
|
39
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`6f3fe60`](https://github.com/graphcommerce-org/graphcommerce/commit/6f3fe60441762d55cb46d587279121e8fe469cdd) - Decreased layout shift on product pages by reserving space for sidebar
|
|
40
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
41
|
+
|
|
42
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`cde3c31`](https://github.com/graphcommerce-org/graphcommerce/commit/cde3c310abf2ac3c82d1062d5fb0a4c00ba50cff) - Removed unnecessary vendor prefixes
|
|
43
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
44
|
+
|
|
45
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`4c83636`](https://github.com/graphcommerce-org/graphcommerce/commit/4c836366c324881ee5121c645c5f94fc60e3ebb3) - Prevent horizontal scrollbar on small screens when using SidebarGallery
|
|
46
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
47
|
+
|
|
48
|
+
- [#2230](https://github.com/graphcommerce-org/graphcommerce/pull/2230) [`1da6b82`](https://github.com/graphcommerce-org/graphcommerce/commit/1da6b82dbb7e1543542d809ea625a8867643ea68) - Fix menu item visibility in accessability tree
|
|
49
|
+
([@JoshuaS98](https://github.com/JoshuaS98))
|
|
50
|
+
|
|
51
|
+
## 8.0.5-canary.10
|
|
52
|
+
|
|
53
|
+
## 8.0.5-canary.9
|
|
54
|
+
|
|
55
|
+
## 8.0.5-canary.8
|
|
56
|
+
|
|
57
|
+
## 8.0.5-canary.7
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`6f3fe60`](https://github.com/graphcommerce-org/graphcommerce/commit/6f3fe60441762d55cb46d587279121e8fe469cdd) - Decreased layout shift on product pages by reserving space for sidebar
|
|
62
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
63
|
+
|
|
64
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`cde3c31`](https://github.com/graphcommerce-org/graphcommerce/commit/cde3c310abf2ac3c82d1062d5fb0a4c00ba50cff) - Removed unnecessary vendor prefixes
|
|
65
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
66
|
+
|
|
67
|
+
- [#2241](https://github.com/graphcommerce-org/graphcommerce/pull/2241) [`4c83636`](https://github.com/graphcommerce-org/graphcommerce/commit/4c836366c324881ee5121c645c5f94fc60e3ebb3) - Prevent horizontal scrollbar on small screens when using SidebarGallery
|
|
68
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
69
|
+
|
|
70
|
+
## 8.0.5-canary.6
|
|
71
|
+
|
|
72
|
+
## 8.0.5-canary.5
|
|
73
|
+
|
|
74
|
+
## 8.0.5-canary.4
|
|
75
|
+
|
|
76
|
+
## 8.0.5-canary.3
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- [#2236](https://github.com/graphcommerce-org/graphcommerce/pull/2236) [`85fb916`](https://github.com/graphcommerce-org/graphcommerce/commit/85fb916e5ec2a1456a93a59bf92a5f414fee8595) - Solve issue where the inert prop wouldnt be properly forwarded
|
|
81
|
+
([@paales](https://github.com/paales))
|
|
82
|
+
|
|
83
|
+
## 8.0.5-canary.2
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- [#2235](https://github.com/graphcommerce-org/graphcommerce/pull/2235) [`de99691`](https://github.com/graphcommerce-org/graphcommerce/commit/de9969155e271cc2535147479b80b602a1b9c335) - The Lazyhydrate component to accepts any BoxProps. Replaced `<section>` with a `<Box>` so it doesn't hold symantic meaning.
|
|
88
|
+
|
|
89
|
+
Please note: If you've used child selectors to style the section, please make sure you update your styles. ([@carlocarels90](https://github.com/carlocarels90))
|
|
90
|
+
|
|
91
|
+
## 8.0.5-canary.1
|
|
92
|
+
|
|
93
|
+
## 8.0.5-canary.0
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- [#2230](https://github.com/graphcommerce-org/graphcommerce/pull/2230) [`1da6b82`](https://github.com/graphcommerce-org/graphcommerce/commit/1da6b82dbb7e1543542d809ea625a8867643ea68) - Fix menu item visibility in accessability tree
|
|
98
|
+
([@JoshuaS98](https://github.com/JoshuaS98))
|
|
99
|
+
|
|
100
|
+
## 8.0.4
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- [#2228](https://github.com/graphcommerce-org/graphcommerce/pull/2228) [`0c0cacb`](https://github.com/graphcommerce-org/graphcommerce/commit/0c0cacb8725f0a626ea5d3acf154d83c433c3eb7) - apply correct type for the inert property
|
|
105
|
+
([@carlocarels90](https://github.com/carlocarels90))
|
|
106
|
+
|
|
107
|
+
## 8.0.4-canary.1
|
|
108
|
+
|
|
109
|
+
## 8.0.4-canary.0
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- [#2228](https://github.com/graphcommerce-org/graphcommerce/pull/2228) [`0c0cacb`](https://github.com/graphcommerce-org/graphcommerce/commit/0c0cacb8725f0a626ea5d3acf154d83c433c3eb7) - apply correct type for the inert property
|
|
114
|
+
([@carlocarels90](https://github.com/carlocarels90))
|
|
115
|
+
|
|
116
|
+
## 8.0.3
|
|
117
|
+
|
|
118
|
+
## 8.0.3-canary.6
|
|
119
|
+
|
|
120
|
+
## 8.0.3-canary.5
|
|
121
|
+
|
|
122
|
+
## 8.0.3-canary.4
|
|
123
|
+
|
|
124
|
+
## 8.0.3-canary.3
|
|
125
|
+
|
|
126
|
+
## 8.0.3-canary.2
|
|
4
127
|
|
|
5
128
|
## 8.0.3-canary.1
|
|
6
129
|
|
|
@@ -144,8 +144,9 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
144
144
|
display: 'grid',
|
|
145
145
|
gridTemplate: '"left" "right"',
|
|
146
146
|
[theme.breakpoints.up('md')]: {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
gridTemplate: `"left right" / 1fr calc(${responsiveVal(300, 500, theme.breakpoints.values.lg)} + ${
|
|
148
|
+
theme.page.horizontal
|
|
149
|
+
} * 2)`,
|
|
149
150
|
},
|
|
150
151
|
background:
|
|
151
152
|
theme.palette.mode === 'light'
|
|
@@ -159,6 +160,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
159
160
|
marginTop: `calc(${theme.appShell.headerHeightSm} * -1)`,
|
|
160
161
|
[theme.breakpoints.up('md')]: {
|
|
161
162
|
marginTop: `calc(${theme.appShell.headerHeightMd} * -1 - ${theme.spacings.lg})`,
|
|
163
|
+
gridTemplateColumns: '1fr auto',
|
|
162
164
|
},
|
|
163
165
|
paddingRight: 0,
|
|
164
166
|
},
|
|
@@ -178,7 +180,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
178
180
|
position: 'relative',
|
|
179
181
|
paddingTop: `min(${ratio}, ${maxHeight})`,
|
|
180
182
|
[theme.breakpoints.down('md')]: {
|
|
181
|
-
width: '
|
|
183
|
+
width: '100%',
|
|
182
184
|
},
|
|
183
185
|
[theme.breakpoints.up('md')]: {
|
|
184
186
|
height: `calc(${dvh(100)} - ${theme.appShell.headerHeightMd} - ${
|
|
@@ -348,11 +350,6 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
348
350
|
justifyItems: 'start',
|
|
349
351
|
alignContent: 'center',
|
|
350
352
|
position: 'relative',
|
|
351
|
-
[theme.breakpoints.up('md')]: {
|
|
352
|
-
width: `calc(${responsiveVal(300, 500, theme.breakpoints.values.lg)} + ${
|
|
353
|
-
theme.page.horizontal
|
|
354
|
-
} * 2)`,
|
|
355
|
-
},
|
|
356
353
|
},
|
|
357
354
|
zoomed && {
|
|
358
355
|
[theme.breakpoints.up('md')]: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Box, BoxProps } from '@mui/material'
|
|
1
2
|
import React, { useState, useRef, startTransition, useLayoutEffect, useEffect } from 'react'
|
|
2
3
|
|
|
3
4
|
// Make sure the server doesn't choke on the useLayoutEffect
|
|
4
5
|
export const useLayoutEffect2 = typeof window !== 'undefined' ? useLayoutEffect : useEffect
|
|
5
6
|
|
|
6
|
-
export type LazyHydrateProps = {
|
|
7
|
+
export type LazyHydrateProps = BoxProps<'div'> & {
|
|
7
8
|
/**
|
|
8
9
|
* The content is always rendered on the server and on the client it uses the server rendered HTML until it is hydrated.
|
|
9
10
|
*/
|
|
@@ -25,8 +26,8 @@ export type LazyHydrateProps = {
|
|
|
25
26
|
* This can be a way to improve the TBT of a page.
|
|
26
27
|
*/
|
|
27
28
|
export function LazyHydrate(props: LazyHydrateProps) {
|
|
28
|
-
const { hydrated, children } = props
|
|
29
|
-
const rootRef = useRef<
|
|
29
|
+
const { hydrated, children, ...elementProps } = props
|
|
30
|
+
const rootRef = useRef<HTMLDivElement>(null)
|
|
30
31
|
|
|
31
32
|
const [isHydrated, setIsHydrated] = useState(hydrated || false)
|
|
32
33
|
if (!isHydrated && hydrated) setIsHydrated(true)
|
|
@@ -58,15 +59,24 @@ export function LazyHydrate(props: LazyHydrateProps) {
|
|
|
58
59
|
}, [hydrated, isHydrated])
|
|
59
60
|
|
|
60
61
|
if (isHydrated) {
|
|
61
|
-
return <
|
|
62
|
+
return <Box {...elementProps}>{children}</Box>
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
if (typeof window === 'undefined') {
|
|
65
|
-
return
|
|
66
|
+
return (
|
|
67
|
+
<Box data-lazy-hydrate {...elementProps}>
|
|
68
|
+
{children}
|
|
69
|
+
</Box>
|
|
70
|
+
)
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
return (
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
<Box
|
|
75
|
+
ref={rootRef}
|
|
76
|
+
// eslint-disable-next-line react/no-danger
|
|
77
|
+
dangerouslySetInnerHTML={{ __html: '' }}
|
|
78
|
+
suppressHydrationWarning
|
|
79
|
+
{...elementProps}
|
|
80
|
+
/>
|
|
71
81
|
)
|
|
72
82
|
}
|
|
@@ -52,6 +52,7 @@ export type LayoutOverlayBaseProps = {
|
|
|
52
52
|
isPresent: boolean
|
|
53
53
|
safeToRemove?: (() => void) | null | undefined
|
|
54
54
|
overlayPaneProps?: MotionProps
|
|
55
|
+
disableInert?: boolean
|
|
55
56
|
|
|
56
57
|
/* For `variantSm='left|right' */
|
|
57
58
|
widthSm?: string | false
|
|
@@ -109,6 +110,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
109
110
|
isPresent,
|
|
110
111
|
safeToRemove,
|
|
111
112
|
overlayPaneProps,
|
|
113
|
+
disableInert,
|
|
112
114
|
widthMd = 'max(800px, 50vw)',
|
|
113
115
|
widthSm = 'max(300px, 80vw)',
|
|
114
116
|
} = props
|
|
@@ -247,7 +249,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
247
249
|
const cancelY = scroll.y.on('change', handleScroll)
|
|
248
250
|
|
|
249
251
|
const ro = new ResizeObserver(handleResize)
|
|
250
|
-
ro.observe(scrollerRef.current)
|
|
252
|
+
if (scrollerRef.current) ro.observe(scrollerRef.current)
|
|
251
253
|
ro.observe(beforeRef.current)
|
|
252
254
|
ro.observe(overlayPaneRef.current)
|
|
253
255
|
ro.observe(overlayRef.current)
|
|
@@ -363,7 +365,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
363
365
|
return (
|
|
364
366
|
<>
|
|
365
367
|
<MotionDiv
|
|
366
|
-
inert={active ? undefined : 'true'}
|
|
368
|
+
inert={active ? undefined : ('true' as unknown as boolean)}
|
|
367
369
|
className={classes.backdrop}
|
|
368
370
|
style={{ opacity: positions.open.visible }}
|
|
369
371
|
sx={[
|
|
@@ -385,7 +387,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
385
387
|
]}
|
|
386
388
|
/>
|
|
387
389
|
<Scroller
|
|
388
|
-
inert={active ? undefined : 'true'}
|
|
390
|
+
inert={disableInert || active ? undefined : ('true' as unknown as boolean)}
|
|
389
391
|
className={`${classes.scroller} ${className ?? ''}`}
|
|
390
392
|
grid={false}
|
|
391
393
|
onClick={onClickAway}
|
|
@@ -31,6 +31,7 @@ export function OverlaySsr(props: OverlayProps) {
|
|
|
31
31
|
<OverlayContainer active={active} hidden={hidden}>
|
|
32
32
|
<ScrollerProvider {...variantsToScrollSnapType(props)}>
|
|
33
33
|
<OverlayBase
|
|
34
|
+
disableInert
|
|
34
35
|
variantMd={variantMd}
|
|
35
36
|
variantSm={variantSm}
|
|
36
37
|
active={active}
|
package/TimeAgo/TimeAgo.tsx
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { useLocale } from '../hooks/useLocale'
|
|
2
|
+
|
|
1
3
|
export type TimeAgoProps = {
|
|
2
4
|
date: Date
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated No longer used
|
|
7
|
+
*/
|
|
3
8
|
locale?: string
|
|
4
9
|
}
|
|
5
10
|
|
|
6
11
|
export function TimeAgo(props: TimeAgoProps) {
|
|
7
|
-
const { date
|
|
12
|
+
const { date } = props
|
|
8
13
|
const msPerMinute = 60 * 1000
|
|
9
14
|
const msPerHour = msPerMinute * 60
|
|
10
15
|
const msPerDay = msPerHour * 24
|
|
11
16
|
|
|
12
17
|
const timestamp = date.getTime()
|
|
13
18
|
const elapsed = Date.now() - timestamp
|
|
14
|
-
|
|
19
|
+
|
|
20
|
+
const rtf = new Intl.RelativeTimeFormat(useLocale(), { numeric: 'auto' })
|
|
15
21
|
|
|
16
22
|
if (elapsed < msPerMinute) {
|
|
17
23
|
return <span>{rtf.format(-Math.floor(elapsed / 1000), 'seconds')}</span>
|
package/hooks/index.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { normalizeLocale } from '@graphcommerce/lingui-next'
|
|
2
|
-
import { useRouter } from 'next/router'
|
|
3
2
|
import { useMemo } from 'react'
|
|
3
|
+
import { useStorefrontConfig } from './useStorefrontConfig'
|
|
4
|
+
import { useLocale } from '@graphcommerce/next-ui'
|
|
4
5
|
|
|
5
6
|
export type DateTimeFormatProps = Intl.DateTimeFormatOptions
|
|
6
7
|
|
|
7
8
|
export function useDateTimeFormat(props?: DateTimeFormatProps) {
|
|
8
|
-
const
|
|
9
|
+
const locale = useLocale()
|
|
9
10
|
|
|
10
|
-
const formatter = useMemo(
|
|
11
|
-
() => new Intl.DateTimeFormat(normalizeLocale(locale), props),
|
|
12
|
-
[locale, props],
|
|
13
|
-
)
|
|
11
|
+
const formatter = useMemo(() => new Intl.DateTimeFormat(locale, props), [locale, props])
|
|
14
12
|
return formatter
|
|
15
13
|
}
|
package/hooks/useMatchMedia.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { Breakpoint, useTheme } from '@mui/material'
|
|
2
|
-
import {
|
|
2
|
+
import { useMotionValue } from 'framer-motion'
|
|
3
|
+
import { useEffect, useMemo } from 'react'
|
|
4
|
+
|
|
5
|
+
export function useMatchMediaMotionValue(
|
|
6
|
+
direction: 'up' | 'down',
|
|
7
|
+
breakpointKey: number | Breakpoint,
|
|
8
|
+
) {
|
|
9
|
+
const matchValue = useMotionValue(false)
|
|
10
|
+
const theme = useTheme()
|
|
11
|
+
const query = theme.breakpoints[direction](breakpointKey).replace(/^@media( ?)/m, '')
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const mql = globalThis?.matchMedia(query)
|
|
15
|
+
const matcher = (e: MediaQueryListEvent) => matchValue.set(e.matches)
|
|
16
|
+
mql.addEventListener('change', matcher)
|
|
17
|
+
return () => mql.removeEventListener('change', matcher)
|
|
18
|
+
}, [matchValue, query])
|
|
19
|
+
|
|
20
|
+
return matchValue
|
|
21
|
+
}
|
|
3
22
|
|
|
4
23
|
export function useMatchMedia() {
|
|
5
24
|
const theme = useTheme()
|
package/hooks/useNumberFormat.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { normalizeLocale } from '@graphcommerce/lingui-next'
|
|
2
|
-
import { useRouter } from 'next/router'
|
|
3
1
|
import { useMemo } from 'react'
|
|
2
|
+
import { useLocale } from './useLocale'
|
|
4
3
|
|
|
5
4
|
export type NumberFormatProps = Intl.NumberFormatOptions
|
|
6
5
|
|
|
7
6
|
export function useNumberFormat(props?: NumberFormatProps) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const formatter = useMemo(
|
|
11
|
-
() => new Intl.NumberFormat(normalizeLocale(locale), props),
|
|
12
|
-
[locale, props],
|
|
13
|
-
)
|
|
7
|
+
const locale = useLocale()
|
|
8
|
+
const formatter = useMemo(() => new Intl.NumberFormat(locale, props), [locale, props])
|
|
14
9
|
return formatter
|
|
15
10
|
}
|
package/hooks/useSsr.ts
ADDED
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.1.0-canary.
|
|
5
|
+
"version": "8.1.0-canary.5",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"typescript": "5.3.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
29
|
-
"@graphcommerce/framer-next-pages": "^8.1.0-canary.
|
|
30
|
-
"@graphcommerce/framer-scroller": "^8.1.0-canary.
|
|
31
|
-
"@graphcommerce/framer-utils": "^8.1.0-canary.
|
|
32
|
-
"@graphcommerce/image": "^8.1.0-canary.
|
|
33
|
-
"@graphcommerce/lingui-next": "^8.1.0-canary.
|
|
34
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
35
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
28
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.5",
|
|
29
|
+
"@graphcommerce/framer-next-pages": "^8.1.0-canary.5",
|
|
30
|
+
"@graphcommerce/framer-scroller": "^8.1.0-canary.5",
|
|
31
|
+
"@graphcommerce/framer-utils": "^8.1.0-canary.5",
|
|
32
|
+
"@graphcommerce/image": "^8.1.0-canary.5",
|
|
33
|
+
"@graphcommerce/lingui-next": "^8.1.0-canary.5",
|
|
34
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.5",
|
|
35
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.5",
|
|
36
36
|
"@lingui/core": "^4.2.1",
|
|
37
37
|
"@lingui/macro": "^4.2.1",
|
|
38
38
|
"@lingui/react": "^4.2.1",
|
package/types.d.ts
CHANGED
|
@@ -6,12 +6,6 @@ import './Theme/createTheme'
|
|
|
6
6
|
// eslint-disable-next-line react/no-typos
|
|
7
7
|
import 'react'
|
|
8
8
|
|
|
9
|
-
declare module 'react' {
|
|
10
|
-
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
|
11
|
-
inert?: 'true'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
declare module '*.po' {
|
|
16
10
|
const messages: Record<
|
|
17
11
|
string,
|