@trafilea/afrodita-components 5.0.0-beta.19 → 5.0.0-beta.21
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 +9 -5
- package/build/index.esm.js +50 -11
- package/build/index.esm.js.map +1 -1
- package/build/index.js +50 -11
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -10642,8 +10642,11 @@ var Container$8 = newStyled.div({
|
|
|
10642
10642
|
display: 'flex',
|
|
10643
10643
|
});
|
|
10644
10644
|
var SearchBar = function (_a) {
|
|
10645
|
-
var suggestions = _a.suggestions, resultOptions = _a.resultOptions, onChange = _a.onChange, onSearch = _a.onSearch, resultsPanelDataTestId = _a.resultsPanelDataTestId, allResults = _a.allResults;
|
|
10645
|
+
var suggestions = _a.suggestions, resultOptions = _a.resultOptions, onChange = _a.onChange, onSearch = _a.onSearch, resultsPanelDataTestId = _a.resultsPanelDataTestId, allResults = _a.allResults, initialTerm = _a.initialTerm;
|
|
10646
10646
|
var theme = useTheme();
|
|
10647
|
+
if (initialTerm) {
|
|
10648
|
+
initialState$1.term = initialTerm;
|
|
10649
|
+
}
|
|
10647
10650
|
var _b = React$2.useReducer(reducer, initialState$1), state = _b[0], dispatch = _b[1];
|
|
10648
10651
|
var ref = React$2.useRef(null);
|
|
10649
10652
|
var shouldDisplaySuggestion = function () {
|
|
@@ -15079,17 +15082,39 @@ var MobileClearContainer = newStyled.div(templateObject_8 || (templateObject_8 =
|
|
|
15079
15082
|
var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4$1, templateObject_5$1, templateObject_6, templateObject_7, templateObject_8;
|
|
15080
15083
|
|
|
15081
15084
|
var Filters = function (_a) {
|
|
15082
|
-
var
|
|
15085
|
+
var values = _a.values, onChange = _a.onChange, _b = _a.tagsColor, tagsColor = _b === void 0 ? '#fff6ef' : _b, filterByText = _a.filterByText, clearAllText = _a.clearAllText, isMobile = _a.isMobile, filtersSelectText = _a.filtersSelectText, applyText = _a.applyText, mobileApplyButtonClick = _a.mobileApplyButtonClick, mobileBackArrowClick = _a.mobileBackArrowClick, onResetValues = _a.onResetValues;
|
|
15083
15086
|
var theme = useTheme();
|
|
15084
|
-
var _c =
|
|
15087
|
+
var _c = React$2.useState(values), filters = _c[0], setFilter = _c[1];
|
|
15088
|
+
var _d = React$2.useState([]), checkedItems = _d[0], setCheckedItems = _d[1];
|
|
15089
|
+
var _e = React$2.useState(), filterState = _e[0], setFilterSection = _e[1];
|
|
15090
|
+
React$2.useEffect(function () {
|
|
15091
|
+
if (filters.length && filterState) {
|
|
15092
|
+
onChange(filters, filterState);
|
|
15093
|
+
}
|
|
15094
|
+
}, [filterState, filters, onChange]);
|
|
15085
15095
|
var handleCheckboxClick = React$2.useCallback(function (_a) {
|
|
15086
15096
|
var sectionIndex = _a.sectionIndex, itemIndex = _a.itemIndex, checked = _a.checked;
|
|
15087
|
-
|
|
15097
|
+
setFilterSection({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: checked });
|
|
15088
15098
|
setCheckedItems(function (prev) {
|
|
15089
15099
|
return checked
|
|
15090
|
-
? __spreadArray(__spreadArray([], prev, true), [
|
|
15100
|
+
? __spreadArray(__spreadArray([], prev, true), [
|
|
15101
|
+
{ sectionIndex: sectionIndex, itemIndex: itemIndex, label: filters[sectionIndex].items[itemIndex].label },
|
|
15102
|
+
], false) : prev.filter(function (item) { return item.sectionIndex !== sectionIndex || item.itemIndex !== itemIndex; });
|
|
15103
|
+
});
|
|
15104
|
+
setFilter(function (prev) {
|
|
15105
|
+
return prev.map(function (filter, indexSection) {
|
|
15106
|
+
if (sectionIndex !== indexSection)
|
|
15107
|
+
return filter;
|
|
15108
|
+
return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value, indexItems) {
|
|
15109
|
+
return {
|
|
15110
|
+
label: value.label,
|
|
15111
|
+
checked: itemIndex === indexItems ? checked : value.checked,
|
|
15112
|
+
};
|
|
15113
|
+
}) });
|
|
15114
|
+
});
|
|
15091
15115
|
});
|
|
15092
|
-
|
|
15116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15117
|
+
}, []);
|
|
15093
15118
|
var handleCloseClick = function (_a) {
|
|
15094
15119
|
var sectionIndex = _a.sectionIndex, itemIndex = _a.itemIndex;
|
|
15095
15120
|
var element = document.getElementById("filter[".concat(sectionIndex, ",").concat(itemIndex, "]"));
|
|
@@ -15100,16 +15125,30 @@ var Filters = function (_a) {
|
|
|
15100
15125
|
var sectionIndex = item.sectionIndex, itemIndex = item.itemIndex;
|
|
15101
15126
|
handleCloseClick({ sectionIndex: sectionIndex, itemIndex: itemIndex });
|
|
15102
15127
|
});
|
|
15128
|
+
setFilter(function (prev) {
|
|
15129
|
+
return prev.map(function (filter) {
|
|
15130
|
+
return __assign$1(__assign$1({}, filter), { items: filter.items.map(function (value) {
|
|
15131
|
+
return {
|
|
15132
|
+
label: value.label,
|
|
15133
|
+
checked: false,
|
|
15134
|
+
};
|
|
15135
|
+
}) });
|
|
15136
|
+
});
|
|
15137
|
+
});
|
|
15103
15138
|
onResetValues();
|
|
15104
15139
|
};
|
|
15105
|
-
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, 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));
|
|
15140
|
+
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));
|
|
15106
15141
|
};
|
|
15107
15142
|
var FilterCheckbox = function (_a) {
|
|
15108
|
-
var sectionIndex = _a.sectionIndex, text = _a.text, itemIndex = _a.itemIndex, onChangeProp = _a.onChange;
|
|
15143
|
+
var sectionIndex = _a.sectionIndex, text = _a.text, itemIndex = _a.itemIndex, onChangeProp = _a.onChange, checked = _a.checked;
|
|
15144
|
+
var _b = React__default["default"].useState(checked), defaultChecked = _b[0], setDefaultChecked = _b[1];
|
|
15109
15145
|
var onChange = React$2.useCallback(function (checked) {
|
|
15110
|
-
|
|
15111
|
-
}, [
|
|
15112
|
-
|
|
15146
|
+
setDefaultChecked(checked);
|
|
15147
|
+
}, []);
|
|
15148
|
+
React__default["default"].useEffect(function () {
|
|
15149
|
+
onChangeProp({ sectionIndex: sectionIndex, itemIndex: itemIndex, checked: defaultChecked });
|
|
15150
|
+
}, [sectionIndex, itemIndex, onChangeProp, defaultChecked]);
|
|
15151
|
+
return (jsxRuntime.jsx(Checkbox, { onChange: onChange, checked: defaultChecked, text: text, id: "filter[".concat(sectionIndex, ",").concat(itemIndex, "]"), size: exports.ComponentSize.Small, variant: "secondary" }, itemIndex));
|
|
15113
15152
|
};
|
|
15114
15153
|
|
|
15115
15154
|
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"])));
|