@revenexx/cover 0.7.1 → 0.11.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/app/api/account.ts +4 -0
- package/app/api/forms.ts +1 -0
- package/app/app.config.ts +17 -12
- package/app/assets/css/cover.css +9 -0
- package/app/components/RevenexxForm.vue +84 -12
- package/app/components/account/AccountShell.vue +18 -0
- package/app/components/account/AccountSidebar.vue +2 -5
- package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
- package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
- package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
- package/app/components/account/orders/AccountOrderDetail.vue +186 -1
- package/app/components/account/organization/AccountOrganization.vue +3 -1
- package/app/components/account/payments/AccountPayments.vue +129 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
- package/app/components/account/team/AccountTeam.vue +32 -7
- package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
- package/app/components/auth/AuthLoginPanel.vue +136 -18
- package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
- package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
- package/app/components/cart/item/CartItem.vue +17 -75
- package/app/components/cart/position/CartPosition.vue +17 -30
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
- package/app/components/cart/view/CartSummaryPanel.vue +54 -0
- package/app/components/category/view/GridView.vue +10 -1
- package/app/components/category/view/ListView.vue +10 -1
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +31 -3
- package/app/components/checkout/onepage/CheckoutGate.vue +10 -7
- package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
- package/app/components/form/FormPage.vue +40 -0
- package/app/components/layout/Region.vue +13 -0
- package/app/components/layout/footer/Footer.vue +8 -0
- package/app/components/layout/header/AppBar.vue +11 -4
- package/app/components/layout/header/MainNav.vue +26 -4
- package/app/components/layout/header/MobileMenu.vue +12 -0
- package/app/components/listing/ListingResults.vue +3 -1
- package/app/components/product/card/Compact.vue +10 -1
- package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
- package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
- package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
- package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
- package/app/components/product/detail/ProductDetailView.vue +57 -0
- package/app/composables/useAccountDashboard.ts +0 -10
- package/app/composables/useAccountHold.ts +45 -0
- package/app/composables/useAccountNavigation.ts +35 -0
- package/app/composables/useAccountPayments.ts +21 -0
- package/app/composables/useAccountQuotes.ts +15 -2
- package/app/composables/useAuthStore.ts +84 -2
- package/app/composables/useAuthoredForms.ts +26 -0
- package/app/composables/useAvailableOffers.ts +42 -0
- package/app/composables/useCategoryListing.ts +6 -0
- package/app/composables/useCheckoutOnePage.ts +21 -2
- package/app/composables/useGuestOrdering.ts +28 -0
- package/app/composables/useMasterDataEditable.ts +45 -7
- package/app/composables/useOrderListRules.ts +21 -1
- package/app/composables/usePendingApprovals.ts +37 -0
- package/app/composables/useProductCard.ts +29 -2
- package/app/composables/useProductListing.ts +79 -0
- package/app/composables/useQuantityStepper.ts +90 -0
- package/app/composables/useQuickActions.ts +35 -0
- package/app/composables/useRoleGrants.ts +32 -0
- package/app/composables/useSearchListing.ts +4 -0
- package/app/composables/useThemeEvents.ts +144 -0
- package/app/config/accountDashboard.ts +26 -0
- package/app/config/icons.ts +2 -0
- package/app/config/navigation.ts +2 -2
- package/app/config/quickActions.ts +40 -5
- package/app/formkit.config.ts +14 -0
- package/app/interfaces/account/approvals.ts +37 -0
- package/app/interfaces/account/dashboard.ts +2 -0
- package/app/interfaces/account/order-list.ts +29 -0
- package/app/interfaces/account/order-lists.ts +9 -0
- package/app/interfaces/account/payments.ts +48 -0
- package/app/interfaces/auth.ts +24 -2
- package/app/interfaces/b2b.ts +8 -8
- package/app/interfaces/offers.ts +35 -0
- package/app/interfaces/quantity-stepper.ts +17 -0
- package/app/interfaces/shopSettings.ts +77 -0
- package/app/layouts/default.vue +19 -10
- package/app/layouts/focus.vue +28 -7
- package/app/middleware/checkout-guard.ts +7 -1
- package/app/pages/punchout/transfer.vue +22 -0
- package/app/plugins/account-hold.client.ts +20 -0
- package/app/plugins/shop-settings.ts +27 -12
- package/app/plugins/theme-events.client.ts +132 -0
- package/app/shared/themeEvents.ts +445 -0
- package/i18n/locales/de/account.json +87 -0
- package/i18n/locales/de/auth.json +30 -0
- package/i18n/locales/de/cart.json +9 -1
- package/i18n/locales/de/checkout.json +4 -2
- package/i18n/locales/de/common.json +4 -0
- package/i18n/locales/de/cover.json +44 -0
- package/i18n/locales/de/editor.json +47 -1
- package/i18n/locales/de/forms.json +27 -0
- package/i18n/locales/en/account.json +87 -0
- package/i18n/locales/en/auth.json +30 -0
- package/i18n/locales/en/cart.json +9 -1
- package/i18n/locales/en/checkout.json +4 -2
- package/i18n/locales/en/common.json +4 -0
- package/i18n/locales/en/cover.json +44 -0
- package/i18n/locales/en/editor.json +47 -1
- package/i18n/locales/en/forms.json +27 -0
- package/nuxt.config.ts +15 -1
- package/package.json +6 -2
- package/server/api/account/address/[id].delete.ts +1 -1
- package/server/api/account/address/[id].put.ts +1 -1
- package/server/api/account/address/index.post.ts +1 -1
- package/server/api/account/order-lists/[id].get.ts +37 -3
- package/server/api/account/orders/[id]/cancel.post.ts +54 -0
- package/server/api/account/orders/[id]/messages.get.ts +63 -0
- package/server/api/account/orders/[id]/messages.post.ts +44 -0
- package/server/api/account/orders/[id]/return.post.ts +1 -0
- package/server/api/account/orders/[id].get.ts +1 -1
- package/server/api/account/organization.put.ts +1 -1
- package/server/api/account/payments.get.ts +54 -0
- package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
- package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
- package/server/api/account/pending-approvals/index.get.ts +26 -0
- package/server/api/account/profile.get.ts +3 -1
- package/server/api/account/profile.put.ts +1 -1
- package/server/api/account/quotes/[id]/decline.post.ts +35 -6
- package/server/api/account/team/[id].put.ts +1 -1
- package/server/api/account/team.post.ts +1 -1
- package/server/api/auth/login.post.ts +6 -0
- package/server/api/auth/magic-link.post.ts +32 -0
- package/server/api/auth/magic-link.put.ts +35 -0
- package/server/api/auth/otp.post.ts +33 -0
- package/server/api/auth/otp.put.ts +33 -0
- package/server/api/carts/[id]/activate.post.ts +1 -0
- package/server/api/carts/[id]/index.delete.ts +1 -0
- package/server/api/carts/[id]/index.put.ts +1 -0
- package/server/api/carts/[id]/items.post.ts +1 -0
- package/server/api/checkout/profile.get.ts +6 -3
- package/server/api/forms/[slug]/submit.post.ts +27 -16
- package/server/api/forms/[slug].get.ts +9 -1
- package/server/api/forms/index.get.ts +23 -0
- package/server/api/orders/index.post.ts +41 -0
- package/server/api/promotions/available.post.ts +37 -0
- package/server/api/quick-actions.get.ts +6 -38
- package/server/config/account/organization.json +0 -4
- package/server/config/shop/app-settings.json +4 -0
- package/server/data/forms/authored.json +337 -0
- package/server/interfaces/forms.ts +51 -0
- package/server/middleware/buyer-principal.ts +18 -0
- package/server/routes/punchout/start.get.ts +2 -2
- package/server/services/ApiAddressBookService.ts +43 -1
- package/server/services/ApiAuthService.ts +101 -10
- package/server/services/ApiCartService.ts +3 -10
- package/server/services/ApiFormsService.ts +56 -0
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/services/MockB2BContextService.ts +1 -5
- package/server/services/MockFormsService.ts +63 -0
- package/server/utils/accountPayments.ts +45 -0
- package/server/utils/appSettings.ts +69 -4
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +27 -0
- package/server/utils/forms.ts +62 -14
- package/server/utils/formsService.ts +29 -0
- package/server/utils/liveOrderLists.ts +50 -23
- package/server/utils/liveOrders.ts +65 -24
- package/server/utils/livePrices.ts +7 -15
- package/server/utils/masterData.ts +60 -11
- package/server/utils/passwordlessSignIn.ts +82 -0
- package/server/utils/pendingApprovals.ts +175 -0
- package/server/utils/procurementCheckout.ts +2 -0
- package/server/utils/promotionsService.ts +90 -0
- package/server/utils/quickActionCatalogue.ts +53 -0
- package/server/utils/quotesService.ts +15 -0
- package/server/utils/revenexxSdk.ts +116 -2
- package/server/utils/shopSettings.ts +35 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { checkoutApi } from "../api/checkout";
|
|
2
|
+
import type { CartCalculation } from "../interfaces/cart-calculation";
|
|
2
3
|
import type { CheckoutOnePageForm, CheckoutProfile } from "../interfaces/checkout";
|
|
4
|
+
import { browserSession, purchaseFromCart, stashPurchase } from "../shared/themeEvents";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Who is checking out:
|
|
@@ -56,6 +58,9 @@ export function useCheckoutOnePage() {
|
|
|
56
58
|
const cart = useCartStore();
|
|
57
59
|
const { settings } = useB2BContext();
|
|
58
60
|
const psp = usePspCheckout();
|
|
61
|
+
// The server-calculated totals the summary shows (shared state) — read when
|
|
62
|
+
// an order is placed, so the confirmation can report what was bought.
|
|
63
|
+
const calculation = useState<CartCalculation | null>("cart-calculation", () => null);
|
|
59
64
|
const { data: profile, refresh: refreshProfile } = useCheckoutProfileSource();
|
|
60
65
|
const profileLoading = computed(() => profile.value === null);
|
|
61
66
|
|
|
@@ -293,7 +298,7 @@ export function useCheckoutOnePage() {
|
|
|
293
298
|
// (approval limits, quantity rules) against the same data.
|
|
294
299
|
items: cart.items,
|
|
295
300
|
...(isGuest.value ? { contactEmail: guestContact.value.email } : {}),
|
|
296
|
-
...(
|
|
301
|
+
...(form.value.deliveryMethod ? { deliveryMethod: f.deliveryMethod } : {}),
|
|
297
302
|
...(f.requestedDate ? { requestedDate: f.requestedDate } : {}),
|
|
298
303
|
...(f.deliveryNote ? { deliveryNote: f.deliveryNote } : {}),
|
|
299
304
|
...(f.partialDelivery ? { partialDelivery: true } : {}),
|
|
@@ -301,7 +306,7 @@ export function useCheckoutOnePage() {
|
|
|
301
306
|
...(f.quoteNumber ? { quoteNumber: f.quoteNumber } : {}),
|
|
302
307
|
...(f.noOrderConfirmation ? { noOrderConfirmation: true } : {}),
|
|
303
308
|
...(f.orderNote ? { orderNote: f.orderNote } : {}),
|
|
304
|
-
...(
|
|
309
|
+
...(form.value.promoCode ? { promoCode: f.promoCode } : {}),
|
|
305
310
|
};
|
|
306
311
|
}
|
|
307
312
|
|
|
@@ -336,6 +341,20 @@ export function useCheckoutOnePage() {
|
|
|
336
341
|
}
|
|
337
342
|
}
|
|
338
343
|
|
|
344
|
+
// The order as it is placed, kept for the confirmation page's
|
|
345
|
+
// `purchase` event — the cart is cleared below, and a PSP redirect
|
|
346
|
+
// leaves this page altogether. Lines and money only, never who.
|
|
347
|
+
if (import.meta.client) {
|
|
348
|
+
stashPurchase(
|
|
349
|
+
browserSession(),
|
|
350
|
+
purchaseFromCart(cart.items, calculation.value?.totals, { subtotal: cart.subtotal, tax: cart.tax }, {
|
|
351
|
+
...(form.value.paymentMethod ? { payment_type: String(form.value.paymentMethod).slice(0, 64) } : {}),
|
|
352
|
+
...(form.value.deliveryMethod ? { shipping_tier: String(form.value.deliveryMethod).slice(0, 64) } : {}),
|
|
353
|
+
...(form.value.promoCode ? { coupon: String(form.value.promoCode).slice(0, 64) } : {}),
|
|
354
|
+
}),
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
339
358
|
const order = await $fetch(checkoutApi.orders(), {
|
|
340
359
|
method: "POST",
|
|
341
360
|
body: payload,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether somebody may order without an account, and as which kind of buyer.
|
|
3
|
+
*
|
|
4
|
+
* The orders app decides. Until it did, every storefront answered this in its
|
|
5
|
+
* own configuration file — so two shops on one tenant could disagree, neither
|
|
6
|
+
* answer was the merchant's, and switching it off meant a developer and a
|
|
7
|
+
* redeploy.
|
|
8
|
+
*
|
|
9
|
+
* The kind matters on both sides. The app cannot tell a company shopper from a
|
|
10
|
+
* private one — a guest has no contact and no organisation to read — so the shop
|
|
11
|
+
* states which it is when it places the order, and the app enforces that answer.
|
|
12
|
+
* Which means the shop must never offer a path it will then be refused on.
|
|
13
|
+
*/
|
|
14
|
+
export function useGuestOrdering() {
|
|
15
|
+
const { orders } = useShopSettings();
|
|
16
|
+
|
|
17
|
+
/** What the merchant allows; `both` while unknown, as the app's own default. */
|
|
18
|
+
const allowed = computed(() => orders.value?.guestOrdering ?? "both");
|
|
19
|
+
|
|
20
|
+
/** May a business buyer order without an account. */
|
|
21
|
+
const b2b = computed(() => allowed.value === "both" || allowed.value === "b2b");
|
|
22
|
+
/** May a private buyer. */
|
|
23
|
+
const b2c = computed(() => allowed.value === "both" || allowed.value === "b2c");
|
|
24
|
+
/** Is there any guest path at all. */
|
|
25
|
+
const any = computed(() => b2b.value || b2c.value);
|
|
26
|
+
|
|
27
|
+
return { allowed, b2b, b2c, any };
|
|
28
|
+
}
|
|
@@ -1,14 +1,52 @@
|
|
|
1
1
|
import type { ComputedRef } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The permission the buyer's role must grant for each area — the same map the
|
|
5
|
+
* BFF refuses the write by. The profile is the buyer's own and needs none.
|
|
6
|
+
*/
|
|
7
|
+
const AREA_PERMISSION: Record<"addresses" | "profile" | "organization" | "team", string | null> = {
|
|
8
|
+
addresses: "addresses.manage",
|
|
9
|
+
profile: null,
|
|
10
|
+
organization: "organization.manage",
|
|
11
|
+
team: "contacts.manage",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether this buyer may change this part of their own master data.
|
|
16
|
+
*
|
|
17
|
+
* The customers app decides, and it refuses the write itself — so this is the
|
|
18
|
+
* matching UX and not the rule. Offering a form the platform will refuse costs
|
|
19
|
+
* the buyer the work of filling it; hiding one it would have accepted costs them
|
|
20
|
+
* the change.
|
|
21
|
+
*
|
|
22
|
+
* `team` follows the company rather than the addresses: a merchant who keeps the
|
|
23
|
+
* company record keeps its people too.
|
|
5
24
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* The BFF enforces the same flag (`assertMasterDataEditable`); this only
|
|
9
|
-
* decides what the UI offers.
|
|
25
|
+
* Two halves: what the merchant left in buyers' hands, and what this buyer's
|
|
26
|
+
* own role grants (RAD-155) — managing the people takes `contacts.manage`.
|
|
10
27
|
*/
|
|
11
28
|
export function useMasterDataEditable(area: "addresses" | "profile" | "organization" | "team"): ComputedRef<boolean> {
|
|
12
|
-
const
|
|
13
|
-
|
|
29
|
+
const { account } = useShopSettings();
|
|
30
|
+
const auth = useAuthStore();
|
|
31
|
+
return computed(() => {
|
|
32
|
+
// The role half: a buyer whose role does not grant the change is not
|
|
33
|
+
// offered it. Only where the platform stated the grants — the demo
|
|
34
|
+
// personas carry none, and the setting alone decides for them.
|
|
35
|
+
const permission = AREA_PERMISSION[area];
|
|
36
|
+
const granted = auth.user?.permissions;
|
|
37
|
+
if (permission && Array.isArray(granted) && !granted.includes(permission)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
switch (account.value?.selfService) {
|
|
41
|
+
case "none":
|
|
42
|
+
return false;
|
|
43
|
+
case "addresses_only":
|
|
44
|
+
return area === "addresses";
|
|
45
|
+
default:
|
|
46
|
+
// Editable while unknown, which is the app's own default — a shop
|
|
47
|
+
// that cannot reach the setting must not lock a buyer out of data
|
|
48
|
+
// the merchant never took away from them.
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
14
52
|
}
|
|
@@ -68,5 +68,25 @@ export function useOrderListRules() {
|
|
|
68
68
|
/** The kind a new list starts as, where the app names one. */
|
|
69
69
|
const defaultKind = computed(() => orderLists.value?.defaultKind ?? null);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
/**
|
|
72
|
+
* What becomes of a position whose part the shop no longer carries.
|
|
73
|
+
*
|
|
74
|
+
* `include` takes it anyway and lets the cart object, `skip` leaves it out and
|
|
75
|
+
* says so, `fail` refuses the whole list. A list outlives the catalogue it was
|
|
76
|
+
* written from, so this is not an edge case — it is what happens to every list
|
|
77
|
+
* eventually.
|
|
78
|
+
*/
|
|
79
|
+
const onMissingArticle = computed<"include" | "skip" | "fail">(() =>
|
|
80
|
+
orderLists.value?.onMissingArticle ?? "include",
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
canEditPositions,
|
|
85
|
+
canManage,
|
|
86
|
+
maxPositions,
|
|
87
|
+
maxLists,
|
|
88
|
+
cartMergeMode,
|
|
89
|
+
defaultKind,
|
|
90
|
+
onMissingArticle,
|
|
91
|
+
};
|
|
72
92
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PendingApproval, PendingApprovalsResponse } from "../interfaces/account/approvals";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What is waiting on this approver, and the two things they can do about it.
|
|
5
|
+
*
|
|
6
|
+
* Oldest first: a request that has been waiting three days is more urgent than
|
|
7
|
+
* one that landed this morning, and a queue sorted the other way hides exactly
|
|
8
|
+
* the row somebody is chasing.
|
|
9
|
+
*/
|
|
10
|
+
export function usePendingApprovals() {
|
|
11
|
+
const { data, status, error, refresh } = useFetch<PendingApprovalsResponse>("/api/account/pending-approvals", {
|
|
12
|
+
key: "pending-approvals",
|
|
13
|
+
default: (): PendingApprovalsResponse => ({ approvals: [] }),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const approvals = computed<PendingApproval[]>(() =>
|
|
17
|
+
[...(data.value?.approvals ?? [])].sort((a, b) => a.at.localeCompare(b.at)),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const deciding = ref<string | null>(null);
|
|
21
|
+
|
|
22
|
+
async function decide(id: string, decision: "approve" | "decline", reason?: string): Promise<void> {
|
|
23
|
+
deciding.value = id;
|
|
24
|
+
try {
|
|
25
|
+
await $fetch(`/api/account/pending-approvals/${id}/${decision}`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: reason?.trim() ? { reason: reason.trim() } : {},
|
|
28
|
+
});
|
|
29
|
+
await refresh();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
deciding.value = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { approvals, count: computed(() => approvals.value.length), deciding, decide, status, error, refresh };
|
|
37
|
+
}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import type { ProductList } from "../interfaces/product-list";
|
|
2
|
+
import { listingProductToItem } from "../shared/themeEvents";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/** Where a card is shown, for the `select_item` it reports when opened. */
|
|
5
|
+
export interface ProductCardListContext {
|
|
6
|
+
listId?: string;
|
|
7
|
+
/** 1-based position in that list. */
|
|
8
|
+
position?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useProductCard(
|
|
12
|
+
getProduct: () => ProductList,
|
|
13
|
+
getList?: () => ProductCardListContext | undefined,
|
|
14
|
+
) {
|
|
4
15
|
const url = computed(() => useProductUrl(getProduct()).value);
|
|
5
16
|
const { getImage } = useProductImage();
|
|
17
|
+
const { useOffer } = useOffers();
|
|
18
|
+
const { offer } = useOffer(() => getProduct().id);
|
|
19
|
+
const events = useThemeEvents();
|
|
20
|
+
|
|
21
|
+
/** Report that the buyer opened this product from the list it was shown in. */
|
|
22
|
+
function select(): void {
|
|
23
|
+
const list = getList?.();
|
|
24
|
+
const item = listingProductToItem(getProduct(), {
|
|
25
|
+
position: list?.position,
|
|
26
|
+
listId: list?.listId,
|
|
27
|
+
prices: offer.value?.prices,
|
|
28
|
+
});
|
|
29
|
+
events.emit("select_item", {
|
|
30
|
+
ecommerce: { items: [item], ...(list?.listId ? { list_id: list.listId } : {}) },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
6
33
|
|
|
7
|
-
return { url, getImage };
|
|
34
|
+
return { url, getImage, select };
|
|
8
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { searchApi } from "../api/search";
|
|
2
2
|
import type { ProductList } from "../interfaces/product-list";
|
|
3
3
|
import type { PriceRange, SearchFacet } from "../interfaces/search-facets";
|
|
4
|
+
import { listingProductToItem } from "../shared/themeEvents";
|
|
4
5
|
|
|
5
6
|
export interface ProductListingOptions {
|
|
6
7
|
/** Unique fetch key per listing surface (e.g. "search", "category"). */
|
|
@@ -16,8 +17,22 @@ export interface ProductListingOptions {
|
|
|
16
17
|
facetFields?: MaybeRefOrGetter<string[]>;
|
|
17
18
|
/** Run the first request even with an empty query (category pages). */
|
|
18
19
|
allowEmptyQuery?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* How a shown page of results is reported to the theme event contract:
|
|
22
|
+
* a category listing is a `view_item_list`, the search page a `search`.
|
|
23
|
+
* Omitted or null → nothing is reported (e.g. the editor's sample listing).
|
|
24
|
+
*/
|
|
25
|
+
listEvent?: () => ListingEvent | null;
|
|
19
26
|
}
|
|
20
27
|
|
|
28
|
+
/** What a listing reports itself as (theme-events/1). */
|
|
29
|
+
export type ListingEvent =
|
|
30
|
+
| { event: "view_item_list"; listId: string }
|
|
31
|
+
| { event: "search"; listId: string; term: string };
|
|
32
|
+
|
|
33
|
+
/** How long a reported listing waits for its prices before it goes out without them. */
|
|
34
|
+
const LIST_EVENT_OFFER_WAIT_MS = 4000;
|
|
35
|
+
|
|
21
36
|
const DEFAULT_FACETS = ["category", "subcategory", "manufacturer", "available"];
|
|
22
37
|
|
|
23
38
|
/** Every sort the layer knows, and the i18n key that names it. */
|
|
@@ -200,6 +215,68 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
200
215
|
}
|
|
201
216
|
}, { immediate: true });
|
|
202
217
|
|
|
218
|
+
/* ---- theme events --------------------------------------------- */
|
|
219
|
+
// Reported once per shown page of results, after the offers for it have
|
|
220
|
+
// settled — a list view without prices tells a tag little. Client-only:
|
|
221
|
+
// `useThemeEvents()` is a no-op on the server and in the editor.
|
|
222
|
+
if (import.meta.client && options.listEvent) {
|
|
223
|
+
const themeEvents = useThemeEvents();
|
|
224
|
+
const offerCache = useState<Record<string, { prices: { [key: string]: number }[] }>>("offers:cache", () => ({}));
|
|
225
|
+
const offerAttempted = useState<Record<string, boolean>>("offers:attempted", () => ({}));
|
|
226
|
+
const offersSettled = (ids: string[]): Promise<void> => new Promise((resolve) => {
|
|
227
|
+
const settled = () => ids.every(id => id in offerCache.value || offerAttempted.value[id]);
|
|
228
|
+
if (settled()) {
|
|
229
|
+
resolve();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const timer = setTimeout(() => {
|
|
233
|
+
stop();
|
|
234
|
+
resolve();
|
|
235
|
+
}, LIST_EVENT_OFFER_WAIT_MS);
|
|
236
|
+
const stop = watch([offerCache, offerAttempted], () => {
|
|
237
|
+
if (settled()) {
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
stop();
|
|
240
|
+
resolve();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
let lastReported = "";
|
|
246
|
+
watch(data, (loaded) => {
|
|
247
|
+
const spec = options.listEvent?.();
|
|
248
|
+
if (!loaded || !spec || !themeEvents.active()) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (spec.event === "search" && (!spec.term.trim() || spec.term.trim() === "*")) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const list = loaded.products ?? [];
|
|
255
|
+
const key = JSON.stringify([spec, loaded.page, list.map(p => p.id)]);
|
|
256
|
+
if (key === lastReported || (spec.event === "view_item_list" && !list.length)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
lastReported = key;
|
|
260
|
+
const offset = (Math.max(1, loaded.page || 1) - 1) * (loaded.perPage || (productsPerPage as number));
|
|
261
|
+
void offersSettled(list.map(p => p.id)).then(() => {
|
|
262
|
+
const items = list.map((product, index) => listingProductToItem(product, {
|
|
263
|
+
position: offset + index + 1,
|
|
264
|
+
listId: spec.listId,
|
|
265
|
+
prices: offerCache.value[product.id]?.prices,
|
|
266
|
+
}));
|
|
267
|
+
if (spec.event === "search") {
|
|
268
|
+
themeEvents.emit("search", {
|
|
269
|
+
search: { search_term: spec.term.trim().slice(0, 256), results_count: loaded.found ?? list.length },
|
|
270
|
+
...(items.length ? { ecommerce: { list_id: spec.listId, items } } : {}),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
themeEvents.emit("view_item_list", { ecommerce: { list_id: spec.listId, items } });
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}, { immediate: true });
|
|
278
|
+
}
|
|
279
|
+
|
|
203
280
|
const found = computed(() => data.value?.found ?? 0);
|
|
204
281
|
const totalPages = computed(() => Math.ceil(found.value / (productsPerPage as number)));
|
|
205
282
|
const isEmpty = computed(() => data.value !== null && data.value !== undefined && products.value.length === 0);
|
|
@@ -254,6 +331,8 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
254
331
|
products, facets, found, totalPages, isEmpty,
|
|
255
332
|
chips, activeFilterCount, removeChip, clearFilters,
|
|
256
333
|
perPage: productsPerPage as number,
|
|
334
|
+
/** The list id cards report a selection from, when the listing reports at all. */
|
|
335
|
+
listId: () => options.listEvent?.()?.listId,
|
|
257
336
|
};
|
|
258
337
|
}
|
|
259
338
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CART_MAX_QUANTITY } from "../interfaces/cart-item";
|
|
2
|
+
import type { QuantityStepperNotice, QuantityStepperOptions } from "../interfaces/quantity-stepper";
|
|
3
|
+
|
|
4
|
+
/** How long a refused or corrected entry keeps its notice on screen. */
|
|
5
|
+
const NOTICE_DURATION_MS = 2000;
|
|
6
|
+
/** Longest number the field accepts — CART_MAX_QUANTITY has six digits. */
|
|
7
|
+
const MAX_INPUT_DIGITS = 6;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The −/+ stepper with a typed field, as the cart page, the mini-cart and the
|
|
11
|
+
* product buy box all use it — one set of rules so the three cannot drift:
|
|
12
|
+
*
|
|
13
|
+
* - typing only edits the field; Enter or leaving it commits
|
|
14
|
+
* - an empty, zero or unparsable entry reverts to the committed quantity
|
|
15
|
+
* - anything above the ceiling — typed or stepped — lands on the ceiling
|
|
16
|
+
*
|
|
17
|
+
* Each correction raises a short-lived `notice`; a surface that has room for
|
|
18
|
+
* the explanation shows it, one that does not just ignores it.
|
|
19
|
+
*/
|
|
20
|
+
export function useQuantityStepper(options: QuantityStepperOptions) {
|
|
21
|
+
const min = options.min ?? 1;
|
|
22
|
+
|
|
23
|
+
const inputValue = ref(String(options.quantity()));
|
|
24
|
+
const notice = ref<QuantityStepperNotice | null>(null);
|
|
25
|
+
let noticeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
26
|
+
|
|
27
|
+
const ceiling = computed(() => options.max() ?? CART_MAX_QUANTITY);
|
|
28
|
+
const canDecrease = computed(() => options.quantity() > min);
|
|
29
|
+
|
|
30
|
+
watch(options.quantity, (value) => {
|
|
31
|
+
inputValue.value = String(value);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function clearNoticeTimer(): void {
|
|
35
|
+
if (noticeTimer !== null) {
|
|
36
|
+
clearTimeout(noticeTimer);
|
|
37
|
+
noticeTimer = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function raiseNotice(kind: QuantityStepperNotice): void {
|
|
42
|
+
notice.value = kind;
|
|
43
|
+
clearNoticeTimer();
|
|
44
|
+
noticeTimer = setTimeout(() => {
|
|
45
|
+
notice.value = null;
|
|
46
|
+
noticeTimer = null;
|
|
47
|
+
}, NOTICE_DURATION_MS);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function applyQuantity(next: number): void {
|
|
51
|
+
let target = Math.max(next, min);
|
|
52
|
+
if (target > ceiling.value) {
|
|
53
|
+
target = ceiling.value;
|
|
54
|
+
raiseNotice("max");
|
|
55
|
+
}
|
|
56
|
+
if (target !== options.quantity()) {
|
|
57
|
+
options.apply(target);
|
|
58
|
+
}
|
|
59
|
+
// The field shows the committed value even when nothing changed (a
|
|
60
|
+
// typed 12 clamped back onto a quantity that already sat at the ceiling).
|
|
61
|
+
inputValue.value = String(target);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function decrease(): void {
|
|
65
|
+
applyQuantity(options.quantity() - 1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function increase(): void {
|
|
69
|
+
applyQuantity(options.quantity() + 1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function onInput(event: Event): void {
|
|
73
|
+
const input = event.target as HTMLInputElement;
|
|
74
|
+
inputValue.value = input.value.replace(/[^0-9]/g, "").slice(0, MAX_INPUT_DIGITS);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function commit(): void {
|
|
78
|
+
const parsed = Number.parseInt(inputValue.value, 10);
|
|
79
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
80
|
+
raiseNotice("invalid");
|
|
81
|
+
inputValue.value = String(options.quantity());
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
applyQuantity(parsed);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onScopeDispose(clearNoticeTimer);
|
|
88
|
+
|
|
89
|
+
return { inputValue, notice, canDecrease, decrease, increase, onInput, commit };
|
|
90
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import type { QuickAction } from "../config/quickActions";
|
|
4
|
+
|
|
5
|
+
import { allowedQuickActionIds, resolveQuickActions } from "../config/quickActions";
|
|
6
|
+
|
|
7
|
+
export interface UseQuickActionsReturn {
|
|
8
|
+
/** Catalogue ids the account navigation in effect permits, in catalogue order. */
|
|
9
|
+
readonly allowedIds: ComputedRef<string[]>;
|
|
10
|
+
/** Resolves an authored selection, in its own order, minus what the nav does not permit. */
|
|
11
|
+
readonly resolveAllowed: (ids: readonly string[]) => QuickAction[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Quick actions as the current tenant may show them. The picker overlay gets
|
|
16
|
+
* the same limit server-side (the theme's catalogue endpoint), and this is the
|
|
17
|
+
* render-time half: a selection authored before the tenant dropped a nav link
|
|
18
|
+
* — or authored against a wider nav — loses the tiles the nav no longer backs.
|
|
19
|
+
*
|
|
20
|
+
* Only a tenant-authored nav limits the set: the layer's static tree (and a
|
|
21
|
+
* theme's app.config override) is the full B2B account, where every catalogue
|
|
22
|
+
* entry is a real page.
|
|
23
|
+
*/
|
|
24
|
+
export function useQuickActions(): UseQuickActionsReturn {
|
|
25
|
+
const { navigation, isTenantAuthored } = useAccountNavigation();
|
|
26
|
+
|
|
27
|
+
const allowedIds = computed(() => allowedQuickActionIds(isTenantAuthored.value ? navigation.value : null));
|
|
28
|
+
|
|
29
|
+
function resolveAllowed(ids: readonly string[]): QuickAction[] {
|
|
30
|
+
const permitted = new Set(allowedIds.value);
|
|
31
|
+
return resolveQuickActions(ids).filter(action => permitted.has(action.id));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return { allowedIds, resolveAllowed };
|
|
35
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import type { AuthRole } from "../interfaces/auth";
|
|
4
|
+
|
|
5
|
+
/** Least → most privileged — the order the BFF ranks roles by. */
|
|
6
|
+
const ROLE_RANK: Record<AuthRole, number> = { requester: 0, buyer: 1, approver: 2, admin: 3 };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What the signed-in buyer's own role lets them do, as the platform stated it
|
|
10
|
+
* (RAD-155). The BFF refuses the write regardless; this only keeps the page from
|
|
11
|
+
* offering what it would refuse.
|
|
12
|
+
*
|
|
13
|
+
* Where the platform stated no grants — the demo personas — nothing is locked
|
|
14
|
+
* by role, which is how the shop behaved before anybody asked.
|
|
15
|
+
*/
|
|
16
|
+
export function useRoleGrants(): {
|
|
17
|
+
lockedByRole: (permission: string) => ComputedRef<boolean>;
|
|
18
|
+
mayGrant: (role: AuthRole) => boolean;
|
|
19
|
+
isSelf: (contactId: string) => boolean;
|
|
20
|
+
outranks: (role: AuthRole) => boolean;
|
|
21
|
+
} {
|
|
22
|
+
const auth = useAuthStore();
|
|
23
|
+
const stated = (): boolean => Array.isArray(auth.user?.permissions);
|
|
24
|
+
const ownRank = (): number => (auth.user?.role ? ROLE_RANK[auth.user.role] ?? -1 : -1);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
lockedByRole: permission => computed(() => stated() && !auth.user!.permissions!.includes(permission)),
|
|
28
|
+
mayGrant: role => !stated() || ROLE_RANK[role] <= ownRank(),
|
|
29
|
+
isSelf: contactId => !!auth.user?.contactId && auth.user.contactId === contactId,
|
|
30
|
+
outranks: role => stated() && ROLE_RANK[role] > ownRank(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -57,6 +57,10 @@ export const useSearchListing = (options: SearchListingOptions) => {
|
|
|
57
57
|
key: "search",
|
|
58
58
|
query: () => query.value,
|
|
59
59
|
facetFields: ["category", "subcategory", "manufacturer", "available"],
|
|
60
|
+
// A search is reported as `search` (term + hit count), not as a list
|
|
61
|
+
// view: etracker reads both as `viewProductList` and would count twice.
|
|
62
|
+
// The match-all `*` is the catalogue, not a search, and is skipped.
|
|
63
|
+
listEvent: () => ({ event: "search", listId: "search", term: query.value }),
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
// `?q=*` is the match-all link (Typesense's native catch-all query): the
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createThemeEvents } from "@revenexx/tag-manager-nuxt/events";
|
|
2
|
+
import type {
|
|
3
|
+
ThemeEventContext,
|
|
4
|
+
ThemeEventData,
|
|
5
|
+
ThemeEventEnvelope,
|
|
6
|
+
ThemeEventName,
|
|
7
|
+
ThemeEvents,
|
|
8
|
+
} from "@revenexx/tag-manager-nuxt/events";
|
|
9
|
+
|
|
10
|
+
import type { ShopMarket } from "../interfaces/market";
|
|
11
|
+
import { isEditorContext, pageTypeOf } from "../shared/themeEvents";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The storefront's voice in the event contract (`theme-events/1`).
|
|
15
|
+
*
|
|
16
|
+
* The theme says WHAT happened — `add_to_cart`, `purchase`, `request_quote` —
|
|
17
|
+
* once, and whoever listens (the Tag Manager module today, a theme extension
|
|
18
|
+
* through the DOM event, the Analytics Studio later) says it to each vendor in
|
|
19
|
+
* its own words. The emitter is the framework-free one from
|
|
20
|
+
* `@revenexx/tag-manager-nuxt/events`: importing it loads no module, so cover
|
|
21
|
+
* emits whether a theme installs the Tag Manager or not.
|
|
22
|
+
*
|
|
23
|
+
* Transport: `nuxtApp.callHook('revenexx:event', envelope)` and
|
|
24
|
+
* `window.dispatchEvent(new CustomEvent('revenexx:event', …))`.
|
|
25
|
+
*
|
|
26
|
+
* Nothing is emitted on the server, in the editor or in a preview — the editor
|
|
27
|
+
* seeds sample carts and renders sample products, and none of that is a buyer.
|
|
28
|
+
* Consent is NOT decided here: an event is a fact about the page, and each tag
|
|
29
|
+
* that hears it is gated by the consent provider on its own.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export interface UseThemeEvents {
|
|
33
|
+
/**
|
|
34
|
+
* Emit one event. Returns the envelope that went out, or null where nothing
|
|
35
|
+
* was emitted (server, editor/preview, an invalid envelope in dev, a repeated
|
|
36
|
+
* purchase).
|
|
37
|
+
*/
|
|
38
|
+
emit<E extends ThemeEventName>(event: E, data?: ThemeEventData): ThemeEventEnvelope<E> | null;
|
|
39
|
+
/** Whether events are emitted on this page at all (client, not editor/preview). */
|
|
40
|
+
active(): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const NOOP: UseThemeEvents = { emit: () => null, active: () => false };
|
|
44
|
+
|
|
45
|
+
const MARKET_RE = /^[a-z0-9][\w-]*$/;
|
|
46
|
+
const CURRENCY_RE = /^[A-Z]{3}$/;
|
|
47
|
+
const LOCALE_RE = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;
|
|
48
|
+
|
|
49
|
+
interface ThemeEventsHost {
|
|
50
|
+
_rvxThemeEvents?: UseThemeEvents;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Build the per-app emitter. Must run inside a Nuxt context (a plugin or a
|
|
55
|
+
* component's setup) — every ref it reads later is captured here.
|
|
56
|
+
*/
|
|
57
|
+
function createForApp(): UseThemeEvents {
|
|
58
|
+
const nuxtApp = useNuxtApp();
|
|
59
|
+
const router = useRouter();
|
|
60
|
+
const config = useRuntimeConfig().public as { locale?: string; currency?: string };
|
|
61
|
+
const marketCookie = useCookie<string>("cover-market", { default: () => "", watch: true });
|
|
62
|
+
const currencyCookie = useCookie<string>("cover-currency", { default: () => "", watch: true });
|
|
63
|
+
const { data: markets } = useNuxtData<ShopMarket[]>("shop-markets");
|
|
64
|
+
const auth = useAuthStore();
|
|
65
|
+
|
|
66
|
+
const i18n = nuxtApp.$i18n as unknown as {
|
|
67
|
+
locale: { value: string };
|
|
68
|
+
locales: { value: ({ code: string; language?: string } | string)[] };
|
|
69
|
+
} | undefined;
|
|
70
|
+
|
|
71
|
+
const localeCodes = (): string[] =>
|
|
72
|
+
(i18n?.locales.value ?? []).map(l => (typeof l === "string" ? l : l.code));
|
|
73
|
+
|
|
74
|
+
const activeMarket = (): ShopMarket | null => {
|
|
75
|
+
const list = markets.value ?? [];
|
|
76
|
+
return list.find(m => m.code === marketCookie.value)
|
|
77
|
+
?? list.find(m => m.isDefault)
|
|
78
|
+
?? list[0]
|
|
79
|
+
?? null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const marketCode = (): string => {
|
|
83
|
+
const code = String(marketCookie.value || activeMarket()?.code || "default").toLowerCase();
|
|
84
|
+
return MARKET_RE.test(code) ? code : "default";
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const localeTag = (): string => {
|
|
88
|
+
const code = i18n?.locale.value ?? "";
|
|
89
|
+
const entry = (i18n?.locales.value ?? []).find(l => (typeof l === "string" ? l : l.code) === code);
|
|
90
|
+
const language = typeof entry === "object" ? entry.language : undefined;
|
|
91
|
+
const candidate = language || code || config.locale || "de";
|
|
92
|
+
// The contract wants a lower-case language subtag (`de-DE`, `en`).
|
|
93
|
+
const [lang, ...rest] = candidate.split("-");
|
|
94
|
+
const tag = [lang!.toLowerCase(), ...rest].join("-");
|
|
95
|
+
return LOCALE_RE.test(tag) ? tag : "de";
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const currencyCode = (): string => {
|
|
99
|
+
const code = String(currencyCookie.value || activeMarket()?.currency || config.currency || "EUR").toUpperCase();
|
|
100
|
+
return CURRENCY_RE.test(code) ? code : "EUR";
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const context = (): ThemeEventContext => {
|
|
104
|
+
const route = router.currentRoute.value;
|
|
105
|
+
return {
|
|
106
|
+
market: marketCode(),
|
|
107
|
+
locale: localeTag(),
|
|
108
|
+
currency: currencyCode(),
|
|
109
|
+
page: { path: route.path || "/", type: pageTypeOf(route.path || "/", localeCodes()) },
|
|
110
|
+
// Exactly the two booleans the contract allows — never who.
|
|
111
|
+
customer: { authenticated: auth.isLoggedIn, b2b: Boolean(auth.user?.organizationId) },
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const events: ThemeEvents = createThemeEvents({
|
|
116
|
+
context,
|
|
117
|
+
callHook: (name, envelope) => nuxtApp.callHook(name as never, envelope as never),
|
|
118
|
+
validate: import.meta.dev,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const active = (): boolean => {
|
|
122
|
+
const route = router.currentRoute.value;
|
|
123
|
+
return !isEditorContext({
|
|
124
|
+
path: route.path || "/",
|
|
125
|
+
host: window.location.host,
|
|
126
|
+
query: route.query,
|
|
127
|
+
localeCodes: localeCodes(),
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
active,
|
|
133
|
+
emit: (event, data) => (active() ? events.emit(event, data) : null),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function useThemeEvents(): UseThemeEvents {
|
|
138
|
+
if (import.meta.server) {
|
|
139
|
+
return NOOP;
|
|
140
|
+
}
|
|
141
|
+
const host = useNuxtApp() as unknown as ThemeEventsHost;
|
|
142
|
+
host._rvxThemeEvents ??= createForApp();
|
|
143
|
+
return host._rvxThemeEvents;
|
|
144
|
+
}
|