@graphcommerce/ecommerce-ui 6.0.0-canary.26 → 6.0.0-canary.27

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
+ ## 6.0.0-canary.27
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1821](https://github.com/graphcommerce-org/graphcommerce/pull/1821) [`1abc50a21`](https://github.com/graphcommerce-org/graphcommerce/commit/1abc50a21103270fad04e4a9ea892ee1e75233e9) - Fix regression bugs and upgrade packages to latest versions ([@paales](https://github.com/paales))
8
+
3
9
  ## 6.0.0-canary.26
4
10
 
5
11
  ## 6.0.0-canary.25
@@ -52,7 +52,7 @@ export function AutocompleteElement<TFieldValues extends FieldValues>({
52
52
  boolean | undefined,
53
53
  boolean | undefined
54
54
  >) {
55
- const validationRules: ControllerProps['rules'] = {
55
+ const validationRules: ControllerProps<TFieldValues>['rules'] = {
56
56
  ...rules,
57
57
  ...(required && {
58
58
  required: rules?.required || 'This field is required',
@@ -64,7 +64,7 @@ export function AutocompleteElement<TFieldValues extends FieldValues>({
64
64
  control={control}
65
65
  rules={validationRules}
66
66
  render={({ field: { onChange, onBlur, value, ...fieldRest }, fieldState: { error } }) => {
67
- const values = Array.isArray(value) ? (value as typeof value[]) : [value]
67
+ const values = Array.isArray(value) ? (value as (typeof value)[]) : [value]
68
68
  let currentValue = multiple ? value || [] : value || null
69
69
  if (matchId) {
70
70
  currentValue = multiple
@@ -33,9 +33,7 @@ const { withState } = extendableComponent<OwnerState, typeof componentName, type
33
33
  parts,
34
34
  )
35
35
 
36
- export function NumberFieldElement<T extends FieldValues = FieldValues>(
37
- props: NumberFieldElementProps<T>,
38
- ) {
36
+ export function NumberFieldElement<T extends FieldValues>(props: NumberFieldElementProps<T>) {
39
37
  const {
40
38
  DownProps = {},
41
39
  UpProps = {},
@@ -5,7 +5,7 @@ export type SelectElementProps<T extends FieldValues> = Omit<
5
5
  TextFieldProps,
6
6
  'name' | 'type' | 'onChange' | 'defaultValue'
7
7
  > & {
8
- validation?: ControllerProps['rules']
8
+ validation?: ControllerProps<T>['rules']
9
9
  options?: { id: string | number; label: string | number }[] | any[]
10
10
  valueKey?: string
11
11
  labelKey?: string
@@ -1,8 +1,10 @@
1
+ /* eslint-disable no-nested-ternary */
1
2
  import {
2
3
  Controller,
3
4
  ControllerProps,
4
5
  FieldError,
5
6
  FieldValues,
7
+ UseControllerProps,
6
8
  } from '@graphcommerce/react-hook-form'
7
9
  import { i18n } from '@lingui/core'
8
10
  import { TextField, TextFieldProps } from '@mui/material'
@@ -11,12 +13,11 @@ export type TextFieldElementProps<T extends FieldValues = FieldValues> = Omit<
11
13
  TextFieldProps,
12
14
  'name' | 'defaultValue'
13
15
  > & {
14
- validation?: ControllerProps['rules']
16
+ validation?: UseControllerProps<T>['rules']
15
17
  parseError?: (error: FieldError) => string
16
- } & Omit<ControllerProps<T>, 'render'>
18
+ } & UseControllerProps<T>
17
19
 
18
- /** This is a copy of the default one, but allowing defaultValue */
19
- export function TextFieldElement<TFieldValues extends FieldValues = FieldValues>({
20
+ export function TextFieldElement<TFieldValues extends FieldValues>({
20
21
  validation = {},
21
22
  parseError,
22
23
  type,
@@ -45,21 +46,21 @@ export function TextFieldElement<TFieldValues extends FieldValues = FieldValues>
45
46
  control={control}
46
47
  rules={validation}
47
48
  defaultValue={defaultValue}
48
- render={({ field: { value, onChange, onBlur }, fieldState: { invalid, error } }) => (
49
+ render={({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => (
49
50
  <TextField
50
51
  {...rest}
51
52
  name={name}
52
53
  value={value ?? ''}
53
54
  onChange={(ev) => {
54
- onChange(ev)
55
- if (typeof rest.onChange === 'function') {
56
- rest?.onChange(ev)
57
- }
55
+ onChange(
56
+ type === 'number' && ev.target.value ? Number(ev.target.value) : ev.target.value,
57
+ )
58
+ rest.onChange?.(ev)
58
59
  }}
59
60
  onBlur={onBlur}
60
61
  required={required}
61
62
  type={type}
62
- error={invalid}
63
+ error={!!error}
63
64
  helperText={
64
65
  error
65
66
  ? typeof parseError === 'function'
@@ -67,6 +68,7 @@ export function TextFieldElement<TFieldValues extends FieldValues = FieldValues>
67
68
  : error.message
68
69
  : rest.helperText
69
70
  }
71
+ inputRef={ref}
70
72
  />
71
73
  )}
72
74
  />
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": "6.0.0-canary.26",
5
+ "version": "6.0.0-canary.27",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,21 +12,21 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@graphcommerce/graphql": "6.0.0-canary.26",
16
- "@graphcommerce/next-ui": "6.0.0-canary.26",
17
- "@graphcommerce/react-hook-form": "6.0.0-canary.26"
15
+ "@graphcommerce/graphql": "6.0.0-canary.27",
16
+ "@graphcommerce/next-ui": "6.0.0-canary.27",
17
+ "@graphcommerce/react-hook-form": "6.0.0-canary.27"
18
18
  },
19
19
  "devDependencies": {
20
- "@graphcommerce/eslint-config-pwa": "6.0.0-canary.26",
21
- "@graphcommerce/prettier-config-pwa": "6.0.0-canary.26",
22
- "@graphcommerce/typescript-config-pwa": "6.0.0-canary.26"
20
+ "@graphcommerce/eslint-config-pwa": "6.0.0-canary.27",
21
+ "@graphcommerce/prettier-config-pwa": "6.0.0-canary.27",
22
+ "@graphcommerce/typescript-config-pwa": "6.0.0-canary.27"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@lingui/react": "^3.13.2",
26
26
  "@lingui/core": "^3.13.2",
27
27
  "@mui/material": "^5.10.16",
28
28
  "framer-motion": "^7.0.0",
29
- "next": "^13.1.1",
29
+ "next": "^13.2.0",
30
30
  "react": "^18.2.0",
31
31
  "react-dom": "^18.2.0"
32
32
  }