@graphcommerce/ecommerce-ui 9.1.0-canary.50 → 9.1.0-canary.52

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,13 @@
1
1
  # @graphcommerce/ecommerce-ui
2
2
 
3
+ ## 9.1.0-canary.52
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ea7af54`](https://github.com/graphcommerce-org/graphcommerce/commit/ea7af54048506228b6fde04d3bba764358b7f7e0) - Round step increment also max to two decimals as we might else get very long numbers ([@paales](https://github.com/paales))
8
+
9
+ ## 9.1.0-canary.51
10
+
3
11
  ## 9.1.0-canary.50
4
12
 
5
13
  ## 9.1.0-canary.49
@@ -34,6 +34,13 @@ const { withState } = extendableComponent<OwnerState, typeof componentName, type
34
34
  parts,
35
35
  )
36
36
 
37
+ const roundStep = (value: number, step: number) => {
38
+ // Round to nearest step
39
+ const newStepValue = Math.round(value / step) * step
40
+ // Round to max 2 decimals
41
+ return Math.round(newStepValue * 100) / 100
42
+ }
43
+
37
44
  /** @public */
38
45
  function NumberFieldElementBase(props: NumberFieldElementProps) {
39
46
  const {
@@ -139,7 +146,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
139
146
  )
140
147
  return
141
148
  // Round to nearest step
142
- onChange(Math.round((valueAsNumber - step) / step) * step)
149
+ onChange(roundStep(valueAsNumber - step, step))
143
150
  }}
144
151
  sx={{
145
152
  boxShadow: variant === 'standard' ? 4 : 0,
@@ -161,7 +168,7 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
161
168
  onClick={() => {
162
169
  if (valueAsNumber >= (inputProps.max ?? Infinity)) return
163
170
  // Round to nearest step
164
- onChange(Math.round((valueAsNumber + step) / step) * step)
171
+ onChange(roundStep(valueAsNumber + step, step))
165
172
  }}
166
173
  sx={{
167
174
  boxShadow: variant === 'standard' ? 4 : 0,
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.50",
5
+ "version": "9.1.0-canary.52",
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.50",
16
- "@graphcommerce/graphql": "^9.1.0-canary.50",
17
- "@graphcommerce/next-ui": "^9.1.0-canary.50",
18
- "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.50",
19
- "@graphcommerce/react-hook-form": "^9.1.0-canary.50",
20
- "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.50",
15
+ "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.52",
16
+ "@graphcommerce/graphql": "^9.1.0-canary.52",
17
+ "@graphcommerce/next-ui": "^9.1.0-canary.52",
18
+ "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.52",
19
+ "@graphcommerce/react-hook-form": "^9.1.0-canary.52",
20
+ "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.52",
21
21
  "@lingui/core": "^4.2.1",
22
22
  "@lingui/macro": "^4.2.1",
23
23
  "@lingui/react": "^4.2.1",