@envive-ai/react-toolkit 0.2.3 → 0.2.5
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.d.cts +2 -2
- package/dist/Accordion/index.d.ts +2 -2
- package/dist/AnimatedChevron/index.d.cts +2 -2
- package/dist/AnimatedChevron/index.d.ts +2 -2
- package/dist/AppliedFiltersScrollbar/index.d.cts +2 -2
- package/dist/AppliedFiltersScrollbar/index.d.ts +2 -2
- package/dist/ButtonBase/index.d.cts +2 -2
- package/dist/ButtonBase/index.d.ts +2 -2
- package/dist/DynamicFiltersScrollbar/index.d.cts +2 -2
- package/dist/DynamicFiltersScrollbar/index.d.ts +2 -2
- package/dist/FilterScrollbar/index.d.cts +3 -3
- package/dist/FilterScrollbar/index.d.ts +3 -3
- package/dist/ImageWithFallback/index.d.cts +2 -2
- package/dist/ImageWithFallback/index.d.ts +2 -2
- package/dist/ModalSheet/index.d.cts +2 -2
- package/dist/ModalSheet/index.d.ts +2 -2
- package/dist/ProductCard/index.cjs +2 -2
- package/dist/ProductCard/index.d.cts +1 -1
- package/dist/ProductCard/index.d.ts +1 -1
- package/dist/ProductCard/index.js +2 -2
- package/dist/{ProductCard-2aPkjS8z.js → ProductCard-BIlnM2nV.js} +1 -1
- package/dist/{ProductCard-D1F9A8Rw.cjs → ProductCard-CByKIsUN.cjs} +1 -1
- package/dist/ProductGrid/index.cjs +3 -3
- package/dist/ProductGrid/index.d.cts +3 -3
- package/dist/ProductGrid/index.d.ts +3 -3
- package/dist/ProductGrid/index.js +3 -3
- package/dist/{ProductGrid-Dcy7JxVN.cjs → ProductGrid-BeFeluHo.cjs} +1 -1
- package/dist/{ProductGrid-NtuMrOtp.js → ProductGrid-Cgkb4vNf.js} +1 -1
- package/dist/RadioButton/index.d.cts +2 -2
- package/dist/RadioButton/index.d.ts +2 -2
- package/dist/RadioButtonGroup/index.d.cts +2 -2
- package/dist/RadioButtonGroup/index.d.ts +2 -2
- package/dist/SearchAutocomplete/index.cjs +2 -1
- package/dist/SearchAutocomplete/index.d.cts +10 -2
- package/dist/SearchAutocomplete/index.d.ts +10 -2
- package/dist/SearchAutocomplete/index.js +2 -1
- package/dist/{SearchAutocomplete-TX8UTczp.cjs → SearchAutocomplete-BBBIDGP_.cjs} +26 -8
- package/dist/SearchAutocomplete-DEY_Cmf6.js +69 -0
- package/dist/SearchFilter/index.cjs +2 -2
- package/dist/SearchFilter/index.d.cts +5 -5
- package/dist/SearchFilter/index.d.ts +5 -5
- package/dist/SearchFilter/index.js +2 -2
- package/dist/{SearchFilter-BQW4o3Xf.js → SearchFilter-B0ICGnqG.js} +1 -1
- package/dist/{SearchFilter-t9or-lnj.cjs → SearchFilter-aSgPzPq-.cjs} +1 -1
- package/dist/SearchInput/index.cjs +4 -4
- package/dist/SearchInput/index.js +4 -4
- package/dist/{SearchInput-BaiWd0_O.js → SearchInput-DY2g3Bra.js} +2 -2
- package/dist/{SearchInput-CO1poiit.cjs → SearchInput-DkGDEb66.cjs} +2 -2
- package/dist/SearchInputForm/index.cjs +50 -30
- package/dist/SearchInputForm/index.d.cts +9 -7
- package/dist/SearchInputForm/index.d.ts +9 -7
- package/dist/SearchInputForm/index.js +49 -31
- package/dist/SearchResultsContent/index.cjs +6 -6
- package/dist/SearchResultsContent/index.d.cts +4 -4
- package/dist/SearchResultsContent/index.d.ts +4 -4
- package/dist/SearchResultsContent/index.js +6 -6
- package/dist/SearchResultsFilterSidebar/index.cjs +5 -5
- package/dist/SearchResultsFilterSidebar/index.d.cts +1 -1
- package/dist/SearchResultsFilterSidebar/index.d.ts +1 -1
- package/dist/SearchResultsFilterSidebar/index.js +5 -5
- package/dist/SearchResultsStates/index.cjs +6 -6
- package/dist/SearchResultsStates/index.d.cts +2 -2
- package/dist/SearchResultsStates/index.d.ts +6 -6
- package/dist/SearchResultsStates/index.js +6 -6
- package/dist/{SearchResultsStates-CalOf6QP.js → SearchResultsStates-DzNMYUKh.js} +3 -3
- package/dist/{SearchResultsStates-DQlstrHd.cjs → SearchResultsStates-e5W9Ok19.cjs} +3 -3
- package/dist/SparkleAnimation/index.d.cts +2 -2
- package/dist/SparkleAnimation/index.d.ts +2 -2
- package/dist/Spinner/index.cjs +1 -1
- package/dist/Spinner/index.d.cts +2 -2
- package/dist/Spinner/index.d.ts +2 -2
- package/dist/Spinner/index.js +1 -1
- package/dist/SuggestionButton/index.cjs +8 -0
- package/dist/SuggestionButton/index.d.cts +3 -3
- package/dist/SuggestionButton/index.d.ts +3 -3
- package/dist/SuggestionButton/index.js +8 -0
- package/dist/TextInput/index.cjs +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/ToggleButton/index.cjs +1 -1
- package/dist/ToggleButton/index.d.cts +2 -2
- package/dist/ToggleButton/index.d.ts +2 -2
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{index-B-5pBFE7.d.cts → index-BQVJifDf.d.cts} +2 -2
- package/dist/{index-BzY_al-V.d.ts → index-BdNJ2gwC.d.ts} +4 -4
- package/dist/{index-cx3r6TgQ.d.cts → index-DWTTeC2a.d.cts} +4 -4
- package/dist/{index-BcvJf9Sr.d.ts → index-fXyRC79n.d.ts} +2 -2
- package/dist/{searchFilterSidebarVariants-DXabOauB.cjs → searchFilterSidebarVariants-CjDvgxxT.cjs} +1 -1
- package/dist/{searchFilterSidebarVariants-BD4SYugF.js → searchFilterSidebarVariants-Clm9ddD5.js} +1 -1
- package/package.json +1 -1
- package/src/components/SearchAutocomplete/SearchAutocomplete.tsx +51 -11
- package/src/components/SearchInputForm/SearchInputForm.tsx +52 -18
- package/src/components/SuggestionButton/SuggestionButton.tsx +15 -0
- package/src/components/SuggestionButton/types.ts +2 -1
- package/dist/SearchAutocomplete-obO19yzL.js +0 -51
- /package/dist/{SettingsVariant-BsBbdjV5.cjs → SettingsVariant-BzZSQvrw.cjs} +0 -0
- /package/dist/{SettingsVariant-CUSFlJEu.js → SettingsVariant-DMgNg4dw.js} +0 -0
- /package/dist/{Spinner-BrHoB-Zg.js → Spinner-BqTt55uu.js} +0 -0
- /package/dist/{Spinner-B1IEMa00.cjs → Spinner-DjK8ts9E.cjs} +0 -0
- /package/dist/{TextInput-iAKCKHwT.cjs → TextInput-BKNorxPl.cjs} +0 -0
- /package/dist/{TextInput-B_4Bu2vf.js → TextInput-NKOORtYu.js} +0 -0
- /package/dist/{ToggleButton-Br6MgjiG.js → ToggleButton-8P9eNKy1.js} +0 -0
- /package/dist/{ToggleButton-CJ74eu-N.cjs → ToggleButton-DCiR4sB5.cjs} +0 -0
- /package/dist/{colorsConfig-D-MZuBvt.cjs → colorsConfig-CRxY3SQ_.cjs} +0 -0
- /package/dist/{colorsConfig-DEfiLHH0.js → colorsConfig-D_IPWAUL.js} +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { SEARCH_INPUT_TESTID } from '@envive-ai/react-hooks/config/locators/components/search';
|
|
1
3
|
import { SearchAutocomplete } from '../SearchAutocomplete';
|
|
2
4
|
import { SearchInput } from '../SearchInput/SearchInput';
|
|
3
5
|
import { searchInputVariantClasses } from '../SearchInput/searchInputVariants';
|
|
@@ -9,13 +11,14 @@ interface SearchInputFormProps {
|
|
|
9
11
|
autocompleteResults: string[];
|
|
10
12
|
searchBoxPlaceholder: string;
|
|
11
13
|
focusedOptionId: string | undefined;
|
|
12
|
-
isDirty: boolean;
|
|
13
14
|
focusedIndex: number;
|
|
14
15
|
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
15
|
-
onAutocompleteSelect: (suggestion: string) => void;
|
|
16
|
+
onAutocompleteSelect: (suggestion: string, rankPosition?: number) => void;
|
|
16
17
|
onSearchInputChange: (value: string) => void;
|
|
17
18
|
onSearchSubmit: () => void;
|
|
18
|
-
|
|
19
|
+
onSearchInputFocus: () => void;
|
|
20
|
+
onSearchInputBlur: () => void;
|
|
21
|
+
shouldShowAutocomplete: boolean;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export const SearchInputForm = ({
|
|
@@ -24,24 +27,50 @@ export const SearchInputForm = ({
|
|
|
24
27
|
autocompleteResults,
|
|
25
28
|
searchBoxPlaceholder,
|
|
26
29
|
focusedOptionId,
|
|
27
|
-
|
|
30
|
+
shouldShowAutocomplete,
|
|
28
31
|
focusedIndex,
|
|
29
32
|
onKeyDown,
|
|
30
33
|
onAutocompleteSelect,
|
|
31
34
|
onSearchInputChange,
|
|
32
35
|
onSearchSubmit,
|
|
33
|
-
|
|
36
|
+
onSearchInputFocus,
|
|
37
|
+
onSearchInputBlur,
|
|
34
38
|
}: SearchInputFormProps) => {
|
|
35
|
-
const {
|
|
39
|
+
const { autocompleteIconColor } = searchInputVariantClasses[searchInputVariant];
|
|
40
|
+
|
|
41
|
+
const containerClasses = classNames(
|
|
42
|
+
'spiffy-tw-relative',
|
|
43
|
+
'spiffy-tw-w-full'
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const formClasses = classNames({
|
|
47
|
+
'spiffy-tw-grow': true,
|
|
48
|
+
'spiffy-tw-relative': true,
|
|
49
|
+
'spiffy-tw-z-20': shouldShowAutocomplete
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const autocompleteContainerClasses = classNames(
|
|
53
|
+
'spiffy-tw-absolute',
|
|
54
|
+
'spiffy-tw-top-1/2',
|
|
55
|
+
'spiffy-tw-z-10',
|
|
56
|
+
'spiffy-tw-left-0',
|
|
57
|
+
'spiffy-tw-right-0',
|
|
58
|
+
'spiffy-tw-bg-white',
|
|
59
|
+
'spiffy-tw-w-full',
|
|
60
|
+
'spiffy-tw-rounded-b-lg',
|
|
61
|
+
'spiffy-tw-border',
|
|
62
|
+
'spiffy-tw-border-t-0',
|
|
63
|
+
'spiffy-tw-pt-4'
|
|
64
|
+
);
|
|
36
65
|
|
|
37
66
|
return (
|
|
38
|
-
|
|
67
|
+
<div className={containerClasses}>
|
|
39
68
|
<form
|
|
40
69
|
onSubmit={(e) => {
|
|
41
70
|
e.preventDefault();
|
|
42
71
|
onSearchSubmit();
|
|
43
72
|
}}
|
|
44
|
-
className=
|
|
73
|
+
className={formClasses}
|
|
45
74
|
>
|
|
46
75
|
<SearchInput
|
|
47
76
|
value={searchText}
|
|
@@ -49,20 +78,25 @@ export const SearchInputForm = ({
|
|
|
49
78
|
suggestions={autocompleteResults}
|
|
50
79
|
ariaActivedescendant={focusedOptionId}
|
|
51
80
|
searchInputVariant={searchInputVariant}
|
|
52
|
-
dataTestId={
|
|
81
|
+
dataTestId={SEARCH_INPUT_TESTID}
|
|
53
82
|
onKeyDown={onKeyDown}
|
|
54
83
|
onChange={onSearchInputChange}
|
|
84
|
+
onFocus={onSearchInputFocus}
|
|
85
|
+
onBlur={onSearchInputBlur}
|
|
55
86
|
/>
|
|
56
87
|
</form>
|
|
57
|
-
{
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
{shouldShowAutocomplete && (
|
|
89
|
+
<div className={autocompleteContainerClasses}>
|
|
90
|
+
<SearchAutocomplete
|
|
91
|
+
id="autocomplete-results"
|
|
92
|
+
results={autocompleteResults}
|
|
93
|
+
focusedIndex={focusedIndex}
|
|
94
|
+
searchText={searchText}
|
|
95
|
+
iconColor={autocompleteIconColor}
|
|
96
|
+
onSuggestionSelect={onAutocompleteSelect}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
65
99
|
)}
|
|
66
|
-
|
|
100
|
+
</div>
|
|
67
101
|
);
|
|
68
102
|
};
|
|
@@ -105,6 +105,20 @@ const variantClassMap = new Map<SuggestionButtonVariant, string[]>([
|
|
|
105
105
|
BORDER_CLASS,
|
|
106
106
|
],
|
|
107
107
|
],
|
|
108
|
+
// dark accent appears to have been originally been made with the bg color text-accent
|
|
109
|
+
// instead of the design, acccent-primary. This is a correction to match the design without
|
|
110
|
+
// regressing intentional uses of the other styling. text-accent and accent-primary are often
|
|
111
|
+
// the same or very similar colors but in some cases, they are very different to deal with contrast correctly.
|
|
112
|
+
[
|
|
113
|
+
'darkAccentContrast',
|
|
114
|
+
[
|
|
115
|
+
...DARK_BACKGROUND_CLASSES,
|
|
116
|
+
'spiffy-tw-text-[--spiffy-colors-text-light]', // hover:spiffy-tw-text-[--spiffy-colors-text-light]
|
|
117
|
+
'spiffy-tw-fill-[--spiffy-colors-accent-primary]', // hover:spiffy-tw-fill-[--spiffy-colors-accent-primary]
|
|
118
|
+
'spiffy-tw-stroke-[--spiffy-colors-accent-primary]', // hover:spiffy-tw-stroke-[--spiffy-colors-accent-primary]
|
|
119
|
+
BORDER_CLASS,
|
|
120
|
+
],
|
|
121
|
+
],
|
|
108
122
|
[
|
|
109
123
|
'transparent',
|
|
110
124
|
[
|
|
@@ -169,6 +183,7 @@ const borderedVariants = [
|
|
|
169
183
|
'tertiary',
|
|
170
184
|
'dark',
|
|
171
185
|
'darkAccent',
|
|
186
|
+
'darkAccentContrast',
|
|
172
187
|
'darkPrimary',
|
|
173
188
|
'transparent',
|
|
174
189
|
'transparentDark',
|
|
@@ -1,51 +0,0 @@
|
|
|
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 };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|