@faststore/ui 1.3.19 → 1.3.23
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 +38 -0
- package/README.md +1 -44
- package/dist/index.d.ts +10 -0
- package/dist/molecules/Banner/Banner.d.ts +13 -0
- package/dist/molecules/Banner/BannerContent.d.ts +10 -0
- package/dist/molecules/Banner/BannerImage.d.ts +10 -0
- package/dist/molecules/Banner/BannerLink.d.ts +10 -0
- package/dist/molecules/Banner/index.d.ts +8 -0
- package/dist/molecules/Banner/stories/Banner.stories.d.ts +4 -0
- package/dist/molecules/RadioGroup/index.d.ts +4 -4
- package/dist/ui.cjs.development.js +199 -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 +195 -2
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +15 -0
- package/src/molecules/Banner/Banner.test.tsx +63 -0
- package/src/molecules/Banner/Banner.tsx +26 -0
- package/src/molecules/Banner/BannerContent.tsx +31 -0
- package/src/molecules/Banner/BannerImage.tsx +29 -0
- package/src/molecules/Banner/BannerLink.tsx +29 -0
- package/src/molecules/Banner/index.ts +11 -0
- package/src/molecules/Banner/stories/Banner.mdx +63 -0
- package/src/molecules/Banner/stories/Banner.stories.tsx +66 -0
- package/src/molecules/RadioGroup/RadioGroup.test.tsx +3 -1
- package/src/molecules/RadioGroup/index.tsx +4 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
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.23 (2021-12-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @faststore/ui
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.3.22 (2021-12-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @faststore/ui
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.3.21 (2021-12-07)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add docs ([#1058](https://github.com/vtex/faststore/issues/1058)) ([35f3e62](https://github.com/vtex/faststore/commit/35f3e62ae09c350632479742c9ce2c22e8862b23))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 1.3.20 (2021-12-07)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **store-ui:** Banner component ([#1048](https://github.com/vtex/faststore/issues/1048)) ([b65d8e5](https://github.com/vtex/faststore/commit/b65d8e574598f8bf8494aac478e4bec4d774ec86))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## 1.3.19 (2021-12-07)
|
|
7
45
|
|
|
8
46
|
|
package/README.md
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
1
|
# @faststore/ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@faststore/ui) [](https://standardjs.com)
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
From the command line in your project directory, run npm install `@faststore/ui` or yarn add `@faststore/ui`.
|
|
10
|
-
|
|
11
|
-
```cmd
|
|
12
|
-
npm install @faststore/ui
|
|
13
|
-
# or
|
|
14
|
-
yarn add @faststore/ui
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
For style, you can use our default theme. To install:
|
|
18
|
-
|
|
19
|
-
```cmd
|
|
20
|
-
npm install @vtex/theme-b2c-tailwind
|
|
21
|
-
# or
|
|
22
|
-
yarn add @vtex/theme-b2c-tailwind
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
import { Button } from '@faststore/ui'
|
|
29
|
-
import '@vtex/theme-b2c-tailwind/dist/index.css'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```tsx
|
|
33
|
-
import React, { Component } from 'react'
|
|
34
|
-
|
|
35
|
-
import MyComponent from '@faststore/ui'
|
|
36
|
-
|
|
37
|
-
class Example extends Component {
|
|
38
|
-
render() {
|
|
39
|
-
return <MyComponent />
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## License
|
|
45
|
-
|
|
46
|
-
MIT © [emersonlaurentino](https://github.com/emersonlaurentino)
|
|
3
|
+
Docs moved to https://faststore.dev/reference/ui/overview
|
package/dist/index.d.ts
CHANGED
|
@@ -40,8 +40,18 @@ export { default as IconButton } from './molecules/IconButton';
|
|
|
40
40
|
export type { IconButtonProps } from './molecules/IconButton';
|
|
41
41
|
export { default as Modal } from './molecules/Modal';
|
|
42
42
|
export type { ModalProps } from './molecules/Modal';
|
|
43
|
+
export { default as Banner } from './molecules/Banner';
|
|
44
|
+
export type { BannerProps } from './molecules/Banner';
|
|
43
45
|
export { default as PaymentMethods } from './molecules/PaymentMethods';
|
|
44
46
|
export type { PaymentMethodsProps } from './molecules/PaymentMethods';
|
|
47
|
+
export { default as Breadcrumb } from './molecules/Breadcrumb';
|
|
48
|
+
export type { BreadcrumbProps } from './molecules/Breadcrumb';
|
|
49
|
+
export { default as LoadingButton } from './molecules/LoadingButton';
|
|
50
|
+
export type { LoadingButtonProps } from './molecules/LoadingButton';
|
|
51
|
+
export { default as PriceRange } from './molecules/PriceRange';
|
|
52
|
+
export type { PriceRangeProps } from './molecules/PriceRange';
|
|
53
|
+
export { default as RadioGroup, RadioOption } from './molecules/RadioGroup';
|
|
54
|
+
export type { RadioGroupProps, RadioOptionProps } from './molecules/RadioGroup';
|
|
45
55
|
export { default as Accordion, AccordionItem, AccordionButton, AccordionPanel, } from './molecules/Accordion';
|
|
46
56
|
export type { AccordionProps, AccordionItemProps, AccordionButtonProps, AccordionPanelProps, } from './molecules/Accordion';
|
|
47
57
|
export { Table, TableBody, TableCell, TableFooter, TableHead, TableRow, } from './molecules/Table';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type BannerDirectionVariant = 'vertical' | 'horizontal';
|
|
3
|
+
export interface BannerProps {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
6
|
+
* testing-library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
variant?: BannerDirectionVariant;
|
|
11
|
+
}
|
|
12
|
+
declare const Banner: ({ testId, children, variant, }: BannerProps) => JSX.Element;
|
|
13
|
+
export default Banner;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface BannerContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
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 BannerContent: React.ForwardRefExoticComponent<BannerContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default BannerContent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface BannerImageProps 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 BannerImage: React.ForwardRefExoticComponent<BannerImageProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default BannerImage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface BannerLinkProps 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 BannerLink: React.ForwardRefExoticComponent<BannerLinkProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default BannerLink;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default } from './Banner';
|
|
2
|
+
export type { BannerProps } from './Banner';
|
|
3
|
+
export { default as BannerImage } from './BannerImage';
|
|
4
|
+
export type { BannerImageProps } from './BannerImage';
|
|
5
|
+
export { default as BannerContent } from './BannerContent';
|
|
6
|
+
export type { BannerContentProps } from './BannerContent';
|
|
7
|
+
export { default as BannerLink } from './BannerLink';
|
|
8
|
+
export type { BannerLinkProps } from './BannerLink';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BannerProps } from '../Banner';
|
|
2
|
+
export declare const Banner: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, BannerProps>;
|
|
3
|
+
declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, import("@storybook/react").Args>;
|
|
4
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
1
|
+
export { default } from './RadioGroup';
|
|
2
|
+
export type { RadioGroupProps } from './RadioGroup';
|
|
3
|
+
export { default as RadioOption } from './RadioOption';
|
|
4
|
+
export type { RadioOptionProps } from './RadioOption';
|
|
@@ -1010,6 +1010,17 @@ const Modal = ({
|
|
|
1010
1010
|
}), children)), document.body) : null;
|
|
1011
1011
|
};
|
|
1012
1012
|
|
|
1013
|
+
const Banner = ({
|
|
1014
|
+
testId = 'store-banner',
|
|
1015
|
+
children,
|
|
1016
|
+
variant = 'vertical'
|
|
1017
|
+
}) => {
|
|
1018
|
+
return React__default.createElement("article", {
|
|
1019
|
+
"data-store-banner": variant,
|
|
1020
|
+
"data-testid": testId
|
|
1021
|
+
}, children);
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1013
1024
|
const PaymentMethods = /*#__PURE__*/React.forwardRef(function PaymentMethods({
|
|
1014
1025
|
testId = 'store-payment-methods',
|
|
1015
1026
|
title,
|
|
@@ -1030,6 +1041,188 @@ const PaymentMethods = /*#__PURE__*/React.forwardRef(function PaymentMethods({
|
|
|
1030
1041
|
}, children));
|
|
1031
1042
|
});
|
|
1032
1043
|
|
|
1044
|
+
const Divider = ({
|
|
1045
|
+
divider,
|
|
1046
|
+
testId
|
|
1047
|
+
}) => {
|
|
1048
|
+
const props = {
|
|
1049
|
+
'data-store-breadcrumb-divider': true,
|
|
1050
|
+
'aria-hidden': true,
|
|
1051
|
+
'data-testid': `${testId}-divider`
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
if (React__default.isValidElement(divider)) {
|
|
1055
|
+
return React__default.cloneElement(divider, props);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return React__default.createElement("span", Object.assign({}, props), divider != null ? divider : '/');
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
const ListItem = ({
|
|
1062
|
+
children,
|
|
1063
|
+
isLastItem,
|
|
1064
|
+
testId
|
|
1065
|
+
}) => {
|
|
1066
|
+
const props = {
|
|
1067
|
+
'data-testid': `${testId}-item`,
|
|
1068
|
+
'data-store-breadcrumb-item': isLastItem ? 'current' : true,
|
|
1069
|
+
'aria-current': isLastItem ? 'page' : undefined
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
if (!React__default.isValidElement(children)) {
|
|
1073
|
+
return React__default.createElement("li", null, React__default.createElement("span", Object.assign({}, props), children));
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
return React__default.createElement("li", null, React__default.cloneElement(children, props));
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
const Breadcrumb = /*#__PURE__*/React.forwardRef(function Breadcrumb({
|
|
1080
|
+
children,
|
|
1081
|
+
divider: rawDivider,
|
|
1082
|
+
testId = 'store-breadcrumb',
|
|
1083
|
+
...otherProps
|
|
1084
|
+
}, ref) {
|
|
1085
|
+
const lastIndex = React__default.Children.count(children);
|
|
1086
|
+
return React__default.createElement("nav", Object.assign({
|
|
1087
|
+
"aria-label": "Breadcrumb",
|
|
1088
|
+
role: "navigation",
|
|
1089
|
+
ref: ref,
|
|
1090
|
+
"data-store-breadcrumb": true,
|
|
1091
|
+
"data-testid": testId
|
|
1092
|
+
}, otherProps), React__default.createElement(List, {
|
|
1093
|
+
"data-store-breadcrumb-list": true,
|
|
1094
|
+
variant: "ordered"
|
|
1095
|
+
}, React__default.Children.map(children, (child, index) => {
|
|
1096
|
+
const isLastItem = index === lastIndex - 1;
|
|
1097
|
+
return React__default.createElement(React.Fragment, {
|
|
1098
|
+
key: `breadcrumb-${index}`
|
|
1099
|
+
}, React__default.createElement(ListItem, {
|
|
1100
|
+
isLastItem: isLastItem,
|
|
1101
|
+
testId: testId
|
|
1102
|
+
}, child), isLastItem ? null : React__default.createElement(Divider, {
|
|
1103
|
+
divider: rawDivider,
|
|
1104
|
+
testId: testId
|
|
1105
|
+
}));
|
|
1106
|
+
})));
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
const LoadingButton = /*#__PURE__*/React.forwardRef(function LoadingButton({
|
|
1110
|
+
children,
|
|
1111
|
+
loading,
|
|
1112
|
+
testId = 'store-loading-button',
|
|
1113
|
+
...otherProps
|
|
1114
|
+
}, ref) {
|
|
1115
|
+
return React__default.createElement(Button, Object.assign({
|
|
1116
|
+
ref: ref,
|
|
1117
|
+
"data-store-loading-button": true,
|
|
1118
|
+
testId: testId
|
|
1119
|
+
}, otherProps), loading ? React__default.createElement(Spinner, null) : children);
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
const PriceRange = ({
|
|
1123
|
+
className,
|
|
1124
|
+
formatter,
|
|
1125
|
+
max,
|
|
1126
|
+
min,
|
|
1127
|
+
onChange,
|
|
1128
|
+
testId = 'store-price-range',
|
|
1129
|
+
variant,
|
|
1130
|
+
'aria-label': ariaLabel
|
|
1131
|
+
}) => {
|
|
1132
|
+
const [minVal, setMinVal] = React.useState(min);
|
|
1133
|
+
const [maxVal, setMaxVal] = React.useState(max);
|
|
1134
|
+
|
|
1135
|
+
const handleChange = values => {
|
|
1136
|
+
if (values.min !== minVal) {
|
|
1137
|
+
setMinVal(values.min);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
if (values.max !== maxVal) {
|
|
1141
|
+
setMaxVal(values.max);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
onChange == null ? void 0 : onChange(values);
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
return React__default.createElement("div", {
|
|
1148
|
+
"data-store-price-range": true,
|
|
1149
|
+
"data-testid": testId,
|
|
1150
|
+
className: className
|
|
1151
|
+
}, React__default.createElement(Slider, {
|
|
1152
|
+
min: min,
|
|
1153
|
+
max: max,
|
|
1154
|
+
onChange: handleChange,
|
|
1155
|
+
"aria-label": ariaLabel
|
|
1156
|
+
}), React__default.createElement("div", {
|
|
1157
|
+
"data-store-price-range-values": true
|
|
1158
|
+
}, React__default.createElement(Price, {
|
|
1159
|
+
formatter: formatter,
|
|
1160
|
+
"data-store-price-range-value": "min",
|
|
1161
|
+
value: minVal,
|
|
1162
|
+
variant: variant
|
|
1163
|
+
}), React__default.createElement(Price, {
|
|
1164
|
+
formatter: formatter,
|
|
1165
|
+
"data-store-price-range-value": "max",
|
|
1166
|
+
value: maxVal,
|
|
1167
|
+
variant: variant
|
|
1168
|
+
})));
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
const RadioGroupContext = /*#__PURE__*/React.createContext(undefined);
|
|
1172
|
+
function useRadioGroup() {
|
|
1173
|
+
const context = React.useContext(RadioGroupContext);
|
|
1174
|
+
|
|
1175
|
+
if (!context) {
|
|
1176
|
+
throw new Error(`useRadioOption hook cannot be used outside the RadioGroup context`);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
return context;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
const RadioGroup = ({
|
|
1183
|
+
name,
|
|
1184
|
+
onChange,
|
|
1185
|
+
children,
|
|
1186
|
+
selectedValue
|
|
1187
|
+
}) => {
|
|
1188
|
+
const contextValues = React__default.useMemo(() => {
|
|
1189
|
+
return {
|
|
1190
|
+
name,
|
|
1191
|
+
selectedValue,
|
|
1192
|
+
onChange
|
|
1193
|
+
};
|
|
1194
|
+
}, [name, selectedValue, onChange]);
|
|
1195
|
+
return React__default.createElement(RadioGroupContext.Provider, {
|
|
1196
|
+
value: contextValues
|
|
1197
|
+
}, children);
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
const RadioOption = /*#__PURE__*/React.forwardRef(function RadioOption({
|
|
1201
|
+
label,
|
|
1202
|
+
value,
|
|
1203
|
+
children,
|
|
1204
|
+
testId = 'store-radio-option',
|
|
1205
|
+
...otherProps
|
|
1206
|
+
}, ref) {
|
|
1207
|
+
const {
|
|
1208
|
+
name,
|
|
1209
|
+
selectedValue,
|
|
1210
|
+
onChange
|
|
1211
|
+
} = useRadioGroup();
|
|
1212
|
+
return React__default.createElement("label", {
|
|
1213
|
+
"aria-label": label,
|
|
1214
|
+
"data-store-radio-option": true
|
|
1215
|
+
}, React__default.createElement(Radio, Object.assign({
|
|
1216
|
+
"data-store-radio-option-item": true,
|
|
1217
|
+
ref: ref,
|
|
1218
|
+
name: name,
|
|
1219
|
+
checked: value === selectedValue,
|
|
1220
|
+
onChange: onChange,
|
|
1221
|
+
value: value,
|
|
1222
|
+
testId: testId
|
|
1223
|
+
}, otherProps)), children);
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1033
1226
|
const AccordionContext = /*#__PURE__*/React.createContext(undefined);
|
|
1034
1227
|
const Accordion = /*#__PURE__*/React.forwardRef(function Accordion({
|
|
1035
1228
|
testId = 'store-accordion',
|
|
@@ -1278,6 +1471,8 @@ exports.AccordionItem = AccordionItem;
|
|
|
1278
1471
|
exports.AccordionPanel = AccordionPanel;
|
|
1279
1472
|
exports.Alert = Alert;
|
|
1280
1473
|
exports.Badge = Badge;
|
|
1474
|
+
exports.Banner = Banner;
|
|
1475
|
+
exports.Breadcrumb = Breadcrumb;
|
|
1281
1476
|
exports.Bullets = Bullets;
|
|
1282
1477
|
exports.Button = Button;
|
|
1283
1478
|
exports.Carousel = Carousel;
|
|
@@ -1288,12 +1483,16 @@ exports.IconButton = IconButton;
|
|
|
1288
1483
|
exports.Input = Input;
|
|
1289
1484
|
exports.Label = Label;
|
|
1290
1485
|
exports.List = List;
|
|
1486
|
+
exports.LoadingButton = LoadingButton;
|
|
1291
1487
|
exports.Modal = Modal;
|
|
1292
1488
|
exports.Overlay = Overlay;
|
|
1293
1489
|
exports.PaymentMethods = PaymentMethods;
|
|
1294
1490
|
exports.Popover = Popover;
|
|
1295
1491
|
exports.Price = Price;
|
|
1492
|
+
exports.PriceRange = PriceRange;
|
|
1296
1493
|
exports.Radio = Radio;
|
|
1494
|
+
exports.RadioGroup = RadioGroup;
|
|
1495
|
+
exports.RadioOption = RadioOption;
|
|
1297
1496
|
exports.SearchInput = SearchInput;
|
|
1298
1497
|
exports.Select = Select;
|
|
1299
1498
|
exports.Skeleton = Skeleton;
|