@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.d.ts +3 -0
- package/build/index.esm.js +38 -17
- package/build/index.esm.js.map +1 -1
- package/build/index.js +38 -17
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ declare type Filter = {
|
|
|
102
102
|
title: string;
|
|
103
103
|
columns: number;
|
|
104
104
|
isOpenByDefault?: boolean;
|
|
105
|
+
isMultiselect: boolean;
|
|
105
106
|
items: Array<{
|
|
106
107
|
label: string;
|
|
107
108
|
checked?: boolean;
|
|
@@ -1634,6 +1635,8 @@ declare const RadioInput: ({ name, value, id, label, checked, disabled, onChange
|
|
|
1634
1635
|
declare type PortalProps = {
|
|
1635
1636
|
id: string;
|
|
1636
1637
|
className?: string;
|
|
1638
|
+
overflow?: boolean;
|
|
1639
|
+
style?: CSSProperties;
|
|
1637
1640
|
};
|
|
1638
1641
|
declare const Portal: FC<PortalProps>;
|
|
1639
1642
|
|
package/build/index.esm.js
CHANGED
|
@@ -3934,8 +3934,13 @@ var Checkbox = function (_a) {
|
|
|
3934
3934
|
if (disabled || !mounted.current) {
|
|
3935
3935
|
return;
|
|
3936
3936
|
}
|
|
3937
|
-
|
|
3938
|
-
|
|
3937
|
+
if (checked !== isChecked) {
|
|
3938
|
+
onChange(isChecked);
|
|
3939
|
+
}
|
|
3940
|
+
}, [isChecked, onChange, disabled, checked]);
|
|
3941
|
+
useEffect(function () {
|
|
3942
|
+
setIsChecked(checked);
|
|
3943
|
+
}, [checked]);
|
|
3939
3944
|
useEffect(function () {
|
|
3940
3945
|
mounted.current = true;
|
|
3941
3946
|
}, []);
|
|
@@ -4007,8 +4012,12 @@ function SimpleDropdown(_a) {
|
|
|
4007
4012
|
if (value == null) {
|
|
4008
4013
|
return;
|
|
4009
4014
|
}
|
|
4015
|
+
if (options.indexOf(value) < 0) {
|
|
4016
|
+
setSelectedValue(undefined);
|
|
4017
|
+
return;
|
|
4018
|
+
}
|
|
4010
4019
|
setSelectedValue(value);
|
|
4011
|
-
}, [value]);
|
|
4020
|
+
}, [value, options]);
|
|
4012
4021
|
var Button = label ? withLabel(BaseDropdown$1.Button, label) : BaseDropdown$1.Button;
|
|
4013
4022
|
return (jsxs$1(BaseDropdown$1, __assign$1({ value: selectedValue, onChange: onChangeHandler, disabled: disabled, wide: wide }, { children: [jsx$1(Button, __assign$1({ OpenIcon: Icon.Arrows.ChevronDown, CloseIcon: Icon.Arrows.ChevronUp, wide: wide, isSortOrFilter: sort, "data-testid": testId }, { children: selectedOptionLabel }), void 0), jsx$1(BaseDropdown$1.Options, { children: options.map(function (item) { return (jsx$1(BaseDropdown$1.Option, __assign$1({ value: item, disabled: false }, { children: item.label }), item.key)); }) }, void 0)] }), void 0));
|
|
4014
4023
|
}
|
|
@@ -12608,7 +12617,7 @@ var ProductGalleryMobile = function (_a) {
|
|
|
12608
12617
|
var templateObject_1$a;
|
|
12609
12618
|
|
|
12610
12619
|
var Portal = function (_a) {
|
|
12611
|
-
var id = _a.id, className = _a.className, children = _a.children;
|
|
12620
|
+
var id = _a.id, className = _a.className, children = _a.children, overflow = _a.overflow, style = _a.style;
|
|
12612
12621
|
var _b = useState(false), mounted = _b[0], setMounted = _b[1];
|
|
12613
12622
|
var container = useRef(null);
|
|
12614
12623
|
useEffect(function () {
|
|
@@ -12622,10 +12631,19 @@ var Portal = function (_a) {
|
|
|
12622
12631
|
throw new Error("Unable to find/create container (".concat(id, ")"));
|
|
12623
12632
|
}
|
|
12624
12633
|
element.dataset.testId = id;
|
|
12625
|
-
element.style.overflow = 'hidden';
|
|
12626
12634
|
setMounted(true);
|
|
12627
12635
|
container.current = element;
|
|
12628
12636
|
}, [id]);
|
|
12637
|
+
useEffect(function () {
|
|
12638
|
+
if (!mounted) {
|
|
12639
|
+
return;
|
|
12640
|
+
}
|
|
12641
|
+
container.current.style.overflow = overflow ? 'visible' : 'hidden';
|
|
12642
|
+
for (var key in style) {
|
|
12643
|
+
// @ts-ignore
|
|
12644
|
+
container.current.style[key] = style[key];
|
|
12645
|
+
}
|
|
12646
|
+
}, [style, overflow, mounted]);
|
|
12629
12647
|
useEffect(function () {
|
|
12630
12648
|
if (mounted) {
|
|
12631
12649
|
container.current.className = className !== null && className !== void 0 ? className : '';
|
|
@@ -16691,9 +16709,12 @@ var Filters = function (_a) {
|
|
|
16691
16709
|
var handleCheckboxClick = useCallback(function (_a) {
|
|
16692
16710
|
var sectionIndex = _a.sectionIndex, itemIndex = _a.itemIndex, checked = _a.checked;
|
|
16693
16711
|
setFilterSection({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: checked });
|
|
16712
|
+
var currentFilter = filters[sectionIndex];
|
|
16694
16713
|
setCheckedItems(function (prev) {
|
|
16714
|
+
if (!currentFilter.isMultiselect)
|
|
16715
|
+
resetCheckedItems(__spreadArray([], prev, true));
|
|
16695
16716
|
return checked
|
|
16696
|
-
? __spreadArray(__spreadArray([], prev, true), [
|
|
16717
|
+
? __spreadArray(__spreadArray([], (currentFilter.isMultiselect ? prev : []), true), [
|
|
16697
16718
|
{ sectionIndex: sectionIndex, itemIndex: itemIndex, label: filters[sectionIndex].items[itemIndex].label },
|
|
16698
16719
|
], false) : prev.filter(function (item) { return item.sectionIndex !== sectionIndex || item.itemIndex !== itemIndex; });
|
|
16699
16720
|
});
|
|
@@ -16704,7 +16725,7 @@ var Filters = function (_a) {
|
|
|
16704
16725
|
return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value, indexItems) {
|
|
16705
16726
|
return {
|
|
16706
16727
|
label: value.label,
|
|
16707
|
-
checked: itemIndex === indexItems ? checked : value.checked,
|
|
16728
|
+
checked: itemIndex === indexItems ? checked : filter.isMultiselect ? value.checked : false,
|
|
16708
16729
|
};
|
|
16709
16730
|
}) });
|
|
16710
16731
|
});
|
|
@@ -16716,11 +16737,15 @@ var Filters = function (_a) {
|
|
|
16716
16737
|
var element = document.getElementById("filter[".concat(sectionIndex, ",").concat(itemIndex, "]"));
|
|
16717
16738
|
simulateMouseClick(element);
|
|
16718
16739
|
};
|
|
16719
|
-
var
|
|
16720
|
-
|
|
16740
|
+
var resetCheckedItems = function (items) {
|
|
16741
|
+
items.forEach(function (item) {
|
|
16721
16742
|
var sectionIndex = item.sectionIndex, itemIndex = item.itemIndex;
|
|
16722
16743
|
handleCloseClick({ sectionIndex: sectionIndex, itemIndex: itemIndex });
|
|
16723
16744
|
});
|
|
16745
|
+
};
|
|
16746
|
+
var handleClearAllClick = function () {
|
|
16747
|
+
resetCheckedItems(checkedItems);
|
|
16748
|
+
setCheckedItems([]);
|
|
16724
16749
|
setFilter(function (prev) {
|
|
16725
16750
|
return prev.map(function (filter) {
|
|
16726
16751
|
return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value) {
|
|
@@ -16733,18 +16758,14 @@ var Filters = function (_a) {
|
|
|
16733
16758
|
});
|
|
16734
16759
|
onResetValues();
|
|
16735
16760
|
};
|
|
16736
|
-
return (jsxs$1(Fragment$1, { children: [!isMobile ? (jsxs$1("div", __assign$1({ "data-testid": "DesktopHeader" }, { children: [jsxs$1(Header, { children: [jsxs$1(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filterByText, " (", checkedItems.length, ")"] }), void 0), jsx$1(ClearAll, __assign$1({ onClick: handleClearAllClick, color: theme.colors.shades['700'].color, "data-testid": "desktop-clear-all" }, { children: clearAllText }), void 0)] }, void 0), jsx$1(Tags, { color: tagsColor, items: checkedItems.map(function (item) { return item.label; }), onCloseClick: function (index) { return handleCloseClick(checkedItems[index]); } }, void 0)] }), void 0)) : (jsxs$1(MobileHeader, __assign$1({ "data-testid": "MobileHeader" }, { children: [jsx$1(MobileIconsContainer, __assign$1({ onClick: mobileBackArrowClick, "data-testid": "mobileBackArrow" }, { children: jsx$1(Icon.Arrows.ChevronRightVariant, { fill: theme.colors.shades['700'].color }, void 0) }), void 0), jsxs$1(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filtersSelectText, " (", checkedItems.length, ")"] }), void 0)] }), void 0)), filters.map(function (filter, sectionIndex) { return (jsx$1(Accordion, __assign$1({ title: filter.title, isOpenByDefault: filter.isOpenByDefault }, { children: jsx$1(SectionContent, __assign$1({ cols: filter.columns }, { children: filter.items.map(function (item, itemIndex) { return (jsx$1(FilterCheckbox, { onChange: handleCheckboxClick, text: item.label, checked: item.checked, itemIndex: itemIndex, sectionIndex: sectionIndex },
|
|
16761
|
+
return (jsxs$1(Fragment$1, { children: [!isMobile ? (jsxs$1("div", __assign$1({ "data-testid": "DesktopHeader" }, { children: [jsxs$1(Header, { children: [jsxs$1(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filterByText, " (", checkedItems.length, ")"] }), void 0), jsx$1(ClearAll, __assign$1({ onClick: handleClearAllClick, color: theme.colors.shades['700'].color, "data-testid": "desktop-clear-all" }, { children: clearAllText }), void 0)] }, void 0), jsx$1(Tags, { color: tagsColor, items: checkedItems.map(function (item) { return item.label; }), onCloseClick: function (index) { return handleCloseClick(checkedItems[index]); } }, void 0)] }), void 0)) : (jsxs$1(MobileHeader, __assign$1({ "data-testid": "MobileHeader" }, { children: [jsx$1(MobileIconsContainer, __assign$1({ onClick: mobileBackArrowClick, "data-testid": "mobileBackArrow" }, { children: jsx$1(Icon.Arrows.ChevronRightVariant, { fill: theme.colors.shades['700'].color }, void 0) }), void 0), jsxs$1(H4, __assign$1({ color: theme.colors.shades['700'].color }, { children: [filtersSelectText, " (", checkedItems.length, ")"] }), void 0)] }), void 0)), filters.map(function (filter, sectionIndex) { return (jsx$1(Accordion, __assign$1({ title: filter.title, isOpenByDefault: filter.isOpenByDefault }, { children: jsx$1(SectionContent, __assign$1({ cols: filter.columns }, { children: filter.items.map(function (item, itemIndex) { return (jsx$1(FilterCheckbox, { onChange: handleCheckboxClick, text: item.label, checked: item.checked, itemIndex: itemIndex, sectionIndex: sectionIndex }, "".concat(item.checked, "-").concat(item.label))); }) }), void 0) }), sectionIndex)); }), isMobile && (jsxs$1(MobileFooter, __assign$1({ "data-testid": "MobileFooter" }, { children: [jsxs$1(MobileClearContainer, __assign$1({ onClick: handleClearAllClick }, { children: [jsx$1(MobileIconsContainer, { children: jsx$1(Icon.Actions.Trash, { fill: theme.colors.shades['700'].color }, void 0) }, void 0), jsx$1(ClearAll, __assign$1({ color: theme.colors.shades['700'].color }, { children: clearAllText }), void 0)] }), void 0), jsx$1(ButtonSecondary, { text: applyText, onClick: mobileApplyButtonClick }, void 0)] }), void 0))] }, void 0));
|
|
16737
16762
|
};
|
|
16738
16763
|
var FilterCheckbox = function (_a) {
|
|
16739
16764
|
var sectionIndex = _a.sectionIndex, text = _a.text, itemIndex = _a.itemIndex, onChangeProp = _a.onChange, checked = _a.checked;
|
|
16740
|
-
var _b = React__default.useState(checked), defaultChecked = _b[0], setDefaultChecked = _b[1];
|
|
16741
16765
|
var onChange = useCallback(function (checked) {
|
|
16742
|
-
|
|
16743
|
-
}, []);
|
|
16744
|
-
|
|
16745
|
-
onChangeProp({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: defaultChecked });
|
|
16746
|
-
}, [sectionIndex, itemIndex, onChangeProp, defaultChecked]);
|
|
16747
|
-
return (jsx$1(Checkbox, { onChange: onChange, checked: defaultChecked, text: text, id: "filter[".concat(sectionIndex, ",").concat(itemIndex, "]"), size: ComponentSize.Small, variant: "secondary" }, itemIndex));
|
|
16766
|
+
onChangeProp({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: checked });
|
|
16767
|
+
}, [sectionIndex, itemIndex, onChangeProp]);
|
|
16768
|
+
return (jsx$1(Checkbox, { onChange: onChange, checked: checked, text: text, id: "filter[".concat(sectionIndex, ",").concat(itemIndex, "]"), size: ComponentSize.Small, variant: "secondary" }, itemIndex));
|
|
16748
16769
|
};
|
|
16749
16770
|
|
|
16750
16771
|
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"])));
|