@trafilea/afrodita-components 6.32.1 → 6.33.1

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 CHANGED
@@ -147,7 +147,7 @@ declare type StyledIconProps = {
147
147
  };
148
148
 
149
149
  declare type Actions$1 = 'actions/add' | 'actions/check_box_empty' | 'actions/check_box_light' | 'actions/check_box_solid' | 'actions/check' | 'actions/circle_check' | 'actions/circle_clear' | 'actions/circle_info' | 'actions/circle_minus' | 'actions/circle_plus' | 'actions/circle_question' | 'actions/circle_solid_check' | 'actions/circle_solid_clear' | 'actions/circle_solid_info' | 'actions/circle_solid_minus' | 'actions/circle_solid_plus' | 'actions/circle_solid_question' | 'actions/circle_solid_styled_check' | 'actions/circle_solid_warning' | 'actions/circle_solid_reload' | 'actions/circle_warning' | 'actions/clear_light' | 'actions/close' | 'actions/copy_outlined' | 'actions/copy' | 'actions/edit' | 'actions/light_check' | 'actions/light_exclamation' | 'actions/like_solid' | 'actions/like' | 'actions/minus' | 'actions/not_allowed' | 'actions/question' | 'actions/radio_empty' | 'actions/radio_filled' | 'actions/settings_solid' | 'actions/settings' | 'actions/share' | 'actions/signout' | 'actions/signout_light' | 'actions/trash' | 'actions/warning' | 'actions/navigate' | 'actions/camera';
150
- declare type Arrows$1 = 'arrows/chevron_down' | 'arrows/chevron_down_variant' | 'arrows/chevron_left' | 'arrows/chevron_left_lite' | 'arrows/chevron_left_variant' | 'arrows/chevron_right' | 'arrows/chevron_right_lite' | 'arrows/chevron_right_variant' | 'arrows/chevron_up' | 'arrows/chevron_up_solid' | 'arrows/chevron_up_variant' | 'arrows/circle_chevron_down' | 'arrows/circle_chevron_left' | 'arrows/circle_chevron_right' | 'arrows/circle_chevron_up' | 'arrows/circle_line_down' | 'arrows/circle_line_left' | 'arrows/circle_line_right' | 'arrows/circle_line_up' | 'arrows/circle_up' | 'arrows/double_arrow_up' | 'arrows/chevron_right_grey';
150
+ declare type Arrows$1 = 'arrows/chevron_down' | 'arrows/chevron_down_variant' | 'arrows/chevron_left' | 'arrows/chevron_left_lite' | 'arrows/chevron_left_variant' | 'arrows/chevron_right' | 'arrows/chevron_right_lite' | 'arrows/chevron_right_variant' | 'arrows/chevron_up' | 'arrows/chevron_up_solid' | 'arrows/chevron_up_variant' | 'arrows/circle_chevron_down' | 'arrows/circle_chevron_left' | 'arrows/circle_chevron_right' | 'arrows/circle_chevron_up' | 'arrows/circle_line_down' | 'arrows/circle_line_left' | 'arrows/circle_line_right' | 'arrows/circle_line_up' | 'arrows/circle_up' | 'arrows/double_arrow_up' | 'arrows/chevron_right_grey' | 'arrows/circle_round';
151
151
  declare type Custom$1 = 'custom/atom' | 'custom/bra' | 'custom/bubbles' | 'custom/bullet_one' | 'custom/bullet_three' | 'custom/bullet_two' | 'custom/certified' | 'custom/clinically_tested' | 'custom/cruelty_free' | 'custom/fair_advantages' | 'custom/frown' | 'custom/frown' | 'custom/money_flow' | 'custom/new_sixty_days_guarantee' | 'custom/packs_and_bundles' | 'custom/seamless_support_bra' | 'custom/sixty_days_bold' | 'custom/sixty_days_guarantee' | 'custom/smiling' | 'custom/subscription' | 'custom/thumbs_down' | 'custom/thumbs_up' | 'custom/underwear' | 'custom/wire_free_comfort' | 'custom/wire_free_comfort_bold' | 'custom/tk_sixty_days_bold' | 'custom/free_shipping_truck' | 'custom/higher_discounts' | 'custom/zoom' | 'custom/focus' | 'custom/beauty_face' | 'custom/bar' | 'custom/ears' | 'custom/pain' | 'custom/rociar' | 'custom/star' | 'custom/time' | 'custom/winter_light' | 'custom/priority_support' | 'custom/sound_on' | 'custom/sound_off';
152
152
  declare type Download$1 = 'download/apple_store' | 'download/google_play';
153
153
  declare type Emoji$1 = 'emoji/blowing_kiss' | 'emoji/frowning' | 'emoji/grinning' | 'emoji/grinning_with_sweat' | 'emoji/relieved' | 'emoji/smiling_v2' | 'emoji/smiling_v3' | 'emoji/thinking';
