@trafilea/afrodita-components 5.0.0-beta.44 → 5.0.0-beta.47

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.js CHANGED
@@ -3960,8 +3960,13 @@ var Checkbox = function (_a) {
3960
3960
  if (disabled || !mounted.current) {
3961
3961
  return;
3962
3962
  }
3963
- onChange(isChecked);
3964
- }, [isChecked, onChange, disabled]);
3963
+ if (checked !== isChecked) {
3964
+ onChange(isChecked);
3965
+ }
3966
+ }, [isChecked, onChange, disabled, checked]);
3967
+ React$2.useEffect(function () {
3968
+ setIsChecked(checked);
3969
+ }, [checked]);
3965
3970
  React$2.useEffect(function () {
3966
3971
  mounted.current = true;
3967
3972
  }, []);
@@ -4033,8 +4038,12 @@ function SimpleDropdown(_a) {
4033
4038
  if (value == null) {
4034
4039
  return;
4035
4040
  }
4041
+ if (options.indexOf(value) < 0) {
4042
+ setSelectedValue(undefined);
4043
+ return;
4044
+ }
4036
4045
  setSelectedValue(value);
4037
- }, [value]);
4046
+ }, [value, options]);
4038
4047
  var Button = label ? withLabel(BaseDropdown$1.Button, label) : BaseDropdown$1.Button;
4039
4048
  return (jsxRuntime.jsxs(BaseDropdown$1, __assign$1({ value: selectedValue, onChange: onChangeHandler, disabled: disabled, wide: wide }, { children: [jsxRuntime.jsx(Button, __assign$1({ OpenIcon: Icon.Arrows.ChevronDown, CloseIcon: Icon.Arrows.ChevronUp, wide: wide, isSortOrFilter: sort, "data-testid": testId }, { children: selectedOptionLabel }), void 0), jsxRuntime.jsx(BaseDropdown$1.Options, { children: options.map(function (item) { return (jsxRuntime.jsx(BaseDropdown$1.Option, __assign$1({ value: item, disabled: false }, { children: item.label }), item.key)); }) }, void 0)] }), void 0));
4040
4049
  }
