basklee-svelte 0.9.14 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/src/lib/components/basklee/account/StorefrontProfile.svelte +2 -1
- package/templates/src/lib/components/basklee/cart/CartCheckoutDetails.svelte +2 -2
- package/templates/src/lib/components/basklee/orders/OrderDetails.svelte +2 -1
- package/templates/src/lib/utils/basklee/phone.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-svelte",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.16",
|
|
4
4
|
"description": "SvelteKit 2 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useBaskleeStore } from '@/lib/stores/basklee.svelte';
|
|
4
4
|
import { useBaskleeSelectionsStore } from '@/lib/stores/baskleeSelections.svelte';
|
|
5
5
|
import { profileLabels } from '@/lib/utils/basklee/profileLabels';
|
|
6
|
+
import { phoneForDisplay } from '@/lib/utils/basklee/phone';
|
|
6
7
|
import { featureLabels } from '@/lib/utils/basklee/featureLabels';
|
|
7
8
|
import '@/lib/components/basklee/shared/features.css';
|
|
8
9
|
import type {
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
>
|
|
151
152
|
<path d="M8 3h8v18H8zM11 18h2"></path>
|
|
152
153
|
</svg>
|
|
153
|
-
{store.profile.phone}
|
|
154
|
+
{phoneForDisplay(store.profile.phone)}
|
|
154
155
|
</li>
|
|
155
156
|
{/if}
|
|
156
157
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useBaskleeCartContext } from '@/lib/composables/useBaskleeCart.svelte';
|
|
5
5
|
import { featureLabels } from '@/lib/utils/basklee/featureLabels';
|
|
6
6
|
import { cartLabels } from '@/lib/utils/basklee/cartLabels';
|
|
7
|
+
import { phoneForDisplay } from '@/lib/utils/basklee/phone';
|
|
7
8
|
import { phoneWithCountryCode } from '@/lib/utils/basklee/phone';
|
|
8
9
|
import { getAvailableValueFromObject } from '@/lib/utils/basklee/presentation';
|
|
9
10
|
import {
|
|
@@ -237,8 +238,7 @@
|
|
|
237
238
|
{labels.value.recipient}
|
|
238
239
|
</h2>
|
|
239
240
|
<p class={['op-feature-copy']}>
|
|
240
|
-
{summary.value?.contact.receiver?.full_name} · {summary.value?.contact
|
|
241
|
-
.receiver?.phone}
|
|
241
|
+
{summary.value?.contact.receiver?.full_name} · {phoneForDisplay(summary.value?.contact.receiver?.phone)}
|
|
242
242
|
</p>
|
|
243
243
|
<div class={['op-feature-actions']}>
|
|
244
244
|
<button
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useBaskleeStore } from '@/lib/stores/basklee.svelte';
|
|
5
5
|
import { useBaskleeSelectionsStore } from '@/lib/stores/baskleeSelections.svelte';
|
|
6
6
|
import { orderLabels } from '@/lib/utils/basklee/orderLabels';
|
|
7
|
+
import { phoneForDisplay } from '@/lib/utils/basklee/phone';
|
|
7
8
|
import {
|
|
8
9
|
hasOrderAmount,
|
|
9
10
|
orderAmount,
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
const shipments = computed(() => inputs.order.delivery_froms ?? []);
|
|
98
99
|
const recipient = computed(() => ({
|
|
99
100
|
name: inputs.order.contact.reciever_name || inputs.order.contact.full_name,
|
|
100
|
-
phone: inputs.order.contact.reciever_phone || inputs.order.contact.phone,
|
|
101
|
+
phone: phoneForDisplay(inputs.order.contact.reciever_phone || inputs.order.contact.phone),
|
|
101
102
|
email: inputs.order.contact.email,
|
|
102
103
|
}));
|
|
103
104
|
const method = computed(() =>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* A phone number typed without «+» on the Russian storefront, as people in
|
|
3
5
|
* Russia usually type it: «8 900 555-01-72» (the domestic prefix 8) or
|
|
@@ -20,3 +22,19 @@ export function phoneWithCountryCode(value: string, locale: string): string {
|
|
|
20
22
|
}
|
|
21
23
|
return value;
|
|
22
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A stored phone as people read it: «+12125550161» becomes «+1 212 555 0161»,
|
|
28
|
+
* «+74955550162» becomes «+7 495 555 01 62». The backend keeps numbers in the
|
|
29
|
+
* international format without spaces; a number the library cannot read is
|
|
30
|
+
* shown as stored.
|
|
31
|
+
*/
|
|
32
|
+
export function phoneForDisplay(value: string | null | undefined): string {
|
|
33
|
+
const text = (value ?? '').trim();
|
|
34
|
+
|
|
35
|
+
if (!text) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return parsePhoneNumberFromString(text)?.formatInternational() ?? text;
|
|
40
|
+
}
|