@faststore/ui 1.3.20 → 1.3.24

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 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.24 (2021-12-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix UI storybook imports ([#1069](https://github.com/vtex/faststore/issues/1069)) ([e4a2402](https://github.com/vtex/faststore/commit/e4a2402235c60488fde7021bf3200d967af3cb83))
12
+
13
+
14
+
15
+
16
+
17
+ ## 1.3.23 (2021-12-09)
18
+
19
+ **Note:** Version bump only for package @faststore/ui
20
+
21
+
22
+
23
+
24
+
25
+ ## 1.3.22 (2021-12-07)
26
+
27
+ **Note:** Version bump only for package @faststore/ui
28
+
29
+
30
+
31
+
32
+
33
+ ## 1.3.21 (2021-12-07)
34
+
35
+
36
+ ### Features
37
+
38
+ * add docs ([#1058](https://github.com/vtex/faststore/issues/1058)) ([35f3e62](https://github.com/vtex/faststore/commit/35f3e62ae09c350632479742c9ce2c22e8862b23))
39
+
40
+
41
+
42
+
43
+
6
44
  ## 1.3.20 (2021-12-07)
7
45
 
8
46
 
package/README.md CHANGED
@@ -1,46 +1,3 @@
1
1
  # @faststore/ui
2
2
 
3
- > Next store component library
4
-
5
- [![NPM](https://img.shields.io/npm/v/@faststore/ui.svg)](https://www.npmjs.com/package/@faststore/ui) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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
@@ -44,6 +44,14 @@ export { default as Banner } from './molecules/Banner';
44
44
  export type { BannerProps } from './molecules/Banner';
45
45
  export { default as PaymentMethods } from './molecules/PaymentMethods';
46
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';
47
55
  export { default as Accordion, AccordionItem, AccordionButton, AccordionPanel, } from './molecules/Accordion';
48
56
  export type { AccordionProps, AccordionItemProps, AccordionButtonProps, AccordionPanelProps, } from './molecules/Accordion';
49
57
  export { Table, TableBody, TableCell, TableFooter, TableHead, TableRow, } from './molecules/Table';
@@ -1,4 +1,4 @@
1
- import RadioGroup, { RadioGroupProps } from './RadioGroup';
2
- import RadioOption, { RadioOptionProps } from './RadioOption';
3
- import { useRadioGroup } from './useRadioGroup';
4
- export { RadioGroup, RadioOption, useRadioGroup, RadioGroupProps, RadioOptionProps, };
1
+ export { default } from './RadioGroup';
2
+ export type { RadioGroupProps } from './RadioGroup';
3
+ export { default as RadioOption } from './RadioOption';
4
+ export type { RadioOptionProps } from './RadioOption';
@@ -1 +1 @@
1
- export type { PolymorphicProps, PolymorphicComponentProps, PolymorphicComponentPropsWithRef, } from './PolymorphicGenerics';
1
+ export type { PolymorphicComponentProps, PolymorphicComponentPropsWithRef, } from './PolymorphicGenerics';
@@ -1041,6 +1041,188 @@ const PaymentMethods = /*#__PURE__*/React.forwardRef(function PaymentMethods({
1041
1041
  }, children));
1042
1042
  });
1043
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
+
1044
1226
  const AccordionContext = /*#__PURE__*/React.createContext(undefined);
1045
1227
  const Accordion = /*#__PURE__*/React.forwardRef(function Accordion({
1046
1228
  testId = 'store-accordion',
@@ -1290,6 +1472,7 @@ exports.AccordionPanel = AccordionPanel;
1290
1472
  exports.Alert = Alert;
1291
1473
  exports.Badge = Badge;
1292
1474
  exports.Banner = Banner;
1475
+ exports.Breadcrumb = Breadcrumb;
1293
1476
  exports.Bullets = Bullets;
1294
1477
  exports.Button = Button;
1295
1478
  exports.Carousel = Carousel;
@@ -1300,12 +1483,16 @@ exports.IconButton = IconButton;
1300
1483
  exports.Input = Input;
1301
1484
  exports.Label = Label;
1302
1485
  exports.List = List;
1486
+ exports.LoadingButton = LoadingButton;
1303
1487
  exports.Modal = Modal;
1304
1488
  exports.Overlay = Overlay;
1305
1489
  exports.PaymentMethods = PaymentMethods;
1306
1490
  exports.Popover = Popover;
1307
1491
  exports.Price = Price;
1492
+ exports.PriceRange = PriceRange;
1308
1493
  exports.Radio = Radio;
1494
+ exports.RadioGroup = RadioGroup;
1495
+ exports.RadioOption = RadioOption;
1309
1496
  exports.SearchInput = SearchInput;
1310
1497
  exports.Select = Select;
1311
1498
  exports.Skeleton = Skeleton;