@@ -12634,7 +12643,7 @@ var ProductGalleryMobile = function (_a) {
12634
12643
  var templateObject_1$a;
12635
12644
 
12636
12645
  var Portal = function (_a) {
12637
- var id = _a.id, className = _a.className, children = _a.children;
12646
+ var id = _a.id, className = _a.className, children = _a.children, overflow = _a.overflow, style = _a.style;
12638
12647
  var _b = React$2.useState(false), mounted = _b[0], setMounted = _b[1];
12639
12648
  var container = React$2.useRef(null);
12640
12649
  React$2.useEffect(function () {
@@ -12648,10 +12657,19 @@ var Portal = function (_a) {
12648
12657
  throw new Error("Unable to find/create container (".concat(id, ")"));
12649
12658
  }
12650
12659
  element.dataset.testId = id;
12651
- element.style.overflow = 'hidden';
12652
12660
  setMounted(true);
12653
12661
  container.current = element;
12654
12662
  }, [id]);
12663
+ React$2.useEffect(function () {
12664
+ if (!mounted) {
12665
+ return;
12666
+ }
12667
+ container.current.style.overflow = overflow ? 'visible' : 'hidden';
12668
+ for (var key in style) {
12669
+ // @ts-ignore
12670
+ container.current.style[key] = style[key];
12671
+ }
12672
+ }, [style, overflow, mounted]);
12655
12673
  React$2.useEffect(function () {
12656
12674
  if (mounted) {
12657
12675
  container.current.className = className !== null && className !== void 0 ? className : '';
@@ -16717,9 +16735,12 @@ var Filters = function (_a) {
16717
16735
  var handleCheckboxClick = React$2.useCallback(function (_a) {
16718
16736
  var sectionIndex = _a.sectionIndex, itemIndex = _a.itemIndex, checked = _a.checked;
16719
16737
  setFilterSection({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: checked });
16738
+ var currentFilter = filters[sectionIndex];
16720
16739
  setCheckedItems(function (prev) {
16740
+ if (!currentFilter.isMultiselect)
16741
+ resetCheckedItems(__spreadArray([], prev, true));
16721
16742
  return checked
16722
- ? __spreadArray(__spreadArray([], prev, true), [
16743
+ ? __spreadArray(__spreadArray([], (currentFilter.isMultiselect ? prev : []), true), [
16723
16744
  { sectionIndex: sectionIndex, itemIndex: itemIndex, label: filters[sectionIndex].items[itemIndex].label },
16724
16745
  ], false) : prev.filter(function (item) { return item.sectionIndex !== sectionIndex || item.itemIndex !== itemIndex; });
16725
16746
  });
@@ -16730,7 +16751,7 @@ var Filters = function (_a) {
16730
16751
  return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value, indexItems) {
16731
16752
  return {
16732
16753
  label: value.label,
16733
- checked: itemIndex === indexItems ? checked : value.checked,
16754
+ checked: itemIndex === indexItems ? checked : filter.isMultiselect ? value.checked : false,
16734
16755
  };
16735
16756
  }) });
16736
16757
  });
@@ -16742,11 +16763,15 @@ var Filters = function (_a) {
16742
16763
  var element = document.getElementById("filter[".concat(sectionIndex, ",").concat(itemIndex, "]"));
16743
16764
  simulateMouseClick(element);
16744
16765
  };
16745
- var handleClearAllClick = function () {
16746
- checkedItems.forEach(function (item) {
16766
+ var resetCheckedItems = function (items) {
16767
+ items.forEach(function (item) {
16747
16768
  var sectionIndex = item.sectionIndex, itemIndex = item.itemIndex;
16748
16769
  handleCloseClick({ sectionIndex: sectionIndex, itemIndex: itemIndex });
16749
16770
  });
16771
+ };
16772
+ var handleClearAllClick = function () {
16773
+ resetCheckedItems(checkedItems);
16774
+ setCheckedItems([]);
16750
16775
  setFilter(function (prev) {
16751
16776
  return prev.map(function (filter) {
16752
16777
  return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value) {
@@ -16759,18 +16784,14 @@ var Filters = function (_a) {
16759
16784
  });
16760
16785
  onResetValues();
16761
16786
  };
16762
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMobile ? (jsxRuntime.jsxs("div", __assign$1({ "data-testid": "DesktopHeader" }, { children: [jsxRuntime.jsxs(Header, { children: [jsxRuntime.jsxs(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filterByText, " (", checkedItems.length, ")"] }), void 0), jsxRuntime.jsx(ClearAll, __assign$1({ onClick: handleClearAllClick, color: theme.colors.shades['700'].color, "data-testid": "desktop-clear-all" }, { children: clearAllText }), void 0)] }, void 0), jsxRuntime.jsx(Tags, { color: tagsColor, items: checkedItems.map(function (item) { return item.label; }), onCloseClick: function (index) { return handleCloseClick(checkedItems[index]); } }, void 0)] }), void 0)) : (jsxRuntime.jsxs(MobileHeader, __assign$1({ "data-testid": "MobileHeader" }, { children: [jsxRuntime.jsx(MobileIconsContainer, __assign$1({ onClick: mobileBackArrowClick, "data-testid": "mobileBackArrow" }, { children: jsxRuntime.jsx(Icon.Arrows.ChevronRightVariant, { fill: theme.colors.shades['700'].color }, void 0) }), void 0), jsxRuntime.jsxs(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filtersSelectText, " (", checkedItems.length, ")"] }), void 0)] }), void 0)), filters.map(function (filter, sectionIndex) { return (jsxRuntime.jsx(Accordion, __assign$1({ title: filter.title, isOpenByDefault: filter.isOpenByDefault }, { children: jsxRuntime.jsx(SectionContent, __assign$1({ cols: filter.columns }, { children: filter.items.map(function (item, itemIndex) { return (jsxRuntime.jsx(FilterCheckbox, { onChange: handleCheckboxClick, text: item.label, checked: item.checked, itemIndex: itemIndex, sectionIndex: sectionIndex }, itemIndex)); }) }), void 0) }), sectionIndex)); }), isMobile && (jsxRuntime.jsxs(MobileFooter, __assign$1({ "data-testid": "MobileFooter" }, { children: [jsxRuntime.jsxs(MobileClearContainer, __assign$1({ onClick: handleClearAllClick }, { children: [jsxRuntime.jsx(MobileIconsContainer, { children: jsxRuntime.jsx(Icon.Actions.Trash, { fill: theme.colors.shades['700'].color }, void 0) }, void 0), jsxRuntime.jsx(ClearAll, __assign$1({ color: theme.colors.shades['700'].color }, { children: clearAllText }), void 0)] }), void 0), jsxRuntime.jsx(ButtonSecondary, { text: applyText, onClick: mobileApplyButtonClick }, void 0)] }), void 0))] }, void 0));
16787
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMobile ? (jsxRuntime.jsxs("div", __assign$1({ "data-testid": "DesktopHeader" }, { children: [jsxRuntime.jsxs(Header, { children: [jsxRuntime.jsxs(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filterByText, " (", checkedItems.length, ")"] }), void 0), jsxRuntime.jsx(ClearAll, __assign$1({ onClick: handleClearAllClick, color: theme.colors.shades['700'].color, "data-testid": "desktop-clear-all" }, { children: clearAllText }), void 0)] }, void 0), jsxRuntime.jsx(Tags, { color: tagsColor, items: checkedItems.map(function (item) { return item.label; }), onCloseClick: function (index) { return handleCloseClick(checkedItems[index]); } }, void 0)] }), void 0)) : (jsxRuntime.jsxs(MobileHeader, __assign$1({ "data-testid": "MobileHeader" }, { children: [jsxRuntime.jsx(MobileIconsContainer, __assign$1({ onClick: mobileBackArrowClick, "data-testid": "mobileBackArrow" }, { children: jsxRuntime.jsx(Icon.Arrows.ChevronRightVariant, { fill: theme.colors.shades['700'].color }, void 0) }), void 0), jsxRuntime.jsxs(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filtersSelectText, " (", checkedItems.length, ")"] }), void 0)] }), void 0)), filters.map(function (filter, sectionIndex) { return (jsxRuntime.jsx(Accordion, __assign$1({ title: filter.title, isOpenByDefault: filter.isOpenByDefault }, { children: jsxRuntime.jsx(SectionContent, __assign$1({ cols: filter.columns }, { children: filter.items.map(function (item, itemIndex) { return (jsxRuntime.jsx(FilterCheckbox, { onChange: handleCheckboxClick, text: item.label, checked: item.checked, itemIndex: itemIndex, sectionIndex: sectionIndex }, "".concat(item.checked, "-").concat(item.label))); }) }), void 0) }), sectionIndex)); }), isMobile && (jsxRuntime.jsxs(MobileFooter, __assign$1({ "data-testid": "MobileFooter" }, { children: [jsxRuntime.jsxs(MobileClearContainer, __assign$1({ onClick: handleClearAllClick }, { children: [jsxRuntime.jsx(MobileIconsContainer, { children: jsxRuntime.jsx(Icon.Actions.Trash, { fill: theme.colors.shades['700'].color }, void 0) }, void 0), jsxRuntime.jsx(ClearAll, __assign$1({ color: theme.colors.shades['700'].color }, { children: clearAllText }), void 0)] }), void 0), jsxRuntime.jsx(ButtonSecondary, { text: applyText, onClick: mobileApplyButtonClick }, void 0)] }), void 0))] }, void 0));
16763
16788
  };
