@graphcommerce/next-ui 4.10.0 → 4.11.0

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.
@@ -1,7 +1,6 @@
1
1
  import { Avatar, Box, Chip, SxProps, Theme } from '@mui/material'
2
- import { useRouter } from 'next/router'
3
- import { useMemo } from 'react'
4
2
  import { responsiveVal } from '../../Styles/responsiveVal'
3
+ import { useDateTimeFormat } from '../../hooks'
5
4
 
6
5
  export type BlogAuthorProps = {
7
6
  author: string
@@ -12,11 +11,7 @@ export type BlogAuthorProps = {
12
11
  export function BlogAuthor(props: BlogAuthorProps) {
13
12
  const { author, date, sx = [] } = props
14
13
 
15
- const { locale } = useRouter()
16
- const formatter = useMemo(
17
- () => new Intl.DateTimeFormat(locale, { month: 'long', day: 'numeric' }),
18
- [locale],
19
- )
14
+ const formatter = useDateTimeFormat({ month: 'long', day: 'numeric' })
20
15
 
21
16
  return (
22
17
  <Box
@@ -3,12 +3,12 @@ import PageLink from 'next/link'
3
3
  import React from 'react'
4
4
  import { extendableComponent } from '../../Styles'
5
5
  import { responsiveVal } from '../../Styles/responsiveVal'
6
+ import { useDateTimeFormat } from '../../hooks'
6
7
 
7
8
  export type BlogListItemProps = {
8
9
  asset: React.ReactNode
9
10
  url: string
10
11
  date: string
11
- locale: string
12
12
  title: string
13
13
  sx?: SxProps<Theme>
14
14
  }
@@ -18,13 +18,9 @@ const parts = ['item', 'date', 'asset', 'title'] as const
18
18
  const { classes } = extendableComponent(name, parts)
19
19
 
20
20
  export function BlogListItem(props: BlogListItemProps) {
21
- const { asset, url, date, locale, title, sx = [] } = props
21
+ const { asset, url, date, title, sx = [] } = props
22
22
 
23
- const formatter = new Intl.DateTimeFormat(locale, {
24
- year: 'numeric',
25
- month: 'long',
26
- day: 'numeric',
27
- })
23
+ const formatter = useDateTimeFormat({ year: 'numeric', month: 'long', day: 'numeric' })
28
24
 
29
25
  return (
30
26
  <Box
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1524](https://github.com/graphcommerce-org/graphcommerce/pull/1524) [`9ec0338df`](https://github.com/graphcommerce-org/graphcommerce/commit/9ec0338dfe34d37b0f2c24e36ffa6ed13ea1145e) Thanks [@paales](https://github.com/paales)! - feat: Added useDateTimeFormat and useNumberFormat which automatically use the locales from nextjs.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @graphcommerce/framer-scroller@2.1.18
13
+
3
14
  ## 4.10.0
4
15
 
5
16
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { useUrlQuery } from '../../useUrlQuery/useUrlQuery'
1
+ import { useUrlQuery } from '../../hooks/useUrlQuery'
2
2
  import { LayoutOverlay, LayoutOverlayProps } from '../components/LayoutOverlay'
3
3
 
4
4
  export type LayoutOverlayState = Omit<
package/hooks/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './useDateTimeFormat'
2
+ export * from './useNumberFormat'
3
+ export * from './useUrlQuery'
@@ -0,0 +1,10 @@
1
+ import { useRouter } from 'next/router'
2
+ import { useMemo } from 'react'
3
+
4
+ export type DateTimeFormatProps = Intl.DateTimeFormatOptions
5
+
6
+ export function useDateTimeFormat(props?: DateTimeFormatProps) {
7
+ const { locale } = useRouter()
8
+ const formatter = useMemo(() => new Intl.DateTimeFormat(locale, props), [locale, props])
9
+ return formatter
10
+ }
@@ -0,0 +1,10 @@
1
+ import { useRouter } from 'next/router'
2
+ import { useMemo } from 'react'
3
+
4
+ export type NumberFormatProps = Intl.NumberFormatOptions
5
+
6
+ export function useNumberFormat(props?: NumberFormatProps) {
7
+ const { locale } = useRouter()
8
+ const formatter = useMemo(() => new Intl.NumberFormat(locale, props), [locale, props])
9
+ return formatter
10
+ }
package/index.ts CHANGED
@@ -50,6 +50,6 @@ export * from './Theme'
50
50
  export * from './TimeAgo/TimeAgo'
51
51
  export * from './ToggleButton/ToggleButton'
52
52
  export * from './ToggleButtonGroup/ToggleButtonGroup'
53
- export * from './useUrlQuery/useUrlQuery'
53
+ export * from './hooks'
54
54
  export * from './UspList/UspList'
55
55
  export * from './UspList/UspListItem'
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": "4.10.0",
5
+ "version": "4.11.0",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -20,7 +20,7 @@
20
20
  "@emotion/server": "^11.4.0",
21
21
  "@emotion/styled": "^11.6.0",
22
22
  "@graphcommerce/framer-next-pages": "3.2.3",
23
- "@graphcommerce/framer-scroller": "2.1.17",
23
+ "@graphcommerce/framer-scroller": "2.1.18",
24
24
  "@graphcommerce/framer-utils": "3.1.4",
25
25
  "@graphcommerce/image": "3.1.7",
26
26
  "react-is": "^18.1.0",