@graphcommerce/next-ui 4.8.1 → 4.8.2
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.
|
@@ -2,18 +2,18 @@ import { Theme } from '@emotion/react'
|
|
|
2
2
|
import { SxProps, ButtonBase, Box } from '@mui/material'
|
|
3
3
|
import React, { FormEvent } from 'react'
|
|
4
4
|
|
|
5
|
-
type ActionCardProps = {
|
|
5
|
+
export type ActionCardProps = {
|
|
6
6
|
sx?: SxProps<Theme>
|
|
7
7
|
title?: string | React.ReactNode
|
|
8
8
|
image?: React.ReactNode
|
|
9
9
|
action?: React.ReactNode
|
|
10
10
|
details?: React.ReactNode
|
|
11
11
|
secondaryAction?: React.ReactNode
|
|
12
|
-
onClick?: (e: FormEvent<HTMLButtonElement>, v: string) => void
|
|
13
|
-
onChange?: (e: FormEvent<HTMLButtonElement>, v: string) => void
|
|
12
|
+
onClick?: (e: FormEvent<HTMLButtonElement>, v: string | number) => void
|
|
13
|
+
onChange?: (e: FormEvent<HTMLButtonElement>, v: string | number) => void
|
|
14
14
|
selected?: boolean
|
|
15
15
|
hidden?: boolean | (() => boolean)
|
|
16
|
-
value: string
|
|
16
|
+
value: string | number
|
|
17
17
|
reset?: React.ReactNode
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -16,7 +16,7 @@ type Select = {
|
|
|
16
16
|
onChange?: (event: React.MouseEvent<HTMLElement>, value: string | null) => void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
type ActionCardListProps<SelectOrMulti = MultiSelect | Select> = {
|
|
19
|
+
export type ActionCardListProps<SelectOrMulti = MultiSelect | Select> = {
|
|
20
20
|
children?: React.ReactNode
|
|
21
21
|
required?: boolean
|
|
22
22
|
error?: boolean
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import { Controller, ControllerProps } from '@graphcommerce/react-hook-form'
|
|
3
|
+
import { Trans } from '@lingui/react'
|
|
4
|
+
import { Button } from '@mui/material'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
import { ActionCard, ActionCardProps } from './ActionCard'
|
|
7
|
+
import { ActionCardList, ActionCardListProps } from './ActionCardList'
|
|
8
|
+
|
|
9
|
+
export type ActionCardRenderProps = Pick<
|
|
10
|
+
ActionCardProps,
|
|
11
|
+
'action' | 'reset' | 'selected' | 'hidden' | 'value' | 'onClick' | 'onChange'
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
export type ActionCardItem = Omit<
|
|
15
|
+
ActionCardProps,
|
|
16
|
+
'action' | 'reset' | 'selected' | 'hidden' | 'onClick' | 'onChange'
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
type ActionCardListFormProps = Omit<ActionCardListProps, 'value'> &
|
|
20
|
+
Omit<ControllerProps<any>, 'render'> & {
|
|
21
|
+
items: ActionCardItem[]
|
|
22
|
+
render?: React.VFC<ActionCardRenderProps>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function ActionCardListForm(props: ActionCardListFormProps) {
|
|
26
|
+
const { required, rules, items, render: RenderItem = ActionCard } = props
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Controller
|
|
30
|
+
{...props}
|
|
31
|
+
rules={{ required, ...rules }}
|
|
32
|
+
render={({ field: { onChange, value }, fieldState, formState }) => (
|
|
33
|
+
<ActionCardList
|
|
34
|
+
required
|
|
35
|
+
value={value}
|
|
36
|
+
onChange={(_, incomming) => onChange(incomming)}
|
|
37
|
+
error={formState.isSubmitted && !!fieldState.error}
|
|
38
|
+
>
|
|
39
|
+
{items.map((item) => (
|
|
40
|
+
<RenderItem
|
|
41
|
+
{...item}
|
|
42
|
+
key={item.value}
|
|
43
|
+
value={item.value}
|
|
44
|
+
selected={value === item.value}
|
|
45
|
+
hidden={!!value && value !== item.value}
|
|
46
|
+
action={
|
|
47
|
+
<Button disableRipple variant='text' color='secondary'>
|
|
48
|
+
<Trans id='Select' />
|
|
49
|
+
</Button>
|
|
50
|
+
}
|
|
51
|
+
reset={
|
|
52
|
+
<Button
|
|
53
|
+
disableRipple
|
|
54
|
+
variant='text'
|
|
55
|
+
color='secondary'
|
|
56
|
+
onClick={(e) => {
|
|
57
|
+
e.preventDefault()
|
|
58
|
+
onChange(null)
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<Trans id='Change' />
|
|
62
|
+
</Button>
|
|
63
|
+
}
|
|
64
|
+
/>
|
|
65
|
+
))}
|
|
66
|
+
</ActionCardList>
|
|
67
|
+
)}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1485](https://github.com/graphcommerce-org/graphcommerce/pull/1485) [`c8c246b8a`](https://github.com/graphcommerce-org/graphcommerce/commit/c8c246b8aaab0621b68a2fca2a1c529a56fad962) Thanks [@paales](https://github.com/paales)! - TextInputNumber: when adding a label it should be displayed properly
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @graphcommerce/framer-scroller@2.1.13
|
|
11
|
+
|
|
3
12
|
## 4.8.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -97,13 +97,10 @@ export function TextInputNumber(props: TextInputNumberProps) {
|
|
|
97
97
|
width: responsiveVal(80, 120),
|
|
98
98
|
backgroundColor: 'inherit',
|
|
99
99
|
},
|
|
100
|
-
|
|
101
100
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
102
101
|
]}
|
|
103
102
|
autoComplete='off'
|
|
104
|
-
label={' '}
|
|
105
103
|
id='quantity-input'
|
|
106
|
-
InputLabelProps={{ shrink: false }}
|
|
107
104
|
InputProps={{
|
|
108
105
|
...textFieldProps.InputProps,
|
|
109
106
|
startAdornment: (
|
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.8.
|
|
5
|
+
"version": "4.8.2",
|
|
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.2",
|
|
23
|
-
"@graphcommerce/framer-scroller": "2.1.
|
|
23
|
+
"@graphcommerce/framer-scroller": "2.1.13",
|
|
24
24
|
"@graphcommerce/framer-utils": "3.1.3",
|
|
25
25
|
"@graphcommerce/image": "3.1.6",
|
|
26
26
|
"react-is": "^17.0.0",
|