@faststore/ui 1.3.42 → 1.3.43
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 +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/molecules/QuantitySelector/QuantitySelector.d.ts +30 -0
- package/dist/molecules/QuantitySelector/index.d.ts +2 -0
- package/dist/molecules/QuantitySelector/stories/QuantitySelector.stories.d.ts +5 -0
- package/dist/molecules/QuantitySelector/stories/assets/Icons.d.ts +7 -0
- package/dist/ui.cjs.development.js +29 -0
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +29 -1
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +3 -0
- package/src/molecules/QuantitySelector/QuantitySelector.test.tsx +93 -0
- package/src/molecules/QuantitySelector/QuantitySelector.tsx +82 -0
- package/src/molecules/QuantitySelector/index.ts +2 -0
- package/src/molecules/QuantitySelector/stories/QuantitySelector.mdx +26 -0
- package/src/molecules/QuantitySelector/stories/QuantitySelector.stories.tsx +77 -0
- package/src/molecules/QuantitySelector/stories/assets/Icons.tsx +52 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## 1.3.43 (2021-12-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* QuantitySelector component ([#1083](https://github.com/vtex/faststore/issues/1083)) ([6ade6c0](https://github.com/vtex/faststore/commit/6ade6c02b06fdb74ba2cd2978d8ac4bda35672d2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 1.3.42 (2021-12-20)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @faststore/ui
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export { default as Form } from './molecules/Form';
|
|
|
64
64
|
export type { FormProps } from './molecules/Form';
|
|
65
65
|
export { default as Alert } from './molecules/Alert';
|
|
66
66
|
export type { AlertProps } from './molecules/Alert';
|
|
67
|
+
export { default as QuantitySelector } from './molecules/QuantitySelector';
|
|
68
|
+
export type { QuantitySelectorProps } from './molecules/QuantitySelector';
|
|
67
69
|
export { default as Card, CardImage, CardContent, CardActions, } from './organisms/Card';
|
|
68
70
|
export type { CardProps, CardImageProps, CardContentProps, CardActionsProps, } from './organisms/Card';
|
|
69
71
|
export { default as useSlider } from './hooks/useSlider';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { InputProps } from '../../atoms/Input';
|
|
4
|
+
import type { IconButtonProps } from '../IconButton';
|
|
5
|
+
export interface QuantitySelectorProps extends InputHTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the current value that should be displayed on the input at the center of the quantity selector.
|
|
8
|
+
*/
|
|
9
|
+
quantity: number | string;
|
|
10
|
+
/**
|
|
11
|
+
* Object with properties that will be passed forward the inner IconButton atom at the left of the input.
|
|
12
|
+
*/
|
|
13
|
+
leftButtonProps: IconButtonProps;
|
|
14
|
+
/**
|
|
15
|
+
* Object with properties that will be passed forward the inner Input atom between the two buttons.
|
|
16
|
+
*/
|
|
17
|
+
inputProps: InputProps;
|
|
18
|
+
/**
|
|
19
|
+
* Object with properties that will be passed forward the inner IconButton atom at the right of the input.
|
|
20
|
+
*/
|
|
21
|
+
rightButtonProps: IconButtonProps;
|
|
22
|
+
/**
|
|
23
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
24
|
+
*
|
|
25
|
+
* @default 'store-quantity-selector'
|
|
26
|
+
*/
|
|
27
|
+
testId?: string;
|
|
28
|
+
}
|
|
29
|
+
declare const QuantitySelector: React.ForwardRefExoticComponent<QuantitySelectorProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
export default QuantitySelector;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Story } from '@storybook/react';
|
|
2
|
+
import type { QuantitySelectorProps } from '../QuantitySelector';
|
|
3
|
+
export declare const QuantitySelector: Story<QuantitySelectorProps>;
|
|
4
|
+
declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, import("@storybook/react").Args>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type QuantitySelectorIconProps = {
|
|
3
|
+
color: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function PlusIcon(props: QuantitySelectorIconProps): JSX.Element;
|
|
6
|
+
export declare function MinusIcon(props: QuantitySelectorIconProps): JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1520,6 +1520,34 @@ const Alert = /*#__PURE__*/React.forwardRef(function Alert({
|
|
|
1520
1520
|
}, otherProps), children);
|
|
1521
1521
|
});
|
|
1522
1522
|
|
|
1523
|
+
const QuantitySelector = /*#__PURE__*/React.forwardRef(function QuantitySelector({
|
|
1524
|
+
quantity,
|
|
1525
|
+
testId = 'store-quantity-selector',
|
|
1526
|
+
leftButtonProps,
|
|
1527
|
+
inputProps,
|
|
1528
|
+
rightButtonProps,
|
|
1529
|
+
...otherProps
|
|
1530
|
+
}, ref) {
|
|
1531
|
+
return React__default.createElement("div", Object.assign({
|
|
1532
|
+
"data-store-quantity-selector": true,
|
|
1533
|
+
"data-testid": testId,
|
|
1534
|
+
ref: ref
|
|
1535
|
+
}, otherProps), React__default.createElement(IconButton, Object.assign({
|
|
1536
|
+
"aria-controls": "quantity-selector-input",
|
|
1537
|
+
"aria-label": "Decrement Quantity",
|
|
1538
|
+
"data-quantity-selector-button": "left"
|
|
1539
|
+
}, leftButtonProps)), React__default.createElement(Input, Object.assign({
|
|
1540
|
+
"aria-label": "Quantity",
|
|
1541
|
+
"data-quantity-selector-input": true,
|
|
1542
|
+
id: "quantity-selector-input",
|
|
1543
|
+
value: quantity
|
|
1544
|
+
}, inputProps)), React__default.createElement(IconButton, Object.assign({
|
|
1545
|
+
"aria-controls": "quantity-selector-input",
|
|
1546
|
+
"aria-label": "Increment Quantity",
|
|
1547
|
+
"data-quantity-selector-button": "right"
|
|
1548
|
+
}, rightButtonProps)));
|
|
1549
|
+
});
|
|
1550
|
+
|
|
1523
1551
|
const Card = /*#__PURE__*/React.forwardRef(function Card({
|
|
1524
1552
|
testId = 'store-card',
|
|
1525
1553
|
children,
|
|
@@ -1605,6 +1633,7 @@ exports.PaymentMethods = PaymentMethods;
|
|
|
1605
1633
|
exports.Popover = Popover;
|
|
1606
1634
|
exports.Price = Price;
|
|
1607
1635
|
exports.PriceRange = PriceRange;
|
|
1636
|
+
exports.QuantitySelector = QuantitySelector;
|
|
1608
1637
|
exports.Radio = Radio;
|
|
1609
1638
|
exports.RadioGroup = RadioGroup;
|
|
1610
1639
|
exports.RadioOption = RadioOption;
|