16764
16789
  var FilterCheckbox = function (_a) {
16765
16790
  var sectionIndex = _a.sectionIndex, text = _a.text, itemIndex = _a.itemIndex, onChangeProp = _a.onChange, checked = _a.checked;
16766
- var _b = React__default["default"].useState(checked), defaultChecked = _b[0], setDefaultChecked = _b[1];
16767
16791
  var onChange = React$2.useCallback(function (checked) {
16768
- setDefaultChecked(checked);
16769
- }, []);
16770
- React__default["default"].useEffect(function () {
16771
- onChangeProp({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: defaultChecked });
16772
- }, [sectionIndex, itemIndex, onChangeProp, defaultChecked]);
16773
- return (jsxRuntime.jsx(Checkbox, { onChange: onChange, checked: defaultChecked, text: text, id: "filter[".concat(sectionIndex, ",").concat(itemIndex, "]"), size: exports.ComponentSize.Small, variant: "secondary" }, itemIndex));
16792
+ onChangeProp({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: checked });
16793
+ }, [sectionIndex, itemIndex, onChangeProp]);
16794
+ return (jsxRuntime.jsx(Checkbox, { onChange: onChange, checked: checked, text: text, id: "filter[".concat(sectionIndex, ",").concat(itemIndex, "]"), size: exports.ComponentSize.Small, variant: "secondary" }, itemIndex));
16774
16795
  };
16775
16796
 
16776
16797
  var Container = newStyled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n padding: 0 1rem 1rem;\n"], ["\n display: flex;\n flex-wrap: wrap;\n padding: 0 1rem 1rem;\n"])));