@faststore/ui 1.3.21 → 1.3.25
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 +35 -0
- package/README.md +1 -44
- package/dist/index.d.ts +8 -0
- package/dist/molecules/RadioGroup/index.d.ts +4 -4
- package/dist/typings/index.d.ts +1 -1
- package/dist/ui.cjs.development.js +187 -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 +184 -2
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +12 -0
- package/src/molecules/RadioGroup/RadioGroup.test.tsx +3 -1
- package/src/molecules/RadioGroup/index.tsx +4 -10
- package/src/molecules/RadioGroup/stories/RadioGroup.stories.tsx +2 -1
- package/src/typings/index.ts +0 -1
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';
|
|
@@ -1033,6 +1033,188 @@ const PaymentMethods = /*#__PURE__*/forwardRef(function PaymentMethods({
|
|
|
1033
1033
|
}, children));
|
|
1034
1034
|
});
|
|
1035
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
|
+
|
|
1036
1218
|
const AccordionContext = /*#__PURE__*/createContext(undefined);
|
|
1037
1219
|
const Accordion = /*#__PURE__*/forwardRef(function Accordion({
|
|
1038
1220
|
testId = 'store-accordion',
|
|
@@ -1275,5 +1457,5 @@ const Alert = /*#__PURE__*/forwardRef(function Alert({
|
|
|
1275
1457
|
}, otherProps), children);
|
|
1276
1458
|
});
|
|
1277
1459
|
|
|
1278
|
-
export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, Badge, Banner, 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 };
|
|
1279
1461
|
//# sourceMappingURL=ui.esm.js.map
|