@frontic/nuxt 0.0.2 → 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/LICENSE +21 -0
- package/dist/module.d.mts +87 -10
- package/dist/module.json +1 -1
- package/dist/module.mjs +117 -56
- package/dist/runtime/composables/blocks.d.ts +0 -0
- package/dist/runtime/composables/blocks.js +31 -0
- package/dist/runtime/composables/index.js +7 -0
- package/dist/runtime/composables/listings.js +15 -9
- package/dist/runtime/composables/pages.d.ts +0 -0
- package/dist/runtime/composables/pages.js +31 -0
- package/dist/runtime/composables/useFronticBlock.d.ts +0 -0
- package/dist/runtime/composables/useFronticBlock.js +31 -0
- package/dist/runtime/composables/useFronticClient.d.ts +0 -0
- package/dist/runtime/composables/useFronticClient.js +67 -0
- package/dist/runtime/composables/useFronticContext.d.ts +0 -0
- package/dist/runtime/composables/useFronticContext.js +77 -0
- package/dist/runtime/composables/useFronticListing.js +26 -201
- package/dist/runtime/composables/useFronticPage.d.ts +0 -0
- package/dist/runtime/composables/useFronticPage.js +74 -0
- package/dist/runtime/composables/useFronticSearch.d.ts +0 -0
- package/dist/runtime/composables/useFronticSearch.js +321 -0
- package/dist/runtime/server/api/frontic/[...path].d.ts +0 -0
- package/dist/runtime/server/api/frontic/[...path].js +21 -0
- package/dist/runtime/types/search.d.ts +0 -0
- package/dist/runtime/types/search.js +0 -0
- package/dist/runtime/utils/state-helpers.js +19 -19
- package/dist/types.d.mts +4 -2
- package/package.json +20 -20
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -48
- package/dist/types.d.ts +0 -7
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { useQuery, useMutation, useQueryCache } from "@pinia/colada";
|
|
2
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
3
|
+
import { makeLogicalFilter, manageFilter, removeFilter } from "../utils/filter-helpers.js";
|
|
4
|
+
import { makeFilterState, processAvailableFilters, processAvailableSorts, applyFilterConfig, countActiveFilters, parseSortString, isSortAllowed } from "../utils/state-helpers.js";
|
|
5
|
+
import { fetchListingQuery } from "./listings.js";
|
|
6
|
+
export function useFronticSearch(name, params, options) {
|
|
7
|
+
const queryCache = useQueryCache();
|
|
8
|
+
const listingName = name;
|
|
9
|
+
const cacheKey = options?.cacheKey ?? String(name);
|
|
10
|
+
const contextKey = options?.contextKey;
|
|
11
|
+
const contextDomain = options?.contextDomain;
|
|
12
|
+
const requestUrl = options?.requestUrl;
|
|
13
|
+
const searchTermThreshold = options?.searchTermThreshold ?? 2;
|
|
14
|
+
const searchDebounce = options?.searchDebounce ?? 200;
|
|
15
|
+
const orFilter = options?.orFilter ?? [];
|
|
16
|
+
const filter = options?.filter;
|
|
17
|
+
const sorting = options?.sorting;
|
|
18
|
+
const disableSearch = options?.disableSearch ?? false;
|
|
19
|
+
const disableFilter = options?.disableFilter ?? false;
|
|
20
|
+
const disableSorting = options?.disableSorting ?? false;
|
|
21
|
+
const staleTime = options?.staleTime ?? 1e3 * 60 * 5;
|
|
22
|
+
const filterConfig = filter || {};
|
|
23
|
+
const sortConfig = sorting || {};
|
|
24
|
+
const searchTerm = useState(`${cacheKey}-searchTerm`, () => "");
|
|
25
|
+
const _orFilterList = useState(`${cacheKey}-orFilterList`, () => []);
|
|
26
|
+
const _andFilterList = useState(`${cacheKey}-andFilterList`, () => []);
|
|
27
|
+
const _sortQuery = useState(`${cacheKey}-sortQuery`, () => void 0);
|
|
28
|
+
const searchState = useState(`${cacheKey}-searchState`, () => ({
|
|
29
|
+
active: {
|
|
30
|
+
filter: {},
|
|
31
|
+
sorting: void 0,
|
|
32
|
+
search: "",
|
|
33
|
+
page: 1,
|
|
34
|
+
count: {
|
|
35
|
+
filter: 0,
|
|
36
|
+
sorting: 0
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
available: {
|
|
40
|
+
filter: [],
|
|
41
|
+
sorting: [],
|
|
42
|
+
nextPage: false,
|
|
43
|
+
prevPage: false,
|
|
44
|
+
count: {
|
|
45
|
+
filter: 0,
|
|
46
|
+
sorting: 0,
|
|
47
|
+
result: 0,
|
|
48
|
+
page: 0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
const apiQuery = computed(() => ({
|
|
53
|
+
sort: !disableSorting ? _sortQuery.value : void 0,
|
|
54
|
+
search: !disableSearch && searchTerm.value && searchTerm.value.trim().length > searchTermThreshold ? searchTerm.value : void 0,
|
|
55
|
+
filter: !disableFilter ? [...makeLogicalFilter("or", _orFilterList.value), ...makeLogicalFilter("and", _andFilterList.value)] : void 0
|
|
56
|
+
}));
|
|
57
|
+
const { data, status, refresh, refetch } = useQuery(
|
|
58
|
+
fetchListingQuery({
|
|
59
|
+
name: listingName,
|
|
60
|
+
params,
|
|
61
|
+
query: apiQuery,
|
|
62
|
+
contextKey,
|
|
63
|
+
contextDomain,
|
|
64
|
+
requestUrl,
|
|
65
|
+
staleTime
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
const { mutateAsync: loadNext } = useMutation({
|
|
69
|
+
mutation: async () => {
|
|
70
|
+
const nextPage = data.value?.page;
|
|
71
|
+
if (!nextPage?.next) return void 0;
|
|
72
|
+
const nextPageQuery = fetchListingQuery({
|
|
73
|
+
name: listingName,
|
|
74
|
+
params,
|
|
75
|
+
query: apiQuery,
|
|
76
|
+
contextKey,
|
|
77
|
+
contextDomain,
|
|
78
|
+
requestUrl,
|
|
79
|
+
page: ref(nextPage.next),
|
|
80
|
+
staleTime
|
|
81
|
+
});
|
|
82
|
+
return await nextPageQuery.query();
|
|
83
|
+
},
|
|
84
|
+
onSuccess: (data2) => {
|
|
85
|
+
const newData = data2;
|
|
86
|
+
const newItems = newData?.items || [];
|
|
87
|
+
if (!newItems.length) return;
|
|
88
|
+
const cacheKeyValue = [cacheKey, JSON.stringify(apiQuery.value)];
|
|
89
|
+
const oldData = queryCache.getQueryData(cacheKeyValue);
|
|
90
|
+
queryCache.setQueryData(cacheKeyValue, {
|
|
91
|
+
...newData,
|
|
92
|
+
items: [...oldData?.items || [], ...newItems]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (!disableSearch) {
|
|
97
|
+
watch(searchTerm, (newTerm) => {
|
|
98
|
+
if (newTerm.trim().length > searchTermThreshold || searchState.value.active.search) {
|
|
99
|
+
triggerSearchFromInput();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
watch(
|
|
104
|
+
data,
|
|
105
|
+
(newData) => {
|
|
106
|
+
if (newData) {
|
|
107
|
+
updateState(newData);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{ immediate: true }
|
|
111
|
+
);
|
|
112
|
+
function updateState(response) {
|
|
113
|
+
const rawFilters = response.filter;
|
|
114
|
+
const pageData = response.page;
|
|
115
|
+
let activeFilters = makeFilterState(rawFilters);
|
|
116
|
+
activeFilters = applyFilterConfig(activeFilters, filterConfig);
|
|
117
|
+
const availableFilters = processAvailableFilters(rawFilters, filterConfig);
|
|
118
|
+
const availableSorts = processAvailableSorts(sortConfig);
|
|
119
|
+
const activeFilterCount = countActiveFilters(activeFilters);
|
|
120
|
+
searchState.value = {
|
|
121
|
+
active: {
|
|
122
|
+
filter: activeFilters,
|
|
123
|
+
sorting: _sortQuery.value,
|
|
124
|
+
search: apiQuery.value.search ?? "",
|
|
125
|
+
page: pageData?.current ?? 1,
|
|
126
|
+
count: {
|
|
127
|
+
filter: activeFilterCount,
|
|
128
|
+
sorting: _sortQuery.value ? 1 : 0
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
available: {
|
|
132
|
+
filter: availableFilters,
|
|
133
|
+
sorting: availableSorts,
|
|
134
|
+
nextPage: pageData?.next !== void 0,
|
|
135
|
+
prevPage: pageData?.prev !== void 0,
|
|
136
|
+
count: {
|
|
137
|
+
filter: availableFilters.length,
|
|
138
|
+
sorting: availableSorts.length,
|
|
139
|
+
result: response.total ?? 0,
|
|
140
|
+
page: pageData?.total ?? 1
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function refreshListing() {
|
|
146
|
+
await refresh();
|
|
147
|
+
if (data.value) {
|
|
148
|
+
updateState(data.value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const triggerSearchFromInput = useDebounceFn(refreshListing, searchDebounce);
|
|
152
|
+
async function paginate(direction) {
|
|
153
|
+
const pageData = data.value?.page;
|
|
154
|
+
const pageNumber = direction === "next" ? pageData?.next : pageData?.prev;
|
|
155
|
+
if (!pageNumber) return false;
|
|
156
|
+
searchState.value.active.page = pageNumber;
|
|
157
|
+
const pageQuery = fetchListingQuery({
|
|
158
|
+
name: listingName,
|
|
159
|
+
params,
|
|
160
|
+
query: apiQuery,
|
|
161
|
+
contextKey,
|
|
162
|
+
contextDomain,
|
|
163
|
+
requestUrl,
|
|
164
|
+
page: ref(pageNumber),
|
|
165
|
+
staleTime
|
|
166
|
+
});
|
|
167
|
+
const response = await pageQuery.query();
|
|
168
|
+
if (response) {
|
|
169
|
+
updateState(response);
|
|
170
|
+
}
|
|
171
|
+
return !!response;
|
|
172
|
+
}
|
|
173
|
+
async function sortResult(sortBy) {
|
|
174
|
+
if (disableSorting) return;
|
|
175
|
+
if (!sortBy) {
|
|
176
|
+
_sortQuery.value = void 0;
|
|
177
|
+
} else {
|
|
178
|
+
const sortValue = parseSortString(sortBy);
|
|
179
|
+
if (!sortValue) {
|
|
180
|
+
_sortQuery.value = void 0;
|
|
181
|
+
} else {
|
|
182
|
+
if (!isSortAllowed(sortBy, sortConfig)) return;
|
|
183
|
+
_sortQuery.value = sortValue;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
await refreshListing();
|
|
187
|
+
}
|
|
188
|
+
async function resetSorting() {
|
|
189
|
+
if (disableSorting) return;
|
|
190
|
+
_sortQuery.value = void 0;
|
|
191
|
+
await refreshListing();
|
|
192
|
+
}
|
|
193
|
+
async function filterResult(filterField, filterOptions) {
|
|
194
|
+
if (disableFilter) return;
|
|
195
|
+
const shouldUseOr = orFilter.includes(filterField);
|
|
196
|
+
const targetList = shouldUseOr ? _orFilterList : _andFilterList;
|
|
197
|
+
targetList.value = manageFilter(targetList.value, filterField, filterOptions);
|
|
198
|
+
await refreshListing();
|
|
199
|
+
}
|
|
200
|
+
async function addFilterOption(filterField, filterOption) {
|
|
201
|
+
if (disableFilter) return;
|
|
202
|
+
const shouldUseOr = orFilter.includes(filterField);
|
|
203
|
+
const targetList = shouldUseOr ? _orFilterList : _andFilterList;
|
|
204
|
+
const existingFilter = targetList.value.find((filter2) => filter2.field === filterField);
|
|
205
|
+
const currentValues = existingFilter ? Array.isArray(existingFilter.value) ? existingFilter.value : [existingFilter.value] : [];
|
|
206
|
+
targetList.value = manageFilter(targetList.value, filterField, [...currentValues, filterOption]);
|
|
207
|
+
await refreshListing();
|
|
208
|
+
}
|
|
209
|
+
async function removeFilterOption(filterField, filterOption) {
|
|
210
|
+
if (disableFilter) return;
|
|
211
|
+
const shouldUseOr = orFilter.includes(filterField);
|
|
212
|
+
const targetList = shouldUseOr ? _orFilterList : _andFilterList;
|
|
213
|
+
targetList.value = removeFilter(targetList.value, filterField, filterOption);
|
|
214
|
+
await refreshListing();
|
|
215
|
+
}
|
|
216
|
+
async function resetFilter(filterField) {
|
|
217
|
+
if (disableFilter) return;
|
|
218
|
+
if (!filterField) {
|
|
219
|
+
_orFilterList.value = [];
|
|
220
|
+
_andFilterList.value = [];
|
|
221
|
+
} else {
|
|
222
|
+
const shouldUseOr = orFilter.includes(filterField);
|
|
223
|
+
const targetList = shouldUseOr ? _orFilterList : _andFilterList;
|
|
224
|
+
targetList.value = removeFilter(targetList.value, filterField);
|
|
225
|
+
}
|
|
226
|
+
await refreshListing();
|
|
227
|
+
}
|
|
228
|
+
async function resetSearch() {
|
|
229
|
+
searchTerm.value = "";
|
|
230
|
+
await refreshListing();
|
|
231
|
+
}
|
|
232
|
+
const result = computed(() => data.value?.items);
|
|
233
|
+
return {
|
|
234
|
+
// ========== State ==========
|
|
235
|
+
/**
|
|
236
|
+
* The full listing response containing items, pagination info, and filter metadata.
|
|
237
|
+
*/
|
|
238
|
+
data,
|
|
239
|
+
/**
|
|
240
|
+
* The items array from the listing response.
|
|
241
|
+
*/
|
|
242
|
+
result,
|
|
243
|
+
/**
|
|
244
|
+
* Query status: 'pending' | 'error' | 'success'
|
|
245
|
+
*/
|
|
246
|
+
status,
|
|
247
|
+
/**
|
|
248
|
+
* Current search state including active filters, sorts, pagination, and available options.
|
|
249
|
+
* Use this to build filter/sort UI components.
|
|
250
|
+
*/
|
|
251
|
+
state: searchState,
|
|
252
|
+
/**
|
|
253
|
+
* Reactive search term. Bind to an input field for live search.
|
|
254
|
+
* Search triggers automatically when term length exceeds searchTermThreshold.
|
|
255
|
+
*/
|
|
256
|
+
searchTerm,
|
|
257
|
+
// ========== Actions ==========
|
|
258
|
+
/**
|
|
259
|
+
* Load the next page of results (infinite scroll).
|
|
260
|
+
* Appends new items to existing results.
|
|
261
|
+
*/
|
|
262
|
+
loadNext,
|
|
263
|
+
/**
|
|
264
|
+
* Refresh the listing data (uses cache if valid).
|
|
265
|
+
* Call after external changes that should trigger a refresh.
|
|
266
|
+
*/
|
|
267
|
+
refresh: refreshListing,
|
|
268
|
+
/**
|
|
269
|
+
* Force a fresh fetch, bypassing cache.
|
|
270
|
+
* Use when you need guaranteed fresh data.
|
|
271
|
+
*/
|
|
272
|
+
refetch: async () => {
|
|
273
|
+
await refetch();
|
|
274
|
+
if (data.value) {
|
|
275
|
+
updateState(data.value);
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
/**
|
|
279
|
+
* Navigate to next or previous page.
|
|
280
|
+
* @param direction - 'next' or 'prev'
|
|
281
|
+
* @returns true if navigation was successful, false if no more pages
|
|
282
|
+
*/
|
|
283
|
+
paginate,
|
|
284
|
+
/**
|
|
285
|
+
* Sort results by a specific field. Call without arguments to reset to default.
|
|
286
|
+
* @param sortBy - Sort string in format 'field:asc' or 'field:desc', or omit to reset
|
|
287
|
+
*/
|
|
288
|
+
sortResult,
|
|
289
|
+
/**
|
|
290
|
+
* Reset sorting to default (backend default order).
|
|
291
|
+
*/
|
|
292
|
+
resetSorting,
|
|
293
|
+
/**
|
|
294
|
+
* Set filter values for a specific field (replaces existing values).
|
|
295
|
+
* @param filterField - The field to filter on (e.g., 'properties.color')
|
|
296
|
+
* @param filterOptions - Array of values to filter by
|
|
297
|
+
*/
|
|
298
|
+
filterResult,
|
|
299
|
+
/**
|
|
300
|
+
* Add a single filter option to a field (keeps existing values).
|
|
301
|
+
* @param filterField - The field to filter on
|
|
302
|
+
* @param filterOption - The value to add
|
|
303
|
+
*/
|
|
304
|
+
addFilter: addFilterOption,
|
|
305
|
+
/**
|
|
306
|
+
* Remove a filter option from a field, or remove all values for that field.
|
|
307
|
+
* @param filterField - The field to remove filter from
|
|
308
|
+
* @param filterOption - Optional specific value to remove (removes all if omitted)
|
|
309
|
+
*/
|
|
310
|
+
removeFilter: removeFilterOption,
|
|
311
|
+
/**
|
|
312
|
+
* Reset filters for a specific field or all fields.
|
|
313
|
+
* @param filterField - Optional field to reset (resets all if omitted)
|
|
314
|
+
*/
|
|
315
|
+
resetFilter,
|
|
316
|
+
/**
|
|
317
|
+
* Clear the search term and refresh results.
|
|
318
|
+
*/
|
|
319
|
+
resetSearch
|
|
320
|
+
};
|
|
321
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { proxyRequest, getHeader, createError, defineEventHandler } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const targetUrl = getHeader(event, "fs-target-url");
|
|
5
|
+
if (!targetUrl) {
|
|
6
|
+
throw createError({
|
|
7
|
+
statusCode: 400,
|
|
8
|
+
statusMessage: "Bad Request",
|
|
9
|
+
message: "Missing fs-target-url header"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (event.node?.req?.headers) {
|
|
13
|
+
delete event.node.req.headers["fs-target-url"];
|
|
14
|
+
}
|
|
15
|
+
const config = useRuntimeConfig(event);
|
|
16
|
+
const fetchApiSecret = config.frontic?.fetchApiSecret;
|
|
17
|
+
if (fetchApiSecret && !getHeader(event, "fs-secret") && event.node?.req?.headers) {
|
|
18
|
+
event.node.req.headers["fs-secret"] = fetchApiSecret;
|
|
19
|
+
}
|
|
20
|
+
return proxyRequest(event, targetUrl);
|
|
21
|
+
});
|
|
File without changes
|
|
File without changes
|
|
@@ -13,46 +13,46 @@ export function makeFilterState(filters) {
|
|
|
13
13
|
}
|
|
14
14
|
export function processAvailableFilters(rawFilters, config = {}) {
|
|
15
15
|
if (!rawFilters) return [];
|
|
16
|
-
const {
|
|
16
|
+
const { select = [], mode = "include", label: labels = {} } = config;
|
|
17
17
|
const availableFilters = [];
|
|
18
18
|
const responseFilterKeys = Object.keys(rawFilters);
|
|
19
19
|
for (const key of responseFilterKeys) {
|
|
20
|
-
const
|
|
21
|
-
const shouldInclude =
|
|
20
|
+
const isInSelect = select.includes(key);
|
|
21
|
+
const shouldInclude = select.length === 0 || (mode === "include" ? isInSelect : !isInSelect);
|
|
22
22
|
if (!shouldInclude) continue;
|
|
23
23
|
const filterOptions = rawFilters[key] || [];
|
|
24
24
|
if (filterOptions.length === 0) continue;
|
|
25
|
-
const
|
|
25
|
+
const filterLabel = labels[key] || key;
|
|
26
26
|
availableFilters.push({
|
|
27
27
|
key,
|
|
28
|
-
label,
|
|
28
|
+
label: filterLabel,
|
|
29
29
|
options: filterOptions
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
return availableFilters;
|
|
33
33
|
}
|
|
34
34
|
export function processAvailableSorts(config = {}) {
|
|
35
|
-
const {
|
|
35
|
+
const { select = [], mode = "include", label: labels = {} } = config;
|
|
36
36
|
return Object.entries(labels).filter(([value]) => {
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
return mode === "include" ?
|
|
37
|
+
if (select.length === 0) return true;
|
|
38
|
+
const isInSelect = select.includes(value);
|
|
39
|
+
return mode === "include" ? isInSelect : !isInSelect;
|
|
40
40
|
}).map(
|
|
41
|
-
([value,
|
|
41
|
+
([value, sortLabel]) => ({
|
|
42
42
|
key: value,
|
|
43
|
-
label,
|
|
43
|
+
label: sortLabel,
|
|
44
44
|
value
|
|
45
45
|
})
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
export function applyFilterConfig(filters, config = {}) {
|
|
49
|
-
const {
|
|
49
|
+
const { select = [], mode = "include", label: labels = {} } = config;
|
|
50
50
|
let result = filters;
|
|
51
|
-
if (
|
|
51
|
+
if (select.length > 0) {
|
|
52
52
|
result = Object.keys(filters).reduce(
|
|
53
53
|
(acc, key) => {
|
|
54
|
-
const
|
|
55
|
-
const shouldInclude = mode === "include" ?
|
|
54
|
+
const isInSelect = select.includes(key);
|
|
55
|
+
const shouldInclude = mode === "include" ? isInSelect : !isInSelect;
|
|
56
56
|
if (shouldInclude && filters[key]) {
|
|
57
57
|
acc[key] = filters[key];
|
|
58
58
|
}
|
|
@@ -81,8 +81,8 @@ export function parseSortString(sortString) {
|
|
|
81
81
|
return { field, order };
|
|
82
82
|
}
|
|
83
83
|
export function isSortAllowed(sortString, config = {}) {
|
|
84
|
-
const {
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
return mode === "include" ?
|
|
84
|
+
const { select = [], mode = "include" } = config;
|
|
85
|
+
if (select.length === 0) return true;
|
|
86
|
+
const isInSelect = select.includes(sortString);
|
|
87
|
+
return mode === "include" ? isInSelect : !isInSelect;
|
|
88
88
|
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
import type { default as Module } from './module.
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module.
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type FronticComposable, type FronticComposablesConfig, type FronticOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontic/nuxt",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Nuxt module for auto-importing UI components - inspired by shadcn-vue",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontic",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/frontic/frontic-nuxt.git",
|
|
10
10
|
"directory": "packages/nuxt"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://docs.frontstack.dev/reference/nuxt-module",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/frontic/frontic-nuxt/issues"
|
|
15
15
|
},
|
|
@@ -24,40 +24,40 @@
|
|
|
24
24
|
"type": "module",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"types": "./dist/module.d.mts",
|
|
28
|
+
"import": "./dist/module.mjs"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
"main": "./dist/module.
|
|
32
|
-
"types": "./dist/types.d.ts",
|
|
31
|
+
"main": "./dist/module.mjs",
|
|
33
32
|
"files": [
|
|
34
33
|
"dist"
|
|
35
34
|
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"prepack": "nuxt-module-build build",
|
|
38
|
-
"dev": "nuxi dev playground",
|
|
39
|
-
"dev:build": "nuxi build playground",
|
|
40
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
41
|
-
"build": "nuxt-module-build build",
|
|
42
|
-
"typecheck": "vue-tsc --noEmit",
|
|
43
|
-
"test": "vitest run",
|
|
44
|
-
"test:watch": "vitest watch",
|
|
45
|
-
"clean": "rm -rf dist .nuxt"
|
|
46
|
-
},
|
|
47
35
|
"dependencies": {
|
|
48
36
|
"@nuxt/kit": "^3.17.0",
|
|
49
37
|
"@pinia/colada": "^0.14.0",
|
|
50
38
|
"@vueuse/core": "^12.0.0"
|
|
51
39
|
},
|
|
52
40
|
"devDependencies": {
|
|
53
|
-
"@nuxt/module-builder": "^0.
|
|
41
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
54
42
|
"@nuxt/schema": "^3.17.0",
|
|
43
|
+
"h3": "^1.15.0",
|
|
55
44
|
"nuxt": "^3.17.0",
|
|
45
|
+
"typescript": "5.6.3",
|
|
56
46
|
"vitest": "^2.x",
|
|
57
47
|
"vue": "^3.x",
|
|
58
|
-
"vue-tsc": "
|
|
48
|
+
"vue-tsc": "2.1.6"
|
|
59
49
|
},
|
|
60
50
|
"peerDependencies": {
|
|
61
51
|
"nuxt": ">=3.17.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "nuxi dev playground",
|
|
55
|
+
"dev:build": "nuxi build playground",
|
|
56
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
57
|
+
"build": "nuxt-module-build build",
|
|
58
|
+
"typecheck": "vue-tsc --noEmit",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest watch",
|
|
61
|
+
"clean": "rm -rf dist .nuxt"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Available Frontic composables that can be enabled/disabled
|
|
5
|
-
*/
|
|
6
|
-
type FronticComposable = 'listing' | 'page' | 'block' | 'context';
|
|
7
|
-
/**
|
|
8
|
-
* Frontic composables configuration
|
|
9
|
-
* - true: Enable all composables (default)
|
|
10
|
-
* - false or []: Disable all composables
|
|
11
|
-
* - string[]: Enable only specified composables
|
|
12
|
-
*/
|
|
13
|
-
type FronticComposablesConfig = boolean | FronticComposable[];
|
|
14
|
-
/**
|
|
15
|
-
* Frontic module configuration options
|
|
16
|
-
*/
|
|
17
|
-
interface FronticOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Prefix for all the imported components
|
|
20
|
-
* @default "Ui"
|
|
21
|
-
*/
|
|
22
|
-
prefix: string;
|
|
23
|
-
/**
|
|
24
|
-
* Directory that the components live in.
|
|
25
|
-
* @default "@/components/ui"
|
|
26
|
-
*/
|
|
27
|
-
componentDir: string;
|
|
28
|
-
/**
|
|
29
|
-
* Configure which Frontic composables to enable
|
|
30
|
-
* - true: Enable all composables (default)
|
|
31
|
-
* - false or []: Disable all composables
|
|
32
|
-
* - string[]: Enable only specified composables
|
|
33
|
-
*
|
|
34
|
-
* Available: 'listing', 'page', 'block', 'context'
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* composables: true // Enable all
|
|
38
|
-
* composables: false // Disable all
|
|
39
|
-
* composables: ['listing', 'page'] // Enable specific ones
|
|
40
|
-
*
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
composables?: FronticComposablesConfig;
|
|
44
|
-
}
|
|
45
|
-
declare const module: NuxtModule<FronticOptions>;
|
|
46
|
-
|
|
47
|
-
export { module as default };
|
|
48
|
-
export type { FronticComposable, FronticComposablesConfig, FronticOptions };
|
package/dist/types.d.ts
DELETED