@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,307 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_Typography = require('./Typography-CFNWgbM5.cjs');
|
|
3
|
+
const require_Accordion = require('./Accordion-RpyCFs2a.cjs');
|
|
4
|
+
const require_ButtonBase = require('./ButtonBase-AU23oGQr.cjs');
|
|
5
|
+
const require_ModalSheet = require('./ModalSheet-CcthFeMD.cjs');
|
|
6
|
+
const require_RadioButtonGroup = require('./RadioButtonGroup-3t2kqSFA.cjs');
|
|
7
|
+
const require_ToggleButton = require('./ToggleButton-CJ74eu-N.cjs');
|
|
8
|
+
let react = require("react");
|
|
9
|
+
react = require_chunk.__toESM(react);
|
|
10
|
+
let classnames = require("classnames");
|
|
11
|
+
classnames = require_chunk.__toESM(classnames);
|
|
12
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
|
|
14
|
+
|
|
15
|
+
//#region src/components/SearchFilter/SearchFilterHeader.tsx
|
|
16
|
+
const SearchFilterHeader = ({ closeModal, productCount, headerClassName, filterCloseIconVariant }) => {
|
|
17
|
+
const closeIconColor = filterCloseIconVariant === "dark" ? "var(--spiffy-colors-text-primary)" : "var(--spiffy-colors-text-light)";
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19
|
+
className: (0, classnames.default)("spiffy-tw-flex spiffy-tw-items-center spiffy-tw-justify-between spiffy-tw-px-4 spiffy-tw-py-3", headerClassName),
|
|
20
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Typography.Typography, {
|
|
21
|
+
variant: "body2",
|
|
22
|
+
className: "spiffy-tw-font-medium",
|
|
23
|
+
children: [
|
|
24
|
+
"Filters (",
|
|
25
|
+
productCount,
|
|
26
|
+
")"
|
|
27
|
+
]
|
|
28
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29
|
+
onClick: closeModal,
|
|
30
|
+
className: "spiffy-tw-p-2",
|
|
31
|
+
type: "button",
|
|
32
|
+
"aria-label": "Open Filter Menu",
|
|
33
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
34
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
+
width: "14",
|
|
36
|
+
height: "14",
|
|
37
|
+
viewBox: "0 0 14 14",
|
|
38
|
+
fill: "none",
|
|
39
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
40
|
+
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",
|
|
41
|
+
fill: closeIconColor
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/SearchFilter/useHasFilterStateChanged.tsx
|
|
50
|
+
const useHasFilterStateChanged = (filters, isOpen) => {
|
|
51
|
+
const [initialFilterStates, setInitialFilterStates] = (0, react.useState)({});
|
|
52
|
+
const currentFilterStates = (0, react.useMemo)(() => {
|
|
53
|
+
const states = {};
|
|
54
|
+
filters.forEach((filter) => {
|
|
55
|
+
filter.items.forEach((item) => {
|
|
56
|
+
states[`${filter.filterId}-${item.filterItemId}`] = item.isSelected;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return states;
|
|
60
|
+
}, [filters]);
|
|
61
|
+
const hasFiltersChanged = (0, react.useMemo)(() => {
|
|
62
|
+
if (Object.keys(initialFilterStates).length === 0) return false;
|
|
63
|
+
return Object.keys(currentFilterStates).some((key) => currentFilterStates[key] !== initialFilterStates[key]);
|
|
64
|
+
}, [currentFilterStates, initialFilterStates]);
|
|
65
|
+
(0, react.useEffect)(() => {
|
|
66
|
+
if (isOpen) setInitialFilterStates(currentFilterStates);
|
|
67
|
+
}, [isOpen]);
|
|
68
|
+
return hasFiltersChanged;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/components/SearchFilter/utils.ts
|
|
73
|
+
const getSelectedFilterItemsCount = (filter) => filter.items.filter((item) => item.isSelected).length;
|
|
74
|
+
const getTotalSelectedFilterItemsCount = (filters) => filters.reduce((acc, filter) => {
|
|
75
|
+
if (filter.filterId === "sort") return acc;
|
|
76
|
+
return acc + getSelectedFilterItemsCount(filter);
|
|
77
|
+
}, 0);
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/components/SearchFilter/SearchFilterFooter.tsx
|
|
81
|
+
const SearchFilterFooter = ({ closeModal, clearAllFilters, filterCount, applyFiltersUnchangedClasses, applyFiltersChangedClasses, hasFiltersChanged }) => {
|
|
82
|
+
const clearAllButtonEnabled = filterCount > 0;
|
|
83
|
+
const footerWrapperClassName = (0, classnames.default)({
|
|
84
|
+
"spiffy-tw-flex": true,
|
|
85
|
+
"spiffy-tw-flex-col": true,
|
|
86
|
+
"spiffy-tw-items-center": true,
|
|
87
|
+
"spiffy-tw-justify-between": true,
|
|
88
|
+
"spiffy-tw-w-full": true,
|
|
89
|
+
"spiffy-tw-border-t": true,
|
|
90
|
+
"spiffy-tw-border-t-[--spiffy-colors-border-light]": true,
|
|
91
|
+
"spiffy-tw-p-[16px]": true,
|
|
92
|
+
"spiffy-tw-gap-[16px]": true
|
|
93
|
+
});
|
|
94
|
+
const applyFilterButtonClassName = (0, classnames.default)("spiffy-tw-flex spiffy-tw-flex-row spiffy-tw-justify-center spiffy-tw-rounded-[8px] spiffy-tw-w-full", hasFiltersChanged ? applyFiltersChangedClasses : applyFiltersUnchangedClasses);
|
|
95
|
+
const clearAllButtonClassName = (0, classnames.default)({
|
|
96
|
+
"spiffy-tw-flex": true,
|
|
97
|
+
"spiffy-tw-flex-row": true,
|
|
98
|
+
"spiffy-tw-justify-center": true,
|
|
99
|
+
"spiffy-tw-w-full": true,
|
|
100
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]": clearAllButtonEnabled,
|
|
101
|
+
"spiffy-tw-text-[--spiffy-colors-text-secondary]": !clearAllButtonEnabled
|
|
102
|
+
});
|
|
103
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
104
|
+
className: footerWrapperClassName,
|
|
105
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonBase.ButtonBase, {
|
|
106
|
+
isDisabled: !hasFiltersChanged,
|
|
107
|
+
buttonClass: applyFilterButtonClassName,
|
|
108
|
+
text: "Apply Filters",
|
|
109
|
+
onClick: closeModal
|
|
110
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonBase.ButtonBase, {
|
|
111
|
+
isDisabled: !clearAllButtonEnabled,
|
|
112
|
+
buttonClass: clearAllButtonClassName,
|
|
113
|
+
text: "Clear All",
|
|
114
|
+
onClick: clearAllFilters
|
|
115
|
+
})]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/components/SearchFilter/SearchFilter.tsx
|
|
121
|
+
const SortFilter = ({ filter, selectFilterItem, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor }) => {
|
|
122
|
+
const filterTitle = filter.displayName;
|
|
123
|
+
const options = filter.items.map((item) => ({
|
|
124
|
+
label: item.displayName,
|
|
125
|
+
value: item.filterItemId,
|
|
126
|
+
isSelected: item.isSelected
|
|
127
|
+
}));
|
|
128
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RadioButtonGroup.RadioButtonGroup, {
|
|
129
|
+
options,
|
|
130
|
+
name: filterTitle,
|
|
131
|
+
onChange: (value) => {
|
|
132
|
+
const selectedItem = filter.items.find((item) => item.filterItemId === value);
|
|
133
|
+
selectFilterItem({
|
|
134
|
+
filterId: filter.filterId,
|
|
135
|
+
filterItemId: value,
|
|
136
|
+
isSelected: true,
|
|
137
|
+
displayName: selectedItem?.displayName || value
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
gap: "large",
|
|
141
|
+
textButtonGap: "large",
|
|
142
|
+
value: filter.items.find((item) => item.isSelected)?.filterItemId,
|
|
143
|
+
fillColor: radioButtonFillColor,
|
|
144
|
+
hoverColor: radioButtonHoverColor,
|
|
145
|
+
uncheckedBorderColor: radioButtonUncheckedBorderColor
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Accordion.Accordion, {
|
|
148
|
+
title: filterTitle,
|
|
149
|
+
content
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const FilterItem = ({ filterId, filterItem, selectFilterItem }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ToggleButton.ToggleButton, {
|
|
153
|
+
label: filterItem.displayName,
|
|
154
|
+
secondaryLabel: `(${filterItem.productCount})`,
|
|
155
|
+
isSelected: filterItem.isSelected,
|
|
156
|
+
onClick: () => selectFilterItem({
|
|
157
|
+
filterId,
|
|
158
|
+
filterItemId: filterItem.filterItemId,
|
|
159
|
+
isSelected: !filterItem.isSelected,
|
|
160
|
+
displayName: filterItem.displayName
|
|
161
|
+
}),
|
|
162
|
+
variant: "default"
|
|
163
|
+
});
|
|
164
|
+
const Filter = ({ filter, selectFilterItem }) => {
|
|
165
|
+
const filterContentClassName = (0, classnames.default)({
|
|
166
|
+
"spiffy-tw-flex": true,
|
|
167
|
+
"spiffy-tw-flex-wrap": true,
|
|
168
|
+
"spiffy-tw-gap-[8px]": true,
|
|
169
|
+
"spiffy-tw-pb-[1px]": true
|
|
170
|
+
});
|
|
171
|
+
const selectedFilterItems = getSelectedFilterItemsCount(filter);
|
|
172
|
+
const filterTitle = selectedFilterItems > 0 ? `${filter.displayName} (${selectedFilterItems})` : filter.displayName;
|
|
173
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
174
|
+
className: filterContentClassName,
|
|
175
|
+
children: filter.items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterItem, {
|
|
176
|
+
filterId: filter.filterId,
|
|
177
|
+
filterItem: item,
|
|
178
|
+
selectFilterItem
|
|
179
|
+
}, item.filterItemId))
|
|
180
|
+
});
|
|
181
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Accordion.Accordion, {
|
|
182
|
+
title: filterTitle,
|
|
183
|
+
content
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const SearchFilter = ({ filters, productCount, selectFilterItem, clearAllFilters, isOpen, setIsOpen, applyFiltersUnchangedClasses, applyFiltersChangedClasses, headerContent, footerContent, headerClassName, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor, filterCloseIconVariant }) => {
|
|
187
|
+
const closeModal = (0, react.useCallback)(() => setIsOpen(false), [setIsOpen]);
|
|
188
|
+
const filterCount = getTotalSelectedFilterItemsCount(filters);
|
|
189
|
+
const hasFiltersChanged = useHasFilterStateChanged(filters, isOpen);
|
|
190
|
+
const filterWrapperClassName = (0, classnames.default)({
|
|
191
|
+
"spiffy-tw-flex": true,
|
|
192
|
+
"spiffy-tw-flex-col": true,
|
|
193
|
+
"spiffy-tw-gap-[16px]": true,
|
|
194
|
+
"spiffy-tw-px-[24px]": true,
|
|
195
|
+
"spiffy-tw-py-[16px]": true,
|
|
196
|
+
"spiffy-tw-max-h-screen": true,
|
|
197
|
+
"spiffy-tw-overflow-y-auto": true
|
|
198
|
+
});
|
|
199
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ModalSheet.ModalSheet, {
|
|
200
|
+
isOpen,
|
|
201
|
+
closeModal,
|
|
202
|
+
headerProps: {
|
|
203
|
+
headerContent: headerContent || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchFilterHeader, {
|
|
204
|
+
closeModal,
|
|
205
|
+
productCount,
|
|
206
|
+
headerClassName: headerClassName ?? "",
|
|
207
|
+
filterCloseIconVariant
|
|
208
|
+
}),
|
|
209
|
+
chevronColor: "#000"
|
|
210
|
+
},
|
|
211
|
+
footerProps: { footerContent: footerContent || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchFilterFooter, {
|
|
212
|
+
closeModal,
|
|
213
|
+
clearAllFilters,
|
|
214
|
+
filterCount,
|
|
215
|
+
hasFiltersChanged,
|
|
216
|
+
applyFiltersUnchangedClasses,
|
|
217
|
+
applyFiltersChangedClasses
|
|
218
|
+
}) },
|
|
219
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
220
|
+
className: filterWrapperClassName,
|
|
221
|
+
children: filters.filter((filter) => filter.displayName !== "").map((filter) => {
|
|
222
|
+
if (filter.filterId === "sort") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortFilter, {
|
|
223
|
+
filter,
|
|
224
|
+
selectFilterItem,
|
|
225
|
+
radioButtonFillColor,
|
|
226
|
+
radioButtonHoverColor,
|
|
227
|
+
radioButtonUncheckedBorderColor
|
|
228
|
+
}, filter.filterId);
|
|
229
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Filter, {
|
|
230
|
+
filter,
|
|
231
|
+
selectFilterItem
|
|
232
|
+
}, filter.filterId);
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/components/SearchFilter/SearchFilterItem.tsx
|
|
240
|
+
const SearchFilterItem = ({ filterItem, onSelectFilterItem, radioButtonFillColor, radioButtonHoverColor, radioButtonUncheckedBorderColor }) => {
|
|
241
|
+
const { displayName, isSelected } = filterItem;
|
|
242
|
+
const radioClasses = (0, classnames.default)("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 });
|
|
243
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
244
|
+
type: "button",
|
|
245
|
+
role: "option",
|
|
246
|
+
"aria-selected": isSelected,
|
|
247
|
+
className: "spiffy-tw-flex spiffy-tw-items-center spiffy-tw-justify-between spiffy-tw-py-2",
|
|
248
|
+
onClick: () => onSelectFilterItem(filterItem),
|
|
249
|
+
onKeyDown: (event) => {
|
|
250
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
onSelectFilterItem(filterItem);
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
onKeyUp: (event) => {
|
|
256
|
+
if (event.key === " ") event.preventDefault();
|
|
257
|
+
},
|
|
258
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.Typography, {
|
|
259
|
+
variant: "body3",
|
|
260
|
+
children: displayName
|
|
261
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
262
|
+
className: radioClasses,
|
|
263
|
+
children: isSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: (0, classnames.default)("spiffy-tw-w-2 spiffy-tw-h-2 spiffy-tw-rounded-full", {
|
|
264
|
+
"spiffy-tw-bg-white": radioButtonFillColor.includes("spiffy-tw-bg-"),
|
|
265
|
+
"spiffy-tw-bg-black": radioButtonFillColor.includes("spiffy-tw-bg-white")
|
|
266
|
+
}) })
|
|
267
|
+
})]
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
//#endregion
|
|
272
|
+
Object.defineProperty(exports, 'SearchFilter', {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function () {
|
|
275
|
+
return SearchFilter;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
Object.defineProperty(exports, 'SearchFilterFooter', {
|
|
279
|
+
enumerable: true,
|
|
280
|
+
get: function () {
|
|
281
|
+
return SearchFilterFooter;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
Object.defineProperty(exports, 'SearchFilterHeader', {
|
|
285
|
+
enumerable: true,
|
|
286
|
+
get: function () {
|
|
287
|
+
return SearchFilterHeader;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
Object.defineProperty(exports, 'SearchFilterItem', {
|
|
291
|
+
enumerable: true,
|
|
292
|
+
get: function () {
|
|
293
|
+
return SearchFilterItem;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
Object.defineProperty(exports, 'getSelectedFilterItemsCount', {
|
|
297
|
+
enumerable: true,
|
|
298
|
+
get: function () {
|
|
299
|
+
return getSelectedFilterItemsCount;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
Object.defineProperty(exports, 'getTotalSelectedFilterItemsCount', {
|
|
303
|
+
enumerable: true,
|
|
304
|
+
get: function () {
|
|
305
|
+
return getTotalSelectedFilterItemsCount;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require('../Typography-CFNWgbM5.cjs');
|
|
2
|
+
const require_SearchInput = require('../SearchInput-CO1poiit.cjs');
|
|
3
|
+
require('../SettingsVariant-BsBbdjV5.cjs');
|
|
4
|
+
require('../TextInput-iAKCKHwT.cjs');
|
|
5
|
+
require('../colorsConfig-D-MZuBvt.cjs');
|
|
6
|
+
|
|
7
|
+
exports.SearchInput = require_SearchInput.SearchInput;
|
|
8
|
+
exports.searchInputVariantClasses = require_SearchInput.searchInputVariantClasses;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SearchInputVariant as SearchInputVariant$1 } from "../types-BhGjnuWx.cjs";
|
|
2
|
+
import { TypographyVariantMap } from "../typographyVariantClasses-DTSltxPN.cjs";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SearchInputVariant } from "@envive-ai/react-hooks/contexts/types";
|
|
5
|
+
|
|
6
|
+
//#region src/components/SearchInput/SearchInput.d.ts
|
|
7
|
+
interface SearchInputProps {
|
|
8
|
+
searchInputVariant?: SearchInputVariant;
|
|
9
|
+
value: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
suggestions?: string[];
|
|
12
|
+
className?: string;
|
|
13
|
+
dataTestId?: string;
|
|
14
|
+
ariaActivedescendant?: string;
|
|
15
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
16
|
+
onChange: (newValue: string) => void;
|
|
17
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
18
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/SearchInput/searchInputVariants.d.ts
|
|
23
|
+
type SearchInputVariantClasses = {
|
|
24
|
+
searchInputIconColor: string;
|
|
25
|
+
searchInputBorderColor: string;
|
|
26
|
+
searchInputCloseIconClasses: string;
|
|
27
|
+
searchInputActiveStarClasses: string;
|
|
28
|
+
autocompleteIconColor: string;
|
|
29
|
+
searchInputClasses: string;
|
|
30
|
+
placeholderVariant: keyof typeof TypographyVariantMap;
|
|
31
|
+
};
|
|
32
|
+
declare const searchInputVariantClasses: Record<SearchInputVariant$1, SearchInputVariantClasses>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { SearchInput, searchInputVariantClasses };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SearchInputVariant as SearchInputVariant$1 } from "../types-CGRog8XL.js";
|
|
2
|
+
import { TypographyVariantMap } from "../typographyVariantClasses-COmQXqcN.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SearchInputVariant } from "@envive-ai/react-hooks/contexts/types";
|
|
5
|
+
|
|
6
|
+
//#region src/components/SearchInput/SearchInput.d.ts
|
|
7
|
+
interface SearchInputProps {
|
|
8
|
+
searchInputVariant?: SearchInputVariant;
|
|
9
|
+
value: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
suggestions?: string[];
|
|
12
|
+
className?: string;
|
|
13
|
+
dataTestId?: string;
|
|
14
|
+
ariaActivedescendant?: string;
|
|
15
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
16
|
+
onChange: (newValue: string) => void;
|
|
17
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
18
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/SearchInput/searchInputVariants.d.ts
|
|
23
|
+
type SearchInputVariantClasses = {
|
|
24
|
+
searchInputIconColor: string;
|
|
25
|
+
searchInputBorderColor: string;
|
|
26
|
+
searchInputCloseIconClasses: string;
|
|
27
|
+
searchInputActiveStarClasses: string;
|
|
28
|
+
autocompleteIconColor: string;
|
|
29
|
+
searchInputClasses: string;
|
|
30
|
+
placeholderVariant: keyof typeof TypographyVariantMap;
|
|
31
|
+
};
|
|
32
|
+
declare const searchInputVariantClasses: Record<SearchInputVariant$1, SearchInputVariantClasses>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { SearchInput, searchInputVariantClasses };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../Typography-D3vDkBMS.js";
|
|
2
|
+
import { SearchInput, searchInputVariantClasses } from "../SearchInput-BaiWd0_O.js";
|
|
3
|
+
import "../SettingsVariant-CUSFlJEu.js";
|
|
4
|
+
import "../TextInput-B_4Bu2vf.js";
|
|
5
|
+
import "../colorsConfig-DEfiLHH0.js";
|
|
6
|
+
|
|
7
|
+
export { SearchInput, searchInputVariantClasses };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TextInput } from "./TextInput-B_4Bu2vf.js";
|
|
2
|
+
import { ColorNames, colorVar } from "./colorsConfig-DEfiLHH0.js";
|
|
3
|
+
import React, { useImperativeHandle, useRef } from "react";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import MagnifyingGlassStarVariant from "@envive-ai/react-icons/MagnifyingGlassStarVariant";
|
|
7
|
+
|
|
8
|
+
//#region ../icons/src/IconClose.tsx
|
|
9
|
+
const SvgIconClose = (props) => /* @__PURE__ */ jsxs("svg", {
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
+
width: 24,
|
|
12
|
+
height: 24,
|
|
13
|
+
fill: "none",
|
|
14
|
+
...props,
|
|
15
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
16
|
+
cx: 12,
|
|
17
|
+
cy: 12,
|
|
18
|
+
r: 12,
|
|
19
|
+
fill: "#FCFCF9"
|
|
20
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
21
|
+
fill: "currentColor",
|
|
22
|
+
d: "M16.167 6 11.5 10.667 6.833 6 5 7.833 9.667 12.5 5 17.167 6.833 19l4.667-4.667L16.167 19 18 17.167 13.333 12.5 18 7.833z"
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
var IconClose_default = SvgIconClose;
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/SearchInput/searchInputVariants.ts
|
|
29
|
+
const searchInputVariantClasses = { standard: {
|
|
30
|
+
searchInputIconColor: "transparent",
|
|
31
|
+
searchInputBorderColor: "spiffy-tw-border-[--spiffy-colors-border-medium]",
|
|
32
|
+
searchInputCloseIconClasses: "[&>circle]:spiffy-tw-fill-[--spiffy-colors-text-secondary] [&>path]:spiffy-tw-fill-[#fff]",
|
|
33
|
+
searchInputActiveStarClasses: `first:[&>path]:spiffy-tw-stroke-[--spiffy-colors-accent-primary] first:[&>path]:spiffy-tw-fill-[--spiffy-colors-accent-primary]`,
|
|
34
|
+
autocompleteIconColor: colorVar(ColorNames.BackgroundPrimary),
|
|
35
|
+
searchInputClasses: "spiffy-tw-text-[--spiffy-colors-text-primary] placeholder:spiffy-tw-text-[--spiffy-colors-text-secondary] spiffy-tw-text-[16px] spiffy-tw-font-normal spiffy-tw-leading-[148%] placeholder:spiffy-tw-font-medium placeholder:spiffy-tw-leading-[124%]",
|
|
36
|
+
placeholderVariant: "h2"
|
|
37
|
+
} };
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/components/SearchInput/SearchInput.tsx
|
|
41
|
+
const SearchInput = React.forwardRef(({ searchInputVariant = "standard", value, placeholder, suggestions, className, dataTestId, ariaActivedescendant, onKeyDown, onChange, onFocus, onBlur }, ref) => {
|
|
42
|
+
const localInputRef = useRef(null);
|
|
43
|
+
const { searchInputClasses: inputClassName, searchInputIconColor: iconColor, searchInputBorderColor: borderColor, searchInputCloseIconClasses: closeIconClasses, searchInputActiveStarClasses, placeholderVariant } = searchInputVariantClasses[searchInputVariant];
|
|
44
|
+
useImperativeHandle(ref, () => localInputRef.current, []);
|
|
45
|
+
const magnifyingGlassClassesBase = [
|
|
46
|
+
"spiffy-tw-w-[24px]",
|
|
47
|
+
"spiffy-tw-h-[32px]",
|
|
48
|
+
"spiffy-tw-stroke-width-1",
|
|
49
|
+
"sm:spiffy-tw-w-[32px]"
|
|
50
|
+
];
|
|
51
|
+
const magnifyingGlassClassesInactive = classNames(magnifyingGlassClassesBase);
|
|
52
|
+
const magnifyingGlassClassesActive = classNames([...magnifyingGlassClassesBase, searchInputActiveStarClasses]);
|
|
53
|
+
const containerClasses = classNames("spiffy-global-search-input-container", "spiffy-tw-relative spiffy-tw-flex spiffy-tw-items-center", className);
|
|
54
|
+
const inputClasses = classNames("spiffy-global-search-input", "spiffy-tw-flex-grow spiffy-tw-p-2 spiffy-tw-px-[42px] sm:spiffy-tw-p-3 sm:spiffy-tw-px-[48px]", "spiffy-tw-border", "spiffy-tw-text-base", inputClassName);
|
|
55
|
+
const closeButtonIconClassName = classNames([
|
|
56
|
+
"spiffy-tw-w-[16px]",
|
|
57
|
+
"spiffy-tw-h-[16px]",
|
|
58
|
+
"sm:spiffy-tw-w-[24px]",
|
|
59
|
+
"sm:spiffy-tw-h-[24px]",
|
|
60
|
+
"spiffy-tw-cursor-pointer",
|
|
61
|
+
closeIconClasses
|
|
62
|
+
]);
|
|
63
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: containerClasses,
|
|
65
|
+
"data-testid": dataTestId,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx("div", {
|
|
68
|
+
className: "spiffy-tw-absolute spiffy-tw-left-3 spiffy-tw-top-1/2 spiffy-tw--translate-y-1/2",
|
|
69
|
+
children: /* @__PURE__ */ jsx(MagnifyingGlassStarVariant, {
|
|
70
|
+
className: value.length > 0 ? magnifyingGlassClassesActive : magnifyingGlassClassesInactive,
|
|
71
|
+
stroke: iconColor,
|
|
72
|
+
strokeWidth: "1px"
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx(TextInput, {
|
|
76
|
+
value,
|
|
77
|
+
onChange: (event) => onChange(event.target.value),
|
|
78
|
+
onFocus,
|
|
79
|
+
onBlur,
|
|
80
|
+
onKeyDown,
|
|
81
|
+
placeholder,
|
|
82
|
+
className: inputClasses,
|
|
83
|
+
placeholderVariant,
|
|
84
|
+
"aria-label": "Search",
|
|
85
|
+
"aria-autocomplete": "list",
|
|
86
|
+
"aria-expanded": !!suggestions && suggestions.length > 0,
|
|
87
|
+
"aria-controls": "autocomplete-results",
|
|
88
|
+
"aria-activedescendant": ariaActivedescendant,
|
|
89
|
+
borderRadius: "xl",
|
|
90
|
+
borderColorClass: borderColor,
|
|
91
|
+
ref: localInputRef
|
|
92
|
+
}),
|
|
93
|
+
value && /* @__PURE__ */ jsx("button", {
|
|
94
|
+
onClick: () => {
|
|
95
|
+
onChange("");
|
|
96
|
+
localInputRef.current?.focus();
|
|
97
|
+
},
|
|
98
|
+
className: "spiffy-tw-absolute spiffy-tw-right-5 spiffy-tw-top-1/2 spiffy-tw--translate-y-1/2 spiffy-tw-text-neutral-500 hover:spiffy-tw-text-neutral-700",
|
|
99
|
+
"aria-label": "Clear search input",
|
|
100
|
+
type: "button",
|
|
101
|
+
children: /* @__PURE__ */ jsx(IconClose_default, { className: closeButtonIconClassName })
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
export { SearchInput, searchInputVariantClasses };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_TextInput = require('./TextInput-iAKCKHwT.cjs');
|
|
3
|
+
const require_colorsConfig = require('./colorsConfig-D-MZuBvt.cjs');
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_chunk.__toESM(react);
|
|
6
|
+
let classnames = require("classnames");
|
|
7
|
+
classnames = require_chunk.__toESM(classnames);
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
|
|
10
|
+
let __envive_ai_react_icons_MagnifyingGlassStarVariant = require("@envive-ai/react-icons/MagnifyingGlassStarVariant");
|
|
11
|
+
__envive_ai_react_icons_MagnifyingGlassStarVariant = require_chunk.__toESM(__envive_ai_react_icons_MagnifyingGlassStarVariant);
|
|
12
|
+
|
|
13
|
+
//#region ../icons/src/IconClose.tsx
|
|
14
|
+
const SvgIconClose = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
width: 24,
|
|
17
|
+
height: 24,
|
|
18
|
+
fill: "none",
|
|
19
|
+
...props,
|
|
20
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
21
|
+
cx: 12,
|
|
22
|
+
cy: 12,
|
|
23
|
+
r: 12,
|
|
24
|
+
fill: "#FCFCF9"
|
|
25
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
26
|
+
fill: "currentColor",
|
|
27
|
+
d: "M16.167 6 11.5 10.667 6.833 6 5 7.833 9.667 12.5 5 17.167 6.833 19l4.667-4.667L16.167 19 18 17.167 13.333 12.5 18 7.833z"
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
var IconClose_default = SvgIconClose;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/components/SearchInput/searchInputVariants.ts
|
|
34
|
+
const searchInputVariantClasses = { standard: {
|
|
35
|
+
searchInputIconColor: "transparent",
|
|
36
|
+
searchInputBorderColor: "spiffy-tw-border-[--spiffy-colors-border-medium]",
|
|
37
|
+
searchInputCloseIconClasses: "[&>circle]:spiffy-tw-fill-[--spiffy-colors-text-secondary] [&>path]:spiffy-tw-fill-[#fff]",
|
|
38
|
+
searchInputActiveStarClasses: `first:[&>path]:spiffy-tw-stroke-[--spiffy-colors-accent-primary] first:[&>path]:spiffy-tw-fill-[--spiffy-colors-accent-primary]`,
|
|
39
|
+
autocompleteIconColor: require_colorsConfig.colorVar(require_colorsConfig.ColorNames.BackgroundPrimary),
|
|
40
|
+
searchInputClasses: "spiffy-tw-text-[--spiffy-colors-text-primary] placeholder:spiffy-tw-text-[--spiffy-colors-text-secondary] spiffy-tw-text-[16px] spiffy-tw-font-normal spiffy-tw-leading-[148%] placeholder:spiffy-tw-font-medium placeholder:spiffy-tw-leading-[124%]",
|
|
41
|
+
placeholderVariant: "h2"
|
|
42
|
+
} };
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/components/SearchInput/SearchInput.tsx
|
|
46
|
+
const SearchInput = react.default.forwardRef(({ searchInputVariant = "standard", value, placeholder, suggestions, className, dataTestId, ariaActivedescendant, onKeyDown, onChange, onFocus, onBlur }, ref) => {
|
|
47
|
+
const localInputRef = (0, react.useRef)(null);
|
|
48
|
+
const { searchInputClasses: inputClassName, searchInputIconColor: iconColor, searchInputBorderColor: borderColor, searchInputCloseIconClasses: closeIconClasses, searchInputActiveStarClasses, placeholderVariant } = searchInputVariantClasses[searchInputVariant];
|
|
49
|
+
(0, react.useImperativeHandle)(ref, () => localInputRef.current, []);
|
|
50
|
+
const magnifyingGlassClassesBase = [
|
|
51
|
+
"spiffy-tw-w-[24px]",
|
|
52
|
+
"spiffy-tw-h-[32px]",
|
|
53
|
+
"spiffy-tw-stroke-width-1",
|
|
54
|
+
"sm:spiffy-tw-w-[32px]"
|
|
55
|
+
];
|
|
56
|
+
const magnifyingGlassClassesInactive = (0, classnames.default)(magnifyingGlassClassesBase);
|
|
57
|
+
const magnifyingGlassClassesActive = (0, classnames.default)([...magnifyingGlassClassesBase, searchInputActiveStarClasses]);
|
|
58
|
+
const containerClasses = (0, classnames.default)("spiffy-global-search-input-container", "spiffy-tw-relative spiffy-tw-flex spiffy-tw-items-center", className);
|
|
59
|
+
const inputClasses = (0, classnames.default)("spiffy-global-search-input", "spiffy-tw-flex-grow spiffy-tw-p-2 spiffy-tw-px-[42px] sm:spiffy-tw-p-3 sm:spiffy-tw-px-[48px]", "spiffy-tw-border", "spiffy-tw-text-base", inputClassName);
|
|
60
|
+
const closeButtonIconClassName = (0, classnames.default)([
|
|
61
|
+
"spiffy-tw-w-[16px]",
|
|
62
|
+
"spiffy-tw-h-[16px]",
|
|
63
|
+
"sm:spiffy-tw-w-[24px]",
|
|
64
|
+
"sm:spiffy-tw-h-[24px]",
|
|
65
|
+
"spiffy-tw-cursor-pointer",
|
|
66
|
+
closeIconClasses
|
|
67
|
+
]);
|
|
68
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
69
|
+
className: containerClasses,
|
|
70
|
+
"data-testid": dataTestId,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
73
|
+
className: "spiffy-tw-absolute spiffy-tw-left-3 spiffy-tw-top-1/2 spiffy-tw--translate-y-1/2",
|
|
74
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_icons_MagnifyingGlassStarVariant.default, {
|
|
75
|
+
className: value.length > 0 ? magnifyingGlassClassesActive : magnifyingGlassClassesInactive,
|
|
76
|
+
stroke: iconColor,
|
|
77
|
+
strokeWidth: "1px"
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TextInput.TextInput, {
|
|
81
|
+
value,
|
|
82
|
+
onChange: (event) => onChange(event.target.value),
|
|
83
|
+
onFocus,
|
|
84
|
+
onBlur,
|
|
85
|
+
onKeyDown,
|
|
86
|
+
placeholder,
|
|
87
|
+
className: inputClasses,
|
|
88
|
+
placeholderVariant,
|
|
89
|
+
"aria-label": "Search",
|
|
90
|
+
"aria-autocomplete": "list",
|
|
91
|
+
"aria-expanded": !!suggestions && suggestions.length > 0,
|
|
92
|
+
"aria-controls": "autocomplete-results",
|
|
93
|
+
"aria-activedescendant": ariaActivedescendant,
|
|
94
|
+
borderRadius: "xl",
|
|
95
|
+
borderColorClass: borderColor,
|
|
96
|
+
ref: localInputRef
|
|
97
|
+
}),
|
|
98
|
+
value && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
onChange("");
|
|
101
|
+
localInputRef.current?.focus();
|
|
102
|
+
},
|
|
103
|
+
className: "spiffy-tw-absolute spiffy-tw-right-5 spiffy-tw-top-1/2 spiffy-tw--translate-y-1/2 spiffy-tw-text-neutral-500 hover:spiffy-tw-text-neutral-700",
|
|
104
|
+
"aria-label": "Clear search input",
|
|
105
|
+
type: "button",
|
|
106
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconClose_default, { className: closeButtonIconClassName })
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
Object.defineProperty(exports, 'SearchInput', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return SearchInput;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, 'searchInputVariantClasses', {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return searchInputVariantClasses;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
require('../Typography-CFNWgbM5.cjs');
|
|
3
|
+
const require_SearchAutocomplete = require('../SearchAutocomplete-TX8UTczp.cjs');
|
|
4
|
+
const require_SearchInput = require('../SearchInput-CO1poiit.cjs');
|
|
5
|
+
require('../SettingsVariant-BsBbdjV5.cjs');
|
|
6
|
+
require('../TextInput-iAKCKHwT.cjs');
|
|
7
|
+
require('../colorsConfig-D-MZuBvt.cjs');
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
|
|
10
|
+
|
|
11
|
+
//#region src/components/SearchInputForm/SearchInputForm.tsx
|
|
12
|
+
const SearchInputForm = ({ searchInputVariant, searchText, autocompleteResults, searchBoxPlaceholder, focusedOptionId, isDirty, focusedIndex, onKeyDown, onAutocompleteSelect, onSearchInputChange, onSearchSubmit, searchInputDataTestId }) => {
|
|
13
|
+
const { searchInputIconColor } = require_SearchInput.searchInputVariantClasses[searchInputVariant];
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
|
|
15
|
+
onSubmit: (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
onSearchSubmit();
|
|
18
|
+
},
|
|
19
|
+
className: "spiffy-tw-grow",
|
|
20
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SearchInput.SearchInput, {
|
|
21
|
+
value: searchText,
|
|
22
|
+
placeholder: searchBoxPlaceholder,
|
|
23
|
+
suggestions: autocompleteResults,
|
|
24
|
+
ariaActivedescendant: focusedOptionId,
|
|
25
|
+
searchInputVariant,
|
|
26
|
+
dataTestId: searchInputDataTestId,
|
|
27
|
+
onKeyDown,
|
|
28
|
+
onChange: onSearchInputChange
|
|
29
|
+
})
|
|
30
|
+
}), isDirty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SearchAutocomplete.SearchAutocomplete, {
|
|
31
|
+
id: "autocomplete-results",
|
|
32
|
+
results: autocompleteResults,
|
|
33
|
+
focusedIndex,
|
|
34
|
+
iconColor: searchInputIconColor,
|
|
35
|
+
onSuggestionSelect: onAutocompleteSelect
|
|
36
|
+
})] });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.SearchInputForm = SearchInputForm;
|