@envive-ai/react-toolkit 0.2.2 → 0.2.3
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/dist/Accordion/index.cjs +4 -0
- package/dist/Accordion/index.d.cts +13 -0
- package/dist/Accordion/index.d.ts +13 -0
- package/dist/Accordion/index.js +4 -0
- package/dist/Accordion-DxtXK__u.js +77 -0
- package/dist/Accordion-RpyCFs2a.cjs +88 -0
- package/dist/AnimatedChevron/index.cjs +3 -0
- package/dist/AnimatedChevron/index.d.cts +14 -0
- package/dist/AnimatedChevron/index.d.ts +14 -0
- package/dist/AnimatedChevron/index.js +3 -0
- package/dist/AnimatedChevron-Bik7GMSe.js +29 -0
- package/dist/AnimatedChevron-Q96FneFy.cjs +37 -0
- package/dist/AppliedFiltersScrollbar/index.cjs +46 -0
- package/dist/AppliedFiltersScrollbar/index.d.cts +22 -0
- package/dist/AppliedFiltersScrollbar/index.d.ts +22 -0
- package/dist/AppliedFiltersScrollbar/index.js +42 -0
- package/dist/ButtonBase/index.cjs +6 -0
- package/dist/ButtonBase/index.d.cts +42 -0
- package/dist/ButtonBase/index.d.ts +42 -0
- package/dist/ButtonBase/index.js +5 -0
- package/dist/ButtonBase-6wjsZ1tU.js +60 -0
- package/dist/ButtonBase-AU23oGQr.cjs +75 -0
- package/dist/ButtonBase-C_uKnl48.js +1 -0
- package/dist/ButtonBase-DbWQ25n-.cjs +0 -0
- package/dist/DynamicFiltersScrollbar/index.cjs +34 -0
- package/dist/DynamicFiltersScrollbar/index.d.cts +28 -0
- package/dist/DynamicFiltersScrollbar/index.d.ts +28 -0
- package/dist/DynamicFiltersScrollbar/index.js +30 -0
- package/dist/DynamicFiltersScrollbar-50i_InZz.cjs +81 -0
- package/dist/DynamicFiltersScrollbar-AhyHehrB.js +66 -0
- package/dist/FilterScrollbar/index.cjs +5 -0
- package/dist/FilterScrollbar/index.d.cts +47 -0
- package/dist/FilterScrollbar/index.d.ts +47 -0
- package/dist/FilterScrollbar/index.js +4 -0
- package/dist/ImageWithFallback/index.cjs +3 -0
- package/dist/ImageWithFallback/index.d.cts +26 -0
- package/dist/ImageWithFallback/index.d.ts +26 -0
- package/dist/ImageWithFallback/index.js +3 -0
- package/dist/ImageWithFallback-1LqhQK1q.cjs +51 -0
- package/dist/ImageWithFallback-Ckwsmd8P.js +42 -0
- package/dist/ModalSheet/index.cjs +4 -0
- package/dist/ModalSheet/index.d.cts +38 -0
- package/dist/ModalSheet/index.d.ts +38 -0
- package/dist/ModalSheet/index.js +4 -0
- package/dist/ModalSheet-BSj_g9JF.js +302 -0
- package/dist/ModalSheet-CcthFeMD.cjs +313 -0
- package/dist/ProductCard/index.cjs +15 -0
- package/dist/ProductCard/index.d.cts +2 -0
- package/dist/ProductCard/index.d.ts +2 -0
- package/dist/ProductCard/index.js +6 -0
- package/dist/ProductCard-2aPkjS8z.js +254 -0
- package/dist/ProductCard-D1F9A8Rw.cjs +318 -0
- package/dist/ProductGrid/index.cjs +8 -0
- package/dist/ProductGrid/index.d.cts +33 -0
- package/dist/ProductGrid/index.d.ts +33 -0
- package/dist/ProductGrid/index.js +7 -0
- package/dist/ProductGrid-Dcy7JxVN.cjs +74 -0
- package/dist/ProductGrid-NtuMrOtp.js +60 -0
- package/dist/RadioButton/index.cjs +4 -0
- package/dist/RadioButton/index.d.cts +32 -0
- package/dist/RadioButton/index.d.ts +32 -0
- package/dist/RadioButton/index.js +4 -0
- package/dist/RadioButton-C_soBi7w.js +75 -0
- package/dist/RadioButton-DG0PgZbz.cjs +84 -0
- package/dist/RadioButtonGroup/index.cjs +6 -0
- package/dist/RadioButtonGroup/index.d.cts +36 -0
- package/dist/RadioButtonGroup/index.d.ts +36 -0
- package/dist/RadioButtonGroup/index.js +5 -0
- package/dist/RadioButtonGroup-3t2kqSFA.cjs +52 -0
- package/dist/RadioButtonGroup-DMbVgPQH.js +38 -0
- package/dist/SearchAutocomplete/index.cjs +3 -0
- package/dist/SearchAutocomplete/index.d.cts +13 -0
- package/dist/SearchAutocomplete/index.d.ts +13 -0
- package/dist/SearchAutocomplete/index.js +3 -0
- package/dist/SearchAutocomplete-TX8UTczp.cjs +62 -0
- package/dist/SearchAutocomplete-obO19yzL.js +51 -0
- package/dist/SearchFilter/index.cjs +17 -0
- package/dist/SearchFilter/index.d.cts +91 -0
- package/dist/SearchFilter/index.d.ts +91 -0
- package/dist/SearchFilter/index.js +12 -0
- package/dist/SearchFilter-BQW4o3Xf.js +268 -0
- package/dist/SearchFilter-t9or-lnj.cjs +307 -0
- package/dist/SearchInput/index.cjs +8 -0
- package/dist/SearchInput/index.d.cts +34 -0
- package/dist/SearchInput/index.d.ts +34 -0
- package/dist/SearchInput/index.js +7 -0
- package/dist/SearchInput-BaiWd0_O.js +108 -0
- package/dist/SearchInput-CO1poiit.cjs +124 -0
- package/dist/SearchInputForm/index.cjs +40 -0
- package/dist/SearchInputForm/index.d.cts +34 -0
- package/dist/SearchInputForm/index.d.ts +34 -0
- package/dist/SearchInputForm/index.js +38 -0
- package/dist/SearchResultsContent/index.cjs +44 -0
- package/dist/SearchResultsContent/index.d.cts +48 -0
- package/dist/SearchResultsContent/index.d.ts +48 -0
- package/dist/SearchResultsContent/index.js +41 -0
- package/dist/SearchResultsFilterSidebar/index.cjs +59 -0
- package/dist/SearchResultsFilterSidebar/index.d.cts +2 -0
- package/dist/SearchResultsFilterSidebar/index.d.ts +2 -0
- package/dist/SearchResultsFilterSidebar/index.js +55 -0
- package/dist/SearchResultsStates/index.cjs +14 -0
- package/dist/SearchResultsStates/index.d.cts +69 -0
- package/dist/SearchResultsStates/index.d.ts +69 -0
- package/dist/SearchResultsStates/index.js +12 -0
- package/dist/SearchResultsStates-CalOf6QP.js +110 -0
- package/dist/SearchResultsStates-DQlstrHd.cjs +132 -0
- package/dist/SettingsVariant-BsBbdjV5.cjs +63 -0
- package/dist/SettingsVariant-CUSFlJEu.js +55 -0
- package/dist/SparkleAnimation/index.cjs +4 -0
- package/dist/SparkleAnimation/index.d.cts +23 -0
- package/dist/SparkleAnimation/index.d.ts +23 -0
- package/dist/SparkleAnimation/index.js +3 -0
- package/dist/SparkleAnimation-Bm3fk2FJ.cjs +101 -0
- package/dist/SparkleAnimation-D1QjYho_.js +84 -0
- package/dist/Spinner/index.cjs +3 -0
- package/dist/Spinner/index.d.cts +11 -0
- package/dist/Spinner/index.d.ts +11 -0
- package/dist/Spinner/index.js +3 -0
- package/dist/Spinner-B1IEMa00.cjs +46 -0
- package/dist/Spinner-BrHoB-Zg.js +38 -0
- package/dist/SuggestionButton/index.cjs +187 -0
- package/dist/SuggestionButton/index.d.cts +35 -0
- package/dist/SuggestionButton/index.d.ts +35 -0
- package/dist/SuggestionButton/index.js +179 -0
- package/dist/TextInput/index.cjs +4 -0
- package/dist/TextInput/index.d.cts +13 -0
- package/dist/TextInput/index.d.ts +13 -0
- package/dist/TextInput/index.js +4 -0
- package/dist/TextInput-B_4Bu2vf.js +31 -0
- package/dist/TextInput-iAKCKHwT.cjs +40 -0
- package/dist/ToggleButton/index.cjs +4 -0
- package/dist/ToggleButton/index.d.cts +30 -0
- package/dist/ToggleButton/index.d.ts +30 -0
- package/dist/ToggleButton/index.js +4 -0
- package/dist/ToggleButton-Br6MgjiG.js +60 -0
- package/dist/ToggleButton-CJ74eu-N.cjs +68 -0
- package/dist/Typography/index.cjs +6 -0
- package/dist/Typography/index.d.cts +3 -0
- package/dist/Typography/index.d.ts +3 -0
- package/dist/Typography/index.js +3 -0
- package/dist/Typography-CFNWgbM5.cjs +176 -0
- package/dist/Typography-D3vDkBMS.js +150 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/colorsConfig-D-MZuBvt.cjs +38 -0
- package/dist/colorsConfig-DEfiLHH0.js +26 -0
- package/dist/index-B-5pBFE7.d.cts +46 -0
- package/dist/index-BH-QK27q.d.ts +31 -0
- package/dist/index-BMHF0IWd.d.cts +31 -0
- package/dist/index-BcvJf9Sr.d.ts +46 -0
- package/dist/index-BzY_al-V.d.ts +325 -0
- package/dist/index-cx3r6TgQ.d.cts +325 -0
- package/dist/searchFilterSidebarVariants-BD4SYugF.js +34 -0
- package/dist/searchFilterSidebarVariants-DXabOauB.cjs +39 -0
- package/dist/types-BhGjnuWx.d.cts +4 -0
- package/dist/types-CGRog8XL.d.ts +4 -0
- package/dist/typographyVariantClasses-COmQXqcN.d.ts +119 -0
- package/dist/typographyVariantClasses-DTSltxPN.d.cts +119 -0
- package/package.json +3 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { motion } from "framer-motion";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import OutlinedStar from "@envive-ai/react-icons/OutlinedStar";
|
|
6
|
+
|
|
7
|
+
//#region src/components/SearchAutocomplete/SearchAutocomplete.tsx
|
|
8
|
+
const SearchAutocomplete = ({ id, results, focusedIndex, onSuggestionSelect, iconColor }) => {
|
|
9
|
+
if (results.length === 0) return null;
|
|
10
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
11
|
+
className: "spiffy-tw-h-full",
|
|
12
|
+
initial: {
|
|
13
|
+
opacity: 0,
|
|
14
|
+
y: -10
|
|
15
|
+
},
|
|
16
|
+
animate: {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
y: 0
|
|
19
|
+
},
|
|
20
|
+
exit: {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
y: -10
|
|
23
|
+
},
|
|
24
|
+
transition: { duration: .2 },
|
|
25
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
26
|
+
id,
|
|
27
|
+
role: "listbox",
|
|
28
|
+
className: "spiffy-tw-mt-4 spiffy-tw-space-y-2",
|
|
29
|
+
children: results.map((result, index) => /* @__PURE__ */ jsxs("li", {
|
|
30
|
+
id: `option-${index}`,
|
|
31
|
+
role: "option",
|
|
32
|
+
"aria-selected": index === focusedIndex,
|
|
33
|
+
className: classNames("spiffy-tw-flex spiffy-tw-items-center spiffy-tw-cursor-pointer spiffy-tw-py-1", { "spiffy-tw-bg-neutral-200": index === focusedIndex }, "hover:spiffy-tw-bg-neutral-100"),
|
|
34
|
+
onClick: () => onSuggestionSelect(result, index),
|
|
35
|
+
onKeyDown: (event) => {
|
|
36
|
+
if (event.key === "Enter" || event.keyCode === 13) onSuggestionSelect(result, index);
|
|
37
|
+
},
|
|
38
|
+
children: [/* @__PURE__ */ jsx(OutlinedStar, {
|
|
39
|
+
className: "spiffy-tw-w-[16px] spiffy-tw-h-[16px] spiffy-tw-mr-2",
|
|
40
|
+
fill: iconColor
|
|
41
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
42
|
+
className: "spiffy-tw-font-bold",
|
|
43
|
+
children: result
|
|
44
|
+
})]
|
|
45
|
+
}, index))
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { SearchAutocomplete };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require('../Typography-CFNWgbM5.cjs');
|
|
2
|
+
require('../Accordion-RpyCFs2a.cjs');
|
|
3
|
+
require('../AnimatedChevron-Q96FneFy.cjs');
|
|
4
|
+
require('../ButtonBase-AU23oGQr.cjs');
|
|
5
|
+
require('../ButtonBase-DbWQ25n-.cjs');
|
|
6
|
+
require('../ModalSheet-CcthFeMD.cjs');
|
|
7
|
+
require('../RadioButton-DG0PgZbz.cjs');
|
|
8
|
+
require('../RadioButtonGroup-3t2kqSFA.cjs');
|
|
9
|
+
const require_SearchFilter = require('../SearchFilter-t9or-lnj.cjs');
|
|
10
|
+
require('../ToggleButton-CJ74eu-N.cjs');
|
|
11
|
+
|
|
12
|
+
exports.SearchFilter = require_SearchFilter.SearchFilter;
|
|
13
|
+
exports.SearchFilterFooter = require_SearchFilter.SearchFilterFooter;
|
|
14
|
+
exports.SearchFilterHeader = require_SearchFilter.SearchFilterHeader;
|
|
15
|
+
exports.SearchFilterItem = require_SearchFilter.SearchFilterItem;
|
|
16
|
+
exports.getSelectedFilterItemsCount = require_SearchFilter.getSelectedFilterItemsCount;
|
|
17
|
+
exports.getTotalSelectedFilterItemsCount = require_SearchFilter.getTotalSelectedFilterItemsCount;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
2
|
+
import { CloseIconVariant, FilterFooterProps, SearchFilterDatum, SearchFilterItemDatum, SelectFilterItem } from "@envive-ai/react-hooks/types";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SearchFilter/types.d.ts
|
|
5
|
+
interface SearchFilterItem$1 extends SearchFilterItemDatum {
|
|
6
|
+
filterId: string;
|
|
7
|
+
filterItemId: string;
|
|
8
|
+
}
|
|
9
|
+
interface SearchFilterItemProps {
|
|
10
|
+
filterItem: SearchFilterItem$1;
|
|
11
|
+
onSelectFilterItem: SelectFilterItem;
|
|
12
|
+
radioButtonFillColor: string;
|
|
13
|
+
radioButtonHoverColor: string;
|
|
14
|
+
radioButtonUncheckedBorderColor: string;
|
|
15
|
+
}
|
|
16
|
+
interface SearchFilterHeaderProps {
|
|
17
|
+
closeModal: () => void;
|
|
18
|
+
productCount: number;
|
|
19
|
+
headerClassName: string;
|
|
20
|
+
filterCloseIconVariant: 'dark' | 'light' | 'tertiary';
|
|
21
|
+
}
|
|
22
|
+
type SearchFilterProps = {
|
|
23
|
+
filters: SearchFilterDatum[];
|
|
24
|
+
selectFilterItem: SelectFilterItem;
|
|
25
|
+
clearAllFilters: () => void;
|
|
26
|
+
productCount: number;
|
|
27
|
+
isOpen: boolean;
|
|
28
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
29
|
+
applyFiltersUnchangedClasses: string;
|
|
30
|
+
applyFiltersChangedClasses: string;
|
|
31
|
+
headerContent?: React.ReactNode;
|
|
32
|
+
footerContent?: React.ReactNode;
|
|
33
|
+
filterButtonText?: string;
|
|
34
|
+
headerClassName?: string;
|
|
35
|
+
radioButtonFillColor: string;
|
|
36
|
+
radioButtonHoverColor?: string;
|
|
37
|
+
radioButtonUncheckedBorderColor?: string;
|
|
38
|
+
filterCloseIconVariant: CloseIconVariant;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/SearchFilter/SearchFilter.d.ts
|
|
42
|
+
declare const SearchFilter: ({
|
|
43
|
+
filters,
|
|
44
|
+
productCount,
|
|
45
|
+
selectFilterItem,
|
|
46
|
+
clearAllFilters,
|
|
47
|
+
isOpen,
|
|
48
|
+
setIsOpen,
|
|
49
|
+
applyFiltersUnchangedClasses,
|
|
50
|
+
applyFiltersChangedClasses,
|
|
51
|
+
headerContent,
|
|
52
|
+
footerContent,
|
|
53
|
+
headerClassName,
|
|
54
|
+
radioButtonFillColor,
|
|
55
|
+
radioButtonHoverColor,
|
|
56
|
+
radioButtonUncheckedBorderColor,
|
|
57
|
+
filterCloseIconVariant
|
|
58
|
+
}: SearchFilterProps) => react_jsx_runtime10.JSX.Element;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/SearchFilter/SearchFilterHeader.d.ts
|
|
61
|
+
declare const SearchFilterHeader: ({
|
|
62
|
+
closeModal,
|
|
63
|
+
productCount,
|
|
64
|
+
headerClassName,
|
|
65
|
+
filterCloseIconVariant
|
|
66
|
+
}: SearchFilterHeaderProps) => react_jsx_runtime10.JSX.Element;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/components/SearchFilter/SearchFilterFooter.d.ts
|
|
69
|
+
declare const SearchFilterFooter: ({
|
|
70
|
+
closeModal,
|
|
71
|
+
clearAllFilters,
|
|
72
|
+
filterCount,
|
|
73
|
+
applyFiltersUnchangedClasses,
|
|
74
|
+
applyFiltersChangedClasses,
|
|
75
|
+
hasFiltersChanged
|
|
76
|
+
}: FilterFooterProps) => react_jsx_runtime10.JSX.Element;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/components/SearchFilter/SearchFilterItem.d.ts
|
|
79
|
+
declare const SearchFilterItem: ({
|
|
80
|
+
filterItem,
|
|
81
|
+
onSelectFilterItem,
|
|
82
|
+
radioButtonFillColor,
|
|
83
|
+
radioButtonHoverColor,
|
|
84
|
+
radioButtonUncheckedBorderColor
|
|
85
|
+
}: SearchFilterItemProps) => react_jsx_runtime10.JSX.Element;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/components/SearchFilter/utils.d.ts
|
|
88
|
+
declare const getSelectedFilterItemsCount: (filter: SearchFilterDatum) => number;
|
|
89
|
+
declare const getTotalSelectedFilterItemsCount: (filters: SearchFilterDatum[]) => number;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { SearchFilter, SearchFilterFooter, SearchFilterHeader, SearchFilterItem, getSelectedFilterItemsCount, getTotalSelectedFilterItemsCount };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
2
|
+
import { CloseIconVariant, FilterFooterProps, SearchFilterDatum, SearchFilterItemDatum, SelectFilterItem } from "@envive-ai/react-hooks/types";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SearchFilter/types.d.ts
|
|
5
|
+
interface SearchFilterItem$1 extends SearchFilterItemDatum {
|
|
6
|
+
filterId: string;
|
|
7
|
+
filterItemId: string;
|
|
8
|
+
}
|
|
9
|
+
interface SearchFilterItemProps {
|
|
10
|
+
filterItem: SearchFilterItem$1;
|
|
11
|
+
onSelectFilterItem: SelectFilterItem;
|
|
12
|
+
radioButtonFillColor: string;
|
|
13
|
+
radioButtonHoverColor: string;
|
|
14
|
+
radioButtonUncheckedBorderColor: string;
|
|
15
|
+
}
|
|
16
|
+
interface SearchFilterHeaderProps {
|
|
17
|
+
closeModal: () => void;
|
|
18
|
+
productCount: number;
|
|
19
|
+
headerClassName: string;
|
|
20
|
+
filterCloseIconVariant: 'dark' | 'light' | 'tertiary';
|
|
21
|
+
}
|
|
22
|
+
type SearchFilterProps = {
|
|
23
|
+
filters: SearchFilterDatum[];
|
|
24
|
+
selectFilterItem: SelectFilterItem;
|
|
25
|
+
clearAllFilters: () => void;
|
|
26
|
+
productCount: number;
|
|
27
|
+
isOpen: boolean;
|
|
28
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
29
|
+
applyFiltersUnchangedClasses: string;
|
|
30
|
+
applyFiltersChangedClasses: string;
|
|
31
|
+
headerContent?: React.ReactNode;
|
|
32
|
+
footerContent?: React.ReactNode;
|
|
33
|
+
filterButtonText?: string;
|
|
34
|
+
headerClassName?: string;
|
|
35
|
+
radioButtonFillColor: string;
|
|
36
|
+
radioButtonHoverColor?: string;
|
|
37
|
+
radioButtonUncheckedBorderColor?: string;
|
|
38
|
+
filterCloseIconVariant: CloseIconVariant;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/SearchFilter/SearchFilter.d.ts
|
|
42
|
+
declare const SearchFilter: ({
|
|
43
|
+
filters,
|
|
44
|
+
productCount,
|
|
45
|
+
selectFilterItem,
|
|
46
|
+
clearAllFilters,
|
|
47
|
+
isOpen,
|
|
48
|
+
setIsOpen,
|
|
49
|
+
applyFiltersUnchangedClasses,
|
|
50
|
+
applyFiltersChangedClasses,
|
|
51
|
+
headerContent,
|
|
52
|
+
footerContent,
|
|
53
|
+
headerClassName,
|
|
54
|
+
radioButtonFillColor,
|
|
55
|
+
radioButtonHoverColor,
|
|
56
|
+
radioButtonUncheckedBorderColor,
|
|
57
|
+
filterCloseIconVariant
|
|
58
|
+
}: SearchFilterProps) => react_jsx_runtime11.JSX.Element;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/SearchFilter/SearchFilterHeader.d.ts
|
|
61
|
+
declare const SearchFilterHeader: ({
|
|
62
|
+
closeModal,
|
|
63
|
+
productCount,
|
|
64
|
+
headerClassName,
|
|
65
|
+
filterCloseIconVariant
|
|
66
|
+
}: SearchFilterHeaderProps) => react_jsx_runtime11.JSX.Element;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/components/SearchFilter/SearchFilterFooter.d.ts
|
|
69
|
+
declare const SearchFilterFooter: ({
|
|
70
|
+
closeModal,
|
|
71
|
+
clearAllFilters,
|
|
72
|
+
filterCount,
|
|
73
|
+
applyFiltersUnchangedClasses,
|
|
74
|
+
applyFiltersChangedClasses,
|
|
75
|
+
hasFiltersChanged
|
|
76
|
+
}: FilterFooterProps) => react_jsx_runtime11.JSX.Element;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/components/SearchFilter/SearchFilterItem.d.ts
|
|
79
|
+
declare const SearchFilterItem: ({
|
|
80
|
+
filterItem,
|
|
81
|
+
onSelectFilterItem,
|
|
82
|
+
radioButtonFillColor,
|
|
83
|
+
radioButtonHoverColor,
|
|
84
|
+
radioButtonUncheckedBorderColor
|
|
85
|
+
}: SearchFilterItemProps) => react_jsx_runtime11.JSX.Element;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/components/SearchFilter/utils.d.ts
|
|
88
|
+
declare const getSelectedFilterItemsCount: (filter: SearchFilterDatum) => number;
|
|
89
|
+
declare const getTotalSelectedFilterItemsCount: (filters: SearchFilterDatum[]) => number;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { SearchFilter, SearchFilterFooter, SearchFilterHeader, SearchFilterItem, getSelectedFilterItemsCount, getTotalSelectedFilterItemsCount };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../Typography-D3vDkBMS.js";
|
|
2
|
+
import "../Accordion-DxtXK__u.js";
|
|
3
|
+
import "../AnimatedChevron-Bik7GMSe.js";
|
|
4
|
+
import "../ButtonBase-6wjsZ1tU.js";
|
|
5
|
+
import "../ButtonBase-C_uKnl48.js";
|
|
6
|
+
import "../ModalSheet-BSj_g9JF.js";
|
|
7
|
+
import "../RadioButton-C_soBi7w.js";
|
|
8
|
+
import "../RadioButtonGroup-DMbVgPQH.js";
|
|
9
|
+
import { SearchFilter, SearchFilterFooter, SearchFilterHeader, SearchFilterItem, getSelectedFilterItemsCount, getTotalSelectedFilterItemsCount } from "../SearchFilter-BQW4o3Xf.js";
|
|
10
|
+
import "../ToggleButton-Br6MgjiG.js";
|
|
11
|
+
|
|
12
|
+
export { SearchFilter, SearchFilterFooter, SearchFilterHeader, SearchFilterItem, getSelectedFilterItemsCount, getTotalSelectedFilterItemsCount };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { Typography } from "./Typography-D3vDkBMS.js";
|
|
2
|
+
import { Accordion } from "./Accordion-DxtXK__u.js";
|
|
3
|
+
import { ButtonBase } from "./ButtonBase-6wjsZ1tU.js";
|
|
4
|
+
import { ModalSheet } from "./ModalSheet-BSj_g9JF.js";
|
|
5
|
+
import { RadioButtonGroup } from "./RadioButtonGroup-DMbVgPQH.js";
|
|
6
|
+
import { ToggleButton } from "./ToggleButton-Br6MgjiG.js";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/components/SearchFilter/SearchFilterHeader.tsx
|
|
12
|
+
const SearchFilterHeader = ({ closeModal, productCount, headerClassName, filterCloseIconVariant }) => {
|
|
13
|
+
const closeIconColor = filterCloseIconVariant === "dark" ? "var(--spiffy-colors-text-primary)" : "var(--spiffy-colors-text-light)";
|
|
14
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
15
|
+
className: classNames("spiffy-tw-flex spiffy-tw-items-center spiffy-tw-justify-between spiffy-tw-px-4 spiffy-tw-py-3", headerClassName),
|
|
16
|
+
children: [/* @__PURE__ */ jsxs(Typography, {
|
|
17
|
+
variant: "body2",
|
|
18
|
+
className: "spiffy-tw-font-medium",
|
|
19
|
+
children: [
|
|
20
|
+
"Filters (",
|
|
21
|
+
productCount,
|
|
22
|
+
")"
|
|
23
|
+
]
|
|
24
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
25
|
+
onClick: closeModal,
|
|
26
|
+
className: "spiffy-tw-p-2",
|
|
27
|
+
type: "button",
|
|
28
|
+
"aria-label": "Open Filter Menu",
|
|
29
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
+
width: "14",
|
|
32
|
+
height: "14",
|
|
33
|
+
viewBox: "0 0 14 14",
|
|
34
|
+
fill: "none",
|
|
35
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
36
|
+
d: "M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976311 12.6834 -0.0976311 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976311 12.6834 -0.0976311 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z",
|
|
37
|
+
fill: closeIconColor
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/components/SearchFilter/useHasFilterStateChanged.tsx
|
|
46
|
+
const useHasFilterStateChanged = (filters, isOpen) => {
|
|
47
|
+
const [initialFilterStates, setInitialFilterStates] = useState({});
|
|
48
|
+
const currentFilterStates = useMemo(() => {
|
|
49
|
+
const states = {};
|
|
50
|
+
filters.forEach((filter) => {
|
|
51
|
+
filter.items.forEach((item) => {
|
|
52
|
+
states[`${filter.filterId}-${item.filterItemId}`] = item.isSelected;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return states;
|
|
56
|
+
}, [filters]);
|
|
57
|
+
const hasFiltersChanged = useMemo(() => {
|
|
58
|
+
if (Object.keys(initialFilterStates).length === 0) return false;
|
|
59
|
+
return Object.keys(currentFilterStates).some((key) => currentFilterStates[key] !== initialFilterStates[key]);
|
|
60
|
+
}, [currentFilterStates, initialFilterStates]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (isOpen) setInitialFilterStates(currentFilterStates);
|
|
63
|
+
}, [isOpen]);
|
|
64
|
+
return hasFiltersChanged;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/components/SearchFilter/utils.ts
|
|
69
|
+
const getSelectedFilterItemsCount = (filter) => filter.items.filter((item) => item.isSelected).length;
|
|
70
|
+
const getTotalSelectedFilterItemsCount = (filters) => filters.reduce((acc, filter) => {
|
|
71
|
+
if (filter.filterId === "sort") return acc;
|
|
72
|
+
return acc + getSelectedFilterItemsCount(filter);
|
|
73
|
+
}, 0);
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/components/SearchFilter/SearchFilterFooter.tsx
|
|
77
|
+
const SearchFilterFooter = ({ closeModal, clearAllFilters, filterCount, applyFiltersUnchangedClasses, applyFiltersChangedClasses, hasFiltersChanged }) => {
|
|
78
|
+
const clearAllButtonEnabled = filterCount > 0;
|
|
79
|
+
const footerWrapperClassName = classNames({
|
|
80
|
+
"spiffy-tw-flex": true,
|
|
81
|
+
"spiffy-tw-flex-col": true,
|
|
82
|
+
"spiffy-tw-items-center": true,
|
|
83
|
+
"spiffy-tw-justify-between": true,
|
|
84
|
+
"spiffy-tw-w-full": true,
|
|
85
|
+
"spiffy-tw-border-t": true,
|
|
86
|
+
"spiffy-tw-border-t-[--spiffy-colors-border-light]": true,
|
|
87
|
+
"spiffy-tw-p-[16px]": true,
|
|
88
|
+
"spiffy-tw-gap-[16px]": true
|
|
89
|
+
});
|
|
90
|
+
const applyFilterButtonClassName = classNames("spiffy-tw-flex spiffy-tw-flex-row spiffy-tw-justify-center spiffy-tw-rounded-[8px] spiffy-tw-w-full", hasFiltersChanged ? applyFiltersChangedClasses : applyFiltersUnchangedClasses);
|
|
91
|
+
const clearAllButtonClassName = classNames({
|
|
92
|
+
"spiffy-tw-flex": true,
|
|
93
|
+
"spiffy-tw-flex-row": true,
|
|
94
|
+
"spiffy-tw-justify-center": true,
|
|
95
|
+
"spiffy-tw-w-full": true,
|
|
96
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]": clearAllButtonEnabled,
|
|
97
|
+
"spiffy-tw-text-[--spiffy-colors-text-secondary]": !clearAllButtonEnabled
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: footerWrapperClassName,
|
|
101
|
+
children: [/* @__PURE__ */ jsx(ButtonBase, {
|
|
102
|
+
isDisabled: !hasFiltersChanged,
|
|
103
|
+
buttonClass: applyFilterButtonClassName,
|
|
104
|
+
text: "Apply Filters",
|
|
105
|
+
onClick: closeModal
|
|
106
|
+
}), /* @__PURE__ */ jsx(ButtonBase, {
|
|
107
|
+
isDisabled: !clearAllButtonEnabled,
|
|
108
|
+
buttonClass: clearAllButtonClassName,
|
|
109
|
+
text: "Clear All",
|
|
110
|
+
onClick: clearAllFilters
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/components/SearchFilter/SearchFilter.tsx
|
|
117
|
+
const SortFilter = ({ filter, selectFilterItem, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor }) => {
|
|
118
|
+
const filterTitle = filter.displayName;
|
|
119
|
+
const options = filter.items.map((item) => ({
|
|
120
|
+
label: item.displayName,
|
|
121
|
+
value: item.filterItemId,
|
|
122
|
+
isSelected: item.isSelected
|
|
123
|
+
}));
|
|
124
|
+
const content = /* @__PURE__ */ jsx(RadioButtonGroup, {
|
|
125
|
+
options,
|
|
126
|
+
name: filterTitle,
|
|
127
|
+
onChange: (value) => {
|
|
128
|
+
const selectedItem = filter.items.find((item) => item.filterItemId === value);
|
|
129
|
+
selectFilterItem({
|
|
130
|
+
filterId: filter.filterId,
|
|
131
|
+
filterItemId: value,
|
|
132
|
+
isSelected: true,
|
|
133
|
+
displayName: selectedItem?.displayName || value
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
gap: "large",
|
|
137
|
+
textButtonGap: "large",
|
|
138
|
+
value: filter.items.find((item) => item.isSelected)?.filterItemId,
|
|
139
|
+
fillColor: radioButtonFillColor,
|
|
140
|
+
hoverColor: radioButtonHoverColor,
|
|
141
|
+
uncheckedBorderColor: radioButtonUncheckedBorderColor
|
|
142
|
+
});
|
|
143
|
+
return /* @__PURE__ */ jsx(Accordion, {
|
|
144
|
+
title: filterTitle,
|
|
145
|
+
content
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const FilterItem = ({ filterId, filterItem, selectFilterItem }) => /* @__PURE__ */ jsx(ToggleButton, {
|
|
149
|
+
label: filterItem.displayName,
|
|
150
|
+
secondaryLabel: `(${filterItem.productCount})`,
|
|
151
|
+
isSelected: filterItem.isSelected,
|
|
152
|
+
onClick: () => selectFilterItem({
|
|
153
|
+
filterId,
|
|
154
|
+
filterItemId: filterItem.filterItemId,
|
|
155
|
+
isSelected: !filterItem.isSelected,
|
|
156
|
+
displayName: filterItem.displayName
|
|
157
|
+
}),
|
|
158
|
+
variant: "default"
|
|
159
|
+
});
|
|
160
|
+
const Filter = ({ filter, selectFilterItem }) => {
|
|
161
|
+
const filterContentClassName = classNames({
|
|
162
|
+
"spiffy-tw-flex": true,
|
|
163
|
+
"spiffy-tw-flex-wrap": true,
|
|
164
|
+
"spiffy-tw-gap-[8px]": true,
|
|
165
|
+
"spiffy-tw-pb-[1px]": true
|
|
166
|
+
});
|
|
167
|
+
const selectedFilterItems = getSelectedFilterItemsCount(filter);
|
|
168
|
+
const filterTitle = selectedFilterItems > 0 ? `${filter.displayName} (${selectedFilterItems})` : filter.displayName;
|
|
169
|
+
const content = /* @__PURE__ */ jsx("div", {
|
|
170
|
+
className: filterContentClassName,
|
|
171
|
+
children: filter.items.map((item) => /* @__PURE__ */ jsx(FilterItem, {
|
|
172
|
+
filterId: filter.filterId,
|
|
173
|
+
filterItem: item,
|
|
174
|
+
selectFilterItem
|
|
175
|
+
}, item.filterItemId))
|
|
176
|
+
});
|
|
177
|
+
return /* @__PURE__ */ jsx(Accordion, {
|
|
178
|
+
title: filterTitle,
|
|
179
|
+
content
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const SearchFilter = ({ filters, productCount, selectFilterItem, clearAllFilters, isOpen, setIsOpen, applyFiltersUnchangedClasses, applyFiltersChangedClasses, headerContent, footerContent, headerClassName, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor, filterCloseIconVariant }) => {
|
|
183
|
+
const closeModal = useCallback(() => setIsOpen(false), [setIsOpen]);
|
|
184
|
+
const filterCount = getTotalSelectedFilterItemsCount(filters);
|
|
185
|
+
const hasFiltersChanged = useHasFilterStateChanged(filters, isOpen);
|
|
186
|
+
const filterWrapperClassName = classNames({
|
|
187
|
+
"spiffy-tw-flex": true,
|
|
188
|
+
"spiffy-tw-flex-col": true,
|
|
189
|
+
"spiffy-tw-gap-[16px]": true,
|
|
190
|
+
"spiffy-tw-px-[24px]": true,
|
|
191
|
+
"spiffy-tw-py-[16px]": true,
|
|
192
|
+
"spiffy-tw-max-h-screen": true,
|
|
193
|
+
"spiffy-tw-overflow-y-auto": true
|
|
194
|
+
});
|
|
195
|
+
return /* @__PURE__ */ jsx(ModalSheet, {
|
|
196
|
+
isOpen,
|
|
197
|
+
closeModal,
|
|
198
|
+
headerProps: {
|
|
199
|
+
headerContent: headerContent || /* @__PURE__ */ jsx(SearchFilterHeader, {
|
|
200
|
+
closeModal,
|
|
201
|
+
productCount,
|
|
202
|
+
headerClassName: headerClassName ?? "",
|
|
203
|
+
filterCloseIconVariant
|
|
204
|
+
}),
|
|
205
|
+
chevronColor: "#000"
|
|
206
|
+
},
|
|
207
|
+
footerProps: { footerContent: footerContent || /* @__PURE__ */ jsx(SearchFilterFooter, {
|
|
208
|
+
closeModal,
|
|
209
|
+
clearAllFilters,
|
|
210
|
+
filterCount,
|
|
211
|
+
hasFiltersChanged,
|
|
212
|
+
applyFiltersUnchangedClasses,
|
|
213
|
+
applyFiltersChangedClasses
|
|
214
|
+
}) },
|
|
215
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
216
|
+
className: filterWrapperClassName,
|
|
217
|
+
children: filters.filter((filter) => filter.displayName !== "").map((filter) => {
|
|
218
|
+
if (filter.filterId === "sort") return /* @__PURE__ */ jsx(SortFilter, {
|
|
219
|
+
filter,
|
|
220
|
+
selectFilterItem,
|
|
221
|
+
radioButtonFillColor,
|
|
222
|
+
radioButtonHoverColor,
|
|
223
|
+
radioButtonUncheckedBorderColor
|
|
224
|
+
}, filter.filterId);
|
|
225
|
+
return /* @__PURE__ */ jsx(Filter, {
|
|
226
|
+
filter,
|
|
227
|
+
selectFilterItem
|
|
228
|
+
}, filter.filterId);
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/components/SearchFilter/SearchFilterItem.tsx
|
|
236
|
+
const SearchFilterItem = ({ filterItem, onSelectFilterItem, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor }) => {
|
|
237
|
+
const { displayName, isSelected } = filterItem;
|
|
238
|
+
const radioClasses = classNames("spiffy-tw-w-4 spiffy-tw-h-4 spiffy-tw-rounded-full spiffy-tw-border-2", "spiffy-tw-flex spiffy-tw-items-center spiffy-tw-justify-center", radioButtonUncheckedBorderColor, radioButtonHoverColor, { [radioButtonFillColor]: isSelected });
|
|
239
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
240
|
+
type: "button",
|
|
241
|
+
role: "option",
|
|
242
|
+
"aria-selected": isSelected,
|
|
243
|
+
className: "spiffy-tw-flex spiffy-tw-items-center spiffy-tw-justify-between spiffy-tw-py-2",
|
|
244
|
+
onClick: () => onSelectFilterItem(filterItem),
|
|
245
|
+
onKeyDown: (event) => {
|
|
246
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
onSelectFilterItem(filterItem);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
onKeyUp: (event) => {
|
|
252
|
+
if (event.key === " ") event.preventDefault();
|
|
253
|
+
},
|
|
254
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
255
|
+
variant: "body3",
|
|
256
|
+
children: displayName
|
|
257
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
258
|
+
className: radioClasses,
|
|
259
|
+
children: isSelected && /* @__PURE__ */ jsx("div", { className: classNames("spiffy-tw-w-2 spiffy-tw-h-2 spiffy-tw-rounded-full", {
|
|
260
|
+
"spiffy-tw-bg-white": radioButtonFillColor.includes("spiffy-tw-bg-"),
|
|
261
|
+
"spiffy-tw-bg-black": radioButtonFillColor.includes("spiffy-tw-bg-white")
|
|
262
|
+
}) })
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//#endregion
|
|
268
|
+
export { SearchFilter, SearchFilterFooter, SearchFilterHeader, SearchFilterItem, getSelectedFilterItemsCount, getTotalSelectedFilterItemsCount };
|