@graphcommerce/ecommerce-ui 9.1.0-canary.55 → 10.0.0-canary.57
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 +82 -0
- package/components/ApolloError/ApolloErrorAlert.tsx +1 -1
- package/components/ApolloError/ApolloErrorFullPage.tsx +2 -2
- package/components/ApolloError/ApolloErrorSnackbar.tsx +1 -1
- package/components/ApolloError/maskNetworkError.tsx +4 -4
- package/components/FormComponents/ActionCardListForm.tsx +1 -1
- package/components/FormComponents/CheckboxButtonGroup.tsx +2 -2
- package/components/FormComponents/CheckboxElement.tsx +3 -3
- package/components/FormComponents/EmailElement.tsx +5 -5
- package/components/FormComponents/InputBaseElement.tsx +3 -3
- package/components/FormComponents/MultiSelectElement.tsx +3 -3
- package/components/FormComponents/NumberFieldElement.tsx +5 -5
- package/components/FormComponents/PasswordElement.tsx +1 -1
- package/components/FormComponents/PasswordRepeatElement.tsx +2 -3
- package/components/FormComponents/RadioButtonGroup.tsx +3 -3
- package/components/FormComponents/SelectElement.tsx +1 -1
- package/components/FormComponents/SliderElement.tsx +3 -3
- package/components/FormComponents/SwitchElement.tsx +1 -1
- package/components/FormComponents/TelephoneElement.tsx +3 -2
- package/components/FormComponents/TextFieldElement.tsx +4 -4
- package/components/FormComponents/ToggleButtonGroup.tsx +2 -2
- package/components/PreviewMode/PreviewModeDisabled.tsx +2 -2
- package/package.json +17 -12
- package/route/preview.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# @graphcommerce/ecommerce-ui
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.57
|
|
4
|
+
|
|
5
|
+
## 10.0.0-canary.56
|
|
6
|
+
|
|
7
|
+
### Major Changes
|
|
8
|
+
|
|
9
|
+
- [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
|
|
10
|
+
|
|
11
|
+
This major release brings full Turbopack compatibility, dramatically improving development speed.
|
|
12
|
+
|
|
13
|
+
### 🚀 Turbopack-Compatible Interceptor System
|
|
14
|
+
|
|
15
|
+
The entire plugin/interceptor system has been rewritten to work with Turbopack:
|
|
16
|
+
|
|
17
|
+
- **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
|
|
18
|
+
- **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
|
|
19
|
+
- **Direct imports** - Interceptors import from `.original` files instead of embedding source
|
|
20
|
+
- **New CLI commands**:
|
|
21
|
+
- `graphcommerce codegen-interceptors` - Generate interceptor files
|
|
22
|
+
- `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
|
|
23
|
+
- **Stable file hashing** - Deterministic interceptor generation for better caching
|
|
24
|
+
|
|
25
|
+
### ⚙️ Treeshakable Configuration System
|
|
26
|
+
|
|
27
|
+
Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
|
|
28
|
+
|
|
29
|
+
- **New `codegen-config-values` command** - Generates TypeScript files with precise typing
|
|
30
|
+
- **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
|
|
31
|
+
- **Fully treeshakable** - Unused config values are eliminated from the bundle
|
|
32
|
+
- **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
|
|
33
|
+
- **Separate files for nested objects** - Optimal treeshaking for complex configurations
|
|
34
|
+
|
|
35
|
+
### 🔧 withGraphCommerce Changes
|
|
36
|
+
|
|
37
|
+
- **Removed** `InterceptorPlugin` - No longer needed with file-based interception
|
|
38
|
+
- **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
|
|
39
|
+
- **Removed** `@mui/*` alias rewrites - No longer required
|
|
40
|
+
- **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
|
|
41
|
+
- **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
|
|
42
|
+
- **Added** `optimizePackageImports` for better bundle optimization
|
|
43
|
+
- **Added** `images.qualities: [52, 75]` for Next.js image optimization
|
|
44
|
+
|
|
45
|
+
### 📦 Lingui Configuration
|
|
46
|
+
|
|
47
|
+
- **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
|
|
48
|
+
- **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
|
|
49
|
+
- **Simplified** formatter options
|
|
50
|
+
|
|
51
|
+
### ⚛️ React 19 & Next.js 16 Compatibility
|
|
52
|
+
|
|
53
|
+
- Updated `RefObject<T>` types for React 19 (now includes `null` by default)
|
|
54
|
+
- Replaced deprecated `React.VFC` with `React.FC`
|
|
55
|
+
- Fixed `useRef` calls to require explicit initial values
|
|
56
|
+
- Updated `MutableRefObject` usage in `framer-scroller`
|
|
57
|
+
|
|
58
|
+
### 📋 ESLint 9 Flat Config
|
|
59
|
+
|
|
60
|
+
- Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
|
|
61
|
+
- Updated `@typescript-eslint/*` packages to v8
|
|
62
|
+
- Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
|
|
63
|
+
|
|
64
|
+
### 🔄 Apollo Client
|
|
65
|
+
|
|
66
|
+
- Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
|
|
67
|
+
- Updated error handling types to accept `ApolloError | null | undefined`
|
|
68
|
+
|
|
69
|
+
### ⚠️ Breaking Changes
|
|
70
|
+
|
|
71
|
+
- **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
|
|
72
|
+
- **Interceptor files changed** - Original components now at `.original.tsx`
|
|
73
|
+
- **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
|
|
74
|
+
- **ESLint config format** - Must use flat config (`eslint.config.mjs`)
|
|
75
|
+
- **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
|
|
76
|
+
|
|
77
|
+
### 🗑️ Removed
|
|
78
|
+
|
|
79
|
+
- `InterceptorPlugin` webpack plugin
|
|
80
|
+
- `configToImportMeta` utility
|
|
81
|
+
- Webpack `DefinePlugin` usage for config
|
|
82
|
+
- `@mui/*` modern alias rewrites
|
|
83
|
+
- Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
|
|
84
|
+
|
|
3
85
|
## 9.1.0-canary.55
|
|
4
86
|
|
|
5
87
|
## 9.1.0-canary.54
|
|
@@ -7,7 +7,7 @@ import { maskNetworkError } from './maskNetworkError'
|
|
|
7
7
|
const { classes, selectors } = extendableComponent('ApolloErrorAlert', ['root', 'alert'] as const)
|
|
8
8
|
|
|
9
9
|
export type ApolloErrorAlertProps = {
|
|
10
|
-
error?: ApolloError
|
|
10
|
+
error?: ApolloError | null
|
|
11
11
|
graphqlErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
12
12
|
networkErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
13
13
|
sx?: SxProps<Theme>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ApolloError } from '@graphcommerce/graphql'
|
|
2
2
|
import type { FullPageMessageProps } from '@graphcommerce/next-ui'
|
|
3
3
|
import { FullPageMessage } from '@graphcommerce/next-ui'
|
|
4
|
-
import { Trans } from '@lingui/react'
|
|
4
|
+
import { Trans } from '@lingui/react/macro'
|
|
5
5
|
import type { AlertProps } from '@mui/material'
|
|
6
6
|
import { ApolloErrorAlert } from './ApolloErrorAlert'
|
|
7
7
|
import { maskNetworkError } from './maskNetworkError'
|
|
@@ -37,7 +37,7 @@ export function ApolloErrorFullPage(props: ApolloErrorFullPageProps) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<FullPageMessage title={<Trans
|
|
40
|
+
<FullPageMessage title={<Trans>Several errors occured</Trans>} {...fullPageMessageProps}>
|
|
41
41
|
<ApolloErrorAlert error={error} />
|
|
42
42
|
</FullPageMessage>
|
|
43
43
|
)
|
|
@@ -4,7 +4,7 @@ import { ErrorSnackbar } from '@graphcommerce/next-ui'
|
|
|
4
4
|
import { maskNetworkError } from './maskNetworkError'
|
|
5
5
|
|
|
6
6
|
export type ApolloErrorSnackbarProps = {
|
|
7
|
-
error?: ApolloError
|
|
7
|
+
error?: ApolloError | null
|
|
8
8
|
} & Pick<ErrorSnackbarProps, 'action' | 'onClose'>
|
|
9
9
|
|
|
10
10
|
export function ApolloErrorSnackbar(props: ApolloErrorSnackbarProps) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerError, ServerParseError } from '@graphcommerce/graphql'
|
|
2
|
-
import { Trans } from '@lingui/react'
|
|
2
|
+
import { Trans } from '@lingui/react/macro'
|
|
3
3
|
|
|
4
4
|
function isServerError(error: Error | ServerParseError | ServerError | null): error is ServerError {
|
|
5
5
|
return 'name' in (error as ServerError)
|
|
@@ -19,12 +19,12 @@ export function maskNetworkError(networkError: Error | ServerParseError | Server
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (isServerParseError(networkError) || isServerError(networkError)) {
|
|
22
|
-
return <Trans
|
|
22
|
+
return <Trans>Something went wrong on the server, please try again later.</Trans>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (globalThis.navigator && !globalThis.navigator?.onLine) {
|
|
26
|
-
return <Trans
|
|
26
|
+
return <Trans>It appears you are offline, please try again later.</Trans>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return <Trans
|
|
29
|
+
return <Trans>Something went wrong</Trans>
|
|
30
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { CheckboxProps } from '@mui/material'
|
|
5
5
|
import {
|
|
6
6
|
Checkbox,
|
|
@@ -61,7 +61,7 @@ function CheckboxButtonGroupBase(props: CheckboxButtonGroupProps) {
|
|
|
61
61
|
fieldState: { invalid, error },
|
|
62
62
|
} = useController({
|
|
63
63
|
name,
|
|
64
|
-
rules: required ? { required:
|
|
64
|
+
rules: required ? { required: t`This field is required` } : undefined,
|
|
65
65
|
control,
|
|
66
66
|
defaultValue,
|
|
67
67
|
shouldUnregister,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type {
|
|
5
5
|
CheckboxProps,
|
|
6
6
|
FormControlLabelProps,
|
|
@@ -32,7 +32,7 @@ type CheckboxElementComponent = <TFieldValues extends FieldValues>(
|
|
|
32
32
|
props: CheckboxElementProps<TFieldValues>,
|
|
33
33
|
) => React.ReactNode
|
|
34
34
|
|
|
35
|
-
function CheckboxElementBase(props: CheckboxElementProps):
|
|
35
|
+
function CheckboxElementBase(props: CheckboxElementProps): React.ReactNode {
|
|
36
36
|
const {
|
|
37
37
|
name,
|
|
38
38
|
rules = {},
|
|
@@ -48,7 +48,7 @@ function CheckboxElementBase(props: CheckboxElementProps): JSX.Element {
|
|
|
48
48
|
} = props
|
|
49
49
|
|
|
50
50
|
if (required && !rules.required) {
|
|
51
|
-
rules.required =
|
|
51
|
+
rules.required = t`This field is required`
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { emailPattern } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
4
|
-
import { Trans } from '@lingui/react'
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
|
+
import { Trans } from '@lingui/react/macro'
|
|
5
5
|
import type { TextFieldElementProps } from './TextFieldElement'
|
|
6
6
|
import { TextFieldElement } from './TextFieldElement'
|
|
7
7
|
|
|
@@ -10,17 +10,17 @@ export type EmailElementProps<T extends FieldValues> = TextFieldElementProps<T>
|
|
|
10
10
|
/** @public */
|
|
11
11
|
export function EmailElement<TFieldValues extends FieldValues>(
|
|
12
12
|
props: EmailElementProps<TFieldValues>,
|
|
13
|
-
):
|
|
13
|
+
): React.ReactNode {
|
|
14
14
|
const { rules, ...rest } = props
|
|
15
15
|
return (
|
|
16
16
|
<TextFieldElement
|
|
17
17
|
type='email'
|
|
18
|
-
label={<Trans
|
|
18
|
+
label={<Trans>Email address</Trans>}
|
|
19
19
|
autoComplete='email'
|
|
20
20
|
rules={{
|
|
21
21
|
pattern: {
|
|
22
22
|
value: emailPattern,
|
|
23
|
-
message:
|
|
23
|
+
message: t`Please enter a valid email address`,
|
|
24
24
|
},
|
|
25
25
|
...rules,
|
|
26
26
|
}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { InputBaseProps } from '@mui/material'
|
|
5
5
|
import { InputBase, useForkRef } from '@mui/material'
|
|
6
6
|
import React from 'react'
|
|
@@ -15,7 +15,7 @@ type InputBaseElementComponent = <TFieldValues extends FieldValues>(
|
|
|
15
15
|
|
|
16
16
|
function InputBaseElementBase(
|
|
17
17
|
props: InputBaseElementProps & { ref?: React.Ref<HTMLInputElement> },
|
|
18
|
-
):
|
|
18
|
+
): React.ReactElement {
|
|
19
19
|
const {
|
|
20
20
|
type,
|
|
21
21
|
required,
|
|
@@ -31,7 +31,7 @@ function InputBaseElementBase(
|
|
|
31
31
|
} = props
|
|
32
32
|
|
|
33
33
|
if (required && !rules.required) {
|
|
34
|
-
rules.required =
|
|
34
|
+
rules.required = t`This field is required`
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { iconClose, IconSvg } from '@graphcommerce/next-ui'
|
|
3
3
|
import type { ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
|
|
4
4
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
5
|
-
import {
|
|
5
|
+
import { t } from '@lingui/core/macro'
|
|
6
6
|
import type { FormControlProps, SelectProps } from '@mui/material'
|
|
7
7
|
import {
|
|
8
8
|
Checkbox,
|
|
@@ -38,7 +38,7 @@ const ITEM_PADDING_TOP = 8
|
|
|
38
38
|
/** @public */
|
|
39
39
|
export function MultiSelectElement<TFieldValues extends FieldValues>(
|
|
40
40
|
props: MultiSelectElementProps<TFieldValues>,
|
|
41
|
-
):
|
|
41
|
+
): React.ReactNode {
|
|
42
42
|
const {
|
|
43
43
|
options,
|
|
44
44
|
label = '',
|
|
@@ -61,7 +61,7 @@ export function MultiSelectElement<TFieldValues extends FieldValues>(
|
|
|
61
61
|
...rest
|
|
62
62
|
} = props
|
|
63
63
|
if (required && !rules.required) {
|
|
64
|
-
rules.required =
|
|
64
|
+
rules.required = t`This field is required`
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@graphcommerce/next-ui'
|
|
8
8
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
9
9
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
10
|
-
import {
|
|
10
|
+
import { t } from '@lingui/core/macro'
|
|
11
11
|
import type { IconButtonProps, SxProps, TextFieldProps, Theme } from '@mui/material'
|
|
12
12
|
import { Fab, TextField, useForkRef } from '@mui/material'
|
|
13
13
|
import React from 'react'
|
|
@@ -70,7 +70,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (required && !rules.required) {
|
|
73
|
-
rules.required =
|
|
73
|
+
rules.required = t`This field is required`
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const {
|
|
@@ -134,7 +134,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
134
134
|
...InputPropsFiltered,
|
|
135
135
|
startAdornment: (
|
|
136
136
|
<Fab
|
|
137
|
-
aria-label={
|
|
137
|
+
aria-label={t`Decrease`}
|
|
138
138
|
size='smaller'
|
|
139
139
|
onClick={() => {
|
|
140
140
|
if (
|
|
@@ -160,7 +160,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
160
160
|
),
|
|
161
161
|
endAdornment: (
|
|
162
162
|
<Fab
|
|
163
|
-
aria-label={
|
|
163
|
+
aria-label={t`Increase`}
|
|
164
164
|
size='smaller'
|
|
165
165
|
onClick={() => {
|
|
166
166
|
if (valueAsNumber >= (inputProps.max ?? Infinity)) return
|
|
@@ -182,7 +182,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
182
182
|
),
|
|
183
183
|
}}
|
|
184
184
|
inputProps={{
|
|
185
|
-
'aria-label':
|
|
185
|
+
'aria-label': t`Number`,
|
|
186
186
|
...inputProps,
|
|
187
187
|
className: `${inputProps?.className ?? ''} ${classes.quantityInput}`,
|
|
188
188
|
sx: {
|
|
@@ -14,7 +14,7 @@ export type PasswordElementProps<T extends FieldValues> = TextFieldElementProps<
|
|
|
14
14
|
/** @public */
|
|
15
15
|
export function PasswordElement<TFieldValues extends FieldValues>(
|
|
16
16
|
props: PasswordElementProps<TFieldValues>,
|
|
17
|
-
):
|
|
17
|
+
): React.ReactNode {
|
|
18
18
|
const { iconColor, ...textFieldProps } = props
|
|
19
19
|
const [password, setPassword] = useState<boolean>(true)
|
|
20
20
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useWatch } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { PasswordElementProps } from './PasswordElement'
|
|
5
5
|
import { PasswordElement } from './PasswordElement'
|
|
6
6
|
|
|
@@ -18,8 +18,7 @@ export function PasswordRepeatElement<TFieldValues extends FieldValues>({
|
|
|
18
18
|
<PasswordElement
|
|
19
19
|
{...rest}
|
|
20
20
|
rules={{
|
|
21
|
-
validate: (value: string) =>
|
|
22
|
-
value === pwValue || i18n._(/* i18n */ "Passwords don't match"),
|
|
21
|
+
validate: (value: string) => value === pwValue || t`Passwords don't match`,
|
|
23
22
|
}}
|
|
24
23
|
/>
|
|
25
24
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import {
|
|
5
5
|
FormControl,
|
|
6
6
|
FormControlLabel,
|
|
@@ -37,7 +37,7 @@ type RadioButtonGroupComponent = <TFieldValues extends FieldValues>(
|
|
|
37
37
|
props: RadioButtonGroupProps<TFieldValues>,
|
|
38
38
|
) => React.ReactNode
|
|
39
39
|
|
|
40
|
-
function RadioButtonGroupBase(props: RadioButtonGroupProps):
|
|
40
|
+
function RadioButtonGroupBase(props: RadioButtonGroupProps): React.ReactNode {
|
|
41
41
|
const {
|
|
42
42
|
helperText,
|
|
43
43
|
options,
|
|
@@ -61,7 +61,7 @@ function RadioButtonGroupBase(props: RadioButtonGroupProps): JSX.Element {
|
|
|
61
61
|
fieldState: { invalid, error },
|
|
62
62
|
} = useController({
|
|
63
63
|
name,
|
|
64
|
-
rules: required ? { required:
|
|
64
|
+
rules: required ? { required: t`This field is required` } : undefined,
|
|
65
65
|
control,
|
|
66
66
|
defaultValue,
|
|
67
67
|
shouldUnregister,
|
|
@@ -17,7 +17,7 @@ type SelectElementComponent = <TFieldValues extends FieldValues>(
|
|
|
17
17
|
) => React.ReactNode
|
|
18
18
|
|
|
19
19
|
/** @public */
|
|
20
|
-
function SelectElementBase(props: SelectElementProps):
|
|
20
|
+
function SelectElementBase(props: SelectElementProps): React.ReactNode {
|
|
21
21
|
const { options } = props as AdditionalProps
|
|
22
22
|
const { SelectProps } = props as TextFieldProps
|
|
23
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { FormControlProps, SliderProps } from '@mui/material'
|
|
5
5
|
import { FormControl, FormHelperText, FormLabel, Slider } from '@mui/material'
|
|
6
6
|
import React from 'react'
|
|
@@ -22,7 +22,7 @@ type SliderElementComponent = <TFieldValues extends FieldValues>(
|
|
|
22
22
|
props: SliderElementProps<TFieldValues>,
|
|
23
23
|
) => React.ReactNode
|
|
24
24
|
|
|
25
|
-
function SliderElementBase(props: SliderElementProps):
|
|
25
|
+
function SliderElementBase(props: SliderElementProps): React.ReactNode {
|
|
26
26
|
const {
|
|
27
27
|
name,
|
|
28
28
|
control,
|
|
@@ -37,7 +37,7 @@ function SliderElementBase(props: SliderElementProps): JSX.Element {
|
|
|
37
37
|
} = props
|
|
38
38
|
|
|
39
39
|
if (required && !rules.required) {
|
|
40
|
-
rules.required =
|
|
40
|
+
rules.required = t`This field is required`
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const {
|
|
@@ -17,7 +17,7 @@ type SwitchElementComponent = <TFieldValues extends FieldValues>(
|
|
|
17
17
|
props: SwitchElementProps<TFieldValues>,
|
|
18
18
|
) => React.ReactNode
|
|
19
19
|
|
|
20
|
-
function SwitchElementBase(props: SwitchElementProps):
|
|
20
|
+
function SwitchElementBase(props: SwitchElementProps): React.ReactNode {
|
|
21
21
|
const { name, control, defaultValue, shouldUnregister, rules, disabled, ...other } = props
|
|
22
22
|
|
|
23
23
|
const { field } = useController({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { phonePattern } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import { t
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
|
+
import { Trans } from '@lingui/react/macro'
|
|
4
5
|
import type { TextFieldElementProps } from './TextFieldElement'
|
|
5
6
|
import { TextFieldElement } from './TextFieldElement'
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ export type TelephoneElementProps<T extends FieldValues> = TextFieldElementProps
|
|
|
9
10
|
/** @public */
|
|
10
11
|
export function TelephoneElement<TFieldValues extends FieldValues>(
|
|
11
12
|
props: TelephoneElementProps<TFieldValues>,
|
|
12
|
-
):
|
|
13
|
+
): React.ReactNode {
|
|
13
14
|
const { rules, ...rest } = props
|
|
14
15
|
return (
|
|
15
16
|
<TextFieldElement
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { InputCheckmark } from '@graphcommerce/next-ui'
|
|
3
3
|
import type { FieldValues } from '@graphcommerce/react-hook-form'
|
|
4
4
|
import { emailPattern, useController } from '@graphcommerce/react-hook-form'
|
|
5
|
-
import {
|
|
5
|
+
import { t } from '@lingui/core/macro'
|
|
6
6
|
import type { TextFieldProps } from '@mui/material'
|
|
7
7
|
import { TextField, useForkRef } from '@mui/material'
|
|
8
8
|
import React, { useState } from 'react'
|
|
@@ -46,7 +46,7 @@ function toValue(incomingValue: unknown, type: React.HTMLInputTypeAttribute) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/** @public */
|
|
49
|
-
function TextFieldElementBase(props: TextFieldElementProps):
|
|
49
|
+
function TextFieldElementBase(props: TextFieldElementProps): React.ReactNode {
|
|
50
50
|
const {
|
|
51
51
|
name,
|
|
52
52
|
control,
|
|
@@ -61,13 +61,13 @@ function TextFieldElementBase(props: TextFieldElementProps): JSX.Element {
|
|
|
61
61
|
} = props as TextFieldProps & InternalProps & BaseControllerProps
|
|
62
62
|
|
|
63
63
|
if (required && !rules.required) {
|
|
64
|
-
rules.required =
|
|
64
|
+
rules.required = t`This field is required`
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
if (type === 'email' && !rules.pattern) {
|
|
68
68
|
rules.pattern = {
|
|
69
69
|
value: emailPattern,
|
|
70
|
-
message:
|
|
70
|
+
message: t`Please enter a valid email address`,
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { useController } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import {
|
|
3
|
+
import { t } from '@lingui/core/macro'
|
|
4
4
|
import type { FormLabelProps, ToggleButtonGroupProps, ToggleButtonProps } from '@mui/material'
|
|
5
5
|
import {
|
|
6
6
|
FormControl,
|
|
@@ -39,7 +39,7 @@ export function ToggleButtonGroupElement<TFieldValues extends FieldValues = Fiel
|
|
|
39
39
|
...toggleButtonGroupProps
|
|
40
40
|
}: ToggleButtonGroupElementProps<TFieldValues>) {
|
|
41
41
|
if (required && !rules.required) {
|
|
42
|
-
rules.required =
|
|
42
|
+
rules.required = t`This field is required`
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const isRequired = required || !!rules?.required
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { previewSecret } from '@graphcommerce/next-config/config'
|
|
1
2
|
import { iconChevronRight, iconContrast, IconSvg, MessageSnackbar } from '@graphcommerce/next-ui'
|
|
2
3
|
import { FormPersist, FormProvider, useForm } from '@graphcommerce/react-hook-form'
|
|
3
4
|
import { Box, IconButton } from '@mui/material'
|
|
@@ -10,8 +11,7 @@ function getPreviewUrl() {
|
|
|
10
11
|
return url
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const secret =
|
|
14
|
-
process.env.NODE_ENV === 'development' ? (import.meta.graphCommerce.previewSecret ?? '') : ''
|
|
14
|
+
const secret = process.env.NODE_ENV === 'development' ? (previewSecret ?? '') : ''
|
|
15
15
|
|
|
16
16
|
type FormValues = { secret: string }
|
|
17
17
|
|
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": "
|
|
5
|
+
"version": "10.0.0-canary.57",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
16
|
-
"@graphcommerce/graphql": "^
|
|
17
|
-
"@graphcommerce/next-ui": "^
|
|
18
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
19
|
-
"@graphcommerce/react-hook-form": "^
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
21
|
-
"@lingui/core": "^
|
|
22
|
-
"@lingui/macro": "^
|
|
23
|
-
"@lingui/react": "^
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.57",
|
|
16
|
+
"@graphcommerce/graphql": "^10.0.0-canary.57",
|
|
17
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.57",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.57",
|
|
19
|
+
"@graphcommerce/react-hook-form": "^10.0.0-canary.57",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.57",
|
|
21
|
+
"@lingui/core": "^5",
|
|
22
|
+
"@lingui/macro": "^5",
|
|
23
|
+
"@lingui/react": "^5",
|
|
24
24
|
"@mui/material": "^5.10.16",
|
|
25
25
|
"framer-motion": "^11.0.0",
|
|
26
26
|
"next": "*",
|
|
27
|
-
"react": "^
|
|
28
|
-
"react-dom": "^
|
|
27
|
+
"react": "^19.2.0",
|
|
28
|
+
"react-dom": "^19.2.0"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./index.ts",
|
|
32
|
+
"./route/preview": "./route/preview.ts",
|
|
33
|
+
"./plugins/PreviewModeFramerNextPages": "./plugins/PreviewModeFramerNextPages.tsx"
|
|
29
34
|
}
|
|
30
35
|
}
|
package/route/preview.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PreviewData } from '@graphcommerce/graphql'
|
|
2
|
+
import { previewSecret } from '@graphcommerce/next-config/config'
|
|
2
3
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
3
4
|
import { previewModeDefaults } from '../components/PreviewMode/previewModeDefaults'
|
|
4
5
|
|
|
@@ -18,7 +19,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
if (action === 'enable' && req.query.secret) {
|
|
21
|
-
if (req.query.secret !==
|
|
22
|
+
if (req.query.secret !== previewSecret) {
|
|
22
23
|
// This secret should only be known to this API route and the CMS
|
|
23
24
|
res.status(401).json({ message: 'Invalid token' })
|
|
24
25
|
res.end()
|