@envive-ai/react-widgets 0.1.0-arthur-3 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envive-ai/react-widgets",
3
- "version": "0.1.0-arthur-3",
3
+ "version": "0.1.0",
4
4
  "description": "React widget library for Envive services.",
5
5
  "keywords": [
6
6
  "react",
@@ -13,7 +13,7 @@
13
13
  "type": "module",
14
14
  "main": "./dist/index.cjs",
15
15
  "module": "./dist/index.js",
16
- "types": "./dist/index-VWNd4lyI.d.cts",
16
+ "types": "./dist/index.d.cts",
17
17
  "files": [
18
18
  "dist",
19
19
  "src",
@@ -36,8 +36,7 @@
36
36
  "@envive-ai/react-toolkit": "*",
37
37
  "@tailwindcss/typography": "^0.5.15",
38
38
  "classnames": "^2.5.1",
39
- "framer-motion": "^12.23.24",
40
- "jotai": "^2.15.1"
39
+ "framer-motion": "^12.23.24"
41
40
  },
42
41
  "peerDependencies": {
43
42
  "react": ">=18.3.1",
@@ -69,10 +68,6 @@
69
68
  "import": "./dist/index.js",
70
69
  "require": "./dist/index.cjs"
71
70
  },
72
- "./SearchResults": {
73
- "import": "./dist/components/SearchResults/index.js",
74
- "require": "./dist/components/SearchResults/index.cjs"
75
- },
76
71
  "./package.json": "./package.json"
77
72
  },
