@graphcommerce/ecommerce-ui 10.0.0-canary.63 → 10.0.0-canary.66

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,15 @@
1
1
  # @graphcommerce/ecommerce-ui
2
2
 
3
+ ## 10.0.0-canary.66
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2538](https://github.com/graphcommerce-org/graphcommerce/pull/2538) [`9b96d69`](https://github.com/graphcommerce-org/graphcommerce/commit/9b96d69d2aba2779e1875ffb068096087582f10d) - fix issue where stepper could have values such as 8,10000000000 inste… ([@FrankHarland](https://github.com/FrankHarland))
8
+
9
+ ## 10.0.0-canary.65
10
+
11
+ ## 10.0.0-canary.64
12
+
3
13
  ## 10.0.0-canary.63
4
14
 
5
15
  ## 10.0.0-canary.62
@@ -34,11 +34,10 @@ 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
37
+ // Add precision rounding helper
38
+ const roundToPrecision = (num: number, precision: number = 2): number => {
39
+ const factor = Math.pow(10, precision)
40
+ return Math.round(num * factor) / factor
42
41
  }
43
42
 
44
43
  /** @public */
@@ -142,8 +141,9 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
142
141
  (inputProps.min === 0 && valueAsNumber <= inputProps.min)
143
142
  )
144
143
  return
145
- // Round to nearest step
146
- onChange(roundStep(valueAsNumber - step, step))
144
+ // Round to nearest step with precision fix
145
+ const newValue = roundToPrecision(Math.round((valueAsNumber - step) / step) * step)
146
+ onChange(newValue)
147
147
  }}
148
148
  sx={{
149
149
  boxShadow: variant === 'standard' ? 4 : 0,
@@ -164,8 +164,9 @@ function NumberFieldElementBase(props: NumberFieldElementProps) {
164
164
  size='smaller'
165
165
  onClick={() => {
166
166
  if (valueAsNumber >= (inputProps.max ?? Infinity)) return
167
- // Round to nearest step
168
- onChange(roundStep(valueAsNumber + step, step))
167
+ // Round to nearest step with precision fix
168
+ const newValue = roundToPrecision(Math.round((valueAsNumber + step) / step) * step)
169
+ onChange(newValue)
169
170
  }}
170
171
  sx={{
171
172
  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": "10.0.0-canary.63",
5
+ "version": "10.0.0-canary.66",
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": "^10.0.0-canary.63",
16
- "@graphcommerce/graphql": "^10.0.0-canary.63",
17
- "@graphcommerce/next-ui": "^10.0.0-canary.63",
18
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.63",
19
- "@graphcommerce/react-hook-form": "^10.0.0-canary.63",
20
- "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.63",
15
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.66",
16
+ "@graphcommerce/graphql": "^10.0.0-canary.66",
17
+ "@graphcommerce/next-ui": "^10.0.0-canary.66",
18
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.66",
19
+ "@graphcommerce/react-hook-form": "^10.0.0-canary.66",
20
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.66",
21
21
  "@lingui/core": "^5",
22
22
  "@lingui/macro": "^5",
23
23
  "@lingui/react": "^5",