@graphcommerce/ecommerce-ui 9.0.0-canary.100 → 9.0.0-canary.101
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,5 +1,11 @@
|
|
|
1
1
|
# @graphcommerce/ecommerce-ui
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.101
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2380](https://github.com/graphcommerce-org/graphcommerce/pull/2380) [`c17e5f1`](https://github.com/graphcommerce-org/graphcommerce/commit/c17e5f1cf9fb291b9bbf1fca0620c2721dceb331) - Solve issue: Warning: Cannot update a component (`FormAutoSubmitBase`) while rendering a different component (`ActionCardListForm`). ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
3
9
|
## 9.0.0-canary.100
|
|
4
10
|
|
|
5
11
|
## 9.0.0-canary.99
|
package/Config.graphqls
CHANGED
|
@@ -4,7 +4,13 @@ enum WebsitePermissions {
|
|
|
4
4
|
# DISABLED will be implemented later
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
"""
|
|
8
|
+
Permissions input
|
|
9
|
+
"""
|
|
7
10
|
input GraphCommercePermissions {
|
|
11
|
+
"""
|
|
12
|
+
Allows the option to require login or completely disable the site.
|
|
13
|
+
"""
|
|
8
14
|
website: WebsitePermissions
|
|
9
15
|
}
|
|
10
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionCardList, ActionCardListProps, ActionCardProps } from '@graphcommerce/next-ui'
|
|
2
2
|
import { ControllerProps, FieldValues, useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import React, { MouseEventHandler } from 'react'
|
|
3
|
+
import React, { MouseEventHandler, useCallback } from 'react'
|
|
4
4
|
|
|
5
5
|
export type ActionCardItemBase = Pick<ActionCardProps, 'value'>
|
|
6
6
|
|
|
@@ -40,11 +40,14 @@ export function ActionCardListForm<
|
|
|
40
40
|
} = props
|
|
41
41
|
const RenderItem = render as React.FC<ActionCardItemRenderProps<ActionCardItemBase>>
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const onSelect = useCallback(
|
|
44
|
+
(itemValue: unknown, selectValues: unknown) =>
|
|
45
|
+
multiple
|
|
46
|
+
? Array.isArray(selectValues) &&
|
|
47
|
+
selectValues.some((selectValue) => selectValue === itemValue)
|
|
48
|
+
: selectValues === itemValue,
|
|
49
|
+
[multiple],
|
|
50
|
+
)
|
|
48
51
|
|
|
49
52
|
const {
|
|
50
53
|
field: { onChange, value, ref },
|
|
@@ -60,6 +63,14 @@ export function ActionCardListForm<
|
|
|
60
63
|
shouldUnregister,
|
|
61
64
|
})
|
|
62
65
|
|
|
66
|
+
const handleReset = useCallback(
|
|
67
|
+
(e: React.MouseEvent<HTMLElement>) => {
|
|
68
|
+
e.preventDefault()
|
|
69
|
+
if (!requireOptionSelection) onChange(null)
|
|
70
|
+
},
|
|
71
|
+
[onChange, requireOptionSelection],
|
|
72
|
+
)
|
|
73
|
+
|
|
63
74
|
return (
|
|
64
75
|
<ActionCardList
|
|
65
76
|
{...other}
|
|
@@ -67,7 +78,7 @@ export function ActionCardListForm<
|
|
|
67
78
|
required={required}
|
|
68
79
|
value={value}
|
|
69
80
|
ref={ref}
|
|
70
|
-
onChange={(_,
|
|
81
|
+
onChange={(_, incoming) => onChange(incoming)}
|
|
71
82
|
error={formState.isSubmitted && !!fieldState.error}
|
|
72
83
|
errorMessage={fieldState.error?.message}
|
|
73
84
|
>
|
|
@@ -77,10 +88,7 @@ export function ActionCardListForm<
|
|
|
77
88
|
key={`${item.value}`}
|
|
78
89
|
value={item.value}
|
|
79
90
|
selected={onSelect(item.value, value)}
|
|
80
|
-
onReset={
|
|
81
|
-
e.preventDefault()
|
|
82
|
-
if (!requireOptionSelection) onChange(null)
|
|
83
|
-
}}
|
|
91
|
+
onReset={handleReset}
|
|
84
92
|
/>
|
|
85
93
|
))}
|
|
86
94
|
</ActionCardList>
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@graphcommerce/react-hook-form'
|
|
9
9
|
import { i18n } from '@lingui/core'
|
|
10
10
|
import { TextField, TextFieldProps } from '@mui/material'
|
|
11
|
+
import React, { useState } from 'react'
|
|
11
12
|
|
|
12
13
|
export type TextFieldElementProps<T extends FieldValues = FieldValues> = Omit<
|
|
13
14
|
TextFieldProps,
|
|
@@ -48,11 +49,24 @@ export function TextFieldElement<TFieldValues extends FieldValues>({
|
|
|
48
49
|
fieldState: { error },
|
|
49
50
|
} = useController({ name, control, rules, defaultValue, shouldUnregister, disabled })
|
|
50
51
|
|
|
52
|
+
// https://stackoverflow.com/questions/76830737/chrome-autofill-causes-textbox-collision-for-textfield-label-and-value
|
|
53
|
+
const [hasAutofill, setHasAutofill] = useState(false)
|
|
54
|
+
const shrink = hasAutofill || rest.InputLabelProps?.shrink || Boolean(value)
|
|
55
|
+
const onAnimationStart = (e: React.AnimationEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
|
56
|
+
if (e.target instanceof HTMLElement) {
|
|
57
|
+
const autofilled = !!e.target.matches('*:-webkit-autofill')
|
|
58
|
+
if (e.animationName === 'mui-auto-fill') setHasAutofill(autofilled)
|
|
59
|
+
if (e.animationName === 'mui-auto-fill-cancel') setHasAutofill(autofilled)
|
|
60
|
+
}
|
|
61
|
+
return rest.inputProps?.onAnimationStart?.(e)
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
return (
|
|
52
65
|
<TextField
|
|
53
66
|
{...rest}
|
|
54
67
|
{...field}
|
|
55
68
|
value={value}
|
|
69
|
+
inputProps={{ ...rest.inputProps, onAnimationStart }}
|
|
56
70
|
onChange={(ev) => {
|
|
57
71
|
onChange(type === 'number' && ev.target.value ? Number(ev.target.value) : ev.target.value)
|
|
58
72
|
rest.onChange?.(ev)
|
|
@@ -62,6 +76,7 @@ export function TextFieldElement<TFieldValues extends FieldValues>({
|
|
|
62
76
|
type={type}
|
|
63
77
|
error={Boolean(error) || rest.error}
|
|
64
78
|
helperText={error ? error.message : rest.helperText}
|
|
79
|
+
InputLabelProps={{ ...rest.InputLabelProps, shrink }}
|
|
65
80
|
InputProps={{
|
|
66
81
|
...rest.InputProps,
|
|
67
82
|
endAdornment:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PreviewData } from '@graphcommerce/graphql'
|
|
2
2
|
import {
|
|
3
|
-
Button,
|
|
4
3
|
IconSvg,
|
|
5
4
|
MessageSnackbar,
|
|
6
5
|
iconChevronRight,
|
|
@@ -16,7 +15,6 @@ import { TextFieldElement } from '../FormComponents'
|
|
|
16
15
|
import { LightTooltip } from './LightTooltip'
|
|
17
16
|
import { PreviewModeActions } from './PreviewModeActions'
|
|
18
17
|
import { PreviewModeToolbar } from './PreviewModeToolbar'
|
|
19
|
-
import { previewModeDefaults } from './previewModeDefaults'
|
|
20
18
|
|
|
21
19
|
export function getPreviewUrl() {
|
|
22
20
|
const url = new URL(window.location.href)
|
|
@@ -26,9 +24,7 @@ export function getPreviewUrl() {
|
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
function PreviewModeEnabled() {
|
|
29
|
-
const form = useForm<{ secret: string; previewData: PreviewData }>({
|
|
30
|
-
defaultValues: { previewData: previewModeDefaults() },
|
|
31
|
-
})
|
|
27
|
+
const form = useForm<{ secret: string; previewData: PreviewData }>({})
|
|
32
28
|
|
|
33
29
|
const submit = form.handleSubmit((formValues) => {
|
|
34
30
|
const url = getPreviewUrl()
|
|
@@ -102,7 +98,14 @@ function PreviewModeEnabled() {
|
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
function PreviewModeDisabled() {
|
|
105
|
-
const form = useForm<{ secret: string }>({
|
|
101
|
+
const form = useForm<{ secret: string }>({
|
|
102
|
+
defaultValues: {
|
|
103
|
+
secret:
|
|
104
|
+
process.env.NODE_ENV === 'development'
|
|
105
|
+
? (import.meta.graphCommerce.previewSecret ?? '')
|
|
106
|
+
: '',
|
|
107
|
+
},
|
|
108
|
+
})
|
|
106
109
|
|
|
107
110
|
const submit = form.handleSubmit((formValues) => {
|
|
108
111
|
const url = getPreviewUrl()
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/ecommerce-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.101",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
16
|
-
"@graphcommerce/graphql": "^9.0.0-canary.
|
|
17
|
-
"@graphcommerce/next-ui": "^9.0.0-canary.
|
|
18
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
19
|
-
"@graphcommerce/react-hook-form": "^9.0.0-canary.
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.101",
|
|
16
|
+
"@graphcommerce/graphql": "^9.0.0-canary.101",
|
|
17
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.101",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.101",
|
|
19
|
+
"@graphcommerce/react-hook-form": "^9.0.0-canary.101",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.101",
|
|
21
21
|
"@lingui/core": "^4.2.1",
|
|
22
22
|
"@lingui/macro": "^4.2.1",
|
|
23
23
|
"@lingui/react": "^4.2.1",
|