78
73
  "eslintConfig": {
@@ -1,6 +0,0 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
-
3
- //#region src/SearchEntrypoint/SearchEntrypoint.d.ts
4
- declare const SearchEntrypoint: () => react_jsx_runtime0.JSX.Element;
5
- //#endregion
6
- export { SearchEntrypoint };
@@ -1,6 +0,0 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
-
3
- //#region src/SearchEntrypoint/SearchEntrypoint.d.ts
4
- declare const SearchEntrypoint: () => react_jsx_runtime0.JSX.Element;
5
- //#endregion
6
- export { SearchEntrypoint };
@@ -1,8 +0,0 @@
1
- const require_SearchResults_index = require('../SearchResults/index.cjs');
2
- let react_jsx_runtime = require("react/jsx-runtime");
3
-
4
- //#region src/SearchEntrypoint/SearchEntrypoint.tsx
5
- const SearchEntrypoint = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "SearchEntrypoint" });
6
-
7
- //#endregion
8
- exports.SearchEntrypoint = SearchEntrypoint;
@@ -1,7 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
-
3
- //#region src/SearchEntrypoint/SearchEntrypoint.tsx
4
- const SearchEntrypoint = () => /* @__PURE__ */ jsx("div", { children: "SearchEntrypoint" });
5
-
6
- //#endregion
7
- export { SearchEntrypoint };
@@ -1,6 +0,0 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
-
3
- //#region src/SearchResults/SearchResultsWidget.d.ts
4
- declare const SearchResultsWidget: () => react_jsx_runtime0.JSX.Element;
5
- //#endregion
6
- export { SearchResultsWidget };
@@ -1,6 +0,0 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
-
3
- //#region src/SearchResults/SearchResultsWidget.d.ts
4
- declare const SearchResultsWidget: () => react_jsx_runtime0.JSX.Element;
5
- //#endregion
6
- export { SearchResultsWidget };
@@ -1,146 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let react_jsx_runtime = require("react/jsx-runtime");
25
- let react = require("react");
26
- let jotai = require("jotai");
27
- let __envive_ai_react_hooks_atoms_globalSearch = require("@envive-ai/react-hooks/atoms/globalSearch");
28
- let __envive_ai_react_hooks_atoms_search = require("@envive-ai/react-hooks/atoms/search");
29
- let __envive_ai_react_hooks_hooks_NewOrgConfig = require("@envive-ai/react-hooks/hooks/NewOrgConfig");
30
- let classnames = require("classnames");
31
- classnames = __toESM(classnames);
32
- let __envive_ai_react_toolkit_SearchResultsContent = require("@envive-ai/react-toolkit/SearchResultsContent");
33
- let __envive_ai_react_toolkit_SearchResultsFilterModal = require("@envive-ai/react-toolkit/SearchResultsFilterModal");
34
- let __envive_ai_react_toolkit_SearchResultsToolbar = require("@envive-ai/react-toolkit/SearchResultsToolbar");
35
- let __envive_ai_react_toolkit_util = require("@envive-ai/react-toolkit/util");
36
- let __envive_ai_react_hooks_hooks_Search = require("@envive-ai/react-hooks/hooks/Search");
37
-
38
- //#region src/SearchResults/withSearchResults.tsx
39
- function withSearchResults(Component) {
40
- return function SearchResultsHoc(props) {
41
- const searchHookResult = (0, __envive_ai_react_hooks_hooks_Search.useSearch)();
42
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
43
- ...props,
44
- ...searchHookResult,
45
- productList: searchHookResult.searchData?.products || []
46
- });
47
- };
48
- }
49
-
50
- //#endregion
51
- //#region src/SearchResults/SearchResults.tsx
52
- const SearchResultsComponent = ({ widgetConfig, productCardConfig, merchantShortName, productList, autocompleteResults, searchFilters, availableDynamicFilters, selectedFilterOptions, searchText, query, searchResultsState, isFilterOpen, shouldShowAutocomplete, focusedIndex, focusedOptionId, recommendedProducts, filterButtonText, onSearchInputChange, onSubmitSearch, onAutocompleteSelect, onKeyDown, onSearchInputFocus, onSearchInputBlur, onToggleDynamicFilter, onSelectFilterItem, onRemoveFilter, onClearAllFilters, setIsFilterOpen, searchResultsRef }) => {
53
- const { searchInputVariant, searchFilterSidebarVariant, productGridVariant, searchBoxPlaceholder, noResultsFoundText, isSearchInputSticky = false } = widgetConfig;
54
- const { toolbarRef: ref, isVisible, toolbarHeight: height } = (0, __envive_ai_react_toolkit_util.useStickyVisibility)();
55
- const toolbarRef = isSearchInputSticky ? ref : null;
56
- const finalIsVisible = isSearchInputSticky ? isVisible : true;
57
- const toolbarHeight = isSearchInputSticky ? height : 0;
58
- const stickyToolbarClasses = (0, classnames.default)("spiffy-tw-fixed", "spiffy-tw-top-0", "spiffy-tw-left-0", "spiffy-tw-right-0", "spiffy-tw-transition-transform", "spiffy-tw-duration-300", "spiffy-tw-py-[8px]");
59
- const containerXPaddingClasses = (0, classnames.default)("spiffy-tw-px-[16px]", "sm:spiffy-tw-px-[46px]");
60
- (0, react.useEffect)(() => {
61
- window.scrollTo({
62
- top: 0,
63
- behavior: "smooth"
64
- });
65
- }, [productList]);
66
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
67
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsFilterModal.SearchResultsFilterModal, {
68
- isOpen: isFilterOpen,
69
- setIsOpen: setIsFilterOpen,
70
- searchFilters,
71
- productCount: productList.length,
72
- onSelectFilterItem,
73
- onClearAllFilters,
74
- searchFilterSidebarVariant,
75
- filterButtonText
76
- }),
77
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsToolbar.SearchResultsToolbar, {
78
- className: isSearchInputSticky ? stickyToolbarClasses : "spiffy-tw-py-[8px]",
79
- toolbarRef,
80
- searchInputVariant,
81
- searchBoxPlaceholder,
82
- searchText,
83
- focusedIndex,
84
- focusedOptionId,
85
- autocompleteResults,
86
- filterButtonText,
87
- onKeyDown,
88
- onSearchInputChange,
89
- onSubmitSearch,
90
- onAutocompleteSelect,
91
- onSearchInputFocus,
92
- onSearchInputBlur,
93
- shouldShowAutocomplete,
94
- setIsFilterOpen,
95
- containerXPaddingClasses,
96
- isVisible: finalIsVisible
97
- }),
98
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsContent.SearchResultsContent, {
99
- searchResultsState,
100
- productList,
101
- recommendedProducts,
102
- productCardConfig,
103
- merchantShortName,
104
- searchFilterSidebarVariant,
105
- noResultsFoundText,
106
- productGridVariant,
107
- containerXPaddingClasses,
108
- selectedFilterOptions,
109
- availableDynamicFilters,
110
- onRemoveFilter,
111
- onToggleDynamicFilter,
112
- searchResultsRef,
113
- toolbarHeight,
114
- query
115
- })
116
- ] });
117
- };
118
- const SearchResults = withSearchResults(SearchResultsComponent);
119
-
120
- //#endregion
121
- //#region src/SearchResults/SearchResultsWidget.tsx
122
- const SearchResultsWidget = () => {
123
- const setIsSearchResultsOpen = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_globalSearch.isSearchResultsOpenAtom);
124
- const setSearchSystem = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_search.searchSystemAtom);
125
- const newConfig = (0, __envive_ai_react_hooks_hooks_NewOrgConfig.useNewOrgConfig)();
126
- (0, react.useEffect)(() => {
127
- setSearchSystem(true);
128
- return () => setSearchSystem(false);
129
- }, [setSearchSystem]);
130
- (0, react.useEffect)(() => {
131
- setIsSearchResultsOpen(true);
132
- return () => {
133
- setIsSearchResultsOpen(false);
134
- };
135
- }, [setIsSearchResultsOpen]);
136
- const widgetConfig = (0, react.useMemo)(() => {
137
- if (newConfig && newConfig.frontendConfig?.widgetConfigs) return { ...(newConfig.frontendConfig?.widgetConfigs).find((widget) => widget.key === "searchResultsEntryPoint").config };
138
- return null;
139
- }, [newConfig]);
140
- if (!widgetConfig) return null;
141
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchResults, { widgetConfig });
142
- };
143
-
144
- //#endregion
145
- exports.SearchResultsWidget = SearchResultsWidget;
146
- exports.__toESM = __toESM;
@@ -1,121 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo } from "react";
3
- import { useSetAtom } from "jotai";
4
- import { isSearchResultsOpenAtom } from "@envive-ai/react-hooks/atoms/globalSearch";
5
- import { searchSystemAtom } from "@envive-ai/react-hooks/atoms/search";
6
- import { useNewOrgConfig } from "@envive-ai/react-hooks/hooks/NewOrgConfig";
7
- import classNames from "classnames";
8
- import { SearchResultsContent } from "@envive-ai/react-toolkit/SearchResultsContent";
9
- import { SearchResultsFilterModal } from "@envive-ai/react-toolkit/SearchResultsFilterModal";
10
- import { SearchResultsToolbar } from "@envive-ai/react-toolkit/SearchResultsToolbar";
11
- import { useStickyVisibility } from "@envive-ai/react-toolkit/util";
12
- import { useSearch } from "@envive-ai/react-hooks/hooks/Search";
13
-
14
- //#region src/SearchResults/withSearchResults.tsx
15
- function withSearchResults(Component) {
16
- return function SearchResultsHoc(props) {
17
- const searchHookResult = useSearch();
18
- return /* @__PURE__ */ jsx(Component, {
19
- ...props,
20
- ...searchHookResult,
21
- productList: searchHookResult.searchData?.products || []
22
- });
23
- };
24
- }
25
-
26
- //#endregion
27
- //#region src/SearchResults/SearchResults.tsx
28
- const SearchResultsComponent = ({ widgetConfig, productCardConfig, merchantShortName, productList, autocompleteResults, searchFilters, availableDynamicFilters, selectedFilterOptions, searchText, query, searchResultsState, isFilterOpen, shouldShowAutocomplete, focusedIndex, focusedOptionId, recommendedProducts, filterButtonText, onSearchInputChange, onSubmitSearch, onAutocompleteSelect, onKeyDown, onSearchInputFocus, onSearchInputBlur, onToggleDynamicFilter, onSelectFilterItem, onRemoveFilter, onClearAllFilters, setIsFilterOpen, searchResultsRef }) => {
29
- const { searchInputVariant, searchFilterSidebarVariant, productGridVariant, searchBoxPlaceholder, noResultsFoundText, isSearchInputSticky = false } = widgetConfig;
30
- const { toolbarRef: ref, isVisible, toolbarHeight: height } = useStickyVisibility();
31
- const toolbarRef = isSearchInputSticky ? ref : null;
32
- const finalIsVisible = isSearchInputSticky ? isVisible : true;
33
- const toolbarHeight = isSearchInputSticky ? height : 0;
34
- const stickyToolbarClasses = classNames("spiffy-tw-fixed", "spiffy-tw-top-0", "spiffy-tw-left-0", "spiffy-tw-right-0", "spiffy-tw-transition-transform", "spiffy-tw-duration-300", "spiffy-tw-py-[8px]");
35
- const containerXPaddingClasses = classNames("spiffy-tw-px-[16px]", "sm:spiffy-tw-px-[46px]");
36
- useEffect(() => {
37
- window.scrollTo({
38
- top: 0,
39
- behavior: "smooth"
40
- });
41
- }, [productList]);
42
- return /* @__PURE__ */ jsxs("div", { children: [
43
- /* @__PURE__ */ jsx(SearchResultsFilterModal, {
44
- isOpen: isFilterOpen,
45
- setIsOpen: setIsFilterOpen,
46
- searchFilters,
47
- productCount: productList.length,
48
- onSelectFilterItem,
49
- onClearAllFilters,
50
- searchFilterSidebarVariant,
51
- filterButtonText
52
- }),
53
- /* @__PURE__ */ jsx(SearchResultsToolbar, {
54
- className: isSearchInputSticky ? stickyToolbarClasses : "spiffy-tw-py-[8px]",
55
- toolbarRef,
56
- searchInputVariant,
57
- searchBoxPlaceholder,
58
- searchText,
59
- focusedIndex,
60
- focusedOptionId,
61
- autocompleteResults,
62
- filterButtonText,
63
- onKeyDown,
64
- onSearchInputChange,
65
- onSubmitSearch,
66
- onAutocompleteSelect,
67
- onSearchInputFocus,
68
- onSearchInputBlur,
69
- shouldShowAutocomplete,
70
- setIsFilterOpen,
71
- containerXPaddingClasses,
72
- isVisible: finalIsVisible
73
- }),
74
- /* @__PURE__ */ jsx(SearchResultsContent, {
75
- searchResultsState,
76
- productList,
77
- recommendedProducts,
78
- productCardConfig,
79
- merchantShortName,
80
- searchFilterSidebarVariant,
81
- noResultsFoundText,
82
- productGridVariant,
83
- containerXPaddingClasses,
84
- selectedFilterOptions,
85
- availableDynamicFilters,
86
- onRemoveFilter,
87
- onToggleDynamicFilter,
88
- searchResultsRef,
89
- toolbarHeight,
90
- query
91
- })
92
- ] });
93
- };
94
- const SearchResults = withSearchResults(SearchResultsComponent);
95
-
96
- //#endregion
97
- //#region src/SearchResults/SearchResultsWidget.tsx
98
- const SearchResultsWidget = () => {
99
- const setIsSearchResultsOpen = useSetAtom(isSearchResultsOpenAtom);
100
- const setSearchSystem = useSetAtom(searchSystemAtom);
101
- const newConfig = useNewOrgConfig();
102
- useEffect(() => {
103
- setSearchSystem(true);
104
- return () => setSearchSystem(false);
105
- }, [setSearchSystem]);
106
- useEffect(() => {
107
- setIsSearchResultsOpen(true);
108
- return () => {
109
- setIsSearchResultsOpen(false);
110
- };
111
- }, [setIsSearchResultsOpen]);
112
- const widgetConfig = useMemo(() => {
113
- if (newConfig && newConfig.frontendConfig?.widgetConfigs) return { ...(newConfig.frontendConfig?.widgetConfigs).find((widget) => widget.key === "searchResultsEntryPoint").config };
114
- return null;
115
- }, [newConfig]);
116
- if (!widgetConfig) return null;
117
- return /* @__PURE__ */ jsx(SearchResults, { widgetConfig });
118
- };
119
-
120
- //#endregion
121
- export { SearchResultsWidget };
@@ -1,3 +0,0 @@
1
- // This is a placeholder
2
- export const SearchEntrypoint = () =>
3
- <div>SearchEntrypoint</div>;
@@ -1 +0,0 @@
1
- export { SearchEntrypoint } from './SearchEntrypoint';