From 4316833c85593e32bbc6fa627e9b0d0ea710956a Mon Sep 17 00:00:00 2001 From: Patryk Tomczyk <13100280+patzick@users.noreply.github.com> Date: Thu, 17 Jun 2021 14:58:22 +0200 Subject: [PATCH] fix(compopsables): proper type for computed ref in readonly refs (#1566) --- api/composables.api.md | 60 ++++++++++++------- .../api/composables.applicationvuecontext.md | 4 +- .../api/composables.getapplicationcontext.md | 2 +- ...composables.iusecheckout.billingaddress.md | 2 +- ...posables.iusecheckout.getpaymentmethods.md | 2 +- ...osables.iusecheckout.getshippingmethods.md | 2 +- .../resources/api/composables.iusecheckout.md | 12 ++-- ...composables.iusecheckout.paymentmethods.md | 2 +- ...omposables.iusecheckout.shippingaddress.md | 2 +- ...omposables.iusecheckout.shippingmethods.md | 2 +- ...iusesessioncontext.activebillingaddress.md | 2 +- ...usesessioncontext.activeshippingaddress.md | 2 +- ...composables.iusesessioncontext.currency.md | 2 +- .../api/composables.iusesessioncontext.md | 10 ++-- ...sables.iusesessioncontext.paymentmethod.md | 2 +- ...ables.iusesessioncontext.shippingmethod.md | 2 +- docs/landing/resources/api/composables.md | 1 + .../composables.routing.availabledomains.md | 14 +++++ .../api/composables.routing.fallbackdomain.md | 14 +++++ .../api/composables.routing.fallbacklocale.md | 14 +++++ .../composables.routing.getcurrentdomain.md | 14 +++++ .../api/composables.routing.geturl.md | 14 +++++ .../resources/api/composables.routing.md | 28 +++++++++ .../api/composables.routing.pwahost.md | 14 +++++ .../composables.routing.setcurrentdomain.md | 14 +++++ .../composables.usecountries.getcountries.md | 2 +- .../composables.usecountry.displaystate.md | 2 +- .../api/composables.usecountry.forcestate.md | 2 +- .../resources/api/composables.usecountry.md | 2 +- ...osables.usecurrency.availablecurrencies.md | 2 +- .../api/composables.usecurrency.currency.md | 2 +- .../composables.usecurrency.currencysymbol.md | 2 +- ...mposables.usesalutations.getsalutations.md | 2 +- .../resources/api/composables.useuistate.md | 2 +- .../composables/src/hooks/useCountries.ts | 11 +++- packages/composables/src/hooks/useCountry.ts | 10 ++-- packages/composables/src/hooks/useCurrency.ts | 8 +-- .../composables/src/hooks/useSalutations.ts | 12 +++- packages/composables/src/index.ts | 6 +- packages/composables/src/logic/useCheckout.ts | 19 +++--- .../src/logic/useSessionContext.ts | 12 ++-- packages/composables/src/logic/useUIState.ts | 10 +++- .../components/forms/SwRegistrationForm.vue | 2 +- 43 files changed, 259 insertions(+), 86 deletions(-) create mode 100644 docs/landing/resources/api/composables.routing.availabledomains.md create mode 100644 docs/landing/resources/api/composables.routing.fallbackdomain.md create mode 100644 docs/landing/resources/api/composables.routing.fallbacklocale.md create mode 100644 docs/landing/resources/api/composables.routing.getcurrentdomain.md create mode 100644 docs/landing/resources/api/composables.routing.geturl.md create mode 100644 docs/landing/resources/api/composables.routing.md create mode 100644 docs/landing/resources/api/composables.routing.pwahost.md create mode 100644 docs/landing/resources/api/composables.routing.setcurrentdomain.md diff --git a/api/composables.api.md b/api/composables.api.md index 81b323aa7..c86b14e7d 100644 --- a/api/composables.api.md +++ b/api/composables.api.md @@ -65,8 +65,6 @@ export interface ApplicationVueContext extends VueConstructor { $route?: any; // (undocumented) $router?: any; - // Warning: (ae-forgotten-export) The symbol "Routing" needs to be exported by the entry point index.d.ts - // // (undocumented) $routing: Routing; // (undocumented) @@ -216,17 +214,17 @@ export interface IUseCart { // @beta export interface IUseCheckout { // (undocumented) - billingAddress: Readonly | undefined>>; + billingAddress: ComputedRef | undefined>; // (undocumented) createOrder: () => Promise; // (undocumented) getPaymentMethods: (options?: { forceReload: boolean; - }) => Promise>>; + }) => Promise>; // (undocumented) getShippingMethods: (options?: { forceReload: boolean; - }) => Promise>>; + }) => Promise>; // (undocumented) loadings: UnwrapRef<{ createOrder: boolean; @@ -236,11 +234,11 @@ export interface IUseCheckout { order: Order; }) => void) => void; // (undocumented) - paymentMethods: Readonly>; + paymentMethods: ComputedRef; // (undocumented) - shippingAddress: Readonly>; + shippingAddress: ComputedRef; // (undocumented) - shippingMethods: Readonly>; + shippingMethods: ComputedRef; } // @beta @@ -352,13 +350,13 @@ export interface IUseProductQuickSearch { // @beta export interface IUseSessionContext { // (undocumented) - activeBillingAddress: Readonly>; + activeBillingAddress: ComputedRef; // (undocumented) - activeShippingAddress: Readonly>; + activeShippingAddress: ComputedRef; // (undocumented) countryId: ComputedRef; // (undocumented) - currency: Readonly>; + currency: ComputedRef; // (undocumented) onCurrencyChange: (fn: (params: { currency: Currency; @@ -372,7 +370,7 @@ export interface IUseSessionContext { shippingMethod: ShippingMethod; }) => void) => void; // (undocumented) - paymentMethod: Readonly>; + paymentMethod: ComputedRef; // (undocumented) refreshSessionContext: () => Promise; // (undocumented) @@ -388,7 +386,7 @@ export interface IUseSessionContext { // (undocumented) setShippingMethod: (shippingMethod: Partial) => Promise; // (undocumented) - shippingMethod: Readonly>; + shippingMethod: ComputedRef; } // @beta @@ -502,6 +500,24 @@ interface Notification_2 { export { Notification_2 as Notification } +// @beta (undocumented) +export interface Routing { + // (undocumented) + availableDomains: any; + // (undocumented) + fallbackDomain: string | undefined; + // (undocumented) + fallbackLocale: string | undefined; + // (undocumented) + getCurrentDomain: ComputedRef; + // (undocumented) + getUrl: (path: string) => string; + // (undocumented) + pwaHost: string | undefined; + // (undocumented) + setCurrentDomain: (domainData: any) => void; +} + // @beta (undocumented) export type Search = (path: string, associations?: any) => any; @@ -543,7 +559,7 @@ export interface UseCountries { // (undocumented) fetchCountries: () => Promise; // (undocumented) - getCountries: Ref>; + getCountries: ComputedRef; // (undocumented) mountedCallback: () => Promise; } @@ -556,22 +572,22 @@ export interface UseCountry { // (undocumented) currentCountry: ComputedRef; // (undocumented) - displayState: Readonly>; + displayState: ComputedRef; // (undocumented) - forceState: Readonly>; + forceState: ComputedRef; } // @beta (undocumented) -export const useCountry: (countryId: Ref>, countries: Ref>) => UseCountry; +export const useCountry: (countryId: ComputedRef, countries: ComputedRef) => UseCountry; // @beta (undocumented) export interface UseCurrency { // (undocumented) - availableCurrencies: Readonly>; + availableCurrencies: ComputedRef; // (undocumented) - currency: Readonly>; + currency: ComputedRef; // (undocumented) - currencySymbol: Ref>; + currencySymbol: ComputedRef; // (undocumented) loadAvailableCurrencies: (options?: { forceReload: boolean; @@ -645,7 +661,7 @@ export interface UseSalutations { // (undocumented) fetchSalutations: () => Promise; // (undocumented) - getSalutations: Ref>; + getSalutations: ComputedRef; // (undocumented) mountedCallback: () => Promise; } @@ -664,7 +680,7 @@ export function useSharedState(rootContext: ApplicationVueContext): { // @beta export const useUIState: (rootContext: ApplicationVueContext, stateName?: string | undefined) => { - isOpen: Readonly>; + isOpen: ComputedRef; switchState: (to?: boolean | undefined) => void; }; diff --git a/docs/landing/resources/api/composables.applicationvuecontext.md b/docs/landing/resources/api/composables.applicationvuecontext.md index 39f57987c..d459be07c 100644 --- a/docs/landing/resources/api/composables.applicationvuecontext.md +++ b/docs/landing/resources/api/composables.applicationvuecontext.md @@ -27,7 +27,7 @@ export interface ApplicationVueContext extends VueConstructor | [$isServer?](./composables.applicationvuecontext._isserver.md) | any | (BETA) (Optional) | | [$route?](./composables.applicationvuecontext._route.md) | any | (BETA) (Optional) | | [$router?](./composables.applicationvuecontext._router.md) | any | (BETA) (Optional) | -| [$routing](./composables.applicationvuecontext._routing.md) | Routing | (BETA) | +| [$routing](./composables.applicationvuecontext._routing.md) | [Routing](./composables.routing.md) | (BETA) | | [$sharedStore?](./composables.applicationvuecontext._sharedstore.md) | any | (BETA) (Optional) | | [$shopwareApiInstance?](./composables.applicationvuecontext._shopwareapiinstance.md) | ShopwareApiInstance | (BETA) (Optional) | | [$shopwareDefaults?](./composables.applicationvuecontext._shopwaredefaults.md) | any | (BETA) (Optional) | @@ -39,7 +39,7 @@ export interface ApplicationVueContext extends VueConstructor | [isServer?](./composables.applicationvuecontext.isserver.md) | any | (BETA) (Optional) | | [route?](./composables.applicationvuecontext.route.md) | any | (BETA) (Optional) | | [router?](./composables.applicationvuecontext.router.md) | any | (BETA) (Optional) | -| [routing](./composables.applicationvuecontext.routing.md) | Routing | (BETA) | +| [routing](./composables.applicationvuecontext.routing.md) | [Routing](./composables.routing.md) | (BETA) | | [sharedStore?](./composables.applicationvuecontext.sharedstore.md) | any | (BETA) (Optional) | | [shopwareApiInstance?](./composables.applicationvuecontext.shopwareapiinstance.md) | ShopwareApiInstance | (BETA) (Optional) | | [shopwareDefaults?](./composables.applicationvuecontext.shopwaredefaults.md) | any | (BETA) (Optional) | diff --git a/docs/landing/resources/api/composables.getapplicationcontext.md b/docs/landing/resources/api/composables.getapplicationcontext.md index 496c98400..df0e2a242 100644 --- a/docs/landing/resources/api/composables.getapplicationcontext.md +++ b/docs/landing/resources/api/composables.getapplicationcontext.md @@ -37,5 +37,5 @@ export declare function getApplicationContext(rootContext: ApplicationVueContext Returns: -{ apiInstance: ShopwareApiInstance \| undefined; vuexStore: any; router: any; route: any; i18n: any; cookies: any; shopwareDefaults: any; interceptors: any; routing: Routing; sharedStore: any; instanceStore: any; isServer: boolean; contextName: string; } +{ apiInstance: ShopwareApiInstance \| undefined; vuexStore: any; router: any; route: any; i18n: any; cookies: any; shopwareDefaults: any; interceptors: any; routing: [Routing](./composables.routing.md); sharedStore: any; instanceStore: any; isServer: boolean; contextName: string; } diff --git a/docs/landing/resources/api/composables.iusecheckout.billingaddress.md b/docs/landing/resources/api/composables.iusecheckout.billingaddress.md index 2956e1ac6..ea31fc65d 100644 --- a/docs/landing/resources/api/composables.iusecheckout.billingaddress.md +++ b/docs/landing/resources/api/composables.iusecheckout.billingaddress.md @@ -10,5 +10,5 @@ Signature: ```typescript -billingAddress: Readonly | undefined>>; +billingAddress: ComputedRef | undefined>; ``` diff --git a/docs/landing/resources/api/composables.iusecheckout.getpaymentmethods.md b/docs/landing/resources/api/composables.iusecheckout.getpaymentmethods.md index 62812ea04..c1fb65084 100644 --- a/docs/landing/resources/api/composables.iusecheckout.getpaymentmethods.md +++ b/docs/landing/resources/api/composables.iusecheckout.getpaymentmethods.md @@ -12,5 +12,5 @@ ```typescript getPaymentMethods: (options?: { forceReload: boolean; - }) => Promise>>; + }) => Promise>; ``` diff --git a/docs/landing/resources/api/composables.iusecheckout.getshippingmethods.md b/docs/landing/resources/api/composables.iusecheckout.getshippingmethods.md index b9d0123e5..0d9528fa1 100644 --- a/docs/landing/resources/api/composables.iusecheckout.getshippingmethods.md +++ b/docs/landing/resources/api/composables.iusecheckout.getshippingmethods.md @@ -12,5 +12,5 @@ ```typescript getShippingMethods: (options?: { forceReload: boolean; - }) => Promise>>; + }) => Promise>; ``` diff --git a/docs/landing/resources/api/composables.iusecheckout.md b/docs/landing/resources/api/composables.iusecheckout.md index f96b0be54..afa79bfe5 100644 --- a/docs/landing/resources/api/composables.iusecheckout.md +++ b/docs/landing/resources/api/composables.iusecheckout.md @@ -19,13 +19,13 @@ export interface IUseCheckout | Property | Type | Description | | --- | --- | --- | -| [billingAddress](./composables.iusecheckout.billingaddress.md) | Readonly<Ref<Partial<BillingAddress> \| undefined>> | (BETA) | +| [billingAddress](./composables.iusecheckout.billingaddress.md) | ComputedRef<Partial<BillingAddress> \| undefined> | (BETA) | | [createOrder](./composables.iusecheckout.createorder.md) | () => Promise<Order> | (BETA) | -| [getPaymentMethods](./composables.iusecheckout.getpaymentmethods.md) | (options?: { forceReload: boolean; }) => Promise<Readonly<Ref<readonly PaymentMethod\[\]>>> | (BETA) | -| [getShippingMethods](./composables.iusecheckout.getshippingmethods.md) | (options?: { forceReload: boolean; }) => Promise<Readonly<Ref<readonly ShippingMethod\[\]>>> | (BETA) | +| [getPaymentMethods](./composables.iusecheckout.getpaymentmethods.md) | (options?: { forceReload: boolean; }) => Promise<ComputedRef<PaymentMethod\[\]>> | (BETA) | +| [getShippingMethods](./composables.iusecheckout.getshippingmethods.md) | (options?: { forceReload: boolean; }) => Promise<ComputedRef<ShippingMethod\[\]>> | (BETA) | | [loadings](./composables.iusecheckout.loadings.md) | UnwrapRef<{ createOrder: boolean; }> | (BETA) | | [onOrderPlace](./composables.iusecheckout.onorderplace.md) | (fn: (params: { order: Order; }) => void) => void | (BETA) | -| [paymentMethods](./composables.iusecheckout.paymentmethods.md) | Readonly<Ref<readonly PaymentMethod\[\]>> | (BETA) | -| [shippingAddress](./composables.iusecheckout.shippingaddress.md) | Readonly<Ref<ShippingAddress \| undefined>> | (BETA) | -| [shippingMethods](./composables.iusecheckout.shippingmethods.md) | Readonly<Ref<readonly ShippingMethod\[\]>> | (BETA) | +| [paymentMethods](./composables.iusecheckout.paymentmethods.md) | ComputedRef<PaymentMethod\[\]> | (BETA) | +| [shippingAddress](./composables.iusecheckout.shippingaddress.md) | ComputedRef<ShippingAddress \| undefined> | (BETA) | +| [shippingMethods](./composables.iusecheckout.shippingmethods.md) | ComputedRef<ShippingMethod\[\]> | (BETA) | diff --git a/docs/landing/resources/api/composables.iusecheckout.paymentmethods.md b/docs/landing/resources/api/composables.iusecheckout.paymentmethods.md index 0c13e004a..2ae04553b 100644 --- a/docs/landing/resources/api/composables.iusecheckout.paymentmethods.md +++ b/docs/landing/resources/api/composables.iusecheckout.paymentmethods.md @@ -10,5 +10,5 @@ Signature: ```typescript -paymentMethods: Readonly>; +paymentMethods: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusecheckout.shippingaddress.md b/docs/landing/resources/api/composables.iusecheckout.shippingaddress.md index cf50e54fe..e408115d1 100644 --- a/docs/landing/resources/api/composables.iusecheckout.shippingaddress.md +++ b/docs/landing/resources/api/composables.iusecheckout.shippingaddress.md @@ -10,5 +10,5 @@ Signature: ```typescript -shippingAddress: Readonly>; +shippingAddress: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusecheckout.shippingmethods.md b/docs/landing/resources/api/composables.iusecheckout.shippingmethods.md index 0ea569946..2d10caa3e 100644 --- a/docs/landing/resources/api/composables.iusecheckout.shippingmethods.md +++ b/docs/landing/resources/api/composables.iusecheckout.shippingmethods.md @@ -10,5 +10,5 @@ Signature: ```typescript -shippingMethods: Readonly>; +shippingMethods: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusesessioncontext.activebillingaddress.md b/docs/landing/resources/api/composables.iusesessioncontext.activebillingaddress.md index 5106dcc5e..1caef5e88 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.activebillingaddress.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.activebillingaddress.md @@ -10,5 +10,5 @@ Signature: ```typescript -activeBillingAddress: Readonly>; +activeBillingAddress: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusesessioncontext.activeshippingaddress.md b/docs/landing/resources/api/composables.iusesessioncontext.activeshippingaddress.md index 280d20c7a..3a3594feb 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.activeshippingaddress.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.activeshippingaddress.md @@ -10,5 +10,5 @@ Signature: ```typescript -activeShippingAddress: Readonly>; +activeShippingAddress: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusesessioncontext.currency.md b/docs/landing/resources/api/composables.iusesessioncontext.currency.md index c109c0e5e..3a287f700 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.currency.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.currency.md @@ -10,5 +10,5 @@ Signature: ```typescript -currency: Readonly>; +currency: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusesessioncontext.md b/docs/landing/resources/api/composables.iusesessioncontext.md index 353d5d166..d081fdf04 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.md @@ -23,14 +23,14 @@ SessionContext contain all related data like user, currency, country, shippingMe | Property | Type | Description | | --- | --- | --- | -| [activeBillingAddress](./composables.iusesessioncontext.activebillingaddress.md) | Readonly<Ref<BillingAddress \| null>> | (BETA) | -| [activeShippingAddress](./composables.iusesessioncontext.activeshippingaddress.md) | Readonly<Ref<ShippingAddress \| null>> | (BETA) | +| [activeBillingAddress](./composables.iusesessioncontext.activebillingaddress.md) | ComputedRef<BillingAddress \| null> | (BETA) | +| [activeShippingAddress](./composables.iusesessioncontext.activeshippingaddress.md) | ComputedRef<ShippingAddress \| null> | (BETA) | | [countryId](./composables.iusesessioncontext.countryid.md) | ComputedRef<string \| undefined> | (BETA) | -| [currency](./composables.iusesessioncontext.currency.md) | Readonly<Ref<Currency \| null>> | (BETA) | +| [currency](./composables.iusesessioncontext.currency.md) | ComputedRef<Currency \| null> | (BETA) | | [onCurrencyChange](./composables.iusesessioncontext.oncurrencychange.md) | (fn: (params: { currency: Currency; }) => void) => void | (BETA) | | [onPaymentMethodChange](./composables.iusesessioncontext.onpaymentmethodchange.md) | (fn: (params: { paymentMethod: PaymentMethod; }) => void) => void | (BETA) | | [onShippingMethodChange](./composables.iusesessioncontext.onshippingmethodchange.md) | (fn: (params: { shippingMethod: ShippingMethod; }) => void) => void | (BETA) | -| [paymentMethod](./composables.iusesessioncontext.paymentmethod.md) | Readonly<Ref<PaymentMethod \| null>> | (BETA) | +| [paymentMethod](./composables.iusesessioncontext.paymentmethod.md) | ComputedRef<PaymentMethod \| null> | (BETA) | | [refreshSessionContext](./composables.iusesessioncontext.refreshsessioncontext.md) | () => Promise<void> | (BETA) | | [sessionContext](./composables.iusesessioncontext.sessioncontext.md) | ComputedRef<SessionContext \| null> | (BETA) | | [setActiveBillingAddress](./composables.iusesessioncontext.setactivebillingaddress.md) | (address: Partial<BillingAddress>) => Promise<void> | (BETA) | @@ -38,5 +38,5 @@ SessionContext contain all related data like user, currency, country, shippingMe | [setCurrency](./composables.iusesessioncontext.setcurrency.md) | (currency: Partial<Currency>) => Promise<void> | (BETA) | | [setPaymentMethod](./composables.iusesessioncontext.setpaymentmethod.md) | (paymentMethod: Partial<PaymentMethod>) => Promise<void> | (BETA) | | [setShippingMethod](./composables.iusesessioncontext.setshippingmethod.md) | (shippingMethod: Partial<ShippingMethod>) => Promise<void> | (BETA) | -| [shippingMethod](./composables.iusesessioncontext.shippingmethod.md) | Readonly<Ref<ShippingMethod \| null>> | (BETA) | +| [shippingMethod](./composables.iusesessioncontext.shippingmethod.md) | ComputedRef<ShippingMethod \| null> | (BETA) | diff --git a/docs/landing/resources/api/composables.iusesessioncontext.paymentmethod.md b/docs/landing/resources/api/composables.iusesessioncontext.paymentmethod.md index c3f08eb5c..17668b3e0 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.paymentmethod.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.paymentmethod.md @@ -10,5 +10,5 @@ Signature: ```typescript -paymentMethod: Readonly>; +paymentMethod: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.iusesessioncontext.shippingmethod.md b/docs/landing/resources/api/composables.iusesessioncontext.shippingmethod.md index 8555c55c0..d2c895026 100644 --- a/docs/landing/resources/api/composables.iusesessioncontext.shippingmethod.md +++ b/docs/landing/resources/api/composables.iusesessioncontext.shippingmethod.md @@ -10,5 +10,5 @@ Signature: ```typescript -shippingMethod: Readonly>; +shippingMethod: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.md b/docs/landing/resources/api/composables.md index 7a14ed69b..978c53e9f 100644 --- a/docs/landing/resources/api/composables.md +++ b/docs/landing/resources/api/composables.md @@ -34,6 +34,7 @@ | [IUseUser](./composables.iuseuser.md) | (BETA) interface for [useUser](./composables.useuser.md) composable | | [IUseWishlist](./composables.iusewishlist.md) | (BETA) interface for [useWishlist](./composables.usewishlist.md) composable | | [Notification\_2](./composables.notification_2.md) | (BETA) | +| [Routing](./composables.routing.md) | (BETA) | | [UseCountries](./composables.usecountries.md) | (BETA) | | [UseCountry](./composables.usecountry.md) | (BETA) | | [UseCurrency](./composables.usecurrency.md) | (BETA) | diff --git a/docs/landing/resources/api/composables.routing.availabledomains.md b/docs/landing/resources/api/composables.routing.availabledomains.md new file mode 100644 index 000000000..4402c3424 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.availabledomains.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [availableDomains](./composables.routing.availabledomains.md) + +## Routing.availableDomains property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +availableDomains: any; +``` diff --git a/docs/landing/resources/api/composables.routing.fallbackdomain.md b/docs/landing/resources/api/composables.routing.fallbackdomain.md new file mode 100644 index 000000000..c2f5bfd35 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.fallbackdomain.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [fallbackDomain](./composables.routing.fallbackdomain.md) + +## Routing.fallbackDomain property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fallbackDomain: string | undefined; +``` diff --git a/docs/landing/resources/api/composables.routing.fallbacklocale.md b/docs/landing/resources/api/composables.routing.fallbacklocale.md new file mode 100644 index 000000000..d16566022 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.fallbacklocale.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [fallbackLocale](./composables.routing.fallbacklocale.md) + +## Routing.fallbackLocale property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fallbackLocale: string | undefined; +``` diff --git a/docs/landing/resources/api/composables.routing.getcurrentdomain.md b/docs/landing/resources/api/composables.routing.getcurrentdomain.md new file mode 100644 index 000000000..105c6fce0 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.getcurrentdomain.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [getCurrentDomain](./composables.routing.getcurrentdomain.md) + +## Routing.getCurrentDomain property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +getCurrentDomain: ComputedRef; +``` diff --git a/docs/landing/resources/api/composables.routing.geturl.md b/docs/landing/resources/api/composables.routing.geturl.md new file mode 100644 index 000000000..2a2e49e38 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.geturl.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [getUrl](./composables.routing.geturl.md) + +## Routing.getUrl property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +getUrl: (path: string) => string; +``` diff --git a/docs/landing/resources/api/composables.routing.md b/docs/landing/resources/api/composables.routing.md new file mode 100644 index 000000000..597075065 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) + +## Routing interface + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export interface Routing +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [availableDomains](./composables.routing.availabledomains.md) | any | (BETA) | +| [fallbackDomain](./composables.routing.fallbackdomain.md) | string \| undefined | (BETA) | +| [fallbackLocale](./composables.routing.fallbacklocale.md) | string \| undefined | (BETA) | +| [getCurrentDomain](./composables.routing.getcurrentdomain.md) | ComputedRef<string> | (BETA) | +| [getUrl](./composables.routing.geturl.md) | (path: string) => string | (BETA) | +| [pwaHost](./composables.routing.pwahost.md) | string \| undefined | (BETA) | +| [setCurrentDomain](./composables.routing.setcurrentdomain.md) | (domainData: any) => void | (BETA) | + diff --git a/docs/landing/resources/api/composables.routing.pwahost.md b/docs/landing/resources/api/composables.routing.pwahost.md new file mode 100644 index 000000000..bf2bf381d --- /dev/null +++ b/docs/landing/resources/api/composables.routing.pwahost.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [pwaHost](./composables.routing.pwahost.md) + +## Routing.pwaHost property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +pwaHost: string | undefined; +``` diff --git a/docs/landing/resources/api/composables.routing.setcurrentdomain.md b/docs/landing/resources/api/composables.routing.setcurrentdomain.md new file mode 100644 index 000000000..3b3e12a28 --- /dev/null +++ b/docs/landing/resources/api/composables.routing.setcurrentdomain.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@shopware-pwa/composables](./composables.md) > [Routing](./composables.routing.md) > [setCurrentDomain](./composables.routing.setcurrentdomain.md) + +## Routing.setCurrentDomain property + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +setCurrentDomain: (domainData: any) => void; +``` diff --git a/docs/landing/resources/api/composables.usecountries.getcountries.md b/docs/landing/resources/api/composables.usecountries.getcountries.md index 0ca767291..f2729df0b 100644 --- a/docs/landing/resources/api/composables.usecountries.getcountries.md +++ b/docs/landing/resources/api/composables.usecountries.getcountries.md @@ -10,5 +10,5 @@ Signature: ```typescript -getCountries: Ref>; +getCountries: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usecountry.displaystate.md b/docs/landing/resources/api/composables.usecountry.displaystate.md index 086aeb565..5cb04024b 100644 --- a/docs/landing/resources/api/composables.usecountry.displaystate.md +++ b/docs/landing/resources/api/composables.usecountry.displaystate.md @@ -10,5 +10,5 @@ Signature: ```typescript -displayState: Readonly>; +displayState: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usecountry.forcestate.md b/docs/landing/resources/api/composables.usecountry.forcestate.md index 323af8c47..c13f0a797 100644 --- a/docs/landing/resources/api/composables.usecountry.forcestate.md +++ b/docs/landing/resources/api/composables.usecountry.forcestate.md @@ -10,5 +10,5 @@ Signature: ```typescript -forceState: Readonly>; +forceState: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usecountry.md b/docs/landing/resources/api/composables.usecountry.md index a30fcd410..5310f613d 100644 --- a/docs/landing/resources/api/composables.usecountry.md +++ b/docs/landing/resources/api/composables.usecountry.md @@ -11,5 +11,5 @@ Signature: ```typescript -useCountry: (countryId: Ref>, countries: Ref>) => UseCountry +useCountry: (countryId: ComputedRef, countries: ComputedRef) => UseCountry ``` diff --git a/docs/landing/resources/api/composables.usecurrency.availablecurrencies.md b/docs/landing/resources/api/composables.usecurrency.availablecurrencies.md index 939b72b44..8a091af53 100644 --- a/docs/landing/resources/api/composables.usecurrency.availablecurrencies.md +++ b/docs/landing/resources/api/composables.usecurrency.availablecurrencies.md @@ -10,5 +10,5 @@ Signature: ```typescript -availableCurrencies: Readonly>; +availableCurrencies: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usecurrency.currency.md b/docs/landing/resources/api/composables.usecurrency.currency.md index edbbf0b9c..7d490b55c 100644 --- a/docs/landing/resources/api/composables.usecurrency.currency.md +++ b/docs/landing/resources/api/composables.usecurrency.currency.md @@ -10,5 +10,5 @@ Signature: ```typescript -currency: Readonly>; +currency: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usecurrency.currencysymbol.md b/docs/landing/resources/api/composables.usecurrency.currencysymbol.md index 92b062973..6233ad7a0 100644 --- a/docs/landing/resources/api/composables.usecurrency.currencysymbol.md +++ b/docs/landing/resources/api/composables.usecurrency.currencysymbol.md @@ -10,5 +10,5 @@ Signature: ```typescript -currencySymbol: Ref>; +currencySymbol: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.usesalutations.getsalutations.md b/docs/landing/resources/api/composables.usesalutations.getsalutations.md index df7ae1839..4ff9e4b24 100644 --- a/docs/landing/resources/api/composables.usesalutations.getsalutations.md +++ b/docs/landing/resources/api/composables.usesalutations.getsalutations.md @@ -10,5 +10,5 @@ Signature: ```typescript -getSalutations: Ref>; +getSalutations: ComputedRef; ``` diff --git a/docs/landing/resources/api/composables.useuistate.md b/docs/landing/resources/api/composables.useuistate.md index e3cef39d0..3e4b71d30 100644 --- a/docs/landing/resources/api/composables.useuistate.md +++ b/docs/landing/resources/api/composables.useuistate.md @@ -13,7 +13,7 @@ Simple state management for UI purposes. ```typescript useUIState: (rootContext: ApplicationVueContext, stateName?: string | undefined) => { - isOpen: Readonly>; + isOpen: ComputedRef; switchState: (to?: boolean | undefined) => void; } ``` diff --git a/packages/composables/src/hooks/useCountries.ts b/packages/composables/src/hooks/useCountries.ts index 8319549c4..30e4e5d09 100644 --- a/packages/composables/src/hooks/useCountries.ts +++ b/packages/composables/src/hooks/useCountries.ts @@ -1,5 +1,12 @@ import Vue from "vue"; -import { computed, Ref, ref, reactive, onMounted } from "@vue/composition-api"; +import { + computed, + Ref, + ref, + reactive, + onMounted, + ComputedRef, +} from "@vue/composition-api"; import { getAvailableCountries } from "@shopware-pwa/shopware-6-client"; import { ClientApiError } from "@shopware-pwa/commons/interfaces/errors/ApiError"; import { getApplicationContext } from "@shopware-pwa/composables"; @@ -11,7 +18,7 @@ import { Country } from "@shopware-pwa/commons/interfaces/models/system/country/ */ export interface UseCountries { mountedCallback: () => Promise; - getCountries: Ref>; + getCountries: ComputedRef; fetchCountries: () => Promise; error: Ref; } diff --git a/packages/composables/src/hooks/useCountry.ts b/packages/composables/src/hooks/useCountry.ts index 11b5bbdc0..8816523ed 100644 --- a/packages/composables/src/hooks/useCountry.ts +++ b/packages/composables/src/hooks/useCountry.ts @@ -1,4 +1,4 @@ -import { computed, ComputedRef, Ref } from "@vue/composition-api"; +import { computed, ComputedRef } from "@vue/composition-api"; import { Country } from "@shopware-pwa/commons/interfaces/models/system/country/Country"; /** @@ -6,16 +6,16 @@ import { Country } from "@shopware-pwa/commons/interfaces/models/system/country/ */ export interface UseCountry { currentCountry: ComputedRef; - displayState: Readonly>; - forceState: Readonly>; + displayState: ComputedRef; + forceState: ComputedRef; } /** * @beta */ export const useCountry = ( - countryId: Ref>, - countries: Ref> + countryId: ComputedRef, + countries: ComputedRef ): UseCountry => { const currentCountry = computed(() => { if (!countryId.value) return null; diff --git a/packages/composables/src/hooks/useCurrency.ts b/packages/composables/src/hooks/useCurrency.ts index afc511ee6..583b78d2a 100644 --- a/packages/composables/src/hooks/useCurrency.ts +++ b/packages/composables/src/hooks/useCurrency.ts @@ -1,5 +1,5 @@ import Vue from "vue"; -import { reactive, computed, Ref } from "@vue/composition-api"; +import { reactive, computed, ComputedRef } from "@vue/composition-api"; import { getAvailableCurrencies } from "@shopware-pwa/shopware-6-client"; import { useSessionContext, useCart } from "@shopware-pwa/composables"; import { Currency } from "@shopware-pwa/commons/interfaces/models/system/currency/Currency"; @@ -17,9 +17,9 @@ export interface UseCurrency { forceReload: boolean; }) => Promise; setCurrency: (parameter: Partial) => Promise; - availableCurrencies: Readonly>; - currency: Readonly>; - currencySymbol: Ref>; + availableCurrencies: ComputedRef; + currency: ComputedRef; + currencySymbol: ComputedRef; } /** diff --git a/packages/composables/src/hooks/useSalutations.ts b/packages/composables/src/hooks/useSalutations.ts index 3c497f452..432bc359a 100644 --- a/packages/composables/src/hooks/useSalutations.ts +++ b/packages/composables/src/hooks/useSalutations.ts @@ -1,16 +1,24 @@ import Vue from "vue"; -import { Ref, ref, computed, reactive, onMounted } from "@vue/composition-api"; +import { + Ref, + ref, + computed, + reactive, + onMounted, + ComputedRef, +} from "@vue/composition-api"; import { getAvailableSalutations } from "@shopware-pwa/shopware-6-client"; import { ClientApiError } from "@shopware-pwa/commons/interfaces/errors/ApiError"; import { getApplicationContext } from "@shopware-pwa/composables"; import { ApplicationVueContext } from "../appContext"; +import { Salutation } from "@shopware-pwa/commons/interfaces/models/system/salutation/Salutation"; /** * @beta */ export interface UseSalutations { mountedCallback: () => Promise; - getSalutations: Ref>; + getSalutations: ComputedRef; fetchSalutations: () => Promise; error: Ref; } diff --git a/packages/composables/src/index.ts b/packages/composables/src/index.ts index 46a74d581..d24746d9c 100644 --- a/packages/composables/src/index.ts +++ b/packages/composables/src/index.ts @@ -24,4 +24,8 @@ export * from "./logic/useProductConfigurator"; export * from "./logic/useBreadcrumbs"; export * from "./logic/useProductAssociations"; export * from "./logic/useSharedState"; -export { getApplicationContext, ApplicationVueContext } from "./appContext"; +export { + getApplicationContext, + ApplicationVueContext, + Routing, +} from "./appContext"; diff --git a/packages/composables/src/logic/useCheckout.ts b/packages/composables/src/logic/useCheckout.ts index 0a24fa46f..4010f42a0 100644 --- a/packages/composables/src/logic/useCheckout.ts +++ b/packages/composables/src/logic/useCheckout.ts @@ -1,4 +1,9 @@ -import { Ref, computed, UnwrapRef, reactive } from "@vue/composition-api"; +import { + computed, + UnwrapRef, + reactive, + ComputedRef, +} from "@vue/composition-api"; import { ShippingAddress } from "@shopware-pwa/commons/interfaces/models/checkout/customer/ShippingAddress"; import { ShippingMethod } from "@shopware-pwa/commons/interfaces/models/checkout/shipping/ShippingMethod"; import { PaymentMethod } from "@shopware-pwa/commons/interfaces/models/checkout/payment/PaymentMethod"; @@ -28,15 +33,15 @@ import { BillingAddress } from "@shopware-pwa/commons/interfaces/models/checkout export interface IUseCheckout { getShippingMethods: (options?: { forceReload: boolean; - }) => Promise>>; - shippingMethods: Readonly>; + }) => Promise>; + shippingMethods: ComputedRef; getPaymentMethods: (options?: { forceReload: boolean; - }) => Promise>>; - paymentMethods: Readonly>; + }) => Promise>; + paymentMethods: ComputedRef; createOrder: () => Promise; - shippingAddress: Readonly>; - billingAddress: Readonly | undefined>>; + shippingAddress: ComputedRef; + billingAddress: ComputedRef | undefined>; onOrderPlace: (fn: (params: { order: Order }) => void) => void; loadings: UnwrapRef<{ createOrder: boolean; diff --git a/packages/composables/src/logic/useSessionContext.ts b/packages/composables/src/logic/useSessionContext.ts index 85a78990f..ca42ab548 100644 --- a/packages/composables/src/logic/useSessionContext.ts +++ b/packages/composables/src/logic/useSessionContext.ts @@ -1,4 +1,4 @@ -import { Ref, computed, ComputedRef } from "@vue/composition-api"; +import { computed, ComputedRef } from "@vue/composition-api"; import { ShippingMethod } from "@shopware-pwa/commons/interfaces/models/checkout/shipping/ShippingMethod"; import { PaymentMethod } from "@shopware-pwa/commons/interfaces/models/checkout/payment/PaymentMethod"; import { Currency } from "@shopware-pwa/commons/interfaces/models/system/currency/Currency"; @@ -33,17 +33,17 @@ import { ApplicationVueContext } from "../appContext"; export interface IUseSessionContext { sessionContext: ComputedRef; refreshSessionContext: () => Promise; - shippingMethod: Readonly>; + shippingMethod: ComputedRef; setShippingMethod: (shippingMethod: Partial) => Promise; - paymentMethod: Readonly>; + paymentMethod: ComputedRef; setPaymentMethod: (paymentMethod: Partial) => Promise; - currency: Readonly>; + currency: ComputedRef; setCurrency: (currency: Partial) => Promise; - activeShippingAddress: Readonly>; + activeShippingAddress: ComputedRef; setActiveShippingAddress: ( address: Partial ) => Promise; - activeBillingAddress: Readonly>; + activeBillingAddress: ComputedRef; setActiveBillingAddress: (address: Partial) => Promise; countryId: ComputedRef; // events for interceptors diff --git a/packages/composables/src/logic/useUIState.ts b/packages/composables/src/logic/useUIState.ts index 4fc5f28ed..9f030ba9e 100644 --- a/packages/composables/src/logic/useUIState.ts +++ b/packages/composables/src/logic/useUIState.ts @@ -1,5 +1,11 @@ import Vue from "vue"; -import { computed, reactive, ref, Ref } from "@vue/composition-api"; +import { + computed, + ComputedRef, + reactive, + ref, + Ref, +} from "@vue/composition-api"; import { getApplicationContext } from "@shopware-pwa/composables"; import { ApplicationVueContext } from "../appContext"; @@ -41,7 +47,7 @@ const sharedUIState: any = {}; export const useUIState = ( rootContext: ApplicationVueContext, stateName?: string -): { isOpen: Readonly>; switchState: (to?: boolean) => void } => { +): { isOpen: ComputedRef; switchState: (to?: boolean) => void } => { getApplicationContext(rootContext, "useUIState"); if (stateName && !sharedUIState[stateName]) { sharedUIState[stateName] = Vue.observable({ state: false } as any); diff --git a/packages/default-theme/src/components/forms/SwRegistrationForm.vue b/packages/default-theme/src/components/forms/SwRegistrationForm.vue index c2d1ddb36..7ce1c2859 100644 --- a/packages/default-theme/src/components/forms/SwRegistrationForm.vue +++ b/packages/default-theme/src/components/forms/SwRegistrationForm.vue @@ -331,7 +331,7 @@ export default { alternativeCity: "", alternativeZipcode: "", alternativePhoneNumber: "", - }) + } as any) watch(countryId, () => { state.countryId = countryId.value })