@scayle/storefront-nuxt 7.63.0 → 7.64.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/CHANGELOG.md +6 -0
- package/dist/module.json +1 -1
- package/dist/runtime/composables/storefront/useSearch.d.ts +5 -4
- package/dist/runtime/composables/storefront/useSearch.mjs +2 -1
- package/dist/runtime/composables/storefront/useStorefrontSearch.d.ts +15 -0
- package/dist/runtime/composables/storefront/useStorefrontSearch.mjs +64 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/module.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type SearchInput, type SearchOptions } from '@scayle/storefront-core';
|
|
1
|
+
import { type SearchInput, type SearchOptions, type TypeaheadSuggestionsEndpointResponseData } from '@scayle/storefront-core';
|
|
2
2
|
type Options = Partial<{
|
|
3
3
|
params: SearchOptions;
|
|
4
4
|
key: string;
|
|
5
5
|
}>;
|
|
6
|
+
/** @deprecated `useSearch` is deprecated. Please, use `useSearchSuggestions` or `useSearchResolve` */
|
|
6
7
|
export declare const useSearch: ({ params, key }?: Options) => {
|
|
7
|
-
data:
|
|
8
|
-
pending:
|
|
9
|
-
searchQuery:
|
|
8
|
+
data: import("vue").Ref<TypeaheadSuggestionsEndpointResponseData | undefined>;
|
|
9
|
+
pending: import("vue").Ref<boolean>;
|
|
10
|
+
searchQuery: import("vue").Ref<string>;
|
|
10
11
|
resetSearch: () => void;
|
|
11
12
|
search: ({ term, slug, productLimit }: SearchInput) => Promise<void>;
|
|
12
13
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { useState } from "nuxt/app";
|
|
1
2
|
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
2
3
|
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
3
|
-
import {
|
|
4
|
+
import { useNuxtApp, toValue } from "#imports";
|
|
4
5
|
export const useSearch = ({ params, key = "search" } = {}) => {
|
|
5
6
|
const data = useState(
|
|
6
7
|
`${key}-data`,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SearchV2SuggestionsEndpointResponseData, type SearchV2With } from '@scayle/storefront-core';
|
|
2
|
+
export type SearchOptions = Partial<{
|
|
3
|
+
params: Partial<{
|
|
4
|
+
categoryId: number;
|
|
5
|
+
with: SearchV2With;
|
|
6
|
+
}>;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useStorefrontSearch: (searchQuery: Ref<string>, { params, key }?: SearchOptions) => {
|
|
10
|
+
data: import("vue").Ref<SearchV2SuggestionsEndpointResponseData | undefined>;
|
|
11
|
+
pending: import("vue").Ref<boolean>;
|
|
12
|
+
resetSearch: () => void;
|
|
13
|
+
getSearchSuggestions: () => Promise<void>;
|
|
14
|
+
resolveSearch: () => Promise<import("@scayle/storefront-core").SearchEntity | null | undefined>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useState } from "nuxt/app";
|
|
2
|
+
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
3
|
+
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
4
|
+
import { useNuxtApp, toValue } from "#imports";
|
|
5
|
+
export const useStorefrontSearch = (searchQuery, { params, key = "search" } = {}) => {
|
|
6
|
+
const data = useState(
|
|
7
|
+
`${key}-data`,
|
|
8
|
+
() => void 0
|
|
9
|
+
);
|
|
10
|
+
const nuxtApp = useNuxtApp();
|
|
11
|
+
const pending = useState(`${key}-pending`, () => false);
|
|
12
|
+
const error = useState(
|
|
13
|
+
`${key}-error`,
|
|
14
|
+
() => void 0
|
|
15
|
+
);
|
|
16
|
+
const status = useState(`${key}-error`, () => "idle");
|
|
17
|
+
const shop = useCurrentShop();
|
|
18
|
+
const getSearchSuggestions = async () => {
|
|
19
|
+
pending.value = true;
|
|
20
|
+
status.value = "pending";
|
|
21
|
+
if (!searchQuery.value) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
data.value = await rpcCall(
|
|
26
|
+
nuxtApp,
|
|
27
|
+
"getSearchSuggestions",
|
|
28
|
+
toValue(shop)
|
|
29
|
+
)({
|
|
30
|
+
term: String(searchQuery.value),
|
|
31
|
+
...params
|
|
32
|
+
});
|
|
33
|
+
} catch (e) {
|
|
34
|
+
error.value = e;
|
|
35
|
+
} finally {
|
|
36
|
+
pending.value = false;
|
|
37
|
+
status.value = error.value ? "error" : "success";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const resolveSearch = async () => {
|
|
41
|
+
if (!searchQuery.value) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
return await rpcCall(
|
|
45
|
+
nuxtApp,
|
|
46
|
+
"resolveSearch",
|
|
47
|
+
toValue(shop)
|
|
48
|
+
)({
|
|
49
|
+
term: searchQuery.value,
|
|
50
|
+
...params
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const resetSearch = () => {
|
|
54
|
+
searchQuery.value = "";
|
|
55
|
+
data.value = { suggestions: [] };
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
data,
|
|
59
|
+
pending,
|
|
60
|
+
resetSearch,
|
|
61
|
+
getSearchSuggestions,
|
|
62
|
+
resolveSearch
|
|
63
|
+
};
|
|
64
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.64.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"prettier": "3.0.0",
|
|
95
95
|
"publint": "0.2.7",
|
|
96
96
|
"vitest": "1.4.0",
|
|
97
|
-
"vue-tsc": "2.0.
|
|
97
|
+
"vue-tsc": "2.0.11"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"h3": "^1.10.0",
|