@faststore/components 2.0.7-alpha.0 → 2.0.9-alpha.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 +9 -0
- package/dist/atoms/Price/Price.d.ts +28 -0
- package/dist/atoms/Price/Price.js +7 -0
- package/dist/atoms/Price/Price.js.map +1 -0
- package/dist/atoms/Price/index.d.ts +2 -0
- package/dist/atoms/Price/index.js +2 -0
- package/dist/atoms/Price/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/atoms/Price/Price.tsx +65 -0
- package/src/atoms/Price/index.ts +2 -0
- package/src/index.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.9-alpha.0](https://github.com/vtex/faststore/compare/v2.0.8-alpha.0...v2.0.9-alpha.0) (2022-12-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Create `Price` component ([#1548](https://github.com/vtex/faststore/issues/1548)) ([2d7418a](https://github.com/vtex/faststore/commit/2d7418ad45f42cdb0174d45d7c4de5b6d6e27f60))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [2.0.7-alpha.0](https://github.com/vtex/faststore/compare/v2.0.6-alpha.0...v2.0.7-alpha.0) (2022-12-09)
|
|
7
16
|
|
|
8
17
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare type PriceVariant = 'selling' | 'listing' | 'spot' | 'savings' | 'installment';
|
|
4
|
+
export declare type PriceFormatter = (price: number, variant: PriceVariant) => ReactNode;
|
|
5
|
+
export interface PriceProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* Set the HTML element tag of this component.
|
|
8
|
+
*/
|
|
9
|
+
as?: ElementType;
|
|
10
|
+
/**
|
|
11
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
12
|
+
*/
|
|
13
|
+
testId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The raw price value.
|
|
16
|
+
*/
|
|
17
|
+
value: number;
|
|
18
|
+
/**
|
|
19
|
+
* Formatter function that transforms the raw price value and render the result.
|
|
20
|
+
*/
|
|
21
|
+
formatter?: PriceFormatter;
|
|
22
|
+
/**
|
|
23
|
+
* The current use case variant for prices.
|
|
24
|
+
*/
|
|
25
|
+
variant?: PriceVariant;
|
|
26
|
+
}
|
|
27
|
+
declare const Price: React.ForwardRefExoticComponent<PriceProps & React.RefAttributes<Omit<HTMLSpanElement, "children">>>;
|
|
28
|
+
export default Price;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
const Price = forwardRef(function Price({ value, as: Component = 'span', variant = 'selling', testId = 'fs-price', formatter = (price) => price, ...otherProps }, ref) {
|
|
3
|
+
const formattedPrice = formatter(value, variant);
|
|
4
|
+
return (React.createElement(Component, { ref: ref, "data-fs-price": true, "data-testid": testId, "data-fs-price-variant": variant, ...otherProps }, formattedPrice));
|
|
5
|
+
});
|
|
6
|
+
export default Price;
|
|
7
|
+
//# sourceMappingURL=Price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Price.js","sourceRoot":"","sources":["../../../src/atoms/Price/Price.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAmCzC,MAAM,KAAK,GAAG,UAAU,CACtB,SAAS,KAAK,CACZ,EACE,KAAK,EACL,EAAE,EAAE,SAAS,GAAG,MAAM,EACtB,OAAO,GAAG,SAAS,EACnB,MAAM,GAAG,UAAU,EACnB,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAC5B,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAEhD,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,wCAEK,MAAM,2BACI,OAAO,KAC1B,UAAU,IAEb,cAAc,CACL,CACb,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/atoms/Price/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { default as Label } from './atoms/Label';
|
|
|
12
12
|
export type { LabelProps } from './atoms/Label';
|
|
13
13
|
export { default as Overlay } from './atoms/Overlay';
|
|
14
14
|
export type { OverlayProps } from './atoms/Overlay';
|
|
15
|
+
export { default as Price } from './atoms/Price';
|
|
16
|
+
export type { PriceProps } from './atoms/Price';
|
|
15
17
|
export { default as Radio } from './atoms/Radio';
|
|
16
18
|
export type { RadioProps } from './atoms/Radio';
|
|
17
19
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as Icon } from './atoms/Icon';
|
|
|
6
6
|
export { default as Input } from './atoms/Input';
|
|
7
7
|
export { default as Label } from './atoms/Label';
|
|
8
8
|
export { default as Overlay } from './atoms/Overlay';
|
|
9
|
+
export { default as Price } from './atoms/Price';
|
|
9
10
|
export { default as Radio } from './atoms/Radio';
|
|
10
11
|
// Molecules
|
|
11
12
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAGhD,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAGhD,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9-alpha.0",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"node": "16.18.0",
|
|
29
29
|
"yarn": "1.19.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "df3ddd2d140bf19046a4753474bebee4298cd6ac"
|
|
32
32
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export type PriceVariant =
|
|
5
|
+
| 'selling'
|
|
6
|
+
| 'listing'
|
|
7
|
+
| 'spot'
|
|
8
|
+
| 'savings'
|
|
9
|
+
| 'installment'
|
|
10
|
+
|
|
11
|
+
export type PriceFormatter = (price: number, variant: PriceVariant) => ReactNode
|
|
12
|
+
|
|
13
|
+
export interface PriceProps
|
|
14
|
+
extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
15
|
+
/**
|
|
16
|
+
* Set the HTML element tag of this component.
|
|
17
|
+
*/
|
|
18
|
+
as?: ElementType
|
|
19
|
+
/**
|
|
20
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
21
|
+
*/
|
|
22
|
+
testId?: string
|
|
23
|
+
/**
|
|
24
|
+
* The raw price value.
|
|
25
|
+
*/
|
|
26
|
+
value: number
|
|
27
|
+
/**
|
|
28
|
+
* Formatter function that transforms the raw price value and render the result.
|
|
29
|
+
*/
|
|
30
|
+
formatter?: PriceFormatter
|
|
31
|
+
/**
|
|
32
|
+
* The current use case variant for prices.
|
|
33
|
+
*/
|
|
34
|
+
variant?: PriceVariant
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const Price = forwardRef<Omit<HTMLSpanElement, 'children'>, PriceProps>(
|
|
38
|
+
function Price(
|
|
39
|
+
{
|
|
40
|
+
value,
|
|
41
|
+
as: Component = 'span',
|
|
42
|
+
variant = 'selling',
|
|
43
|
+
testId = 'fs-price',
|
|
44
|
+
formatter = (price) => price,
|
|
45
|
+
...otherProps
|
|
46
|
+
},
|
|
47
|
+
ref
|
|
48
|
+
) {
|
|
49
|
+
const formattedPrice = formatter(value, variant)
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Component
|
|
53
|
+
ref={ref}
|
|
54
|
+
data-fs-price
|
|
55
|
+
data-testid={testId}
|
|
56
|
+
data-fs-price-variant={variant}
|
|
57
|
+
{...otherProps}
|
|
58
|
+
>
|
|
59
|
+
{formattedPrice}
|
|
60
|
+
</Component>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
export default Price
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { default as Label } from './atoms/Label'
|
|
|
13
13
|
export type { LabelProps } from './atoms/Label'
|
|
14
14
|
export { default as Overlay } from './atoms/Overlay'
|
|
15
15
|
export type { OverlayProps } from './atoms/Overlay'
|
|
16
|
+
export { default as Price } from './atoms/Price'
|
|
17
|
+
export type { PriceProps } from './atoms/Price'
|
|
16
18
|
export { default as Radio } from './atoms/Radio'
|
|
17
19
|
export type { RadioProps } from './atoms/Radio'
|
|
18
20
|
|