@trafilea/afrodita-components 4.1.0 → 4.2.0
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/build/index.d.ts +34 -5
- package/build/index.esm.js +78 -17
- package/build/index.esm.js.map +1 -1
- package/build/index.js +87 -16
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ interface CTAProps {
|
|
|
42
42
|
text: string;
|
|
43
43
|
type?: ButtonType;
|
|
44
44
|
className?: string;
|
|
45
|
+
inline?: boolean;
|
|
45
46
|
}
|
|
46
47
|
declare type DropdownOption<T> = {
|
|
47
48
|
key: string;
|
|
@@ -446,11 +447,11 @@ declare const _default: (({ children, backgroundColor, widthAuto, border, flex }
|
|
|
446
447
|
Body: ({ children }: CardBodyProps) => JSX.Element;
|
|
447
448
|
};
|
|
448
449
|
|
|
449
|
-
declare const ButtonPrimary: (
|
|
450
|
+
declare const ButtonPrimary: (props: CTAProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
450
451
|
|
|
451
|
-
declare const ButtonSecondary: (
|
|
452
|
+
declare const ButtonSecondary: (props: CTAProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
452
453
|
|
|
453
|
-
declare const ButtonSecondaryOutline: (
|
|
454
|
+
declare const ButtonSecondaryOutline: (props: CTAProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
454
455
|
|
|
455
456
|
declare type Value<T> = DropdownOption<T>;
|
|
456
457
|
declare type OnChange<T> = (option: Value<T>) => void;
|
|
@@ -1121,6 +1122,7 @@ interface BaseCTAProps {
|
|
|
1121
1122
|
size?: ComponentSize;
|
|
1122
1123
|
text: string;
|
|
1123
1124
|
type?: ButtonType;
|
|
1125
|
+
inline?: boolean;
|
|
1124
1126
|
}
|
|
1125
1127
|
|
|
1126
1128
|
declare type ButtonProps = {
|
|
@@ -1341,7 +1343,7 @@ interface ProductItemProps {
|
|
|
1341
1343
|
}
|
|
1342
1344
|
|
|
1343
1345
|
interface ProductItemSmallMobileProps extends ProductItemProps {
|
|
1344
|
-
size: ComponentSize.Medium | ComponentSize.Small;
|
|
1346
|
+
size: ComponentSize.Medium | ComponentSize.Small | ComponentSize.Large;
|
|
1345
1347
|
}
|
|
1346
1348
|
|
|
1347
1349
|
declare function withProductGrid<P extends ProductItemProps>(ProductItemComponent: React.FC<P>, data: ProductItemProps[]): {
|
|
@@ -1608,6 +1610,13 @@ declare type QuantityPickerProps = {
|
|
|
1608
1610
|
} & (QuantityPickerPropsControlled | QuantityPickerPropsUncontrolled);
|
|
1609
1611
|
declare const QuantityPicker: ({ initialValue, maxValue, value, onChange, }: QuantityPickerProps) => JSX.Element;
|
|
1610
1612
|
|
|
1613
|
+
declare type SpacingProps = {
|
|
1614
|
+
size: number;
|
|
1615
|
+
type?: 'block' | 'inline';
|
|
1616
|
+
style?: CSSProperties;
|
|
1617
|
+
};
|
|
1618
|
+
declare const Spacing: FC<SpacingProps>;
|
|
1619
|
+
|
|
1611
1620
|
declare const useOnClickOutside: <T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: (event: Event) => void) => void;
|
|
1612
1621
|
|
|
1613
1622
|
declare const useWindowDimensions: (breakpoints: ThemeBreakpoints) => {
|
|
@@ -1618,4 +1627,24 @@ declare const useWindowDimensions: (breakpoints: ThemeBreakpoints) => {
|
|
|
1618
1627
|
};
|
|
1619
1628
|
};
|
|
1620
1629
|
|
|
1621
|
-
|
|
1630
|
+
/**
|
|
1631
|
+
* @returns number formatted with "," and 2 decimals as string
|
|
1632
|
+
*/
|
|
1633
|
+
declare const decimalFormat: (number: number) => string;
|
|
1634
|
+
|
|
1635
|
+
declare const isEmpty: (value: string) => boolean;
|
|
1636
|
+
declare const isEmail: (value: string) => boolean;
|
|
1637
|
+
declare const isNumber: (value: string) => boolean;
|
|
1638
|
+
declare const isPhoneNumber: (value: string) => boolean;
|
|
1639
|
+
declare const isValidDate: (value: string) => boolean;
|
|
1640
|
+
|
|
1641
|
+
declare const simulateMouseClick: (element: HTMLElement) => void;
|
|
1642
|
+
|
|
1643
|
+
declare const sliceString: (str: string, maxLength: number) => string;
|
|
1644
|
+
|
|
1645
|
+
declare const formatPrice: (value: number, { locale, currency }?: {
|
|
1646
|
+
locale?: string | undefined;
|
|
1647
|
+
currency?: string | undefined;
|
|
1648
|
+
}) => string;
|
|
1649
|
+
|
|
1650
|
+
export { Accordion, AmazonButton, AssetsProvider, Bundle, ButtonPrimary, ButtonSecondary, ButtonSecondaryOutline, ButtonType, CTAProps, _default as Card, CardSectionType, CartProductItem, CategoryTag, Checkbox, Collection, Color, ColorPickerOption, ComponentPosition, ComponentSize, index_d as CrossSell, DeliveryDetails, DiscountTag, Drawer, DropdownListIcons, DropdownListIconsItem, DropdownListIconsSubItem, DropdownOption, Filter, FilterChange, FilteringDropdown, Tags as FilteringTags, FitPredictor, Icon, IconButton, IconProps, IconWithOpacityProps, Image, ImageType, Input, InputValidationType, Modal, MultiColorPicker, OfferBanner, OrderBar, Overlay, Pagination, Pattern, PaymentMethod, PaypalButton, Portal, PriceLabel, ProductGallery, ProductGalleryMobile, ProgressBar, QuantityPicker, RadioGroupInput, RadioGroupOption, RadioInput, Rating, Review, ScrollToTop, SearchBar, SearchBarOptionItem, SeasonOfferTag, SimpleDropdown, SimpleOrderItem, SingleColorPicker, SizeFitGuide, SizeOption, SizeSelector, SizeTable, SliderNavigation, Spacing, Spinner, StarList, Text, TextButton, Theme, ThemeAssets, ThemeBasicPallete, ThemeBreakpoints, ThemeColorPallete, ThemeColors, ThemeComponent, ThemeFonts, ThemeProvider, ThemeTypography, ThemeVariables, Timer, Tooltip, Totals, WithTestId, decimalFormat, formatPrice, isEmail, isEmpty, isNumber, isPhoneNumber, isValidDate, modalEvent, simulateMouseClick, sliceString, useOnClickOutside, useTheme, useThemeAssets, useWindowDimensions };
|
package/build/index.esm.js
CHANGED
|
@@ -3490,7 +3490,7 @@ function jsxs(type, props, key) {
|
|
|
3490
3490
|
var BaseButton = function (_a) {
|
|
3491
3491
|
var children = _a.children, renderLeading = _a.renderLeading, renderTrailing = _a.renderTrailing, disabled = _a.disabled, _b = _a.type, type = _b === void 0 ? 'button' : _b, onClick = _a.onClick, className = _a.className, inline = _a.inline;
|
|
3492
3492
|
return (jsxs("button", __assign({ onClick: onClick, disabled: disabled, className: className, type: type, css: {
|
|
3493
|
-
display: inline ? '
|
|
3493
|
+
display: inline ? 'inline-flex' : 'flex',
|
|
3494
3494
|
justifyContent: 'center',
|
|
3495
3495
|
alignItems: 'center',
|
|
3496
3496
|
padding: '0.75rem 2rem',
|
|
@@ -3526,20 +3526,19 @@ var getStylesBySize$9 = function (size, theme) {
|
|
|
3526
3526
|
}
|
|
3527
3527
|
};
|
|
3528
3528
|
var BaseCTA = function (_a) {
|
|
3529
|
-
var text = _a.text,
|
|
3529
|
+
var text = _a.text, _b = _a.wide, wide = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? ComponentSize.Medium : _c, props = __rest(_a, ["text", "wide", "size"]);
|
|
3530
3530
|
var theme = useTheme();
|
|
3531
3531
|
var stylesBySize = getStylesBySize$9(size, theme);
|
|
3532
|
-
return (jsx(BaseButton, __assign({
|
|
3532
|
+
return (jsx(BaseButton, __assign({}, props, { css: __assign(__assign({ width: wide ? '100%' : 'fit-content' }, stylesBySize), { fontWeight: theme.component.button.fontWeight, borderRadius: "".concat(theme.component.button.borderRadius), cursor: 'pointer', '&:disabled': {
|
|
3533
3533
|
backgroundColor: theme.colors.background.disabled,
|
|
3534
3534
|
color: theme.colors.text.disabled,
|
|
3535
3535
|
cursor: 'not-allowed',
|
|
3536
3536
|
} }) }, { children: text }), void 0));
|
|
3537
3537
|
};
|
|
3538
3538
|
|
|
3539
|
-
var ButtonPrimary = function (
|
|
3540
|
-
var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, type = _a.type;
|
|
3539
|
+
var ButtonPrimary = function (props) {
|
|
3541
3540
|
var theme = useTheme();
|
|
3542
|
-
return (jsx(BaseCTA, {
|
|
3541
|
+
return (jsx(BaseCTA, __assign({}, props, { css: {
|
|
3543
3542
|
backgroundColor: theme.component.button.primary.active.backgroundColor,
|
|
3544
3543
|
color: theme.component.button.primary.active.color,
|
|
3545
3544
|
border: theme.component.button.border,
|
|
@@ -3551,13 +3550,12 @@ var ButtonPrimary = function (_a) {
|
|
|
3551
3550
|
backgroundColor: theme.colors.background.disabled,
|
|
3552
3551
|
color: theme.colors.text.disabled,
|
|
3553
3552
|
},
|
|
3554
|
-
}
|
|
3553
|
+
} }), void 0));
|
|
3555
3554
|
};
|
|
3556
3555
|
|
|
3557
|
-
var ButtonSecondary = function (
|
|
3558
|
-
var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, className = _a.className;
|
|
3556
|
+
var ButtonSecondary = function (props) {
|
|
3559
3557
|
var theme = useTheme();
|
|
3560
|
-
return (jsx(BaseCTA, {
|
|
3558
|
+
return (jsx(BaseCTA, __assign({}, props, { css: {
|
|
3561
3559
|
backgroundColor: theme.component.button.secondary.active.backgroundColor,
|
|
3562
3560
|
color: theme.component.button.secondary.active.color,
|
|
3563
3561
|
border: theme.component.button.border,
|
|
@@ -3568,13 +3566,12 @@ var ButtonSecondary = function (_a) {
|
|
|
3568
3566
|
backgroundColor: theme.colors.shades['50'].color,
|
|
3569
3567
|
color: theme.colors.shades['250'].color,
|
|
3570
3568
|
},
|
|
3571
|
-
}
|
|
3569
|
+
} }), void 0));
|
|
3572
3570
|
};
|
|
3573
3571
|
|
|
3574
|
-
var ButtonSecondaryOutline = function (
|
|
3575
|
-
var text = _a.text, onClick = _a.onClick, _b = _a.disabled, disabled = _b === void 0 ? false : _b, wide = _a.wide, size = _a.size, className = _a.className;
|
|
3572
|
+
var ButtonSecondaryOutline = function (props) {
|
|
3576
3573
|
var theme = useTheme();
|
|
3577
|
-
return (jsx(BaseCTA, {
|
|
3574
|
+
return (jsx(BaseCTA, __assign({}, props, { css: {
|
|
3578
3575
|
backgroundColor: theme.component.button.secondary.active.color,
|
|
3579
3576
|
color: theme.component.button.secondary.active.backgroundColor,
|
|
3580
3577
|
border: "1px solid ".concat(theme.component.button.secondary.active.backgroundColor),
|
|
@@ -3587,7 +3584,7 @@ var ButtonSecondaryOutline = function (_a) {
|
|
|
3587
3584
|
color: theme.colors.text.disabled,
|
|
3588
3585
|
border: 'none',
|
|
3589
3586
|
},
|
|
3590
|
-
}
|
|
3587
|
+
} }), void 0));
|
|
3591
3588
|
};
|
|
3592
3589
|
|
|
3593
3590
|
function _extends() {
|
|
@@ -7536,14 +7533,53 @@ var InputLabel = function (_a) {
|
|
|
7536
7533
|
};
|
|
7537
7534
|
var templateObject_1$F, templateObject_2$q;
|
|
7538
7535
|
|
|
7536
|
+
/**
|
|
7537
|
+
* @returns number formatted with "," and 2 decimals as string
|
|
7538
|
+
*/
|
|
7539
|
+
var decimalFormat = function (number) {
|
|
7540
|
+
return number.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
|
7541
|
+
};
|
|
7542
|
+
|
|
7539
7543
|
var isEmpty = function (value) {
|
|
7540
7544
|
return value.length === 0;
|
|
7545
|
+
};
|
|
7546
|
+
var isEmail = function (value) {
|
|
7547
|
+
return /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(value);
|
|
7548
|
+
};
|
|
7549
|
+
var isNumber = function (value) {
|
|
7550
|
+
return /^[0-9]*$/.test(value);
|
|
7551
|
+
};
|
|
7552
|
+
var isPhoneNumber = function (value) {
|
|
7553
|
+
return /^\d{10}$/.test(value);
|
|
7554
|
+
};
|
|
7555
|
+
var isValidDate = function (value) {
|
|
7556
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
7557
|
+
};
|
|
7558
|
+
|
|
7559
|
+
var mouseClickEvents = ['mousedown', 'click', 'mouseup'];
|
|
7560
|
+
var simulateMouseClick = function (element) {
|
|
7561
|
+
mouseClickEvents.forEach(function (mouseEventType) {
|
|
7562
|
+
return element.dispatchEvent(new MouseEvent(mouseEventType, {
|
|
7563
|
+
view: window,
|
|
7564
|
+
bubbles: true,
|
|
7565
|
+
cancelable: true,
|
|
7566
|
+
buttons: 1,
|
|
7567
|
+
}));
|
|
7568
|
+
});
|
|
7541
7569
|
};
|
|
7542
7570
|
|
|
7543
7571
|
var sliceString = function (str, maxLength) {
|
|
7544
7572
|
return str.length > maxLength ? "".concat(str.slice(0, maxLength), "...") : str;
|
|
7545
7573
|
};
|
|
7546
7574
|
|
|
7575
|
+
var formatPrice = function (value, _a) {
|
|
7576
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.locale, locale = _c === void 0 ? 'en-US' : _c, _d = _b.currency, currency = _d === void 0 ? 'USD' : _d;
|
|
7577
|
+
return new Intl.NumberFormat(locale, {
|
|
7578
|
+
style: 'currency',
|
|
7579
|
+
currency: currency,
|
|
7580
|
+
}).format(value);
|
|
7581
|
+
};
|
|
7582
|
+
|
|
7547
7583
|
var ErrorText = newStyled.h3(templateObject_1$E || (templateObject_1$E = __makeTemplateObject(["\n color: ", " !important;\n font-size: 0.75rem;\n font-weight: 600;\n margin: 0;\n font-height: 1rem;\n margin-left: 0.313rem;\n"], ["\n color: ", " !important;\n font-size: 0.75rem;\n font-weight: 600;\n margin: 0;\n font-height: 1rem;\n margin-left: 0.313rem;\n"])), function (props) { return props.color; });
|
|
7548
7584
|
var ErrorContainer = newStyled.div(templateObject_2$p || (templateObject_2$p = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-top: 0.25rem;\n"], ["\n display: flex;\n align-items: center;\n margin-top: 0.25rem;\n"])));
|
|
7549
7585
|
var Error$1 = function (_a) {
|
|
@@ -12440,6 +12476,12 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
12440
12476
|
CrossSellCheckbox: CrossSellCheckbox
|
|
12441
12477
|
});
|
|
12442
12478
|
|
|
12479
|
+
var Spacing = function (_a) {
|
|
12480
|
+
var size = _a.size, _b = _a.type, type = _b === void 0 ? 'block' : _b, children = _a.children, styleProp = _a.style;
|
|
12481
|
+
var style = useMemo(function () { return (__assign(__assign({}, styleProp), { width: size, height: size, verticalAlign: 'middle', display: type === 'block' ? 'block' : 'inline-block' })); }, [size, type, styleProp]);
|
|
12482
|
+
return jsx$1("div", __assign({ style: style }, { children: children }), void 0);
|
|
12483
|
+
};
|
|
12484
|
+
|
|
12443
12485
|
var ImageContainer = newStyled.div(function (_a) {
|
|
12444
12486
|
var width = _a.width, height = _a.height;
|
|
12445
12487
|
return ({
|
|
@@ -12462,6 +12504,11 @@ var getStylesBySize = function (size) {
|
|
|
12462
12504
|
width: '9.813rem',
|
|
12463
12505
|
height: '13.125rem',
|
|
12464
12506
|
};
|
|
12507
|
+
case ComponentSize.Large:
|
|
12508
|
+
return {
|
|
12509
|
+
width: '262px',
|
|
12510
|
+
height: '350px',
|
|
12511
|
+
};
|
|
12465
12512
|
/* istanbul ignore next */
|
|
12466
12513
|
default:
|
|
12467
12514
|
return {
|
|
@@ -12474,7 +12521,21 @@ var ProductItemMobile = function (_a) {
|
|
|
12474
12521
|
var title = _a.title, image = _a.image, price = _a.price, rating = _a.rating, size = _a.size, tags = _a.tags, _b = _a.alignName, alignName = _b === void 0 ? 'center' : _b;
|
|
12475
12522
|
var theme = useTheme();
|
|
12476
12523
|
var styles = getStylesBySize(size);
|
|
12477
|
-
|
|
12524
|
+
var spaces = useMemo(function () {
|
|
12525
|
+
var _a, _b;
|
|
12526
|
+
var first = (_a = {},
|
|
12527
|
+
_a[ComponentSize.Large] = 20,
|
|
12528
|
+
_a[ComponentSize.Medium] = 12,
|
|
12529
|
+
_a[ComponentSize.Small] = 6,
|
|
12530
|
+
_a)[size];
|
|
12531
|
+
var second = (_b = {},
|
|
12532
|
+
_b[ComponentSize.Large] = 12,
|
|
12533
|
+
_b[ComponentSize.Medium] = 6,
|
|
12534
|
+
_b[ComponentSize.Small] = 4,
|
|
12535
|
+
_b)[size];
|
|
12536
|
+
return [first, second];
|
|
12537
|
+
}, [size]);
|
|
12538
|
+
return (jsxs(Container$d, { children: [tags ? (jsxs(ImageContainer, __assign({ width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height, "data-testid": "tags-image-container" }, { children: [jsx(Image, { src: image.src, alt: image.alt, width: "100%", height: "100%" }, void 0), jsx(SeasonOfferTag, { text: tags.seasonOfferTagText, size: ComponentSize.Small, css: { position: 'absolute', top: 0, left: 0 } }, void 0), jsx(CategoryTag, { text: tags.categoryTagText, size: ComponentSize.Small, css: { position: 'absolute', bottom: '1rem', left: 0 } }, void 0)] }), void 0)) : (jsx(Image, { src: image.src, alt: image.alt, width: styles === null || styles === void 0 ? void 0 : styles.width, height: styles === null || styles === void 0 ? void 0 : styles.height }, void 0)), jsx(Spacing, { size: spaces[0] }, void 0), jsx(H1, __assign({ theme: theme, align: alignName }, { children: title }), void 0), jsx(Spacing, { size: spaces[1] }, void 0), jsx(PriceLabel, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, color: price.color, size: ComponentSize.Small }, void 0), jsx(Rating, { size: size === ComponentSize.Large ? ComponentSize.Small : ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "" }, void 0)] }, void 0));
|
|
12478
12539
|
};
|
|
12479
12540
|
var templateObject_1$j, templateObject_2$9;
|
|
12480
12541
|
|
|
@@ -13052,5 +13113,5 @@ var QuantityPicker = function (_a) {
|
|
|
13052
13113
|
};
|
|
13053
13114
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
13054
13115
|
|
|
13055
|
-
export { Accordion, AmazonButton, AssetsProvider, Bundle, ButtonPrimary, ButtonSecondary, ButtonSecondaryOutline, Card$1 as Card, CardSectionType, CartProductItem, CategoryTag, Checkbox, Collection, ComponentPosition, ComponentSize, index as CrossSell, DeliveryDetails, DiscountTag, Drawer, DropdownListIcons, FilteringDropdown, Tags as FilteringTags, FitPredictor, Icon, IconButton, Image, Input$1 as Input, InputValidationType, Modal, MultiColorPicker, OfferBanner, OrderBar, Overlay, Pagination, PaymentMethod, PaypalButton, Portal, PriceLabel, ProductGallery, ProductGalleryMobile, ProgressBar, QuantityPicker, RadioGroupInput, RadioInput, Rating, Review, ScrollToTop, SearchBar, SeasonOfferTag, SimpleDropdown, SimpleOrderItem, SingleColorPicker, SizeFitGuide, SizeSelector, SizeTable, SliderNavigation, Spinner, StarList, Text$5 as Text, TextButton, ThemeProvider, ThemeVariables, Timer, Tooltip, Totals, modalEvent, useOnClickOutside, useTheme, useThemeAssets, useWindowDimensions };
|
|
13116
|
+
export { Accordion, AmazonButton, AssetsProvider, Bundle, ButtonPrimary, ButtonSecondary, ButtonSecondaryOutline, Card$1 as Card, CardSectionType, CartProductItem, CategoryTag, Checkbox, Collection, ComponentPosition, ComponentSize, index as CrossSell, DeliveryDetails, DiscountTag, Drawer, DropdownListIcons, FilteringDropdown, Tags as FilteringTags, FitPredictor, Icon, IconButton, Image, Input$1 as Input, InputValidationType, Modal, MultiColorPicker, OfferBanner, OrderBar, Overlay, Pagination, PaymentMethod, PaypalButton, Portal, PriceLabel, ProductGallery, ProductGalleryMobile, ProgressBar, QuantityPicker, RadioGroupInput, RadioInput, Rating, Review, ScrollToTop, SearchBar, SeasonOfferTag, SimpleDropdown, SimpleOrderItem, SingleColorPicker, SizeFitGuide, SizeSelector, SizeTable, SliderNavigation, Spacing, Spinner, StarList, Text$5 as Text, TextButton, ThemeProvider, ThemeVariables, Timer, Tooltip, Totals, decimalFormat, formatPrice, isEmail, isEmpty, isNumber, isPhoneNumber, isValidDate, modalEvent, simulateMouseClick, sliceString, useOnClickOutside, useTheme, useThemeAssets, useWindowDimensions };
|
|
13056
13117
|
//# sourceMappingURL=index.esm.js.map
|