@graphcommerce/next-ui 4.4.0 → 4.5.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.
- package/CHANGELOG.md +18 -0
- package/Form/Form.tsx +3 -1
- package/Layout/components/LayoutProvider.tsx +1 -0
- package/LayoutOverlay/test/LayoutOverlayDemo.tsx +2 -14
- package/Snackbar/ErrorSnackbar.tsx +24 -0
- package/TextInputNumber/TextInputNumber.tsx +1 -1
- package/index.ts +3 -1
- package/package.json +12 -12
- package/useUrlQuery/useUrlQuery.tsx +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - Added a new <ErrorSnackbar /> component to more easily create an error snackbar.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - <FormDiv contained/> would throw an error that contained isn't a recognized prop
|
|
12
|
+
|
|
13
|
+
* [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
|
|
14
|
+
|
|
15
|
+
* Updated dependencies [[`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9)]:
|
|
16
|
+
- @graphcommerce/framer-next-pages@3.1.4
|
|
17
|
+
- @graphcommerce/framer-scroller@2.1.3
|
|
18
|
+
- @graphcommerce/framer-utils@3.1.1
|
|
19
|
+
- @graphcommerce/image@3.1.2
|
|
20
|
+
|
|
3
21
|
## 4.4.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/Form/Form.tsx
CHANGED
|
@@ -34,4 +34,6 @@ export const Form = styled('form', {
|
|
|
34
34
|
shouldForwardProp: (prop) => prop !== 'contained',
|
|
35
35
|
})<FormStyleProps>(styles)
|
|
36
36
|
|
|
37
|
-
export const FormDiv = styled('div'
|
|
37
|
+
export const FormDiv = styled('div', {
|
|
38
|
+
shouldForwardProp: (prop) => prop !== 'contained',
|
|
39
|
+
})<FormStyleProps>(styles)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ParsedUrlQuery } from 'querystring'
|
|
2
|
-
import { useRouter } from 'next/router'
|
|
3
1
|
import { useCallback } from 'react'
|
|
2
|
+
import { useUrlQuery } from '../../useUrlQuery/useUrlQuery'
|
|
4
3
|
import { LayoutOverlay, LayoutOverlayProps } from '../components/LayoutOverlay'
|
|
5
4
|
|
|
6
5
|
export type LayoutOverlayState = Omit<
|
|
@@ -8,19 +7,8 @@ export type LayoutOverlayState = Omit<
|
|
|
8
7
|
'children' | 'sx' | 'sxBackdrop' | 'mdSpacingTop' | 'smSpacingTop'
|
|
9
8
|
>
|
|
10
9
|
|
|
11
|
-
function useQueryState<T extends ParsedUrlQuery>(builder: (query: T) => T) {
|
|
12
|
-
const { query, replace } = useRouter()
|
|
13
|
-
const queryState = builder(query as T)
|
|
14
|
-
|
|
15
|
-
const setRouterQuery = (partialQuery: T) => {
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
17
|
-
replace({ query: { ...queryState, ...partialQuery } }, undefined, { shallow: true })
|
|
18
|
-
}
|
|
19
|
-
return [queryState, setRouterQuery] as const
|
|
20
|
-
}
|
|
21
|
-
|
|
22
10
|
export function useLayoutState() {
|
|
23
|
-
const [routerQuery, setRouterQuery] =
|
|
11
|
+
const [routerQuery, setRouterQuery] = useUrlQuery<LayoutOverlayState>(
|
|
24
12
|
useCallback(
|
|
25
13
|
({ sizeMd, sizeSm, justifyMd, justifySm, variantMd, variantSm }) => ({
|
|
26
14
|
sizeMd,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Trans } from '@lingui/macro'
|
|
2
|
+
import { Button } from '@mui/material'
|
|
3
|
+
import { MessageSnackbar } from './MessageSnackbar'
|
|
4
|
+
import { MessageSnackbarImplProps } from './MessageSnackbarImpl'
|
|
5
|
+
|
|
6
|
+
export type ErrorSnackbarProps = MessageSnackbarImplProps
|
|
7
|
+
|
|
8
|
+
export function ErrorSnackbar(props: ErrorSnackbarProps) {
|
|
9
|
+
const { action, ...passedProps } = props
|
|
10
|
+
return (
|
|
11
|
+
<MessageSnackbar
|
|
12
|
+
variant='pill'
|
|
13
|
+
severity='error'
|
|
14
|
+
{...passedProps}
|
|
15
|
+
action={
|
|
16
|
+
action ?? (
|
|
17
|
+
<Button size='medium' variant='pill' color='secondary'>
|
|
18
|
+
<Trans>Ok</Trans>
|
|
19
|
+
</Button>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -42,7 +42,7 @@ export function TextInputNumber(props: TextInputNumberProps) {
|
|
|
42
42
|
const classes = withState({})
|
|
43
43
|
|
|
44
44
|
const ref = useRef<HTMLInputElement>(null)
|
|
45
|
-
const forkRef = useForkRef
|
|
45
|
+
const forkRef = useForkRef(ref, inputRef as Ref<HTMLInputElement>)
|
|
46
46
|
|
|
47
47
|
const [direction, setDirection] = useState<'up' | 'down' | 'runUp' | 'runDown' | null>(null)
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
package/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './FullPageMessage/FullPageMessage'
|
|
|
22
22
|
export * from './Highlight/Highlight'
|
|
23
23
|
export * from './IconHeader/IconHeader'
|
|
24
24
|
export * from './icons'
|
|
25
|
+
export * from './IconSvg'
|
|
25
26
|
export * from './JsonLd/JsonLd'
|
|
26
27
|
export * from './Layout'
|
|
27
28
|
export * from './LayoutDefault'
|
|
@@ -37,15 +38,16 @@ export * from './SectionContainer/SectionContainer'
|
|
|
37
38
|
export * from './SectionHeader/SectionHeader'
|
|
38
39
|
export * from './Separator/Separator'
|
|
39
40
|
export * from './Snackbar/MessageSnackbar'
|
|
41
|
+
export * from './Snackbar/ErrorSnackbar'
|
|
40
42
|
export * from './Snackbar/MessageSnackbarImpl'
|
|
41
43
|
export * from './StarRatingField/StarRatingField'
|
|
42
44
|
export * from './Stepper/Stepper'
|
|
43
45
|
export * from './Styles'
|
|
44
|
-
export * from './IconSvg'
|
|
45
46
|
export * from './TextInputNumber/TextInputNumber'
|
|
46
47
|
export * from './Theme'
|
|
47
48
|
export * from './TimeAgo/TimeAgo'
|
|
48
49
|
export * from './ToggleButton/ToggleButton'
|
|
49
50
|
export * from './ToggleButtonGroup/ToggleButtonGroup'
|
|
51
|
+
export * from './useUrlQuery/useUrlQuery'
|
|
50
52
|
export * from './UspList/UspList'
|
|
51
53
|
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.
|
|
5
|
+
"version": "4.5.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
"@emotion/react": "^11.8.2",
|
|
20
20
|
"@emotion/server": "^11.4.0",
|
|
21
21
|
"@emotion/styled": "^11.6.0",
|
|
22
|
-
"@graphcommerce/framer-next-pages": "^3.1.
|
|
23
|
-
"@graphcommerce/framer-scroller": "^2.1.
|
|
24
|
-
"@graphcommerce/framer-utils": "^3.1.
|
|
25
|
-
"@graphcommerce/image": "^3.1.
|
|
26
|
-
"react-is": "^
|
|
22
|
+
"@graphcommerce/framer-next-pages": "^3.1.4",
|
|
23
|
+
"@graphcommerce/framer-scroller": "^2.1.3",
|
|
24
|
+
"@graphcommerce/framer-utils": "^3.1.1",
|
|
25
|
+
"@graphcommerce/image": "^3.1.2",
|
|
26
|
+
"react-is": "^18.0.0",
|
|
27
27
|
"react-schemaorg": "^2.0.0",
|
|
28
|
-
"schema-dts": "^1.1.0"
|
|
29
|
-
"type-fest": "^2.12.0"
|
|
28
|
+
"schema-dts": "^1.1.0"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"@lingui/macro": "^3.13.2",
|
|
@@ -38,11 +37,12 @@
|
|
|
38
37
|
"react-dom": "^17.0.2"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
42
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
40
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.3",
|
|
41
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.5",
|
|
43
42
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
44
|
-
"@playwright/test": "^1.
|
|
43
|
+
"@playwright/test": "^1.20.1",
|
|
45
44
|
"@types/react-is": "^17.0.3",
|
|
46
|
-
"
|
|
45
|
+
"type-fest": "2.12.1",
|
|
46
|
+
"typescript": "4.6.3"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParsedUrlQuery } from 'querystring'
|
|
2
|
+
import { useRouter } from 'next/router'
|
|
3
|
+
import { useCallback } from 'react'
|
|
4
|
+
|
|
5
|
+
export function useUrlQuery<T extends ParsedUrlQuery>(builder: (query: T) => T = (query) => query) {
|
|
6
|
+
const { query, replace } = useRouter()
|
|
7
|
+
const queryState = builder(query as T)
|
|
8
|
+
|
|
9
|
+
const setRouterQuery = useCallback(
|
|
10
|
+
(partialQuery: T) => {
|
|
11
|
+
if (JSON.stringify(queryState) === JSON.stringify(partialQuery)) return
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
13
|
+
replace({ query: { ...queryState, ...partialQuery } }, undefined, { shallow: true })
|
|
14
|
+
},
|
|
15
|
+
[queryState, replace],
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return [queryState, setRouterQuery] as const
|
|
19
|
+
}
|