@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/dist/ui.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useCallback, useEffect, useMemo, useReducer,
|
|
1
|
+
import React, { forwardRef, useState, useRef, useCallback, useEffect, useMemo, useReducer, Fragment, createContext, useContext, cloneElement } from 'react';
|
|
2
2
|
import ReachPopover, { positionDefault } from '@reach/popover';
|
|
3
3
|
import { useSwipeable } from 'react-swipeable';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
@@ -1002,6 +1002,17 @@ const Modal = ({
|
|
|
1002
1002
|
}), children)), document.body) : null;
|
|
1003
1003
|
};
|
|
1004
1004
|
|
|
1005
|
+
const Banner = ({
|
|
1006
|
+
testId = 'store-banner',
|
|
1007
|
+
children,
|
|
1008
|
+
variant = 'vertical'
|
|
1009
|
+
}) => {
|
|
1010
|
+
return React.createElement("article", {
|
|
1011
|
+
"data-store-banner": variant,
|
|
1012
|
+
"data-testid": testId
|
|
1013
|
+
}, children);
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1005
1016
|
const PaymentMethods = /*#__PURE__*/forwardRef(function PaymentMethods({
|
|
1006
1017
|
testId = 'store-payment-methods',
|
|
1007
1018
|
title,
|
|
@@ -1022,6 +1033,188 @@ const PaymentMethods = /*#__PURE__*/forwardRef(function PaymentMethods({
|
|
|
1022
1033
|
}, children));
|
|
1023
1034
|
});
|
|
1024
1035
|
|
|
1036
|
+
const Divider = ({
|
|
1037
|
+
divider,
|
|
1038
|
+
testId
|
|
1039
|
+
}) => {
|
|
1040
|
+
const props = {
|
|
1041
|
+
'data-store-breadcrumb-divider': true,
|
|
1042
|
+
'aria-hidden': true,
|
|
1043
|
+
'data-testid': `${testId}-divider`
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
if (React.isValidElement(divider)) {
|
|
1047
|
+
return React.cloneElement(divider, props);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
return React.createElement("span", Object.assign({}, props), divider != null ? divider : '/');
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
const ListItem = ({
|
|
1054
|
+
children,
|
|
1055
|
+
isLastItem,
|
|
1056
|
+
testId
|
|
1057
|
+
}) => {
|
|
1058
|
+
const props = {
|
|
1059
|
+
'data-testid': `${testId}-item`,
|
|
1060
|
+
'data-store-breadcrumb-item': isLastItem ? 'current' : true,
|
|
1061
|
+
'aria-current': isLastItem ? 'page' : undefined
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
if (!React.isValidElement(children)) {
|
|
1065
|
+
return React.createElement("li", null, React.createElement("span", Object.assign({}, props), children));
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
return React.createElement("li", null, React.cloneElement(children, props));
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
const Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb({
|
|
1072
|
+
children,
|
|
1073
|
+
divider: rawDivider,
|
|
1074
|
+
testId = 'store-breadcrumb',
|
|
1075
|
+
...otherProps
|
|
1076
|
+
}, ref) {
|
|
1077
|
+
const lastIndex = React.Children.count(children);
|
|
1078
|
+
return React.createElement("nav", Object.assign({
|
|
1079
|
+
"aria-label": "Breadcrumb",
|
|
1080
|
+
role: "navigation",
|
|
1081
|
+
ref: ref,
|
|
1082
|
+
"data-store-breadcrumb": true,
|
|
1083
|
+
"data-testid": testId
|
|
1084
|
+
}, otherProps), React.createElement(List, {
|
|
1085
|
+
"data-store-breadcrumb-list": true,
|
|
1086
|
+
variant: "ordered"
|
|
1087
|
+
}, React.Children.map(children, (child, index) => {
|
|
1088
|
+
const isLastItem = index === lastIndex - 1;
|
|
1089
|
+
return React.createElement(Fragment, {
|
|
1090
|
+
key: `breadcrumb-${index}`
|
|
1091
|
+
}, React.createElement(ListItem, {
|
|
1092
|
+
isLastItem: isLastItem,
|
|
1093
|
+
testId: testId
|
|
1094
|
+
}, child), isLastItem ? null : React.createElement(Divider, {
|
|
1095
|
+
divider: rawDivider,
|
|
1096
|
+
testId: testId
|
|
1097
|
+
}));
|
|
1098
|
+
})));
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
const LoadingButton = /*#__PURE__*/forwardRef(function LoadingButton({
|
|
1102
|
+
children,
|
|
1103
|
+
loading,
|
|
1104
|
+
testId = 'store-loading-button',
|
|
1105
|
+
...otherProps
|
|
1106
|
+
}, ref) {
|
|
1107
|
+
return React.createElement(Button, Object.assign({
|
|
1108
|
+
ref: ref,
|
|
1109
|
+
"data-store-loading-button": true,
|
|
1110
|
+
testId: testId
|
|
1111
|
+
}, otherProps), loading ? React.createElement(Spinner, null) : children);
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
const PriceRange = ({
|
|
1115
|
+
className,
|
|
1116
|
+
formatter,
|
|
1117
|
+
max,
|
|
1118
|
+
min,
|
|
1119
|
+
onChange,
|
|
1120
|
+
testId = 'store-price-range',
|
|
1121
|
+
variant,
|
|
1122
|
+
'aria-label': ariaLabel
|
|
1123
|
+
}) => {
|
|
1124
|
+
const [minVal, setMinVal] = useState(min);
|
|
1125
|
+
const [maxVal, setMaxVal] = useState(max);
|
|
1126
|
+
|
|
1127
|
+
const handleChange = values => {
|
|
1128
|
+
if (values.min !== minVal) {
|
|
1129
|
+
setMinVal(values.min);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (values.max !== maxVal) {
|
|
1133
|
+
setMaxVal(values.max);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
onChange == null ? void 0 : onChange(values);
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
return React.createElement("div", {
|
|
1140
|
+
"data-store-price-range": true,
|
|
1141
|
+
"data-testid": testId,
|
|
1142
|
+
className: className
|
|
1143
|
+
}, React.createElement(Slider, {
|
|
1144
|
+
min: min,
|
|
1145
|
+
max: max,
|
|
1146
|
+
onChange: handleChange,
|
|
1147
|
+
"aria-label": ariaLabel
|
|
1148
|
+
}), React.createElement("div", {
|
|
1149
|
+
"data-store-price-range-values": true
|
|
1150
|
+
}, React.createElement(Price, {
|
|
1151
|
+
formatter: formatter,
|
|
1152
|
+
"data-store-price-range-value": "min",
|
|
1153
|
+
value: minVal,
|
|
1154
|
+
variant: variant
|
|
1155
|
+
}), React.createElement(Price, {
|
|
1156
|
+
formatter: formatter,
|
|
1157
|
+
"data-store-price-range-value": "max",
|
|
1158
|
+
value: maxVal,
|
|
1159
|
+
variant: variant
|
|
1160
|
+
})));
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
const RadioGroupContext = /*#__PURE__*/createContext(undefined);
|
|
1164
|
+
function useRadioGroup() {
|
|
1165
|
+
const context = useContext(RadioGroupContext);
|
|
1166
|
+
|
|
1167
|
+
if (!context) {
|
|
1168
|
+
throw new Error(`useRadioOption hook cannot be used outside the RadioGroup context`);
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
return context;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
const RadioGroup = ({
|
|
1175
|
+
name,
|
|
1176
|
+
onChange,
|
|
1177
|
+
children,
|
|
1178
|
+
selectedValue
|
|
1179
|
+
}) => {
|
|
1180
|
+
const contextValues = React.useMemo(() => {
|
|
1181
|
+
return {
|
|
1182
|
+
name,
|
|
1183
|
+
selectedValue,
|
|
1184
|
+
onChange
|
|
1185
|
+
};
|
|
1186
|
+
}, [name, selectedValue, onChange]);
|
|
1187
|
+
return React.createElement(RadioGroupContext.Provider, {
|
|
1188
|
+
value: contextValues
|
|
1189
|
+
}, children);
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
const RadioOption = /*#__PURE__*/forwardRef(function RadioOption({
|
|
1193
|
+
label,
|
|
1194
|
+
value,
|
|
1195
|
+
children,
|
|
1196
|
+
testId = 'store-radio-option',
|
|
1197
|
+
...otherProps
|
|
1198
|
+
}, ref) {
|
|
1199
|
+
const {
|
|
1200
|
+
name,
|
|
1201
|
+
selectedValue,
|
|
1202
|
+
onChange
|
|
1203
|
+
} = useRadioGroup();
|
|
1204
|
+
return React.createElement("label", {
|
|
1205
|
+
"aria-label": label,
|
|
1206
|
+
"data-store-radio-option": true
|
|
1207
|
+
}, React.createElement(Radio, Object.assign({
|
|
1208
|
+
"data-store-radio-option-item": true,
|
|
1209
|
+
ref: ref,
|
|
1210
|
+
name: name,
|
|
1211
|
+
checked: value === selectedValue,
|
|
1212
|
+
onChange: onChange,
|
|
1213
|
+
value: value,
|
|
1214
|
+
testId: testId
|
|
1215
|
+
}, otherProps)), children);
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1025
1218
|
const AccordionContext = /*#__PURE__*/createContext(undefined);
|
|
1026
1219
|
const Accordion = /*#__PURE__*/forwardRef(function Accordion({
|
|
1027
1220
|
testId = 'store-accordion',
|
|
@@ -1264,5 +1457,5 @@ const Alert = /*#__PURE__*/forwardRef(function Alert({
|
|
|
1264
1457
|
}, otherProps), children);
|
|
1265
1458
|
});
|
|
1266
1459
|
|
|
1267
|
-
export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, Badge, Bullets, Button, Carousel, Checkbox, Form, Icon, IconButton, Input, Label, List, Modal, Overlay, PaymentMethods, Popover, Price, Radio, SearchInput, Select, Skeleton, Slider, Spinner, Table, TableBody, TableCell, TableFooter, TableHead, TableRow, TextArea, useSlider };
|
|
1460
|
+
export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, Badge, Banner, Breadcrumb, Bullets, Button, Carousel, Checkbox, Form, Icon, IconButton, Input, Label, List, LoadingButton, Modal, Overlay, PaymentMethods, Popover, Price, PriceRange, Radio, RadioGroup, RadioOption, SearchInput, Select, Skeleton, Slider, Spinner, Table, TableBody, TableCell, TableFooter, TableHead, TableRow, TextArea, useSlider };
|
|
1268
1461
|
//# sourceMappingURL=ui.esm.js.map
|