@graphcommerce/ecommerce-ui 9.1.0-canary.40 → 9.1.0-canary.41
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.1.0-canary.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2530](https://github.com/graphcommerce-org/graphcommerce/pull/2530) [`fe48501`](https://github.com/graphcommerce-org/graphcommerce/commit/fe4850106abebe1fe113e08e38623ebfd5481c1d) - Make sure the increment step of the NumberInputField rounds to the nearest step. ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
3
9
|
## 9.1.0-canary.40
|
|
4
10
|
|
|
5
11
|
## 9.1.0-canary.39
|
|
@@ -10,6 +10,7 @@ import { useController } from '@graphcommerce/react-hook-form'
|
|
|
10
10
|
import { i18n } from '@lingui/core'
|
|
11
11
|
import type { IconButtonProps, SxProps, TextFieldProps, Theme } from '@mui/material'
|
|
12
12
|
import { Fab, TextField, useForkRef } from '@mui/material'
|
|
13
|
+
import React from 'react'
|
|
13
14
|
import type { FieldElementProps } from './types'
|
|
14
15
|
|
|
15
16
|
type AdditionalProps = {
|
|
@@ -79,6 +80,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
79
80
|
})
|
|
80
81
|
|
|
81
82
|
const valueAsNumber = value ? parseFloat(value) : 0
|
|
83
|
+
const step: number = inputProps.step ?? 1
|
|
82
84
|
|
|
83
85
|
return (
|
|
84
86
|
<TextField
|
|
@@ -136,7 +138,8 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
136
138
|
(inputProps.min === 0 && valueAsNumber <= inputProps.min)
|
|
137
139
|
)
|
|
138
140
|
return
|
|
139
|
-
|
|
141
|
+
// Round to nearest step
|
|
142
|
+
onChange(Math.round((valueAsNumber - step) / step) * step)
|
|
140
143
|
}}
|
|
141
144
|
sx={{
|
|
142
145
|
boxShadow: variant === 'standard' ? 4 : 0,
|
|
@@ -157,7 +160,8 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
157
160
|
size='smaller'
|
|
158
161
|
onClick={() => {
|
|
159
162
|
if (valueAsNumber >= (inputProps.max ?? Infinity)) return
|
|
160
|
-
|
|
163
|
+
// Round to nearest step
|
|
164
|
+
onChange(Math.round((valueAsNumber + step) / step) * step)
|
|
161
165
|
}}
|
|
162
166
|
sx={{
|
|
163
167
|
boxShadow: variant === 'standard' ? 4 : 0,
|
|
@@ -189,4 +193,6 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
|
|
|
189
193
|
)
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
export const NumberFieldElement =
|
|
196
|
+
export const NumberFieldElement = React.forwardRef<HTMLInputElement, NumberFieldElementProps>(
|
|
197
|
+
(props, ref) => NumberFieldElementBase({ ...props, ref }),
|
|
198
|
+
) as NumberFieldElementComponent
|
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.1.0-canary.
|
|
5
|
+
"version": "9.1.0-canary.41",
|
|
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.1.0-canary.
|
|
16
|
-
"@graphcommerce/graphql": "^9.1.0-canary.
|
|
17
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
|
18
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
|
19
|
-
"@graphcommerce/react-hook-form": "^9.1.0-canary.
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.41",
|
|
16
|
+
"@graphcommerce/graphql": "^9.1.0-canary.41",
|
|
17
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.41",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.41",
|
|
19
|
+
"@graphcommerce/react-hook-form": "^9.1.0-canary.41",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.41",
|
|
21
21
|
"@lingui/core": "^4.2.1",
|
|
22
22
|
"@lingui/macro": "^4.2.1",
|
|
23
23
|
"@lingui/react": "^4.2.1",
|