@graphcommerce/magento-store 4.0.3 → 4.1.0
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 +34 -0
- package/Money.tsx +24 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1285](https://github.com/ho-nl/m2-pwa/pull/1285)
|
|
8
|
+
[`ed9703b06`](https://github.com/ho-nl/m2-pwa/commit/ed9703b062d23ee01b1605ff9917c0ac3247fc25)
|
|
9
|
+
Thanks [@paales](https://github.com/paales)! - Added the ability to configure `defaultProps` for
|
|
10
|
+
the <Money/> component.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// For example in examples/magento-graphcms/theme.ts
|
|
14
|
+
|
|
15
|
+
const createOverrides = (theme: Theme): Components => ({
|
|
16
|
+
Money: {
|
|
17
|
+
defaultProps: {
|
|
18
|
+
round: true,
|
|
19
|
+
formatOptions: {
|
|
20
|
+
style: 'decimal',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#1285](https://github.com/ho-nl/m2-pwa/pull/1285)
|
|
30
|
+
[`c85294ba6`](https://github.com/ho-nl/m2-pwa/commit/c85294ba6d742ce78c074559a1e95409b25a5017)
|
|
31
|
+
Thanks [@paales](https://github.com/paales)! - upgraded dependencies
|
|
32
|
+
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
[[`c85294ba6`](https://github.com/ho-nl/m2-pwa/commit/c85294ba6d742ce78c074559a1e95409b25a5017)]:
|
|
35
|
+
- @graphcommerce/next-ui@4.1.3
|
|
36
|
+
|
|
3
37
|
## 4.0.3
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/Money.tsx
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { useQuery } from '@graphcommerce/graphql'
|
|
2
|
-
import
|
|
2
|
+
import { ExtendableComponent } from '@graphcommerce/next-ui'
|
|
3
|
+
import { useThemeProps } from '@mui/material'
|
|
4
|
+
import { useMemo } from 'react'
|
|
3
5
|
import { MoneyFragment } from './Money.gql'
|
|
4
6
|
import { StoreConfigDocument } from './StoreConfig.gql'
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
type OverridableProps = {
|
|
9
|
+
round?: boolean
|
|
10
|
+
/** @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters */
|
|
11
|
+
formatOptions?: Intl.NumberFormatOptions
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type MoneyProps = MoneyFragment & OverridableProps
|
|
15
|
+
|
|
16
|
+
const name = 'Money'
|
|
17
|
+
|
|
18
|
+
/** Expose the component to be exendable in your theme.components */
|
|
19
|
+
declare module '@mui/material/styles/components' {
|
|
20
|
+
interface Components {
|
|
21
|
+
Money?: Pick<ExtendableComponent<OverridableProps>, 'defaultProps'>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Money(props: MoneyProps) {
|
|
26
|
+
const { currency, value, round = false, formatOptions } = useThemeProps({ name, props })
|
|
7
27
|
|
|
8
|
-
export function Money({ currency, value, round = false }: MoneyProps) {
|
|
9
28
|
const { data: config } = useQuery(StoreConfigDocument)
|
|
10
29
|
const locale = config?.storeConfig?.locale
|
|
11
30
|
|
|
@@ -18,8 +37,9 @@ export function Money({ currency, value, round = false }: MoneyProps) {
|
|
|
18
37
|
style: 'currency',
|
|
19
38
|
currency: currency ?? config?.storeConfig?.base_currency_code ?? '',
|
|
20
39
|
...(digits && { minimumFractionDigits: 0 }),
|
|
40
|
+
...formatOptions,
|
|
21
41
|
})
|
|
22
|
-
}, [config?.storeConfig?.base_currency_code, currency, digits, locale])
|
|
42
|
+
}, [config?.storeConfig?.base_currency_code, currency, digits, formatOptions, locale])
|
|
23
43
|
|
|
24
44
|
if (!numberFormatter || !value) return null
|
|
25
45
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-store",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "4.0
|
|
5
|
+
"version": "4.1.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^4.0.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^4.0.4",
|
|
16
16
|
"@graphcommerce/prettier-config-pwa": "^4.0.2",
|
|
17
17
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
18
18
|
"@playwright/test": "^1.19.1"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@graphcommerce/graphql": "^3.0.3",
|
|
22
22
|
"@graphcommerce/image": "^3.1.0",
|
|
23
|
-
"@graphcommerce/next-ui": "^4.1.
|
|
23
|
+
"@graphcommerce/next-ui": "^4.1.3",
|
|
24
24
|
"type-fest": "^2.12.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|