@graphcommerce/ecommerce-ui 8.0.6-canary.4 → 8.0.7

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,26 +1,8 @@
1
1
  # @graphcommerce/ecommerce-ui
2
2
 
3
- ## 8.0.6-canary.4
3
+ ## 8.0.7
4
4
 
5
- ## 8.0.6-canary.3
6
-
7
- ## 8.0.6-canary.2
8
-
9
- ### Patch Changes
10
-
11
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
12
- ([@FrankHarland](https://github.com/FrankHarland))
13
-
14
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Make sure the TextFieldElement doesn’t give a uncontrolled to controlled warning.
15
- Convert SelectElement to useController instead of a separate Controller component.
16
- Make sure the original endAdornment is always shown only until the value is valid ([@FrankHarland](https://github.com/FrankHarland))
17
-
18
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`d4e693d`](https://github.com/graphcommerce-org/graphcommerce/commit/d4e693d553198c9a1ef398d000ca23d209e6c2ba) - The `<WaitForQueries/>` component now uses the useIsSSR hook which prevents loading spinners when navigating on the client, which make all account/cart/checkout pages faster.
19
- ([@FrankHarland](https://github.com/FrankHarland))
20
-
21
- ## 8.0.6-canary.1
22
-
23
- ## 8.0.6-canary.0
5
+ ## 8.0.6
24
6
 
25
7
  ## 8.0.5
26
8
 
@@ -56,14 +38,11 @@
56
38
 
57
39
  ### Patch Changes
58
40
 
59
- - [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`e12d1dc`](https://github.com/graphcommerce-org/graphcommerce/commit/e12d1dc201bf7b23a996bd58a256a117b91a9334) - Rename validation to rules for all Form field components and deprecate validation
60
- ([@paales](https://github.com/paales))
41
+ - [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`e12d1dc`](https://github.com/graphcommerce-org/graphcommerce/commit/e12d1dc201bf7b23a996bd58a256a117b91a9334) - Rename validation to rules for all Form field components and deprecate validation ([@paales](https://github.com/paales))
61
42
 
62
- - [#2203](https://github.com/graphcommerce-org/graphcommerce/pull/2203) [`7ef7dc7`](https://github.com/graphcommerce-org/graphcommerce/commit/7ef7dc7631f61a2feba67a531a210df9c22fed4b) - CheckboxElement, MultiSelectElement, NumberFieldElement, SelectElement, SliderElement and TextFieldElement have their inputRef passed, allowing focus to be set by the form.
63
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
43
+ - [#2203](https://github.com/graphcommerce-org/graphcommerce/pull/2203) [`7ef7dc7`](https://github.com/graphcommerce-org/graphcommerce/commit/7ef7dc7631f61a2feba67a531a210df9c22fed4b) - CheckboxElement, MultiSelectElement, NumberFieldElement, SelectElement, SliderElement and TextFieldElement have their inputRef passed, allowing focus to be set by the form. ([@Jessevdpoel](https://github.com/Jessevdpoel))
64
44
 
65
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`eb14696`](https://github.com/graphcommerce-org/graphcommerce/commit/eb14696fc65e084a06790c88a8218fb3003f7c2c) - `<WaitForQueries/>` will default to loading, restoring the previous behavior. This might introduce , this might introduce an additional spinner but prevents a flash where it is shown that there is no cart
66
- ([@paales](https://github.com/paales))
45
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`eb14696`](https://github.com/graphcommerce-org/graphcommerce/commit/eb14696fc65e084a06790c88a8218fb3003f7c2c) - `<WaitForQueries/>` will default to loading, restoring the previous behavior. This might introduce , this might introduce an additional spinner but prevents a flash where it is shown that there is no cart ([@paales](https://github.com/paales))
67
46
 
68
47
  ## 8.0.3-canary.6
69
48
 
@@ -71,15 +50,13 @@
71
50
 
72
51
  ### Patch Changes
73
52
 
74
- - [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`e12d1dc`](https://github.com/graphcommerce-org/graphcommerce/commit/e12d1dc201bf7b23a996bd58a256a117b91a9334) - Rename validation to rules for all Form field components and deprecate validation
75
- ([@paales](https://github.com/paales))
53
+ - [#2212](https://github.com/graphcommerce-org/graphcommerce/pull/2212) [`e12d1dc`](https://github.com/graphcommerce-org/graphcommerce/commit/e12d1dc201bf7b23a996bd58a256a117b91a9334) - Rename validation to rules for all Form field components and deprecate validation ([@paales](https://github.com/paales))
76
54
 
77
55
  ## 8.0.3-canary.4
78
56
 
79
57
  ### Patch Changes
80
58
 
81
- - [#2203](https://github.com/graphcommerce-org/graphcommerce/pull/2203) [`7ef7dc7`](https://github.com/graphcommerce-org/graphcommerce/commit/7ef7dc7631f61a2feba67a531a210df9c22fed4b) - CheckboxElement, MultiSelectElement, NumberFieldElement, SelectElement, SliderElement and TextFieldElement have their inputRef passed, allowing focus to be set by the form.
82
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
59
+ - [#2203](https://github.com/graphcommerce-org/graphcommerce/pull/2203) [`7ef7dc7`](https://github.com/graphcommerce-org/graphcommerce/commit/7ef7dc7631f61a2feba67a531a210df9c22fed4b) - CheckboxElement, MultiSelectElement, NumberFieldElement, SelectElement, SliderElement and TextFieldElement have their inputRef passed, allowing focus to be set by the form. ([@Jessevdpoel](https://github.com/Jessevdpoel))
83
60
 
84
61
  ## 8.0.3-canary.3
85
62
 
@@ -87,8 +64,7 @@
87
64
 
88
65
  ### Patch Changes
89
66
 
90
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`eb14696`](https://github.com/graphcommerce-org/graphcommerce/commit/eb14696fc65e084a06790c88a8218fb3003f7c2c) - `<WaitForQueries/>` will default to loading, restoring the previous behavior. This might introduce , this might introduce an additional spinner but prevents a flash where it is shown that there is no cart
91
- ([@paales](https://github.com/paales))
67
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`eb14696`](https://github.com/graphcommerce-org/graphcommerce/commit/eb14696fc65e084a06790c88a8218fb3003f7c2c) - `<WaitForQueries/>` will default to loading, restoring the previous behavior. This might introduce , this might introduce an additional spinner but prevents a flash where it is shown that there is no cart ([@paales](https://github.com/paales))
92
68
 
93
69
  ## 8.0.3-canary.1
94
70
 
@@ -120,19 +96,15 @@
120
96
 
121
97
  ### Minor Changes
122
98
 
123
- - [#2111](https://github.com/graphcommerce-org/graphcommerce/pull/2111) [`35f3d3e`](https://github.com/graphcommerce-org/graphcommerce/commit/35f3d3eaf46f4b782bb1149e0efb0ec3819442d6) - Only show network errors in development mode.
124
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
99
+ - [#2111](https://github.com/graphcommerce-org/graphcommerce/pull/2111) [`35f3d3e`](https://github.com/graphcommerce-org/graphcommerce/commit/35f3d3eaf46f4b782bb1149e0efb0ec3819442d6) - Only show network errors in development mode. ([@Jessevdpoel](https://github.com/Jessevdpoel))
125
100
 
126
- - [#2048](https://github.com/graphcommerce-org/graphcommerce/pull/2048) [`13e23e4`](https://github.com/graphcommerce-org/graphcommerce/commit/13e23e4265bac70fb4d0830e4661019e71ce299f) - Wishlist will now support configurable products and uses the `<ActionCardLayout/>`
127
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
101
+ - [#2048](https://github.com/graphcommerce-org/graphcommerce/pull/2048) [`13e23e4`](https://github.com/graphcommerce-org/graphcommerce/commit/13e23e4265bac70fb4d0830e4661019e71ce299f) - Wishlist will now support configurable products and uses the `<ActionCardLayout/>` ([@Jessevdpoel](https://github.com/Jessevdpoel))
128
102
 
129
- - [#2018](https://github.com/graphcommerce-org/graphcommerce/pull/2018) [`750aa6a`](https://github.com/graphcommerce-org/graphcommerce/commit/750aa6a72710869d54244467253212e551d335e0) - Changed the layout of the succes page. We are using ActionCards right now to match the design of the cart.
130
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
103
+ - [#2018](https://github.com/graphcommerce-org/graphcommerce/pull/2018) [`750aa6a`](https://github.com/graphcommerce-org/graphcommerce/commit/750aa6a72710869d54244467253212e551d335e0) - Changed the layout of the succes page. We are using ActionCards right now to match the design of the cart. ([@Jessevdpoel](https://github.com/Jessevdpoel))
131
104
 
132
105
  ### Patch Changes
133
106
 
134
- - [`e33660f`](https://github.com/graphcommerce-org/graphcommerce/commit/e33660f172466dcfa0ab7262cee612d9a3e47776) - Accessibility improvements for the frontend: Added skip content link. Removed empty buttons from tab flow. Gave focus to elements (such as the menu) that appear when after clicking a button. Improved aria labels where needed
135
- ([@FrankHarland](https://github.com/FrankHarland))
107
+ - [`e33660f`](https://github.com/graphcommerce-org/graphcommerce/commit/e33660f172466dcfa0ab7262cee612d9a3e47776) - Accessibility improvements for the frontend: Added skip content link. Removed empty buttons from tab flow. Gave focus to elements (such as the menu) that appear when after clicking a button. Improved aria labels where needed ([@FrankHarland](https://github.com/FrankHarland))
136
108
 
137
109
  ## 8.0.0-canary.100
138
110
 
@@ -184,8 +156,7 @@
184
156
 
185
157
  ### Patch Changes
186
158
 
187
- - [`e33660f`](https://github.com/graphcommerce-org/graphcommerce/commit/e33660f172466dcfa0ab7262cee612d9a3e47776) - a11y improvements (see https://github.com/graphcommerce-org/graphcommerce/issues/1995 for more info)
188
- ([@FrankHarland](https://github.com/FrankHarland))
159
+ - [`e33660f`](https://github.com/graphcommerce-org/graphcommerce/commit/e33660f172466dcfa0ab7262cee612d9a3e47776) - a11y improvements (see https://github.com/graphcommerce-org/graphcommerce/issues/1995 for more info) ([@FrankHarland](https://github.com/FrankHarland))
189
160
 
190
161
  ## 8.0.0-canary.76
191
162
 
@@ -1277,31 +1248,31 @@
1277
1248
  All occurences of `<Trans>` and `t` need to be replaced:
1278
1249
 
1279
1250
  ```tsx
1280
- import { Trans, t } from "@lingui/macro";
1251
+ import { Trans, t } from '@lingui/macro'
1281
1252
 
1282
1253
  function MyComponent() {
1283
- const foo = "bar";
1254
+ const foo = 'bar'
1284
1255
  return (
1285
1256
  <div aria-label={t`Account ${foo}`}>
1286
1257
  <Trans>My Translation {foo}</Trans>
1287
1258
  </div>
1288
- );
1259
+ )
1289
1260
  }
1290
1261
  ```
1291
1262
 
1292
1263
  Needs to be replaced with:
1293
1264
 
1294
1265
  ```tsx
1295
- import { Trans } from "@lingui/react";
1296
- import { i18n } from "@lingui/core";
1266
+ import { Trans } from '@lingui/react'
1267
+ import { i18n } from '@lingui/core'
1297
1268
 
1298
1269
  function MyComponent() {
1299
- const foo = "bar";
1270
+ const foo = 'bar'
1300
1271
  return (
1301
1272
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1302
- <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1273
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1303
1274
  </div>
1304
- );
1275
+ )
1305
1276
  }
1306
1277
  ```
1307
1278
 
@@ -5,12 +5,7 @@ import {
5
5
  IconSvg,
6
6
  responsiveVal,
7
7
  } from '@graphcommerce/next-ui'
8
- import {
9
- Controller,
10
- ControllerProps,
11
- FieldValues,
12
- useController,
13
- } from '@graphcommerce/react-hook-form'
8
+ import { Controller, ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
14
9
  import { i18n } from '@lingui/core'
15
10
  import { IconButtonProps, SxProps, Theme, TextField, TextFieldProps, Fab } from '@mui/material'
16
11
 
@@ -53,117 +48,117 @@ export function NumberFieldElement<T extends FieldValues>(props: NumberFieldElem
53
48
  rules.required = i18n._(/* i18n */ 'This field is required')
54
49
  }
55
50
 
56
- const {
57
- field: { value, onChange, ref, ...field },
58
- fieldState: { invalid, error },
59
- } = useController({
60
- name,
61
- control,
62
- rules,
63
- defaultValue,
64
- })
65
-
66
- const valueAsNumber = value ? parseFloat(value) : 0
67
-
68
51
  return (
69
- <TextField
70
- {...textFieldProps}
71
- {...field}
72
- inputRef={ref}
73
- value={value ?? ''}
74
- onChange={(ev) => {
75
- const newValue = (ev.target as HTMLInputElement).valueAsNumber
76
- onChange(Number.isNaN(newValue) ? '' : newValue)
77
- textFieldProps.onChange?.(ev)
78
- }}
79
- variant={variant}
80
- required={required}
81
- error={invalid}
82
- helperText={error ? error.message : textFieldProps.helperText}
83
- size={size}
84
- type='number'
85
- className={`${textFieldProps.className ?? ''} ${classes.quantity}`}
86
- sx={[
87
- {
88
- width: responsiveVal(90, 120),
89
- },
90
- {
91
- '& input[type=number]': {
92
- MozAppearance: 'textfield',
93
- },
94
- '& .MuiOutlinedInput-root': {
95
- px: '2px',
96
- display: 'grid',
97
- gridTemplateColumns: '1fr auto 1fr',
98
- },
99
- },
100
- variant === 'standard' && {
101
- '& .MuiOutlinedInput-input': {
102
- padding: 0,
103
- },
104
- '& .MuiOutlinedInput-notchedOutline': {
105
- display: 'none',
106
- },
107
- },
108
- ...(Array.isArray(sx) ? sx : [sx]),
109
- ]}
110
- autoComplete='off'
111
- InputProps={{
112
- ...textFieldProps.InputProps,
113
- startAdornment: (
114
- <Fab
115
- aria-label={i18n._(/* i18n */ 'Decrease')}
116
- size='smaller'
117
- onClick={() => {
118
- if ((valueAsNumber || Infinity) <= inputProps.min) return
119
- onChange(value - 1)
120
- }}
121
- sx={{
122
- boxShadow: variant === 'standard' ? 4 : 0,
123
- minHeight: '30px',
124
- minWidth: '30px',
52
+ <Controller
53
+ name={name}
54
+ control={control}
55
+ rules={rules}
56
+ defaultValue={defaultValue}
57
+ render={({ field: { value, onChange, ref, ...field }, fieldState: { invalid, error } }) => {
58
+ const valueAsNumber = value ? parseFloat(value) : 0
59
+
60
+ return (
61
+ <TextField
62
+ {...textFieldProps}
63
+ {...field}
64
+ inputRef={ref}
65
+ value={value ?? ''}
66
+ onChange={(ev) => {
67
+ const newValue = (ev.target as HTMLInputElement).valueAsNumber
68
+ onChange(Number.isNaN(newValue) ? '' : newValue)
69
+ textFieldProps.onChange?.(ev)
125
70
  }}
126
- tabIndex={-1}
127
- color='inherit'
128
- {...DownProps}
129
- className={`${classes.button} ${DownProps.className ?? ''}`}
130
- >
131
- {DownProps.children ?? <IconSvg src={iconMin} size='small' />}
132
- </Fab>
133
- ),
134
- endAdornment: (
135
- <Fab
136
- aria-label={i18n._(/* i18n */ 'Increase')}
137
- size='smaller'
138
- onClick={() => {
139
- if (valueAsNumber >= (inputProps.max ?? Infinity)) return
140
- onChange(valueAsNumber + 1)
71
+ variant={variant}
72
+ required={required}
73
+ error={invalid}
74
+ helperText={error ? error.message : textFieldProps.helperText}
75
+ size={size}
76
+ type='number'
77
+ className={`${textFieldProps.className ?? ''} ${classes.quantity}`}
78
+ sx={[
79
+ {
80
+ width: responsiveVal(90, 120),
81
+ },
82
+ {
83
+ '& input[type=number]': {
84
+ MozAppearance: 'textfield',
85
+ },
86
+ '& .MuiOutlinedInput-root': {
87
+ px: '2px',
88
+ display: 'grid',
89
+ gridTemplateColumns: '1fr auto 1fr',
90
+ },
91
+ },
92
+ variant === 'standard' && {
93
+ '& .MuiOutlinedInput-input': {
94
+ padding: 0,
95
+ },
96
+ '& .MuiOutlinedInput-notchedOutline': {
97
+ display: 'none',
98
+ },
99
+ },
100
+ ...(Array.isArray(sx) ? sx : [sx]),
101
+ ]}
102
+ autoComplete='off'
103
+ InputProps={{
104
+ ...textFieldProps.InputProps,
105
+ startAdornment: (
106
+ <Fab
107
+ aria-label={i18n._(/* i18n */ 'Decrease')}
108
+ size='smaller'
109
+ onClick={() => {
110
+ if ((valueAsNumber || Infinity) <= inputProps.min) return
111
+ onChange(value - 1)
112
+ }}
113
+ sx={{
114
+ boxShadow: variant === 'standard' ? 4 : 0,
115
+ minHeight: '30px',
116
+ minWidth: '30px',
117
+ }}
118
+ tabIndex={-1}
119
+ color='inherit'
120
+ {...DownProps}
121
+ className={`${classes.button} ${DownProps.className ?? ''}`}
122
+ >
123
+ {DownProps.children ?? <IconSvg src={iconMin} size='small' />}
124
+ </Fab>
125
+ ),
126
+ endAdornment: (
127
+ <Fab
128
+ aria-label={i18n._(/* i18n */ 'Increase')}
129
+ size='smaller'
130
+ onClick={() => {
131
+ if (valueAsNumber >= (inputProps.max ?? Infinity)) return
132
+ onChange(valueAsNumber + 1)
133
+ }}
134
+ sx={{
135
+ boxShadow: variant === 'standard' ? 4 : 0,
136
+ minHeight: '30px',
137
+ minWidth: '30px',
138
+ }}
139
+ tabIndex={-1}
140
+ color='inherit'
141
+ {...UpProps}
142
+ className={`${classes.button} ${UpProps.className ?? ''}`}
143
+ >
144
+ {UpProps.children ?? <IconSvg src={iconPlus} size='small' />}
145
+ </Fab>
146
+ ),
141
147
  }}
142
- sx={{
143
- boxShadow: variant === 'standard' ? 4 : 0,
144
- minHeight: '30px',
145
- minWidth: '30px',
148
+ inputProps={{
149
+ 'aria-label': i18n._(/* i18n */ 'Number'),
150
+ ...inputProps,
151
+ className: `${inputProps?.className ?? ''} ${classes.quantityInput}`,
152
+ sx: {
153
+ typography: 'body1',
154
+ textAlign: 'center',
155
+ '&::-webkit-inner-spin-button,&::-webkit-outer-spin-button': {
156
+ appearance: 'none',
157
+ },
158
+ },
146
159
  }}
147
- tabIndex={-1}
148
- color='inherit'
149
- {...UpProps}
150
- className={`${classes.button} ${UpProps.className ?? ''}`}
151
- >
152
- {UpProps.children ?? <IconSvg src={iconPlus} size='small' />}
153
- </Fab>
154
- ),
155
- }}
156
- inputProps={{
157
- 'aria-label': i18n._(/* i18n */ 'Number'),
158
- ...inputProps,
159
- className: `${inputProps?.className ?? ''} ${classes.quantityInput}`,
160
- sx: {
161
- typography: 'body1',
162
- textAlign: 'center',
163
- '&::-webkit-inner-spin-button,&::-webkit-outer-spin-button': {
164
- appearance: 'none',
165
- },
166
- },
160
+ />
161
+ )
167
162
  }}
168
163
  />
169
164
  )
@@ -1,10 +1,4 @@
1
- import { InputCheckmark } from '@graphcommerce/next-ui'
2
- import {
3
- Controller,
4
- ControllerProps,
5
- FieldValues,
6
- useController,
7
- } from '@graphcommerce/react-hook-form'
1
+ import { Controller, ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
8
2
  import { i18n } from '@lingui/core'
9
3
  import { MenuItem, TextField, TextFieldProps } from '@mui/material'
10
4
 
@@ -19,7 +13,6 @@ export type SelectElementProps<T extends FieldValues, O extends OptionBase> = Om
19
13
  options?: O[]
20
14
  type?: 'string' | 'number'
21
15
  onChange?: (value: string | number) => void
22
- showValid?: boolean
23
16
  } & Omit<ControllerProps<T>, 'render'>
24
17
 
25
18
  export function SelectElement<TFieldValues extends FieldValues, O extends OptionBase>({
@@ -31,9 +24,6 @@ export function SelectElement<TFieldValues extends FieldValues, O extends Option
31
24
  control,
32
25
  defaultValue,
33
26
  rules = validation ?? {},
34
- showValid,
35
- disabled,
36
- shouldUnregister,
37
27
  ...rest
38
28
  }: SelectElementProps<TFieldValues, O>): JSX.Element {
39
29
  const isNativeSelect = !!rest.SelectProps?.native
@@ -43,56 +33,45 @@ export function SelectElement<TFieldValues extends FieldValues, O extends Option
43
33
  rules.required = i18n._(/* i18n */ 'This field is required')
44
34
  }
45
35
 
46
- const {
47
- field: { onChange, value, ref, ...field },
48
- fieldState: { invalid, error },
49
- } = useController({
50
- name,
51
- rules,
52
- control,
53
- defaultValue,
54
- disabled,
55
- shouldUnregister,
56
- })
57
-
58
- // handle shrink on number input fields
59
- if (type === 'number' && typeof value !== 'undefined') {
60
- rest.InputLabelProps = rest.InputLabelProps || {}
61
- rest.InputLabelProps.shrink = true
62
- }
63
-
64
36
  return (
65
- <TextField
66
- {...rest}
67
- value={value ?? ''}
68
- {...field}
69
- inputRef={ref}
70
- onChange={(event) => {
71
- let item: number | string | O | undefined = event.target.value
72
- if (type === 'number') item = Number(item)
73
- rest.onChange?.(item)
74
- onChange(item)
75
- }}
76
- select
77
- required={required}
78
- error={invalid}
79
- helperText={error ? error.message : rest.helperText}
80
- InputProps={{
81
- ...rest.InputProps,
82
- endAdornment:
83
- showValid && value && !error ? (
84
- <InputCheckmark show={!error} />
85
- ) : (
86
- rest.InputProps?.endAdornment
87
- ),
37
+ <Controller
38
+ name={name}
39
+ rules={rules}
40
+ control={control}
41
+ defaultValue={defaultValue}
42
+ render={({ field: { onChange, value, ref, ...field }, fieldState: { invalid, error } }) => {
43
+ // handle shrink on number input fields
44
+ if (type === 'number' && typeof value !== 'undefined') {
45
+ rest.InputLabelProps = rest.InputLabelProps || {}
46
+ rest.InputLabelProps.shrink = true
47
+ }
48
+
49
+ return (
50
+ <TextField
51
+ {...rest}
52
+ value={value ?? ''}
53
+ {...field}
54
+ inputRef={ref}
55
+ onChange={(event) => {
56
+ let item: number | string | O | undefined = event.target.value
57
+ if (type === 'number') item = Number(item)
58
+ rest.onChange?.(item)
59
+ onChange(item)
60
+ }}
61
+ select
62
+ required={required}
63
+ error={invalid}
64
+ helperText={error ? error.message : rest.helperText}
65
+ >
66
+ {isNativeSelect && <option />}
67
+ {options.map((item) => (
68
+ <ChildComponent key={item.id} value={item.id}>
69
+ {item.label}
70
+ </ChildComponent>
71
+ ))}
72
+ </TextField>
73
+ )
88
74
  }}
89
- >
90
- {isNativeSelect && <option />}
91
- {options.map((item) => (
92
- <ChildComponent key={item.id} value={item.id}>
93
- {item.label}
94
- </ChildComponent>
95
- ))}
96
- </TextField>
75
+ />
97
76
  )
98
77
  }
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-nested-ternary */
2
- import { InputCheckmark } from '@graphcommerce/next-ui'
3
- import { FieldValues, UseControllerProps, useController } from '@graphcommerce/react-hook-form'
2
+ import { Controller, FieldValues, UseControllerProps } from '@graphcommerce/react-hook-form'
4
3
  import { i18n } from '@lingui/core'
5
4
  import { TextField, TextFieldProps } from '@mui/material'
6
5
 
@@ -10,8 +9,6 @@ export type TextFieldElementProps<T extends FieldValues = FieldValues> = Omit<
10
9
  > & {
11
10
  /** @deprecated Please use the rules props instead */
12
11
  validation?: UseControllerProps<T>['rules']
13
-
14
- showValid?: boolean
15
12
  } & UseControllerProps<T>
16
13
 
17
14
  export function TextFieldElement<TFieldValues extends FieldValues>({
@@ -22,7 +19,6 @@ export function TextFieldElement<TFieldValues extends FieldValues>({
22
19
  control,
23
20
  defaultValue,
24
21
  rules = validation,
25
- showValid,
26
22
  ...rest
27
23
  }: TextFieldElementProps<TFieldValues>): JSX.Element {
28
24
  if (required && !rules.required) {
@@ -38,34 +34,29 @@ export function TextFieldElement<TFieldValues extends FieldValues>({
38
34
  }
39
35
  }
40
36
 
41
- const {
42
- field: { onChange, ref, value = '', ...field },
43
- fieldState: { error },
44
- } = useController({ name, control, rules, defaultValue })
45
-
46
37
  return (
47
- <TextField
48
- {...rest}
49
- {...field}
50
- value={value}
51
- onChange={(ev) => {
52
- onChange(type === 'number' && ev.target.value ? Number(ev.target.value) : ev.target.value)
53
- rest.onChange?.(ev)
54
- }}
55
- inputRef={ref}
56
- required={required}
57
- type={type}
58
- error={Boolean(error) || rest.error}
59
- helperText={error ? error.message : rest.helperText}
60
- InputProps={{
61
- ...rest.InputProps,
62
- endAdornment:
63
- showValid && value && !error ? (
64
- <InputCheckmark show={!error} />
65
- ) : (
66
- rest.InputProps?.endAdornment
67
- ),
68
- }}
38
+ <Controller
39
+ name={name}
40
+ control={control}
41
+ rules={rules}
42
+ defaultValue={defaultValue}
43
+ render={({ field: { onChange, ref, ...field }, fieldState: { error } }) => (
44
+ <TextField
45
+ {...rest}
46
+ {...field}
47
+ onChange={(ev) => {
48
+ onChange(
49
+ type === 'number' && ev.target.value ? Number(ev.target.value) : ev.target.value,
50
+ )
51
+ rest.onChange?.(ev)
52
+ }}
53
+ inputRef={ref}
54
+ required={required}
55
+ type={type}
56
+ error={Boolean(error) || rest.error}
57
+ helperText={error ? error.message : rest.helperText}
58
+ />
59
+ )}
69
60
  />
70
61
  )
71
62
  }
@@ -1,12 +1,9 @@
1
+ import { useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
1
2
  import { QueryResult } from '@graphcommerce/graphql'
2
- import { useIsSSR } from '@graphcommerce/next-ui'
3
- import React from 'react'
3
+ import React, { startTransition, useEffect, useState } from 'react'
4
4
 
5
5
  export type WaitForQueriesProps = {
6
6
  waitFor: QueryResult<any, any> | boolean | (QueryResult<any, any> | boolean)[] | undefined
7
- /**
8
- * @deprecated Will be automatically correct.
9
- */
10
7
  noSsr?: boolean
11
8
  children: React.ReactNode
12
9
  fallback?: React.ReactNode
@@ -14,9 +11,14 @@ export type WaitForQueriesProps = {
14
11
 
15
12
  /** Shows the fallback during: SSR, Hydration and Query Loading. */
16
13
  export const WaitForQueries = (props: WaitForQueriesProps) => {
17
- const { waitFor, fallback, children } = props
14
+ const { waitFor, fallback, children, noSsr = true } = props
18
15
 
19
- const mounted = !useIsSSR()
16
+ // Make sure the first render is always the same as the server.
17
+ // Make sure we we use startTransition to make sure we don't get into trouble with Suspense.
18
+ const [mounted, setMounted] = useState(!noSsr)
19
+ useEffect(() => {
20
+ if (noSsr) setMounted(true)
21
+ }, [noSsr])
20
22
 
21
23
  // We are done when all queries either have data or an error.
22
24
  const isDone = (Array.isArray(waitFor) ? waitFor : [waitFor]).every((res) => {
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": "8.0.6-canary.4",
5
+ "version": "8.0.7",
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": "^8.0.6-canary.4",
16
- "@graphcommerce/graphql": "^8.0.6-canary.4",
17
- "@graphcommerce/next-ui": "^8.0.6-canary.4",
18
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.4",
19
- "@graphcommerce/react-hook-form": "^8.0.6-canary.4",
20
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.4",
15
+ "@graphcommerce/eslint-config-pwa": "^8.0.7",
16
+ "@graphcommerce/graphql": "^8.0.7",
17
+ "@graphcommerce/next-ui": "^8.0.7",
18
+ "@graphcommerce/prettier-config-pwa": "^8.0.7",
19
+ "@graphcommerce/react-hook-form": "^8.0.7",
20
+ "@graphcommerce/typescript-config-pwa": "^8.0.7",
21
21
  "@lingui/core": "^4.2.1",
22
22
  "@lingui/macro": "^4.2.1",
23
23
  "@lingui/react": "^4.2.1",