@faststore/components 2.0.60-alpha.0 → 2.0.61-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/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/molecules/CartItem/CartItem.d.ts +37 -0
- package/dist/molecules/CartItem/CartItem.js +15 -0
- package/dist/molecules/CartItem/CartItem.js.map +1 -0
- package/dist/molecules/CartItem/CartItemImage.d.ts +10 -0
- package/dist/molecules/CartItem/CartItemImage.js +6 -0
- package/dist/molecules/CartItem/CartItemImage.js.map +1 -0
- package/dist/molecules/CartItem/CartItemSummary.d.ts +21 -0
- package/dist/molecules/CartItem/CartItemSummary.js +12 -0
- package/dist/molecules/CartItem/CartItemSummary.js.map +1 -0
- package/dist/molecules/CartItem/index.d.ts +6 -0
- package/dist/molecules/CartItem/index.js +4 -0
- package/dist/molecules/CartItem/index.js.map +1 -0
- package/dist/molecules/IconButton/IconButton.js +2 -4
- package/dist/molecules/IconButton/IconButton.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +10 -0
- package/src/molecules/CartItem/CartItem.tsx +92 -0
- package/src/molecules/CartItem/CartItemImage.tsx +29 -0
- package/src/molecules/CartItem/CartItemSummary.tsx +53 -0
- package/src/molecules/CartItem/index.tsx +8 -0
- package/src/molecules/IconButton/IconButton.tsx +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type { AccordionProps, AccordionItemProps, AccordionButtonProps, Accordio
|
|
|
36
36
|
export { default as Alert } from './molecules/Alert';
|
|
37
37
|
export type { AlertProps } from './molecules/Alert';
|
|
38
38
|
export { default as BuyButton } from './molecules/BuyButton';
|
|
39
|
+
export { default as CartItem, CartItemImage, CartItemSummary, } from './molecules/CartItem';
|
|
40
|
+
export type { CartItemProps, CartItemImageProps, CartItemSummaryProps, } from './molecules/CartItem';
|
|
39
41
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
|
40
42
|
export type { CheckboxFieldProps } from './molecules/CheckboxField';
|
|
41
43
|
export { default as IconButton } from './molecules/IconButton';
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { default as SROnly } from './atoms/SROnly';
|
|
|
23
23
|
export { default as Accordion, AccordionItem, AccordionButton, AccordionPanel, } from './molecules/Accordion';
|
|
24
24
|
export { default as Alert } from './molecules/Alert';
|
|
25
25
|
export { default as BuyButton } from './molecules/BuyButton';
|
|
26
|
+
export { default as CartItem, CartItemImage, CartItemSummary, } from './molecules/CartItem';
|
|
26
27
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
|
27
28
|
export { default as IconButton } from './molecules/IconButton';
|
|
28
29
|
export { default as DiscountBadge } from './molecules/DiscountBadge';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,UAAU,CAAA;AAExB,QAAQ;AACR,cAAc,SAAS,CAAA;AAEvB,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,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9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SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAO1E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IconButtonProps, Price } from '../../';
|
|
4
|
+
import type { PriceFormatter } from '../../atoms/Price/Price';
|
|
5
|
+
interface Price {
|
|
6
|
+
value: number;
|
|
7
|
+
listPrice: number;
|
|
8
|
+
formatter: PriceFormatter;
|
|
9
|
+
}
|
|
10
|
+
export interface CartItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
/**
|
|
12
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
13
|
+
*/
|
|
14
|
+
testId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Specifies product Price.
|
|
17
|
+
*/
|
|
18
|
+
price?: Price;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the quantity of items of the same product.
|
|
21
|
+
*/
|
|
22
|
+
quantity?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies that this product is unavailable.
|
|
25
|
+
*/
|
|
26
|
+
unavailable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Event emitted when product quantity value is changed.
|
|
29
|
+
*/
|
|
30
|
+
onQuantityChange?: (value: number) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Props for the Remove from cart IconButton component.
|
|
33
|
+
*/
|
|
34
|
+
removeBtnProps?: Partial<IconButtonProps>;
|
|
35
|
+
}
|
|
36
|
+
declare const CartItem: React.ForwardRefExoticComponent<CartItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
37
|
+
export default CartItem;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { XCircle } from '../../assets';
|
|
3
|
+
import { IconButton, Price, QuantitySelector } from '../../';
|
|
4
|
+
const CartItem = forwardRef(function CartItem({ testId = 'fs-cart-item', price, quantity, unavailable, onQuantityChange, children, removeBtnProps, ...otherProps }, ref) {
|
|
5
|
+
return (React.createElement("article", { ref: ref, "data-fs-cart-item": unavailable ? 'unavailable' : 'true', "data-testid": testId, ...otherProps },
|
|
6
|
+
React.createElement("div", { "data-fs-cart-item-content": true }, children),
|
|
7
|
+
React.createElement(IconButton, { "data-fs-cart-item-remove-button": true, icon: React.createElement(XCircle, null), "aria-label": "Remove", ...removeBtnProps }),
|
|
8
|
+
React.createElement("div", { "data-fs-cart-item-actions": true },
|
|
9
|
+
React.createElement(QuantitySelector, { min: 1, initial: quantity, onChange: onQuantityChange }),
|
|
10
|
+
React.createElement("span", { "data-fs-cart-item-prices": true },
|
|
11
|
+
React.createElement(Price, { value: price?.listPrice ? price.listPrice : 0, formatter: price?.formatter, variant: "listing" }),
|
|
12
|
+
React.createElement(Price, { value: price?.value ? price.value : 0, formatter: price?.formatter, variant: "spot" })))));
|
|
13
|
+
});
|
|
14
|
+
export default CartItem;
|
|
15
|
+
//# sourceMappingURL=CartItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartItem.js","sourceRoot":"","sources":["../../../src/molecules/CartItem/CartItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAmB,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAqC7E,MAAM,QAAQ,GAAG,UAAU,CAAgC,SAAS,QAAQ,CAC1E,EACE,MAAM,GAAG,cAAc,EACvB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,iCACE,GAAG,EAAE,GAAG,uBACW,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,iBAC1C,MAAM,KACf,UAAU;QAEd,kEAAgC,QAAQ,CAAO;QAC/C,oBAAC,UAAU,6CAET,IAAI,EAAE,oBAAC,OAAO,OAAG,gBACN,QAAQ,KACf,cAAc,GAClB;QACF;YACE,oBAAC,gBAAgB,IACf,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,gBAAgB,GAC1B;YACF;gBACE,oBAAC,KAAK,IACJ,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7C,SAAS,EAAE,KAAK,EAAE,SAAS,EAC3B,OAAO,EAAC,SAAS,GACjB;gBACF,oBAAC,KAAK,IACJ,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACrC,SAAS,EAAE,KAAK,EAAE,SAAS,EAC3B,OAAO,EAAC,MAAM,GACd,CACG,CACH,CACE,CACX,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface CartItemImageProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
6
|
+
*/
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const CartItemImage: React.ForwardRefExoticComponent<CartItemImageProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default CartItemImage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
const CartItemImage = forwardRef(function CartItemImage({ testId = 'fs-cart-item-image', children, ...otherProps }, ref) {
|
|
3
|
+
return (React.createElement("div", { ref: ref, "data-fs-cart-item-image": true, "data-testid": testId, ...otherProps }, children));
|
|
4
|
+
});
|
|
5
|
+
export default CartItemImage;
|
|
6
|
+
//# sourceMappingURL=CartItemImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartItemImage.js","sourceRoot":"","sources":["../../../src/molecules/CartItem/CartItemImage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AASzC,MAAM,aAAa,GAAG,UAAU,CAC9B,SAAS,aAAa,CACpB,EAAE,MAAM,GAAG,oBAAoB,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAC1D,GAAG;IAEH,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,kDAEK,MAAM,KACf,UAAU,IAEb,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { HTMLAttributes } from 'react';
|
|
3
|
+
export interface CartItemSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
6
|
+
*/
|
|
7
|
+
testId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Specifies the product's title.
|
|
10
|
+
*/
|
|
11
|
+
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* Array of the product's chosen variations.
|
|
14
|
+
*/
|
|
15
|
+
activeVariations?: Array<{
|
|
16
|
+
label: string;
|
|
17
|
+
option: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
declare const CartItemSummary: React.ForwardRefExoticComponent<CartItemSummaryProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export default CartItemSummary;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
const CartItemSummary = forwardRef(function CartItemSummary({ testId = 'fs-cart-item-summary', title, activeVariations = [], children, ...otherProps }, ref) {
|
|
3
|
+
return (React.createElement("div", { ref: ref, "data-fs-cart-item-summary": true, "data-testid": testId, ...otherProps },
|
|
4
|
+
React.createElement("div", { "data-fs-cart-item-title": true }, title),
|
|
5
|
+
activeVariations.length > 0 && (React.createElement("div", { "data-fs-cart-item-skus": true }, activeVariations.map(({ label, option }) => (React.createElement("p", { key: label },
|
|
6
|
+
label,
|
|
7
|
+
": ",
|
|
8
|
+
React.createElement("span", null, option)))))),
|
|
9
|
+
children));
|
|
10
|
+
});
|
|
11
|
+
export default CartItemSummary;
|
|
12
|
+
//# sourceMappingURL=CartItemSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CartItemSummary.js","sourceRoot":"","sources":["../../../src/molecules/CartItem/CartItemSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAkBzC,MAAM,eAAe,GAAG,UAAU,CAChC,SAAS,eAAe,CACtB,EACE,MAAM,GAAG,sBAAsB,EAC/B,KAAK,EACL,gBAAgB,GAAG,EAAE,EACrB,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,oDAEK,MAAM,KACf,UAAU;QAEd,gEAA8B,KAAK,CAAO;QACzC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,CAC9B,+DACG,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAC3C,2BAAG,GAAG,EAAE,KAAK;YACV,KAAK;;YAAG,kCAAO,MAAM,CAAQ,CAC5B,CACL,CAAC,CACE,CACP;QACA,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default } from './CartItem';
|
|
2
|
+
export type { CartItemProps } from './CartItem';
|
|
3
|
+
export { default as CartItemImage } from './CartItemImage';
|
|
4
|
+
export type { CartItemImageProps } from './CartItemImage';
|
|
5
|
+
export { default as CartItemSummary } from './CartItemSummary';
|
|
6
|
+
export type { CartItemSummaryProps } from './CartItemSummary';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/CartItem/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Button } from '../../';
|
|
3
3
|
const IconButton = forwardRef(function IconButton({ icon, children, testId = 'fs-icon-button', 'aria-label': ariaLabel, variant, ...otherProps }, ref) {
|
|
4
|
-
return (React.createElement(Button, { ref: ref, "data-fs-button": true, "data-fs-icon-button": true, variant: variant ?? 'tertiary', "aria-label": ariaLabel, testId: testId, ...otherProps },
|
|
5
|
-
children,
|
|
6
|
-
React.createElement(Icon, { component: icon })));
|
|
4
|
+
return (React.createElement(Button, { ref: ref, "data-fs-button": true, "data-fs-icon-button": true, variant: variant ?? 'tertiary', icon: icon, "aria-label": ariaLabel, testId: testId, ...otherProps }, children));
|
|
7
5
|
});
|
|
8
6
|
export default IconButton;
|
|
9
7
|
//# sourceMappingURL=IconButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../src/molecules/IconButton/IconButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../src/molecules/IconButton/IconButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAkB/B,MAAM,UAAU,GAAG,UAAU,CAC3B,SAAS,UAAU,CACjB,EACE,IAAI,EACJ,QAAQ,EACR,MAAM,GAAG,gBAAgB,EACzB,YAAY,EAAE,SAAS,EACvB,OAAO,EACP,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,oBAAC,MAAM,IACL,GAAG,EAAE,GAAG,uDAGR,OAAO,EAAE,OAAO,IAAI,UAAU,EAC9B,IAAI,EAAE,IAAI,gBACE,SAAS,EACrB,MAAM,EAAE,MAAM,KACV,UAAU,IAEb,QAAQ,CACF,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.61-alpha.0",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"node": "16.18.0",
|
|
31
31
|
"yarn": "1.19.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7cb1ceba4bdfd0495b1f9226fa640d476ba15810"
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,16 @@ export type {
|
|
|
53
53
|
export { default as Alert } from './molecules/Alert'
|
|
54
54
|
export type { AlertProps } from './molecules/Alert'
|
|
55
55
|
export { default as BuyButton } from './molecules/BuyButton'
|
|
56
|
+
export {
|
|
57
|
+
default as CartItem,
|
|
58
|
+
CartItemImage,
|
|
59
|
+
CartItemSummary,
|
|
60
|
+
} from './molecules/CartItem'
|
|
61
|
+
export type {
|
|
62
|
+
CartItemProps,
|
|
63
|
+
CartItemImageProps,
|
|
64
|
+
CartItemSummaryProps,
|
|
65
|
+
} from './molecules/CartItem'
|
|
56
66
|
export { default as CheckboxField } from './molecules/CheckboxField'
|
|
57
67
|
export type { CheckboxFieldProps } from './molecules/CheckboxField'
|
|
58
68
|
export { default as IconButton } from './molecules/IconButton'
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
import { XCircle } from '../../assets'
|
|
5
|
+
import { IconButton, IconButtonProps, Price, QuantitySelector } from '../../'
|
|
6
|
+
|
|
7
|
+
import type { PriceFormatter } from '../../atoms/Price/Price'
|
|
8
|
+
|
|
9
|
+
interface Price {
|
|
10
|
+
value: number
|
|
11
|
+
listPrice: number
|
|
12
|
+
formatter: PriceFormatter
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CartItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
/**
|
|
17
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
18
|
+
*/
|
|
19
|
+
testId?: string
|
|
20
|
+
/**
|
|
21
|
+
* Specifies product Price.
|
|
22
|
+
*/
|
|
23
|
+
price?: Price
|
|
24
|
+
/**
|
|
25
|
+
* Specifies the quantity of items of the same product.
|
|
26
|
+
*/
|
|
27
|
+
quantity?: number
|
|
28
|
+
/**
|
|
29
|
+
* Specifies that this product is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
unavailable?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Event emitted when product quantity value is changed.
|
|
34
|
+
*/
|
|
35
|
+
onQuantityChange?: (value: number) => void
|
|
36
|
+
/**
|
|
37
|
+
* Props for the Remove from cart IconButton component.
|
|
38
|
+
*/
|
|
39
|
+
removeBtnProps?: Partial<IconButtonProps>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const CartItem = forwardRef<HTMLDivElement, CartItemProps>(function CartItem(
|
|
43
|
+
{
|
|
44
|
+
testId = 'fs-cart-item',
|
|
45
|
+
price,
|
|
46
|
+
quantity,
|
|
47
|
+
unavailable,
|
|
48
|
+
onQuantityChange,
|
|
49
|
+
children,
|
|
50
|
+
removeBtnProps,
|
|
51
|
+
...otherProps
|
|
52
|
+
},
|
|
53
|
+
ref
|
|
54
|
+
) {
|
|
55
|
+
return (
|
|
56
|
+
<article
|
|
57
|
+
ref={ref}
|
|
58
|
+
data-fs-cart-item={unavailable ? 'unavailable' : 'true'}
|
|
59
|
+
data-testid={testId}
|
|
60
|
+
{...otherProps}
|
|
61
|
+
>
|
|
62
|
+
<div data-fs-cart-item-content>{children}</div>
|
|
63
|
+
<IconButton
|
|
64
|
+
data-fs-cart-item-remove-button
|
|
65
|
+
icon={<XCircle />}
|
|
66
|
+
aria-label="Remove"
|
|
67
|
+
{...removeBtnProps}
|
|
68
|
+
/>
|
|
69
|
+
<div data-fs-cart-item-actions>
|
|
70
|
+
<QuantitySelector
|
|
71
|
+
min={1}
|
|
72
|
+
initial={quantity}
|
|
73
|
+
onChange={onQuantityChange}
|
|
74
|
+
/>
|
|
75
|
+
<span data-fs-cart-item-prices>
|
|
76
|
+
<Price
|
|
77
|
+
value={price?.listPrice ? price.listPrice : 0}
|
|
78
|
+
formatter={price?.formatter}
|
|
79
|
+
variant="listing"
|
|
80
|
+
/>
|
|
81
|
+
<Price
|
|
82
|
+
value={price?.value ? price.value : 0}
|
|
83
|
+
formatter={price?.formatter}
|
|
84
|
+
variant="spot"
|
|
85
|
+
/>
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
88
|
+
</article>
|
|
89
|
+
)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
export default CartItem
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface CartItemImageProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const CartItemImage = forwardRef<HTMLDivElement, CartItemImageProps>(
|
|
12
|
+
function CartItemImage(
|
|
13
|
+
{ testId = 'fs-cart-item-image', children, ...otherProps },
|
|
14
|
+
ref
|
|
15
|
+
) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
data-fs-cart-item-image
|
|
20
|
+
data-testid={testId}
|
|
21
|
+
{...otherProps}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export default CartItemImage
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import type { HTMLAttributes } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface CartItemSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
/**
|
|
10
|
+
* Specifies the product's title.
|
|
11
|
+
*/
|
|
12
|
+
title: string
|
|
13
|
+
/**
|
|
14
|
+
* Array of the product's chosen variations.
|
|
15
|
+
*/
|
|
16
|
+
activeVariations?: Array<{ label: string; option: string }>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CartItemSummary = forwardRef<HTMLDivElement, CartItemSummaryProps>(
|
|
20
|
+
function CartItemSummary(
|
|
21
|
+
{
|
|
22
|
+
testId = 'fs-cart-item-summary',
|
|
23
|
+
title,
|
|
24
|
+
activeVariations = [],
|
|
25
|
+
children,
|
|
26
|
+
...otherProps
|
|
27
|
+
},
|
|
28
|
+
ref
|
|
29
|
+
) {
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
ref={ref}
|
|
33
|
+
data-fs-cart-item-summary
|
|
34
|
+
data-testid={testId}
|
|
35
|
+
{...otherProps}
|
|
36
|
+
>
|
|
37
|
+
<div data-fs-cart-item-title>{title}</div>
|
|
38
|
+
{activeVariations.length > 0 && (
|
|
39
|
+
<div data-fs-cart-item-skus>
|
|
40
|
+
{activeVariations.map(({ label, option }) => (
|
|
41
|
+
<p key={label}>
|
|
42
|
+
{label}: <span>{option}</span>
|
|
43
|
+
</p>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
export default CartItemSummary
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default } from './CartItem'
|
|
2
|
+
export type { CartItemProps } from './CartItem'
|
|
3
|
+
|
|
4
|
+
export { default as CartItemImage } from './CartItemImage'
|
|
5
|
+
export type { CartItemImageProps } from './CartItemImage'
|
|
6
|
+
|
|
7
|
+
export { default as CartItemSummary } from './CartItemSummary'
|
|
8
|
+
export type { CartItemSummaryProps } from './CartItemSummary'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode, AriaAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Button } from '../../'
|
|
5
5
|
import type { ButtonProps } from '../../'
|
|
6
6
|
|
|
7
7
|
export interface IconButtonProps extends Omit<ButtonProps, 'aria-label'> {
|
|
@@ -37,12 +37,12 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
37
37
|
data-fs-button
|
|
38
38
|
data-fs-icon-button
|
|
39
39
|
variant={variant ?? 'tertiary'}
|
|
40
|
+
icon={icon}
|
|
40
41
|
aria-label={ariaLabel}
|
|
41
42
|
testId={testId}
|
|
42
43
|
{...otherProps}
|
|
43
44
|
>
|
|
44
45
|
{children}
|
|
45
|
-
<Icon component={icon} />
|
|
46
46
|
</Button>
|
|
47
47
|
)
|
|
48
48
|
}
|