@faststore/components 2.0.87-alpha.0 → 2.0.88-alpha.0
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/assets/MagnifyingGlass.d.ts +3 -2
- package/dist/assets/MagnifyingGlass.js +3 -4
- package/dist/assets/MagnifyingGlass.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useSearch.d.ts +7 -0
- package/dist/hooks/useSearch.js +10 -0
- package/dist/hooks/useSearch.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/molecules/SearchAutoComplete/SearchAutoComplete.d.ts +1 -1
- package/dist/molecules/SearchAutoComplete/SearchAutoComplete.js +5 -1
- package/dist/molecules/SearchAutoComplete/SearchAutoComplete.js.map +1 -1
- package/dist/molecules/SearchDropdown/SearchDropdown.d.ts +14 -0
- package/dist/molecules/SearchDropdown/SearchDropdown.js +14 -0
- package/dist/molecules/SearchDropdown/SearchDropdown.js.map +1 -0
- package/dist/molecules/SearchDropdown/index.d.ts +2 -0
- package/dist/molecules/SearchDropdown/index.js +2 -0
- package/dist/molecules/SearchDropdown/index.js.map +1 -0
- package/dist/molecules/SearchHistory/SearchHistory.d.ts +1 -1
- package/dist/molecules/SearchHistory/SearchHistory.js +5 -1
- package/dist/molecules/SearchHistory/SearchHistory.js.map +1 -1
- package/dist/molecules/SearchInputField/SearchInputField.d.ts +36 -0
- package/dist/molecules/SearchInputField/SearchInputField.js +21 -0
- package/dist/molecules/SearchInputField/SearchInputField.js.map +1 -0
- package/dist/molecules/SearchInputField/index.d.ts +2 -0
- package/dist/molecules/SearchInputField/index.js +2 -0
- package/dist/molecules/SearchInputField/index.js.map +1 -0
- package/dist/molecules/SearchProducts/SearchProductItemContent.d.ts +2 -2
- package/dist/molecules/SearchProducts/SearchProducts.d.ts +1 -1
- package/dist/molecules/SearchProducts/SearchProducts.js +5 -1
- package/dist/molecules/SearchProducts/SearchProducts.js.map +1 -1
- package/dist/molecules/SearchProvider/SearchProvider.d.ts +29 -0
- package/dist/molecules/SearchProvider/SearchProvider.js +8 -0
- package/dist/molecules/SearchProvider/SearchProvider.js.map +1 -0
- package/dist/molecules/SearchProvider/index.d.ts +2 -0
- package/dist/molecules/SearchProvider/index.js +2 -0
- package/dist/molecules/SearchProvider/index.js.map +1 -0
- package/dist/molecules/SearchTop/SearchTop.d.ts +0 -8
- package/dist/molecules/SearchTop/SearchTop.js +8 -4
- package/dist/molecules/SearchTop/SearchTop.js.map +1 -1
- package/dist/organisms/SearchInput/SearchInput.d.ts +26 -0
- package/dist/organisms/SearchInput/SearchInput.js +8 -0
- package/dist/organisms/SearchInput/SearchInput.js.map +1 -0
- package/dist/organisms/SearchInput/index.d.ts +2 -0
- package/dist/organisms/SearchInput/index.js +2 -0
- package/dist/organisms/SearchInput/index.js.map +1 -0
- package/package.json +2 -2
- package/src/assets/MagnifyingGlass.tsx +12 -29
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useSearch.ts +12 -0
- package/src/index.ts +18 -0
- package/src/molecules/SearchAutoComplete/SearchAutoComplete.tsx +8 -1
- package/src/molecules/SearchDropdown/SearchDropdown.tsx +45 -0
- package/src/molecules/SearchDropdown/index.ts +2 -0
- package/src/molecules/SearchHistory/SearchHistory.tsx +8 -1
- package/src/molecules/SearchInputField/SearchInputField.tsx +100 -0
- package/src/molecules/SearchInputField/index.ts +5 -0
- package/src/molecules/SearchProducts/SearchProductItemContent.tsx +1 -1
- package/src/molecules/SearchProducts/SearchProducts.tsx +6 -1
- package/src/molecules/SearchProvider/SearchProvider.tsx +49 -0
- package/src/molecules/SearchProvider/index.ts +2 -0
- package/src/molecules/SearchTop/SearchTop.tsx +12 -21
- package/src/organisms/SearchInput/SearchInput.tsx +55 -0
- package/src/organisms/SearchInput/index.ts +2 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
// Icon from Phosphor Icons
|
|
3
|
-
const MagnifyingGlass = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg",
|
|
4
|
-
React.createElement("
|
|
5
|
-
React.createElement("
|
|
6
|
-
React.createElement("line", { x1: "175.4", y1: "175.4", x2: "224", y2: "224", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" })));
|
|
3
|
+
const MagnifyingGlass = ({ size = 24 }) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
|
|
4
|
+
React.createElement("circle", { cx: "11", cy: "11", r: "8" }),
|
|
5
|
+
React.createElement("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })));
|
|
7
6
|
export default MagnifyingGlass;
|
|
8
7
|
//# sourceMappingURL=MagnifyingGlass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MagnifyingGlass.js","sourceRoot":"","sources":["../../src/assets/MagnifyingGlass.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,2BAA2B;AAC3B,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"MagnifyingGlass.js","sourceRoot":"","sources":["../../src/assets/MagnifyingGlass.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,2BAA2B;AAC3B,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAa,EAAE,EAAE,CAAC,CACpD,6BACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO;IAEtB,gCAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,GAAG;IAChC,8BAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,GAAG,CAC1C,CACP,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAuB,KAAK,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAuB,KAAK,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SearchContext } from "../molecules/SearchProvider/SearchProvider";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
export const useSearch = () => {
|
|
4
|
+
const context = useContext(SearchContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
return { inContext: false };
|
|
7
|
+
}
|
|
8
|
+
return { inContext: true, values: context };
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../../src/hooks/useSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAEzC,IAAI,CAAC,OAAO,EAAE;QACV,OAAO,EAAE,SAAS,EAAE,KAAc,EAAE,CAAA;KACvC;IAED,OAAO,EAAE,SAAS,EAAE,IAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AACxD,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -66,8 +66,13 @@ export { default as RadioGroup, RadioOption } from './molecules/RadioGroup';
|
|
|
66
66
|
export type { RadioGroupProps, RadioOptionProps } from './molecules/RadioGroup';
|
|
67
67
|
export { default as Rating } from './molecules/Rating';
|
|
68
68
|
export type { RatingProps } from './molecules/Rating';
|
|
69
|
+
export { default as SearchProvider } from './molecules/SearchProvider';
|
|
70
|
+
export type { SearchProviderContextValue, } from './molecules/SearchProvider';
|
|
71
|
+
export { default as SearchInputField } from './molecules/SearchInputField';
|
|
72
|
+
export type { SearchInputFieldProps, SearchInputFieldRef, } from './molecules/SearchInputField';
|
|
69
73
|
export { default as SearchAutoComplete, SearchAutoCompleteTerm, } from './molecules/SearchAutoComplete';
|
|
70
74
|
export type { SearchAutoCompleteProps, SearchAutoCompleteTermProps, } from './molecules/SearchAutoComplete';
|
|
75
|
+
export { default as SearchDropdown, SearchDropdownProps, } from './molecules/SearchDropdown';
|
|
71
76
|
export { default as SearchHistory, SearchHistoryTerm, } from './molecules/SearchHistory';
|
|
72
77
|
export type { SearchHistoryProps, SearchHistoryTermProps, } from './molecules/SearchHistory';
|
|
73
78
|
export { default as SearchProducts, SearchProductItem, SearchProductItemImage, SearchProductItemContent, } from './molecules/SearchProducts';
|
|
@@ -95,5 +100,7 @@ export { default as PaymentMethods } from './organisms/PaymentMethods';
|
|
|
95
100
|
export type { PaymentMethodsProps } from './organisms/PaymentMethods';
|
|
96
101
|
export { default as PriceRange } from './organisms/PriceRange';
|
|
97
102
|
export type { PriceRangeProps } from './organisms/PriceRange';
|
|
103
|
+
export { default as SearchInput } from './organisms/SearchInput';
|
|
104
|
+
export type { SearchInputProps } from './organisms/SearchInput';
|
|
98
105
|
export { default as SlideOver, SlideOverHeader } from './organisms/SlideOver';
|
|
99
106
|
export type { SlideOverProps, SlideOverHeaderProps, } from './organisms/SlideOver';
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,10 @@ export { default as ProductTitle } from './molecules/ProductTitle';
|
|
|
38
38
|
export { default as RadioField } from './molecules/RadioField';
|
|
39
39
|
export { default as RadioGroup, RadioOption } from './molecules/RadioGroup';
|
|
40
40
|
export { default as Rating } from './molecules/Rating';
|
|
41
|
+
export { default as SearchProvider } from './molecules/SearchProvider';
|
|
42
|
+
export { default as SearchInputField } from './molecules/SearchInputField';
|
|
41
43
|
export { default as SearchAutoComplete, SearchAutoCompleteTerm, } from './molecules/SearchAutoComplete';
|
|
44
|
+
export { default as SearchDropdown, } from './molecules/SearchDropdown';
|
|
42
45
|
export { default as SearchHistory, SearchHistoryTerm, } from './molecules/SearchHistory';
|
|
43
46
|
export { default as SearchProducts, SearchProductItem, SearchProductItemImage, SearchProductItemContent, } from './molecules/SearchProducts';
|
|
44
47
|
export { default as SearchTop, SearchTopTerm } from './molecules/SearchTop';
|
|
@@ -54,5 +57,6 @@ export { default as QuantitySelector } from './molecules/QuantitySelector';
|
|
|
54
57
|
export { default as Hero, HeroImage, HeroHeader } from './organisms/Hero';
|
|
55
58
|
export { default as PaymentMethods } from './organisms/PaymentMethods';
|
|
56
59
|
export { default as PriceRange } from './organisms/PriceRange';
|
|
60
|
+
export { default as SearchInput } from './organisms/SearchInput';
|
|
57
61
|
export { default as SlideOver, SlideOverHeader } from './organisms/SlideOver';
|
|
58
62
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,UAAU,CAAA;AAExB,QAAQ;AACR,cAAc,SAAS,CAAA;AAEvB,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,g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AACZ,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOzE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGtE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAG9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGhE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -5,5 +5,5 @@ export interface SearchAutoCompleteProps extends HTMLAttributes<HTMLDivElement>
|
|
|
5
5
|
*/
|
|
6
6
|
testId?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const SearchAutoComplete: ({ testId, children, ...otherProps }: SearchAutoCompleteProps) => JSX.Element;
|
|
8
|
+
declare const SearchAutoComplete: ({ testId, children, ...otherProps }: SearchAutoCompleteProps) => JSX.Element | null;
|
|
9
9
|
export default SearchAutoComplete;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { List } from '../..';
|
|
2
|
+
import { List, useSearch } from '../..';
|
|
3
3
|
const SearchAutoComplete = ({ testId = 'fs-search-auto-complete', children, ...otherProps }) => {
|
|
4
|
+
const { inContext, values } = useSearch();
|
|
5
|
+
if (inContext && (values.terms.length <= 0 || values.term.length <= 0)) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
4
8
|
return (React.createElement("section", { "data-testid": testId, "data-fs-search-auto-complete": true, ...otherProps },
|
|
5
9
|
React.createElement(List, { as: "ol" }, children)));
|
|
6
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchAutoComplete.js","sourceRoot":"","sources":["../../../src/molecules/SearchAutoComplete/SearchAutoComplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchAutoComplete.js","sourceRoot":"","sources":["../../../src/molecules/SearchAutoComplete/SearchAutoComplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAUvC,MAAM,kBAAkB,GAAG,CAAC,EAC1B,MAAM,GAAG,yBAAyB,EAClC,QAAQ,EACR,GAAG,UAAU,EACW,EAAE,EAAE;IAE5B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAEzC,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE;QACtE,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,CACL,gDAAsB,MAAM,2CAAmC,UAAU;QACvE,oBAAC,IAAI,IAAC,EAAE,EAAC,IAAI,IAAE,QAAQ,CAAQ,CACvB,CACX,CAAA;AACH,CAAC,CAAA;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface SearchDropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
6
|
+
* testing-library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare const SearchDropdown: React.ForwardRefExoticComponent<SearchDropdownProps & {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default SearchDropdown;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useSearch } from '../../hooks';
|
|
3
|
+
const SearchLoading = () => {
|
|
4
|
+
const { inContext, values } = useSearch();
|
|
5
|
+
return (React.createElement(React.Fragment, null, (inContext && values.isLoading) && React.createElement("p", { "data-fs-search-dropdown-loading-text": true }, "Loading...")));
|
|
6
|
+
};
|
|
7
|
+
const SearchDropdown = forwardRef(function SearchDropdown({ testId = 'fs-search-dropdown', children, ...otherProps }, ref) {
|
|
8
|
+
return (React.createElement("div", { ref: ref, "data-fs-search-dropdown": true, "data-testid": testId, ...otherProps },
|
|
9
|
+
React.createElement("section", null,
|
|
10
|
+
React.createElement(SearchLoading, null),
|
|
11
|
+
children)));
|
|
12
|
+
});
|
|
13
|
+
export default SearchDropdown;
|
|
14
|
+
//# sourceMappingURL=SearchDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchDropdown.js","sourceRoot":"","sources":["../../../src/molecules/SearchDropdown/SearchDropdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAWvC,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAEzC,OAAO,CACL,0CACI,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,wFAAsD,CAC1F,CACJ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,UAAU,CAG/B,SAAS,cAAc,CACvB,EACE,MAAM,GAAG,oBAAoB,EAC7B,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,kDAAuC,MAAM,KAAM,UAAU;QACxE;YACE,oBAAC,aAAa,OAAE;YACf,QAAQ,CACD,CACN,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/SearchDropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -17,5 +17,5 @@ export interface SearchHistoryProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
17
17
|
*/
|
|
18
18
|
onClear?: () => void;
|
|
19
19
|
}
|
|
20
|
-
declare const SearchHistory: ({ testId, title, clearLabel, onClear, children, ...otherProps }: SearchHistoryProps) => JSX.Element;
|
|
20
|
+
declare const SearchHistory: ({ testId, title, clearLabel, onClear, children, ...otherProps }: SearchHistoryProps) => JSX.Element | null;
|
|
21
21
|
export default SearchHistory;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { List, Button } from '../..';
|
|
2
|
+
import { List, Button, useSearch } from '../..';
|
|
3
3
|
const SearchHistory = ({ testId = 'fs-search-history', title = 'History', clearLabel = 'Clear History', onClear, children, ...otherProps }) => {
|
|
4
|
+
const { inContext, values } = useSearch();
|
|
5
|
+
if (inContext && (values.term.length !== 0 || values.isLoading)) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
4
8
|
return (React.createElement("section", { "data-testid": testId, "data-fs-search-history": true, ...otherProps },
|
|
5
9
|
React.createElement("header", { "data-fs-search-history-header": true },
|
|
6
10
|
React.createElement("p", { "data-fs-search-history-title": true }, title),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchHistory.js","sourceRoot":"","sources":["../../../src/molecules/SearchHistory/SearchHistory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchHistory.js","sourceRoot":"","sources":["../../../src/molecules/SearchHistory/SearchHistory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAqB/C,MAAM,aAAa,GAAG,CAAC,EACrB,MAAM,GAAG,mBAAmB,EAC5B,KAAK,GAAG,SAAS,EACjB,UAAU,GAAG,eAAe,EAC5B,OAAO,EACP,QAAQ,EACR,GAAG,UAAU,EACM,EAAE,EAAE;IAEvB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAEzC,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,CACL,gDAAsB,MAAM,qCAA6B,UAAU;QACjE;YACE,mEAAiC,KAAK,CAAK;YAC3C,oBAAC,MAAM,IAAC,OAAO,EAAC,UAAU,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,OAAO,IACtD,UAAU,CACJ,CACF;QACT,oBAAC,IAAI,IAAC,EAAE,EAAC,IAAI,IAAE,QAAQ,CAAQ,CACvB,CACX,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AriaAttributes, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onSubmit'>;
|
|
4
|
+
type ButtonProps = {
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
testId?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface SearchInputFieldProps extends InputProps {
|
|
9
|
+
/**
|
|
10
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
11
|
+
*/
|
|
12
|
+
testId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Props for the submit button inside the input.
|
|
15
|
+
*/
|
|
16
|
+
buttonProps?: ButtonProps;
|
|
17
|
+
/**
|
|
18
|
+
* A React component that will be rendered as an icon (submit button).
|
|
19
|
+
* @default <MagnifyingGlass />
|
|
20
|
+
*/
|
|
21
|
+
buttonIcon?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Custom aria-label for input and button.
|
|
24
|
+
*/
|
|
25
|
+
'aria-label'?: AriaAttributes['aria-label'];
|
|
26
|
+
/**
|
|
27
|
+
* Callback function when submitted.
|
|
28
|
+
*/
|
|
29
|
+
onSubmit: (value: string) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface SearchInputFieldRef {
|
|
32
|
+
inputRef?: HTMLInputElement | null;
|
|
33
|
+
formRef?: HTMLFormElement | null;
|
|
34
|
+
}
|
|
35
|
+
declare const SearchInputField: React.ForwardRefExoticComponent<SearchInputFieldProps & React.RefAttributes<SearchInputFieldRef | null>>;
|
|
36
|
+
export default SearchInputField;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { IconButton, Input, MagnifyingGlass } from '../..';
|
|
3
|
+
const SearchInputField = forwardRef(function SearchInputField({ onSubmit, buttonIcon, 'aria-label': ariaLabel = 'search', testId = 'fs-search-input', buttonProps, ...otherProps }, ref) {
|
|
4
|
+
const inputRef = useRef(null);
|
|
5
|
+
const formRef = useRef(null);
|
|
6
|
+
const handleSubmit = (event) => {
|
|
7
|
+
event.preventDefault();
|
|
8
|
+
if (inputRef.current?.value !== '') {
|
|
9
|
+
onSubmit(inputRef.current.value);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
useImperativeHandle(ref, () => ({
|
|
13
|
+
inputRef: inputRef.current,
|
|
14
|
+
formRef: formRef.current,
|
|
15
|
+
}));
|
|
16
|
+
return (React.createElement("form", { ref: formRef, "data-fs-search-input-field": true, "data-testid": testId, onSubmit: handleSubmit, role: "search" },
|
|
17
|
+
React.createElement(Input, { ref: inputRef, "aria-label": ariaLabel, "data-fs-search-input-field-input": true, ...otherProps }),
|
|
18
|
+
React.createElement(IconButton, { type: "submit", "aria-label": "Submit Search", icon: buttonIcon ?? React.createElement(MagnifyingGlass, null), ...buttonProps })));
|
|
19
|
+
});
|
|
20
|
+
export default SearchInputField;
|
|
21
|
+
//# sourceMappingURL=SearchInputField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchInputField.js","sourceRoot":"","sources":["../../../src/molecules/SearchInputField/SearchInputField.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAqC1D,MAAM,gBAAgB,GAAG,UAAU,CAGjC,SAAS,gBAAgB,CACzB,EACE,QAAQ,EACR,UAAU,EACV,YAAY,EAAE,SAAS,GAAG,QAAQ,EAClC,MAAM,GAAG,iBAAiB,EAC1B,WAAW,EACX,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAA;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAA;IAE7C,MAAM,YAAY,GAAG,CAAC,KAAgB,EAAE,EAAE;QACxC,KAAK,CAAC,cAAc,EAAE,CAAA;QAEtB,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,KAAK,EAAE,EAAE;YAClC,QAAQ,CAAC,QAAQ,CAAC,OAAQ,CAAC,KAAK,CAAC,CAAA;SAClC;IACH,CAAC,CAAA;IAED,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,OAAO;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC,CAAA;IAEH,OAAO,CACL,8BACE,GAAG,EAAE,OAAO,qDAEC,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAC,QAAQ;QAEb,oBAAC,KAAK,IACJ,GAAG,EAAE,QAAQ,gBACD,SAAS,+CAEjB,UAAU,GACd;QACF,oBAAC,UAAU,IACT,IAAI,EAAC,QAAQ,gBACF,eAAe,EAC1B,IAAI,EAAE,UAAU,IAAI,oBAAC,eAAe,OAAG,KACnC,WAAW,GACf,CACG,CACR,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/SearchInputField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -6,7 +6,7 @@ interface Price {
|
|
|
6
6
|
listPrice: number;
|
|
7
7
|
formatter: PriceFormatter;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export interface SearchProductItemContentProps {
|
|
10
10
|
/**
|
|
11
11
|
* Specifies the product's title.
|
|
12
12
|
*/
|
|
@@ -15,6 +15,6 @@ export type SearchProductItemContentProps = {
|
|
|
15
15
|
* Specifies product's prices.
|
|
16
16
|
*/
|
|
17
17
|
price: Price;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
declare const SearchProductItemContent: React.ForwardRefExoticComponent<SearchProductItemContentProps & React.RefAttributes<HTMLElement>>;
|
|
20
20
|
export default SearchProductItemContent;
|
|
@@ -9,5 +9,5 @@ export interface SearchProductsProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
*/
|
|
10
10
|
title?: string;
|
|
11
11
|
}
|
|
12
|
-
declare const SearchProductsProps: ({ testId, title, children, ...otherProps }: SearchProductsProps) => JSX.Element;
|
|
12
|
+
declare const SearchProductsProps: ({ testId, title, children, ...otherProps }: SearchProductsProps) => JSX.Element | null;
|
|
13
13
|
export default SearchProductsProps;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { List } from '../..';
|
|
2
|
+
import { List, useSearch } from '../..';
|
|
3
3
|
const SearchProductsProps = ({ testId = 'fs-search-products', title = 'Suggested Products', children, ...otherProps }) => {
|
|
4
|
+
const { inContext, values } = useSearch();
|
|
5
|
+
if (inContext && (values.products.length <= 0)) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
4
8
|
return (React.createElement("section", { "data-testid": testId, "data-fs-search-products": true, ...otherProps },
|
|
5
9
|
React.createElement("header", { "data-fs-search-products-header": true },
|
|
6
10
|
React.createElement("p", { "data-fs-search-products-title": true }, title)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchProducts.js","sourceRoot":"","sources":["../../../src/molecules/SearchProducts/SearchProducts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchProducts.js","sourceRoot":"","sources":["../../../src/molecules/SearchProducts/SearchProducts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAavC,MAAM,mBAAmB,GAAG,CAAC,EAC3B,MAAM,GAAG,oBAAoB,EAC7B,KAAK,GAAG,oBAAoB,EAC5B,QAAQ,EACR,GAAG,UAAU,EACO,EAAE,EAAE;IACxB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAEzC,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE;QAC9C,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,CACL,gDAAsB,MAAM,sCAA8B,UAAU;QAClE;YACE,oEAAkC,KAAK,CAAK,CACrC;QACT,oBAAC,IAAI,IAAC,EAAE,EAAC,IAAI,IAAE,QAAQ,CAAQ,CACvB,CACX,CAAA;AACH,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
export interface SearchProviderContextValue {
|
|
4
|
+
/**
|
|
5
|
+
* Term to be researched.
|
|
6
|
+
*/
|
|
7
|
+
term: string;
|
|
8
|
+
/**
|
|
9
|
+
* Enables a loading state.
|
|
10
|
+
*/
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* List of Suggestion terms.
|
|
14
|
+
*/
|
|
15
|
+
terms: Array<{
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* List of Suggested products.
|
|
20
|
+
*/
|
|
21
|
+
products: {}[];
|
|
22
|
+
/**
|
|
23
|
+
* Callback function when a search term is selected.
|
|
24
|
+
*/
|
|
25
|
+
onSearchSelection?: (term: string, path: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const SearchContext: React.Context<SearchProviderContextValue | null>;
|
|
28
|
+
declare function SearchProvider({ onSearchSelection, children, term, terms, products, isLoading, }: PropsWithChildren<SearchProviderContextValue>): JSX.Element;
|
|
29
|
+
export default SearchProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
export const SearchContext = createContext(null);
|
|
4
|
+
function SearchProvider({ onSearchSelection, children, term, terms, products, isLoading, }) {
|
|
5
|
+
return (React.createElement(SearchContext.Provider, { value: { onSearchSelection, term, terms, products, isLoading } }, children));
|
|
6
|
+
}
|
|
7
|
+
export default SearchProvider;
|
|
8
|
+
//# sourceMappingURL=SearchProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchProvider.js","sourceRoot":"","sources":["../../../src/molecules/SearchProvider/SearchProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAyBrC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CACxC,IAAI,CACL,CAAA;AAED,SAAS,cAAc,CAAC,EACtB,iBAAiB,EACjB,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GACqC;IAC9C,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IACrB,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAE7D,QAAQ,CACc,CAC1B,CAAA;AACH,CAAC;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/SearchProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -9,14 +9,6 @@ export interface SearchTopProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
* Title attribute for the <section> tag rendered by this component.
|
|
10
10
|
*/
|
|
11
11
|
title: string;
|
|
12
|
-
/**
|
|
13
|
-
* Defines the the message displayed while loading.
|
|
14
|
-
*/
|
|
15
|
-
loadingMessage?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Enables a loading state.
|
|
18
|
-
*/
|
|
19
|
-
isLoading?: boolean;
|
|
20
12
|
}
|
|
21
13
|
declare const SearchTop: React.ForwardRefExoticComponent<SearchTopProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
14
|
export default SearchTop;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { List } from '../../';
|
|
4
|
-
const SearchTop = forwardRef(function SearchTop({ testId = 'fs-top-search', title = 'Top Search',
|
|
5
|
-
|
|
3
|
+
import { List, useSearch } from '../../';
|
|
4
|
+
const SearchTop = forwardRef(function SearchTop({ testId = 'fs-top-search', title = 'Top Search', children, ...otherProps }, ref) {
|
|
5
|
+
const { inContext, values } = useSearch();
|
|
6
|
+
if (inContext && (values.term.length !== 0 || values.isLoading)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (React.createElement("section", { ref: ref, "data-testid": testId, "data-fs-search-top": true, ...otherProps },
|
|
6
10
|
React.createElement("header", { "data-fs-search-top-header": true },
|
|
7
11
|
React.createElement("p", { "data-fs-search-top-title": true }, title)),
|
|
8
|
-
React.createElement(List, { as: "ol" }, children)))
|
|
12
|
+
React.createElement(List, { as: "ol" }, children)));
|
|
9
13
|
});
|
|
10
14
|
export default SearchTop;
|
|
11
15
|
//# sourceMappingURL=SearchTop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchTop.js","sourceRoot":"","sources":["../../../src/molecules/SearchTop/SearchTop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchTop.js","sourceRoot":"","sources":["../../../src/molecules/SearchTop/SearchTop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGlC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAaxC,MAAM,SAAS,GAAG,UAAU,CAAiC,SAAS,SAAS,CAC7E,EACE,MAAM,GAAG,eAAe,EACxB,KAAK,GAAG,YAAY,EACpB,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAGH,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAEzC,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,CACL,iCAAS,GAAG,EAAE,GAAG,iBAAe,MAAM,iCAAyB,UAAU;QACrE;YACE,+DAA6B,KAAK,CAAK,CAChC;QACT,oBAAC,IAAI,IAAC,EAAE,EAAC,IAAI,IAAE,QAAQ,CAAQ,CACzB,CACX,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { HTMLAttributes } from 'react';
|
|
3
|
+
import { SearchProviderContextValue } from '../../molecules/SearchProvider';
|
|
4
|
+
export type SearchInputProps = {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
7
|
+
* testing-library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The current status of the Search Dropdown.
|
|
12
|
+
*/
|
|
13
|
+
visibleDropdown: boolean;
|
|
14
|
+
} & HTMLAttributes<HTMLDivElement> & SearchProviderContextValue;
|
|
15
|
+
declare const SearchInput: React.ForwardRefExoticComponent<{
|
|
16
|
+
/**
|
|
17
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
18
|
+
* testing-library, and jest).
|
|
19
|
+
*/
|
|
20
|
+
testId?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The current status of the Search Dropdown.
|
|
23
|
+
*/
|
|
24
|
+
visibleDropdown: boolean;
|
|
25
|
+
} & React.HTMLAttributes<HTMLDivElement> & SearchProviderContextValue & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export default SearchInput;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import SearchProvider from '../../molecules/SearchProvider';
|
|
3
|
+
const SearchInput = forwardRef(function SearchInput({ children, visibleDropdown = false, testId = 'fs-search-input', isLoading, products, term, terms, onSearchSelection, ...otherProps }, ref) {
|
|
4
|
+
return (React.createElement("div", { ref: ref, "data-fs-search-input": true, "data-fs-search-input-dropdown-visible": visibleDropdown, "data-testid": testId, ...otherProps },
|
|
5
|
+
React.createElement(SearchProvider, { onSearchSelection: onSearchSelection, isLoading: isLoading, term: term, products: products, terms: terms }, children)));
|
|
6
|
+
});
|
|
7
|
+
export default SearchInput;
|
|
8
|
+
//# sourceMappingURL=SearchInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../../src/organisms/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,cAA8C,MAAM,gCAAgC,CAAA;AAe3F,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EACE,QAAQ,EACR,eAAe,GAAG,KAAK,EACvB,MAAM,GAAG,iBAAiB,EAC1B,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,iBAAiB,EACjB,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,yEAE+B,eAAe,iBACzC,MAAM,KACf,UAAU;QAEd,oBAAC,cAAc,IACb,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,IAEX,QAAQ,CACM,CACb,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/organisms/SearchInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.88-alpha.0",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"node": "16.18.0",
|
|
31
31
|
"yarn": "1.19.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a9aa7a6572c08e0bd26e384bb66464e633f1ad84"
|
|
34
34
|
}
|
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import
|
|
2
|
+
import { IconProps } from './IconProps'
|
|
3
3
|
|
|
4
4
|
// Icon from Phosphor Icons
|
|
5
|
-
const MagnifyingGlass
|
|
5
|
+
const MagnifyingGlass = ({ size = 24 }: IconProps) => (
|
|
6
6
|
<svg
|
|
7
7
|
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
width={size}
|
|
9
|
+
height={size}
|
|
10
|
+
viewBox="0 0 24 24"
|
|
11
|
+
fill="none"
|
|
12
|
+
stroke="currentColor"
|
|
13
|
+
strokeWidth="2"
|
|
14
|
+
strokeLinecap="round"
|
|
15
|
+
strokeLinejoin="round"
|
|
13
16
|
>
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
cx="116"
|
|
17
|
-
cy="116"
|
|
18
|
-
r="84"
|
|
19
|
-
fill="none"
|
|
20
|
-
stroke="currentColor"
|
|
21
|
-
strokeLinecap="round"
|
|
22
|
-
strokeLinejoin="round"
|
|
23
|
-
strokeWidth="16"
|
|
24
|
-
></circle>
|
|
25
|
-
<line
|
|
26
|
-
x1="175.4"
|
|
27
|
-
y1="175.4"
|
|
28
|
-
x2="224"
|
|
29
|
-
y2="224"
|
|
30
|
-
fill="none"
|
|
31
|
-
stroke="currentColor"
|
|
32
|
-
strokeLinecap="round"
|
|
33
|
-
strokeLinejoin="round"
|
|
34
|
-
strokeWidth="16"
|
|
35
|
-
></line>
|
|
17
|
+
<circle cx="11" cy="11" r="8" />
|
|
18
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
36
19
|
</svg>
|
|
37
20
|
)
|
|
38
21
|
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SearchContext } from "../molecules/SearchProvider/SearchProvider"
|
|
2
|
+
import { useContext } from "react"
|
|
3
|
+
|
|
4
|
+
export const useSearch = () => {
|
|
5
|
+
const context = useContext(SearchContext)
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
return { inContext: false as const }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return { inContext: true as const, values: context }
|
|
12
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -116,6 +116,17 @@ export { default as RadioGroup, RadioOption } from './molecules/RadioGroup'
|
|
|
116
116
|
export type { RadioGroupProps, RadioOptionProps } from './molecules/RadioGroup'
|
|
117
117
|
export { default as Rating } from './molecules/Rating'
|
|
118
118
|
export type { RatingProps } from './molecules/Rating'
|
|
119
|
+
|
|
120
|
+
export { default as SearchProvider } from './molecules/SearchProvider'
|
|
121
|
+
export type {
|
|
122
|
+
SearchProviderContextValue,
|
|
123
|
+
} from './molecules/SearchProvider'
|
|
124
|
+
|
|
125
|
+
export { default as SearchInputField } from './molecules/SearchInputField'
|
|
126
|
+
export type {
|
|
127
|
+
SearchInputFieldProps,
|
|
128
|
+
SearchInputFieldRef,
|
|
129
|
+
} from './molecules/SearchInputField'
|
|
119
130
|
export {
|
|
120
131
|
default as SearchAutoComplete,
|
|
121
132
|
SearchAutoCompleteTerm,
|
|
@@ -124,6 +135,10 @@ export type {
|
|
|
124
135
|
SearchAutoCompleteProps,
|
|
125
136
|
SearchAutoCompleteTermProps,
|
|
126
137
|
} from './molecules/SearchAutoComplete'
|
|
138
|
+
export {
|
|
139
|
+
default as SearchDropdown,
|
|
140
|
+
SearchDropdownProps,
|
|
141
|
+
} from './molecules/SearchDropdown'
|
|
127
142
|
export {
|
|
128
143
|
default as SearchHistory,
|
|
129
144
|
SearchHistoryTerm,
|
|
@@ -190,6 +205,9 @@ export type { PaymentMethodsProps } from './organisms/PaymentMethods'
|
|
|
190
205
|
export { default as PriceRange } from './organisms/PriceRange'
|
|
191
206
|
export type { PriceRangeProps } from './organisms/PriceRange'
|
|
192
207
|
|
|
208
|
+
export { default as SearchInput } from './organisms/SearchInput'
|
|
209
|
+
export type { SearchInputProps } from './organisms/SearchInput'
|
|
210
|
+
|
|
193
211
|
export { default as SlideOver, SlideOverHeader } from './organisms/SlideOver'
|
|
194
212
|
export type {
|
|
195
213
|
SlideOverProps,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react'
|
|
2
|
-
import { List } from '../..'
|
|
2
|
+
import { List, useSearch } from '../..'
|
|
3
3
|
|
|
4
4
|
export interface SearchAutoCompleteProps
|
|
5
5
|
extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -14,6 +14,13 @@ const SearchAutoComplete = ({
|
|
|
14
14
|
children,
|
|
15
15
|
...otherProps
|
|
16
16
|
}: SearchAutoCompleteProps) => {
|
|
17
|
+
|
|
18
|
+
const { inContext, values } = useSearch()
|
|
19
|
+
|
|
20
|
+
if (inContext && (values.terms.length <= 0 || values.term.length <= 0)) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
return (
|
|
18
25
|
<section data-testid={testId} data-fs-search-auto-complete {...otherProps}>
|
|
19
26
|
<List as="ol">{children}</List>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, PropsWithChildren } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
import { useSearch } from '../../hooks'
|
|
4
|
+
|
|
5
|
+
export interface SearchDropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
8
|
+
* testing-library, and jest).
|
|
9
|
+
*/
|
|
10
|
+
testId?: string
|
|
11
|
+
children?: ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const SearchLoading = () => {
|
|
15
|
+
const { inContext, values } = useSearch()
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
{ (inContext && values.isLoading) && <p data-fs-search-dropdown-loading-text>Loading...</p> }
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const SearchDropdown = forwardRef<
|
|
25
|
+
HTMLDivElement,
|
|
26
|
+
PropsWithChildren<SearchDropdownProps>
|
|
27
|
+
>(function SearchDropdown(
|
|
28
|
+
{
|
|
29
|
+
testId = 'fs-search-dropdown',
|
|
30
|
+
children,
|
|
31
|
+
...otherProps
|
|
32
|
+
},
|
|
33
|
+
ref
|
|
34
|
+
) {
|
|
35
|
+
return (
|
|
36
|
+
<div ref={ref} data-fs-search-dropdown data-testid={testId} {...otherProps}>
|
|
37
|
+
<section>
|
|
38
|
+
<SearchLoading/>
|
|
39
|
+
{children}
|
|
40
|
+
</section>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export default SearchDropdown
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react'
|
|
2
|
-
import { List, Button } from '../..'
|
|
2
|
+
import { List, Button, useSearch } from '../..'
|
|
3
3
|
|
|
4
4
|
export interface SearchHistoryProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
/**
|
|
@@ -28,6 +28,13 @@ const SearchHistory = ({
|
|
|
28
28
|
children,
|
|
29
29
|
...otherProps
|
|
30
30
|
}: SearchHistoryProps) => {
|
|
31
|
+
|
|
32
|
+
const { inContext, values } = useSearch()
|
|
33
|
+
|
|
34
|
+
if (inContext && (values.term.length !== 0 || values.isLoading)) {
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
return (
|
|
32
39
|
<section data-testid={testId} data-fs-search-history {...otherProps}>
|
|
33
40
|
<header data-fs-search-history-header>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AriaAttributes,
|
|
3
|
+
FormEvent,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react'
|
|
7
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react'
|
|
8
|
+
|
|
9
|
+
import { IconButton, Input, MagnifyingGlass } from '../..'
|
|
10
|
+
|
|
11
|
+
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onSubmit'>
|
|
12
|
+
|
|
13
|
+
type ButtonProps = {
|
|
14
|
+
onClick?: () => void
|
|
15
|
+
testId?: string
|
|
16
|
+
}
|
|
17
|
+
export interface SearchInputFieldProps extends InputProps {
|
|
18
|
+
/**
|
|
19
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
20
|
+
*/
|
|
21
|
+
testId?: string
|
|
22
|
+
/**
|
|
23
|
+
* Props for the submit button inside the input.
|
|
24
|
+
*/
|
|
25
|
+
buttonProps?: ButtonProps
|
|
26
|
+
/**
|
|
27
|
+
* A React component that will be rendered as an icon (submit button).
|
|
28
|
+
* @default <MagnifyingGlass />
|
|
29
|
+
*/
|
|
30
|
+
buttonIcon?: ReactNode
|
|
31
|
+
/**
|
|
32
|
+
* Custom aria-label for input and button.
|
|
33
|
+
*/
|
|
34
|
+
'aria-label'?: AriaAttributes['aria-label']
|
|
35
|
+
/**
|
|
36
|
+
* Callback function when submitted.
|
|
37
|
+
*/
|
|
38
|
+
onSubmit: (value: string) => void
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SearchInputFieldRef {
|
|
42
|
+
inputRef?: HTMLInputElement | null
|
|
43
|
+
formRef?: HTMLFormElement | null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const SearchInputField = forwardRef<
|
|
47
|
+
SearchInputFieldRef | null,
|
|
48
|
+
SearchInputFieldProps
|
|
49
|
+
>(function SearchInputField(
|
|
50
|
+
{
|
|
51
|
+
onSubmit,
|
|
52
|
+
buttonIcon,
|
|
53
|
+
'aria-label': ariaLabel = 'search',
|
|
54
|
+
testId = 'fs-search-input',
|
|
55
|
+
buttonProps,
|
|
56
|
+
...otherProps
|
|
57
|
+
},
|
|
58
|
+
ref
|
|
59
|
+
) {
|
|
60
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
61
|
+
const formRef = useRef<HTMLFormElement>(null)
|
|
62
|
+
|
|
63
|
+
const handleSubmit = (event: FormEvent) => {
|
|
64
|
+
event.preventDefault()
|
|
65
|
+
|
|
66
|
+
if (inputRef.current?.value !== '') {
|
|
67
|
+
onSubmit(inputRef.current!.value)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
useImperativeHandle(ref, () => ({
|
|
72
|
+
inputRef: inputRef.current,
|
|
73
|
+
formRef: formRef.current,
|
|
74
|
+
}))
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<form
|
|
78
|
+
ref={formRef}
|
|
79
|
+
data-fs-search-input-field
|
|
80
|
+
data-testid={testId}
|
|
81
|
+
onSubmit={handleSubmit}
|
|
82
|
+
role="search"
|
|
83
|
+
>
|
|
84
|
+
<Input
|
|
85
|
+
ref={inputRef}
|
|
86
|
+
aria-label={ariaLabel}
|
|
87
|
+
data-fs-search-input-field-input
|
|
88
|
+
{...otherProps}
|
|
89
|
+
/>
|
|
90
|
+
<IconButton
|
|
91
|
+
type="submit"
|
|
92
|
+
aria-label="Submit Search"
|
|
93
|
+
icon={buttonIcon ?? <MagnifyingGlass />}
|
|
94
|
+
{...buttonProps}
|
|
95
|
+
/>
|
|
96
|
+
</form>
|
|
97
|
+
)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
export default SearchInputField
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react'
|
|
2
|
-
import { List } from '../..'
|
|
2
|
+
import { List, useSearch } from '../..'
|
|
3
3
|
|
|
4
4
|
export interface SearchProductsProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
/**
|
|
@@ -18,6 +18,11 @@ const SearchProductsProps = ({
|
|
|
18
18
|
children,
|
|
19
19
|
...otherProps
|
|
20
20
|
}: SearchProductsProps) => {
|
|
21
|
+
const { inContext, values } = useSearch()
|
|
22
|
+
|
|
23
|
+
if (inContext && (values.products.length <= 0)) {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
21
26
|
return (
|
|
22
27
|
<section data-testid={testId} data-fs-search-products {...otherProps}>
|
|
23
28
|
<header data-fs-search-products-header>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { PropsWithChildren } from 'react'
|
|
3
|
+
import { createContext } from 'react'
|
|
4
|
+
|
|
5
|
+
export interface SearchProviderContextValue {
|
|
6
|
+
/**
|
|
7
|
+
* Term to be researched.
|
|
8
|
+
*/
|
|
9
|
+
term: string
|
|
10
|
+
/**
|
|
11
|
+
* Enables a loading state.
|
|
12
|
+
*/
|
|
13
|
+
isLoading: boolean
|
|
14
|
+
/**
|
|
15
|
+
* List of Suggestion terms.
|
|
16
|
+
*/
|
|
17
|
+
terms: Array<{ value: string }>
|
|
18
|
+
/**
|
|
19
|
+
* List of Suggested products.
|
|
20
|
+
*/
|
|
21
|
+
products: {}[]
|
|
22
|
+
/**
|
|
23
|
+
* Callback function when a search term is selected.
|
|
24
|
+
*/
|
|
25
|
+
onSearchSelection?: (term: string, path: string) => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SearchContext = createContext<SearchProviderContextValue | null>(
|
|
29
|
+
null
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
function SearchProvider({
|
|
33
|
+
onSearchSelection,
|
|
34
|
+
children,
|
|
35
|
+
term,
|
|
36
|
+
terms,
|
|
37
|
+
products,
|
|
38
|
+
isLoading,
|
|
39
|
+
}: PropsWithChildren<SearchProviderContextValue>) {
|
|
40
|
+
return (
|
|
41
|
+
<SearchContext.Provider
|
|
42
|
+
value={{ onSearchSelection, term, terms, products, isLoading }}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</SearchContext.Provider>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default SearchProvider
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { forwardRef } from 'react'
|
|
3
3
|
import type { HTMLAttributes } from 'react'
|
|
4
4
|
|
|
5
|
-
import { List } from '../../'
|
|
5
|
+
import { List, useSearch } from '../../'
|
|
6
6
|
|
|
7
7
|
export interface SearchTopProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
/**
|
|
@@ -13,39 +13,30 @@ export interface SearchTopProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
13
13
|
* Title attribute for the <section> tag rendered by this component.
|
|
14
14
|
*/
|
|
15
15
|
title: string
|
|
16
|
-
/**
|
|
17
|
-
* Defines the the message displayed while loading.
|
|
18
|
-
*/
|
|
19
|
-
loadingMessage?: string
|
|
20
|
-
/**
|
|
21
|
-
* Enables a loading state.
|
|
22
|
-
*/
|
|
23
|
-
isLoading?: boolean
|
|
24
16
|
}
|
|
25
17
|
|
|
26
18
|
const SearchTop = forwardRef<HTMLDivElement, SearchTopProps>(function SearchTop(
|
|
27
19
|
{
|
|
28
20
|
testId = 'fs-top-search',
|
|
29
21
|
title = 'Top Search',
|
|
30
|
-
loadingMessage = 'Loading...',
|
|
31
|
-
isLoading,
|
|
32
22
|
children,
|
|
33
23
|
...otherProps
|
|
34
24
|
},
|
|
35
25
|
ref
|
|
36
26
|
) {
|
|
27
|
+
|
|
28
|
+
const { inContext, values } = useSearch()
|
|
29
|
+
|
|
30
|
+
if (inContext && (values.term.length !== 0 || values.isLoading)) {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
|
|
37
34
|
return (
|
|
38
35
|
<section ref={ref} data-testid={testId} data-fs-search-top {...otherProps}>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<header data-fs-search-top-header>
|
|
44
|
-
<p data-fs-search-top-title>{title}</p>
|
|
45
|
-
</header>
|
|
46
|
-
<List as="ol">{children}</List>
|
|
47
|
-
</>
|
|
48
|
-
)}
|
|
36
|
+
<header data-fs-search-top-header>
|
|
37
|
+
<p data-fs-search-top-title>{title}</p>
|
|
38
|
+
</header>
|
|
39
|
+
<List as="ol">{children}</List>
|
|
49
40
|
</section>
|
|
50
41
|
)
|
|
51
42
|
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import type { HTMLAttributes } from 'react'
|
|
3
|
+
import SearchProvider, { SearchProviderContextValue } from '../../molecules/SearchProvider'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type SearchInputProps = {
|
|
7
|
+
/**
|
|
8
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
9
|
+
* testing-library, and jest).
|
|
10
|
+
*/
|
|
11
|
+
testId?: string
|
|
12
|
+
/**
|
|
13
|
+
* The current status of the Search Dropdown.
|
|
14
|
+
*/
|
|
15
|
+
visibleDropdown: boolean
|
|
16
|
+
} & HTMLAttributes<HTMLDivElement> & SearchProviderContextValue
|
|
17
|
+
|
|
18
|
+
const SearchInput = forwardRef<HTMLDivElement, SearchInputProps>(
|
|
19
|
+
function SearchInput(
|
|
20
|
+
{
|
|
21
|
+
children,
|
|
22
|
+
visibleDropdown = false,
|
|
23
|
+
testId = 'fs-search-input',
|
|
24
|
+
isLoading,
|
|
25
|
+
products,
|
|
26
|
+
term,
|
|
27
|
+
terms,
|
|
28
|
+
onSearchSelection,
|
|
29
|
+
...otherProps
|
|
30
|
+
},
|
|
31
|
+
ref
|
|
32
|
+
) {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
ref={ref}
|
|
36
|
+
data-fs-search-input
|
|
37
|
+
data-fs-search-input-dropdown-visible={visibleDropdown}
|
|
38
|
+
data-testid={testId}
|
|
39
|
+
{...otherProps}
|
|
40
|
+
>
|
|
41
|
+
<SearchProvider
|
|
42
|
+
onSearchSelection={onSearchSelection}
|
|
43
|
+
isLoading={isLoading}
|
|
44
|
+
term={term}
|
|
45
|
+
products={products}
|
|
46
|
+
terms={terms}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</SearchProvider>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
export default SearchInput
|