@@ -2483,6 +2483,7 @@ declare type CTAProps = {
2483
2483
  declare type DropdownOption<T> = {
2484
2484
  key: string;
2485
2485
  label: string;
2486
+ selectedLabel?: string;
2486
2487
  value: T;
2487
2488
  disabled: boolean;
2488
2489
  imageURL?: string;
@@ -3189,11 +3190,12 @@ interface RadioProps {
3189
3190
  checked?: boolean;
3190
3191
  disabled?: boolean;
3191
3192
  onChange: (option: RadioGroupOption$1) => void;
3192
- style?: react__default.CSSProperties;
3193
- labelStyle?: react__default.CSSProperties;
3193
+ style?: React.CSSProperties;
3194
+ labelStyle?: React.CSSProperties;
3194
3195
  useV2Style?: boolean;
3196
+ icon?: ReactNode;
3195
3197
  }
3196
- declare const RadioInput: ({ style, name, value, id, label, checked, disabled, onChange, size, useV2Style, labelStyle, }: RadioProps) => JSX.Element;
3198
+ declare const RadioInput: ({ style, name, value, id, label, checked, disabled, onChange, size, useV2Style, labelStyle, icon, }: RadioProps) => JSX.Element;
3197
3199
 
3198
3200
  interface StarListProps {
3199
3201
  rating: number;
@@ -3786,12 +3788,13 @@ declare type VideoProps = {
3786
3788
  } & DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
3787
3789
  declare const Video: React.FC<VideoProps>;
3788
3790
 
3789
- declare type AutoshipFrequency$1 = {
3791
+ declare type AutoshipFrequency = {
3790
3792
  values: number[];
3791
3793
  unit: string;
3794
+ labels?: string[];
3792
3795
  };
3793
3796
  interface ISubscriptionFrequencyDropdown {
3794
- frequency: AutoshipFrequency$1;
3797
+ frequency: AutoshipFrequency;
3795
3798
  onChange?: (value: DropdownOption<number>) => void;
3796
3799
  }
3797
3800
  declare const AutoshipFrequencyDropdown: FC<ISubscriptionFrequencyDropdown>;
@@ -3965,6 +3968,7 @@ declare type SelectorOnChangeProps = {
3965
3968
  };
3966
3969
  declare type RadioConfig = {
3967
3970
  label: string;
3971
+ icon?: ReactNode;
3968
3972
  disabled: boolean;
3969
3973
  checked: boolean;
3970
3974
  };
@@ -3972,10 +3976,6 @@ declare type RadiosConfig = {
3972
3976
  oneTime: RadioConfig;
3973
3977
  subscription: RadioConfig;
3974
3978
  };
3975
- declare type AutoshipFrequency = {
3976
- values: number[];
3977
- unit: string;
3978
- };
3979
3979
  declare type TooltipContent = {
3980
3980
  text: string;
3981
3981
  color?: string;
@@ -1,6 +1,6 @@
1
1
  import { jsx as jsx$1, jsxs as jsxs$1, Fragment as Fragment$2 } from 'react/jsx-runtime';
2
2
  import * as React$2 from 'react';
3
- import React__default, { useContext, createContext, forwardRef, createElement, Fragment as Fragment$1, useRef, useLayoutEffect, useMemo, useState, useEffect, useCallback, useReducer, createRef, isValidElement, cloneElement, memo, useImperativeHandle } from 'react';
3
+ import React__default, { useContext, createContext, forwardRef, createElement, Fragment as Fragment$1, useRef, useLayoutEffect, useMemo, useState, useEffect, useCallback, useReducer, createRef, isValidElement, cloneElement, memo, useImperativeHandle, Children } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
 
6
6
  /*! *****************************************************************************
@@ -5639,8 +5639,9 @@ function SimpleDropdown(_a) {
5639
5639
  var options = _a.options, _b = _a.disabled, disabled = _b === void 0 ? false : _b, initialValue = _a.initialValue, placeHolder = _a.placeHolder, label = _a.label, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.sort, sort = _d === void 0 ? false : _d, onChange = _a.onChange, value = _a.value, _e = _a.testId, testId = _e === void 0 ? 'simple-dropdown' : _e, required = _a.required, showRequiredPlaceholder = _a.showRequiredPlaceholder, selectedOptionWeight = _a.selectedOptionWeight;
5640
5640
  var _f = useState(value || initialValue), selectedValue = _f[0], setSelectedValue = _f[1];
5641
5641
  var selectedOptionLabel = useMemo(function () {
5642
+ var _a;
5642
5643
  if (selectedValue) {
5643
- return selectedValue.label;
5644
+ return (_a = selectedValue.selectedLabel) !== null && _a !== void 0 ? _a : selectedValue.label;
5644
5645
  }
5645
5646
  return showRequiredPlaceholder ? (jsx$1(RequiredPlaceholder, { children: placeHolder }, void 0)) : (placeHolder);
5646
5647
  }, [selectedValue, showRequiredPlaceholder, placeHolder]);
@@ -5748,21 +5749,24 @@ var StyledLabel$3 = newStyled(Label$6)(templateObject_3$14 || (templateObject_3$
5748
5749
  var theme = _a.theme;
5749
5750
  return theme.component.radio.lineHeight;
5750
5751
  });
5751
- var StyledLabelV2 = newStyled(Label$6)(templateObject_4$U || (templateObject_4$U = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 600 !important;\n line-height: ", " !important;\n"], ["\n font-size: ", ";\n font-weight: 600 !important;\n line-height: ", " !important;\n"])), function (_a) {
5752
+ var StyledLabelV2 = newStyled(Label$6)(templateObject_4$U || (templateObject_4$U = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 600 !important;\n line-height: ", " !important;\n\n color: ", ";\n"], ["\n font-size: ", ";\n font-weight: 600 !important;\n line-height: ", " !important;\n\n color: ", ";\n"])), function (_a) {
5752
5753
  var theme = _a.theme;
5753
5754
  return theme.component.radio.textSize;
5754
5755
  }, function (_a) {
5755
5756
  var theme = _a.theme;
5756
5757
  return theme.component.radio.lineHeight;
5758
+ }, function (_a) {
5759
+ var disabled = _a.disabled;
5760
+ return (disabled ? 'var(--colors-shades-250-color)' : 'inherit');
5757
5761
  });
5758
5762
  var RadioInput = function (_a) {
5759
- var style = _a.style, name = _a.name, value = _a.value, id = _a.id, label = _a.label, _b = _a.checked, checked = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.size, size = _d === void 0 ? ComponentSize.Medium : _d, _e = _a.useV2Style, useV2Style = _e === void 0 ? false : _e, labelStyle = _a.labelStyle;
5763
+ var style = _a.style, name = _a.name, value = _a.value, id = _a.id, label = _a.label, _b = _a.checked, checked = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.size, size = _d === void 0 ? ComponentSize.Medium : _d, _e = _a.useV2Style, useV2Style = _e === void 0 ? false : _e, labelStyle = _a.labelStyle, icon = _a.icon;
5760
5764
  var theme = useTheme();
5761
5765
  var handleChange = function (event, label) {
5762
5766
  var value = event.currentTarget.value;
5763
5767
  onChange({ value: value, label: label });
5764
5768
  };
5765
- return (jsxs$1(Wrapper$7, { children: [jsxs$1(Container$1a, __assign$1({ theme: theme, size: size, style: style, "data-testid": "container" }, { children: [jsx$1(Input$4, { id: "".concat(name, "-").concat(id), type: "radio", name: name, value: value, checked: checked, onChange: function (e) { return (disabled ? null : handleChange(e, label)); }, disabled: disabled, style: style }, void 0), jsx$1(CustomRadio$2, { size: size, isChecked: checked, disabled: disabled, theme: theme, "data-testid": "custom-radio", style: style }, void 0)] }), void 0), useV2Style ? (jsx$1(StyledLabelV2, __assign$1({ htmlFor: "".concat(name, "-").concat(id), "data-testid": "label", variant: "regular", size: size, disabled: disabled, style: labelStyle }, { children: label }), void 0)) : (jsx$1(StyledLabel$3, __assign$1({ htmlFor: "".concat(name, "-").concat(id), "data-testid": "label", variant: "regular", size: size, disabled: disabled }, { children: label }), void 0))] }, void 0));
5769
+ return (jsxs$1(Wrapper$7, { children: [jsxs$1(Container$1a, __assign$1({ theme: theme, size: size, style: style, "data-testid": "container" }, { children: [jsx$1(Input$4, { id: "".concat(name, "-").concat(id), type: "radio", name: name, value: value, checked: checked, onChange: function (e) { return (disabled ? null : handleChange(e, label)); }, disabled: disabled, style: style }, void 0), jsx$1(CustomRadio$2, { size: size, isChecked: checked, disabled: disabled, theme: theme, "data-testid": "custom-radio", style: style }, void 0)] }), void 0), useV2Style ? (jsxs$1(StyledLabelV2, __assign$1({ htmlFor: "".concat(name, "-").concat(id), "data-testid": "label", variant: "regular", size: size, disabled: disabled, style: labelStyle }, { children: [icon, " ", label] }), void 0)) : (jsx$1(StyledLabel$3, __assign$1({ htmlFor: "".concat(name, "-").concat(id), "data-testid": "label", variant: "regular", size: size, disabled: disabled }, { children: label }), void 0))] }, void 0));
5766
5770
  };
5767
5771
  var templateObject_1$1S, templateObject_2$1l, templateObject_3$14, templateObject_4$U;
5768
5772
 
@@ -20548,10 +20552,20 @@ var AutoshipFrequencyDropdown = function (_a) {
20548
20552
  };
20549
20553
  return (jsx$1(Fragment$2, { children: options.length > 1 ? (jsxs$1(FlexContainer$2, __assign$1({ onClick: function (e) { return e.stopPropagation(); } }, { children: [jsx$1(DeliveryFrequencyLabel, __assign$1({ variant: "body" }, { children: "Deliver every:" }), void 0), jsx$1(SimpleDropdown, { testId: "subscription-frequency", initialValue: options[0], options: options, onChange: handleChange, placeHolder: "" }, void 0)] }), void 0)) : (jsxs$1(DeliveryFrequencyLabel, __assign$1({ variant: "body" }, { children: ["Deliver every ", options[0].label.toLowerCase()] }), void 0)) }, void 0));
20550
20554
  };
20555
+ var getLabel = function (number, frequency) {
20556
+ return "".concat(number, " ").concat(number === 1 ? frequency.unit.slice(0, -1) : frequency.unit);
20557
+ };
20558
+ var getSelectedLabel = function (number, index, frequency) {
20559
+ var _a;
20560
+ var label = getLabel(number, frequency);
20561
+ var additionalLabel = ((_a = frequency.labels) === null || _a === void 0 ? void 0 : _a[index]) ? " ".concat(frequency.labels[index]) : '';
20562
+ return "".concat(label).concat(additionalLabel);
20563
+ };
20551
20564
  var getDropdownOptions = function (frequency) {
20552
- return frequency.values.map(function (number) { return ({
20565
+ return frequency.values.map(function (number, index) { return ({
20553
20566
  key: "drop-down-autoship-".concat(number),
20554
- label: "".concat(number, " ").concat(number === 1 ? frequency.unit.slice(0, -1) : frequency.unit),
20567
+ label: getLabel(number, frequency),
20568
+ selectedLabel: getSelectedLabel(number, index, frequency),
20555
20569
  value: number,
20556
20570
  disabled: false,
20557
20571
  }); });
@@ -20563,7 +20577,7 @@ var templateObject_1$a, templateObject_2$9;
20563
20577
 
20564
20578
  var BenefitsList = function (_a) {
20565
20579
  var benefits = _a.benefits, isSelected = _a.isSelected, selectedColor = _a.selectedColor, baseColor = _a.baseColor;
20566
- return (jsx$1(Fragment$2, { children: benefits.map(function (benefit, index) { return (jsxs$1(Benefit$1, { children: [jsx$1(Icon.Actions.Check, { "data-testid": "icon-check", width: 1.2, height: 1.2, fill: isSelected ? selectedColor : baseColor }, void 0), jsx$1(BenefitText$1, { variant: "body", dangerouslySetInnerHTML: { __html: benefit } }, void 0)] }, index)); }) }, void 0));
20580
+ return (jsx$1(Fragment$2, { children: benefits.map(function (benefit) { return (jsxs$1(Benefit$1, { children: [jsx$1(Icon.Actions.Check, { "data-testid": "icon-check", width: 1.2, height: 1.2, fill: isSelected ? selectedColor : baseColor }, void 0), jsx$1(BenefitText$1, { variant: "body", dangerouslySetInnerHTML: { __html: benefit } }, void 0)] }, benefit)); }) }, void 0));
20567
20581
  };
20568
20582
 
20569
20583
  var ContainerWrapper$1 = newStyled.div(templateObject_1$9 || (templateObject_1$9 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n max-height: 180px;\n width: auto;\n max-width: 450px;\n gap: 5px;\n @media (max-width: 480px) {\n gap: 0px;\n font-size: 12px !important;\n }\n"], ["\n display: flex;\n flex-direction: row;\n max-height: 180px;\n width: auto;\n max-width: 450px;\n gap: 5px;\n @media (max-width: 480px) {\n gap: 0px;\n font-size: 12px !important;\n }\n"])));
@@ -21174,10 +21188,10 @@ var FlexContainer = newStyled.div(templateObject_1 || (templateObject_1 = __make
21174
21188
  "\n [data-testid='subscription-frequency'] {\n border: 0;\n padding-left: 0 !important;\n padding-right: 32px !important;\n }\n\n [role='listbox']{\n margin-left: -20px;\n }\n ";
21175
21189
  });
21176
21190
  var DiscountTag = newStyled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: -24px;\n right: 18px;\n background-color: ", ";\n color: white;\n padding: 5px 10px;\n font-size: 12px;\n font-weight: bold;\n line-height: 14px;\n border-radius: ", ";\n"], ["\n position: absolute;\n top: -24px;\n right: 18px;\n background-color: ", ";\n color: white;\n padding: 5px 10px;\n font-size: 12px;\n font-weight: bold;\n line-height: 14px;\n border-radius: ", ";\n"])), function (_a) {
21177
- var theme = _a.theme, isSelected = _a.isSelected;
21178
- return isSelected
21179
- ? theme.component.autoship.discountTag.backgroundColor
21180
- : theme.colors.shades[350].color;
21191
+ var theme = _a.theme, disabled = _a.disabled;
21192
+ return disabled
21193
+ ? theme.colors.shades[350].color
21194
+ : theme.component.autoship.discountTag.backgroundColor;
21181
21195
  }, function (_a) {
21182
21196
  var theme = _a.theme;
21183
21197
  return "".concat(theme.component.autoship.discountTag.borderRadius, " \n ").concat(theme.component.autoship.discountTag.borderRadius, " 0 0");
@@ -21190,13 +21204,13 @@ var getSelectedBorder = function (_a) {
21190
21204
  return "1.5px solid ".concat(colors.shades['700'].color);
21191
21205
  };
21192
21206
  var ContainerBase = newStyled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n border-radius: 8px;\n\n border: ", ";\n\n ", "\n\n & input:checked + div {\n border-color: ", ";\n }\n\n & label {\n cursor: pointer;\n }\n"], ["\n border-radius: 8px;\n\n border: ", ";\n\n ", "\n\n & input:checked + div {\n border-color: ", ";\n }\n\n & label {\n cursor: pointer;\n }\n"])), function (_a) {
21193
- var selected = _a.selected, theme = _a.theme;
21194
- return selected ? getSelectedBorder(theme) : "1px solid ".concat(theme.colors.shades[200].color);
21207
+ var disabled = _a.disabled, theme = _a.theme;
21208
+ return disabled ? "1px solid ".concat(theme.colors.shades[200].color) : getSelectedBorder(theme);
21195
21209
  }, function (_a) {
21196
- var selected = _a.selected;
21197
- return selected
21198
- ? "& label {\n font-weight: 700;\n }"
21199
- : '';
21210
+ var disabled = _a.disabled;
21211
+ return disabled
21212
+ ? ''
21213
+ : "& label {\n font-weight: 700;\n }";
21200
21214
  }, function (_a) {
21201
21215
  var theme = _a.theme;
21202
21216
  return theme.colors.pallete.primary.color;
@@ -21213,10 +21227,13 @@ var SubscriptionHeader = newStyled.div(templateObject_6 || (templateObject_6 = _
21213
21227
  var theme = _a.theme;
21214
21228
  return theme.colors.pallete.primary.color;
21215
21229
  });
21216
- var BenefitsContainer = newStyled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin-bottom: 5px;\n"], ["\n margin-bottom: 5px;\n"])));
21230
+ var BenefitsContainer = newStyled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin-bottom: 5px;\n\n p {\n color: ", ";\n }\n"], ["\n margin-bottom: 5px;\n\n p {\n color: ", ";\n }\n"])), function (_a) {
21231
+ var disabled = _a.disabled;
21232
+ return (disabled ? 'var(--colors-shades-250-color)' : 'inherit');
21233
+ });
21217
21234
  var StyledPrice = newStyled(PriceLabelV2$1)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n div p {\n color: ", ";\n }\n"], ["\n div p {\n color: ", ";\n }\n"])), function (_a) {
21218
- var selected = _a.selected, theme = _a.theme;
21219
- return selected ? theme.colors.shades[700].color : theme.colors.shades[200].color;
21235
+ var disabled = _a.disabled, theme = _a.theme;
21236
+ return disabled ? theme.colors.shades[200].color : theme.colors.shades[700].color;
21220
21237
  });
21221
21238
  var Container = newStyled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-top: 20px;\n"], ["\n margin-top: 20px;\n"])));
21222
21239
  var TooltipWrapper = newStyled.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin: ", ";\n"], ["\n margin: ", ";\n"])), function (_a) {
@@ -21226,24 +21243,16 @@ var TooltipWrapper = newStyled.div(templateObject_10 || (templateObject_10 = __m
21226
21243
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
21227
21244
 
21228
21245
  var SubscriptionPlanSelector = function (_a) {
21229
- var _b, _c;
21230
21246
  var children = _a.children, benefits = _a.benefits, tooltip = _a.tooltip, pricing = _a.pricing, frequency = _a.frequency, onChange = _a.onChange, className = _a.className, discountTagClassName = _a.discountTagClassName, closeIcon = _a.closeIcon, currencySymbol = _a.currencySymbol, discountLabel = _a.discountLabel, radios = _a.radios;
21231
21247
  var theme = useTheme();
21232
- var _d = useState({
21248
+ var _b = useState({
21233
21249
  oneTime: radios.oneTime,
21234
21250
  subscription: radios.subscription,
21235
- }), radiosStatuses = _d[0], setRadiosStatuses = _d[1];
21236
- // Only for Autoship
21237
- var getDropDownOptions = function (frequency) {
21238
- return frequency.values.map(function (number) { return ({
21239
- key: "drop-down-subscription-plan-selector-".concat(number),
21240
- label: "".concat(number, " ").concat(number === 1 ? frequency.unit.slice(0, -1) : frequency),
21241
- value: number,
21242
- disabled: false,
21243
- }); });
21244
- };
21245
- var dropdownOptions = frequency ? getDropDownOptions(frequency) : undefined;
21246
- var _e = useState((_c = (_b = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : undefined), subscriptionPeriod = _e[0], setSubscriptionPeriod = _e[1];
21251
+ }), radiosStatuses = _b[0], setRadiosStatuses = _b[1];
21252
+ useEffect(function () {
21253
+ setRadiosStatuses(function (prevStatuses) { return (__assign$1(__assign$1({}, prevStatuses), { oneTime: __assign$1(__assign$1({}, prevStatuses.oneTime), { checked: prevStatuses.oneTime.disabled ? false : prevStatuses.oneTime.checked }), subscription: __assign$1(__assign$1({}, prevStatuses.subscription), { checked: prevStatuses.subscription.disabled ? false : prevStatuses.subscription.checked }) })); });
21254
+ }, [radiosStatuses.oneTime.disabled, radiosStatuses.subscription.disabled]);
21255
+ var _c = useState(frequency === null || frequency === void 0 ? void 0 : frequency.values[0]), subscriptionPeriod = _c[0], setSubscriptionPeriod = _c[1];
21247
21256
  var listPrice = pricing.listPrice, discountedPrice = pricing.discountedPrice, subscriptionDiscountPercentage = pricing.subscriptionDiscountPercentage;
21248
21257
  var subscriptionAdditionalDiscount = discountedPrice * (subscriptionDiscountPercentage / 100);
21249
21258
  var subscriptionFinalPrice = Number((discountedPrice - subscriptionAdditionalDiscount).toFixed(2));
@@ -21268,33 +21277,52 @@ var SubscriptionPlanSelector = function (_a) {
21268
21277
  }
21269
21278
  }, [dataObject, onChange]);
21270
21279
  var handleRadioClicked = function (radioValue) {
21280
+ var isDisabled = function (value) {
21281
+ return ((value === 'subscription' && radiosStatuses.subscription.disabled) ||
21282
+ (value === 'oneTime' && radiosStatuses.oneTime.disabled));
21283
+ };
21284
+ if (isDisabled(radioValue)) {
21285
+ return;
21286
+ }
21271
21287
  setRadiosStatuses(function (prevStatuses) { return (__assign$1(__assign$1({}, prevStatuses), { oneTime: __assign$1(__assign$1({}, prevStatuses.oneTime), { checked: radioValue === 'oneTime' }), subscription: __assign$1(__assign$1({}, prevStatuses.subscription), { checked: radioValue === 'subscription' }) })); });
21288
+ if (radioValue === 'oneTime') {
21289
+ setSubscriptionPeriod(undefined);
21290
+ }
21291
+ else if (radioValue === 'subscription' && frequency) {
21292
+ setSubscriptionPeriod(frequency.values[0]);
21293
+ }
21272
21294
  };
21273
- var handleValueChanged = function (value) {
21274
- console.log('value', value);
21275
- setSubscriptionPeriod(value.value);
21295
+ var handleFrequencyChange = function (value) {
21296
+ setSubscriptionPeriod(radiosStatuses.subscription.checked ? value.value : undefined);
21276
21297
  };
21277
21298
  var benefitsColor = benefitsColorMapper(theme);
21278
21299
  var renderBenefitsOrChildren = function () {
21300
+ var isDisabled = radiosStatuses.subscription.disabled;
21279
21301
  if (children) {
21280
- return children;
21302
+ var disabledStyle_1 = isDisabled ? { opacity: 0.5, pointerEvents: 'none' } : {};
21303
+ return Children.map(children, function (child) {
21304
+ return isValidElement(child)
21305
+ ? cloneElement(child, { style: __assign$1(__assign$1({}, child.props.style), disabledStyle_1) })
21306
+ : child;
21307
+ });
21281
21308
  }
21282
21309
  else if (benefits) {
21283
- return (jsx$1(BenefitsList, { benefits: benefits, isSelected: radiosStatuses.subscription.checked, selectedColor: benefitsColor.selected, baseColor: benefitsColor.base }, void 0));
21310
+ var isSelected = radiosStatuses.subscription.checked;
21311
+ return (jsx$1(BenefitsList, { benefits: benefits, isSelected: isSelected, selectedColor: benefitsColor.selected, baseColor: isDisabled ? 'var(--colors-shades-250-color)' : benefitsColor.base }, void 0));
21284
21312
  }
21285
21313
  return null;
21286
21314
  };
21287
- return (jsxs$1(Container, __assign$1({ className: className }, { children: [jsxs$1(SubscriptionContainer, __assign$1({ onClick: function () { return handleRadioClicked('subscription'); }, "data-testid": "subscription-purchase-block", selected: radiosStatuses.subscription.checked }, { children: [jsx$1(DiscountTag, __assign$1({ className: discountTagClassName, isSelected: radiosStatuses.subscription.checked }, { children: discountLabel !== null && discountLabel !== void 0 ? discountLabel : "".concat(subscriptionPctOverListPriceRounded, "% OFF - SAVE ").concat(currencySymbol).concat(subscriptionSaving.toFixed(2)) }), void 0), jsxs$1(SubscriptionHeader, { children: [jsxs$1(FlexContainer, __assign$1({ "data-testid": "subscription-block", onClick: function () { return handleRadioClicked('subscription'); } }, { children: [jsx$1(RadioInput, { label: radios.subscription.label, name: "subscription", id: "subscription", value: "subscription", size: ComponentSize.Medium, style: { marginRight: '10px' }, useV2Style: true, onChange: function () {
21315
+ return (jsxs$1(Container, __assign$1({ className: className }, { children: [jsxs$1(SubscriptionContainer, __assign$1({ onClick: function () { return handleRadioClicked('subscription'); }, "data-testid": "subscription-purchase-block", disabled: radiosStatuses.subscription.disabled }, { children: [jsx$1(DiscountTag, __assign$1({ className: discountTagClassName, disabled: radiosStatuses.subscription.disabled }, { children: discountLabel !== null && discountLabel !== void 0 ? discountLabel : "".concat(subscriptionPctOverListPriceRounded, "% OFF - SAVE ").concat(currencySymbol).concat(subscriptionSaving.toFixed(2)) }), void 0), jsxs$1(SubscriptionHeader, { children: [jsxs$1(FlexContainer, __assign$1({ "data-testid": "subscription-block", onClick: function () { return handleRadioClicked('subscription'); } }, { children: [jsx$1(RadioInput, { label: radios.subscription.label, icon: radios.subscription.icon, name: "subscription", id: "subscription", value: "subscription", size: ComponentSize.Medium, style: { marginRight: '10px' }, useV2Style: true, onChange: function () {
21288
21316
  setRadiosStatuses(function (prev) { return ({
21289
21317
  subscription: __assign$1(__assign$1({}, prev.subscription), { checked: true }),
21290
21318
  oneTime: __assign$1(__assign$1({}, prev.oneTime), { checked: false }),
21291
21319
  }); });
21292
- }, checked: radiosStatuses.subscription.checked, disabled: radiosStatuses.subscription.disabled }, void 0), jsx$1(TooltipWrapper, { children: jsx$1(Tooltip, __assign$1({ position: 0, content: tooltip === null || tooltip === void 0 ? void 0 : tooltip.content, header: tooltip === null || tooltip === void 0 ? void 0 : tooltip.header, maxWidth: "248px", showCloseIcon: closeIcon, closeBtnSize: 0.7 }, { children: jsx$1(Icon.Actions.CircleQuestion, { width: 1 }, void 0) }), void 0) }, void 0)] }), void 0), jsx$1(StyledPrice, { testId: "subscription", finalPrice: "$".concat(decimalFormat(Number(subscriptionFinalPrice))), selected: radiosStatuses.subscription.checked, size: ComponentSize.Large, originalPrice: "$".concat(decimalFormat(Number(listPrice))) }, void 0)] }, void 0), jsx$1(BenefitsContainer, { children: renderBenefitsOrChildren() }, void 0), frequency && (jsx$1(AutoshipFrequencyDropdown, { frequency: frequency, onChange: handleValueChanged }, void 0))] }), void 0), jsxs$1(SinglePurchaseContainer, __assign$1({ "data-testid": "single-purchase-block", selected: radiosStatuses.oneTime.checked, onClick: function () { return handleRadioClicked('oneTime'); } }, { children: [jsx$1(RadioInput, { label: radios.oneTime.label, name: "oneTime", id: "oneTime", value: "oneTime", size: ComponentSize.Medium, onChange: function () {
21320
+ }, checked: !radiosStatuses.subscription.disabled && radiosStatuses.subscription.checked, disabled: radiosStatuses.subscription.disabled }, void 0), jsx$1(TooltipWrapper, { children: jsx$1(Tooltip, __assign$1({ position: 0, content: tooltip === null || tooltip === void 0 ? void 0 : tooltip.content, header: tooltip === null || tooltip === void 0 ? void 0 : tooltip.header, maxWidth: "248px", showCloseIcon: closeIcon, closeBtnSize: 0.7 }, { children: jsx$1(Icon.Actions.CircleQuestion, { width: 1 }, void 0) }), void 0) }, void 0)] }), void 0), jsx$1(StyledPrice, { testId: "subscription", finalPrice: "$".concat(decimalFormat(Number(subscriptionFinalPrice))), disabled: radiosStatuses.subscription.disabled, size: ComponentSize.Large, originalPrice: "$".concat(decimalFormat(Number(listPrice))) }, void 0)] }, void 0), jsx$1(BenefitsContainer, __assign$1({ disabled: radiosStatuses.subscription.disabled }, { children: renderBenefitsOrChildren() }), void 0), radiosStatuses.subscription.checked && frequency && (jsx$1(AutoshipFrequencyDropdown, { frequency: frequency, onChange: handleFrequencyChange }, void 0))] }), void 0), jsxs$1(SinglePurchaseContainer, __assign$1({ "data-testid": "single-purchase-block", disabled: radiosStatuses.oneTime.disabled, onClick: function () { return handleRadioClicked('oneTime'); } }, { children: [jsx$1(RadioInput, { label: radios.oneTime.label, icon: radios.oneTime.icon, name: "oneTime", id: "oneTime", value: "oneTime", size: ComponentSize.Medium, onChange: function () {
21293
21321
  setRadiosStatuses(function (prev) { return ({
21294
21322
  subscription: __assign$1(__assign$1({}, prev.subscription), { checked: false }),
21295
21323
  oneTime: __assign$1(__assign$1({}, prev.oneTime), { checked: true }),
21296
21324
  }); });
21297
- }, useV2Style: true, checked: radiosStatuses.oneTime.checked, disabled: radiosStatuses.oneTime.disabled }, void 0), jsx$1(StyledPrice, { testId: "single-purchase", finalPrice: "$".concat(decimalFormat(Number(discountedPrice))), selected: radiosStatuses.oneTime.checked, size: ComponentSize.Large, originalPrice: "$".concat(decimalFormat(Number(listPrice))) }, void 0)] }), void 0)] }), void 0));
21325
+ }, useV2Style: true, checked: !radiosStatuses.oneTime.disabled && radiosStatuses.oneTime.checked, disabled: radiosStatuses.oneTime.disabled }, void 0), jsx$1(StyledPrice, { testId: "single-purchase", finalPrice: "$".concat(decimalFormat(Number(discountedPrice))), disabled: radiosStatuses.oneTime.disabled, size: ComponentSize.Large, originalPrice: "$".concat(decimalFormat(Number(listPrice))) }, void 0)] }), void 0)] }), void 0));
21298
21326
  };
21299
21327
 
21300
21328
  export { AbsorbencyLevel, Accordion$1 as Accordion, AccordionOptions, AmazonButton, AssetsProvider, Autoship, AutoshipFrequencyDropdown, AutoshipV2, BasicAccordion, BeforeAfterCard, BeforeAfterVariant, BenefitsList, Bundle, ButtonPrimary, ButtonSecondary, ButtonSecondaryOutline, BuyNowPayLater, CacheProvider, CancellationFlowAccordionContentPerPartner, Card$3 as Card, CardSectionType, CartItemCard, CartProductItem, CategorySquareTag, CategoryTag, Checkbox, ClubOfferSelector, ClubOfferTag, ClubPriceMemberLabel, ClubRadioGroupInput, Collection, ColorPickerWithTooltip, ComponentPosition, ComponentSize, CouponCard, index$1 as CrossSell, DeliveryDetails, DiscountTag$3 as DiscountTag, Drawer, DropdownDialog, DropdownListIcons, FilteringDropdown, Tags as FilteringTags, Filters, FitGuarantee, FitPredictor, Global, HurryUp, Icon, IconButton, IconsWithTitle, Image$3 as Image, ImageCardWithDescription, Input$3 as Input, InputValidationType, JoinClubCard, Icon$1 as LibIcon, Modal, MotivatorProgressBar, MultiColorPicker, Note, OfferBanner, OrderBar, Overlay, PackSelector, PackSelectorV2, Pagination, PaginatorBlog, PaymentMethod, PaypalButton, Portal, PriceLabel$1 as PriceLabel, PriceLabelV2$1 as PriceLabelV2, PriceLabelV3, ProductCard, ProductCardV2, ProductCardV3, ProductGallery, ProductGalleryMobile, ProductGalleryMobileV2, ProductGalleryMobileV3, ProductGalleryMobileV4, ProgressBar, QuantityPicker, RadioGroupInput, RadioInput, RadioPrimary, Rating, Review, Review$1 as ReviewDetail, ReviewsHeader, ScrollToTop, SearchBar, SearchNavigation, SeasonOfferTag, ShortBanner, SimpleDropdown, SimpleOrderItem, SingleColorPicker, SizeChartTable, SizeChartTableV2, SizeChartTableV3, SizeDropdown, SizeFitGuide, SizeSelector, SizeTable, SliderNavigation, Spacing, Spinner, StarList, StrengthBars, SubscriptionPlanSelector, Tab, Tabs, Text$7 as Text, TextButton, TextWithImage, ThemeProvider, ThemeVariables, Timer, Toast, ToggleComponent, Tooltip, Totals, TrackingProgress, TrackingProgressV2, Video$1 as Video, buildImageUrl, componentSizeMapper, createCache, css, decimalFormat, formatPrice, getSrcSet, isEmail, isEmpty, isNumber$1 as isNumber, isPhoneNumber, isValidDate, mediaQueries, modalEvent, SeasonOfferRoundedTag as seasonOfferRoundedTag, simulateMouseClick, sliceString, newStyled as styled, useDeviceType, useModal, useModalEvent, useOnClickOutside, useTheme, useThemeAssets, useWindowDimensions };