basklee-svelte 0.9.3 → 0.9.5
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/README.md +4 -0
- package/package.json +2 -2
- package/templates/src/lib/components/basklee/account/StorefrontLogout.README.md +2 -0
- package/templates/src/lib/components/basklee/blog/BlogArticle.README.md +1 -1
- package/templates/src/lib/components/basklee/blog/BlogArticle.svelte +55 -9
- package/templates/src/lib/components/basklee/orders/OrderDetails.README.md +2 -0
- package/templates/src/lib/components/basklee/orders/OrderDetails.svelte +5 -0
- package/templates/src/lib/components/basklee/storefront/StorefrontFooter.README.md +6 -0
- package/templates/src/lib/components/basklee/storefront/StorefrontFooter.svelte +25 -7
- package/templates/src/lib/components/basklee/stores/StorefrontStores.README.md +2 -0
- package/templates/src/lib/components/basklee/stores/StorefrontStores.svelte +2 -1
- package/templates/src/lib/utils/basklee/blogArticleHtml.ts +267 -2
- package/templates/src/lib/utils/basklee/browseLabels.ts +12 -0
- package/templates/src/lib/utils/basklee/cartLabels.ts +3 -0
- package/templates/src/lib/utils/basklee/contactLabels.ts +12 -0
- package/templates/src/lib/utils/basklee/directoryLabels.ts +3 -0
- package/templates/src/lib/utils/basklee/featureLabels.ts +12 -0
- package/templates/src/lib/utils/basklee/footerLabels.ts +3 -0
- package/templates/src/lib/utils/basklee/htmlText.ts +1 -1
- package/templates/src/lib/utils/basklee/profile.ts +52 -0
- package/templates/src/lib/utils/basklee/profileLabels.ts +15 -0
- package/templates/src/lib/utils/basklee/reviewLabels.ts +6 -0
- package/templates/src/lib/utils/basklee/sellerDirectory.ts +93 -0
- package/templates/src/lib/utils/basklee/sessionLabels.ts +6 -6
- package/templates/src/lib/utils/basklee/storeDirectory.ts +26 -0
- package/templates/src/lib/utils/basklee/subscriptionLabels.ts +3 -0
- package/templates/src/lib/utils/basklee/tabLocation.ts +37 -0
- package/templates/src/lib/utils/basklee/ticketDraft.ts +56 -0
- package/templates/src/routes/browse/+page.svelte +2 -2
package/README.md
CHANGED
|
@@ -641,3 +641,7 @@ The store is scoped to one render on the server and the root layout in the
|
|
|
641
641
|
browser. It preserves valid selections when Application Load refreshes. HTTP
|
|
642
642
|
401 clears account data and refreshes the guest session without repeating the
|
|
643
643
|
failed mutation. API validation errors remain beside the affected form.
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
647
|
+
Powered by [Basklee](https://basklee.com).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-svelte",
|
|
3
|
-
"version": "0.9.
|
|
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.",
|
|
3
|
+
"version": "0.9.5",
|
|
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",
|
|
7
7
|
"author": "Basklee",
|
|
@@ -10,6 +10,8 @@ running, failed and finished states and sends no other request.
|
|
|
10
10
|
|
|
11
11
|
Source: `src/lib/components/basklee/account/StorefrontLogout.svelte`.
|
|
12
12
|
|
|
13
|
+
The progress and success messages say that the session is ended on all devices: `profile_logout` signs the customer out everywhere, and the page says so.
|
|
14
|
+
|
|
13
15
|
## Inputs
|
|
14
16
|
|
|
15
17
|
| Input | Type | Default |
|
|
@@ -6,7 +6,7 @@ The article page shows one journal article: its cover, its text, the products at
|
|
|
6
6
|
|
|
7
7
|
Article videos may come as the backend's own paths (`/ps3/...`). In an Android app build those paths (cover, videos, images and videos inside the text) load from the storefront address.
|
|
8
8
|
|
|
9
|
-
The text
|
|
9
|
+
The server render shows the text as plain blocks (`blogArticleBlocks` in `src/lib/utils/basklee/blogArticleHtml.ts`): headings, paragraphs with their checked links, lists, quotes and pictures with captions, so search engines read the structure without scripts; in the browser the text is then sanitized with DOMPurify. A YouTube player the editor inserts (an `<iframe>` with a `youtube.com` or `youtube-nocookie.com` `/embed/<id>` address) is kept and played from `youtube-nocookie.com` at the article's width in 16:9, with fixed `allow`, `loading="lazy"` and referrer attributes and an optional start second. Other frames, scripts, forms and event attributes are removed.
|
|
10
10
|
|
|
11
11
|
The cover and the images of the text open larger: a click, Enter or Space on one opens `ProductReviewImageViewer` at that image, with the article's other images a step away and each image's caption (its `figcaption`, else its `title`, else its `alt`) under it. The images get `role="button"`, a keyboard stop and an «Open image» name; a zoom-in cursor marks them. Images inside a link, a button or a product placement keep their own action. The helper is `src/lib/utils/basklee/blogImageViewer.ts`.
|
|
12
12
|
|
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
safePublicUrl,
|
|
24
24
|
} from '@/lib/utils/basklee/presentation';
|
|
25
25
|
import {
|
|
26
|
+
blogArticleBlocks,
|
|
26
27
|
removeLeadingDuplicateBlogHeading,
|
|
27
28
|
safeBlogArticleHtml,
|
|
29
|
+
type IBlogArticleInline,
|
|
30
|
+
type TBlogArticleBlock,
|
|
28
31
|
} from '@/lib/utils/basklee/blogArticleHtml';
|
|
29
|
-
import { htmlTextParagraphs } from '@/lib/utils/basklee/htmlText';
|
|
30
32
|
import { APP_ORIGIN, appMediaUrl } from '@/lib/utils/basklee/nativeApp';
|
|
31
33
|
import { requestBlogPost } from '@/lib/utils/basklee/blogLayout';
|
|
32
34
|
import {
|
|
@@ -213,10 +215,12 @@
|
|
|
213
215
|
removeLeadingDuplicateBlogHeading(source.value, title.value),
|
|
214
216
|
);
|
|
215
217
|
const html = computed(() => safeBlogArticleHtml(articleSource.value));
|
|
216
|
-
// The server render and hydration show the text as plain
|
|
217
|
-
//
|
|
218
|
+
// The server render and hydration show the text as plain blocks (headings,
|
|
219
|
+
// paragraphs with links, lists, quotes, pictures: blogArticleBlocks), so
|
|
220
|
+
// search engines read its structure; the sanitized HTML replaces them once
|
|
221
|
+
// the component is mounted.
|
|
218
222
|
const mounted = ref(false);
|
|
219
|
-
const
|
|
223
|
+
const blocks = computed(() => blogArticleBlocks(articleSource.value));
|
|
220
224
|
const cover = computed(() => {
|
|
221
225
|
const images = [...(post.value?.preview_images ?? [])].sort(
|
|
222
226
|
(left, right) => left.display_order - right.display_order,
|
|
@@ -415,6 +419,52 @@
|
|
|
415
419
|
});
|
|
416
420
|
</script>
|
|
417
421
|
|
|
422
|
+
{#snippet articleInline(parts: IBlogArticleInline[])}
|
|
423
|
+
{#each parts as part, index (index)}
|
|
424
|
+
{#if part.href}
|
|
425
|
+
<a
|
|
426
|
+
href={part.href}
|
|
427
|
+
target={part.external ? '_blank' : undefined}
|
|
428
|
+
rel={part.external ? 'noopener noreferrer' : undefined}
|
|
429
|
+
>{part.text}</a>
|
|
430
|
+
{:else}{part.text}{/if}
|
|
431
|
+
{/each}
|
|
432
|
+
{/snippet}
|
|
433
|
+
|
|
434
|
+
{#snippet articleBlocks(items: TBlogArticleBlock[])}
|
|
435
|
+
{#each items as block, index (index)}
|
|
436
|
+
{#if block.kind === 'heading'}
|
|
437
|
+
<svelte:element this={`h${block.level}`}>{@render articleInline(block.inline)}</svelte:element>
|
|
438
|
+
{:else if block.kind === 'paragraph'}
|
|
439
|
+
<p>{@render articleInline(block.inline)}</p>
|
|
440
|
+
{:else if block.kind === 'list'}
|
|
441
|
+
<svelte:element this={block.ordered ? 'ol' : 'ul'}>
|
|
442
|
+
{#each block.items as item, itemIndex (itemIndex)}
|
|
443
|
+
<li>{@render articleInline(item)}</li>
|
|
444
|
+
{/each}
|
|
445
|
+
</svelte:element>
|
|
446
|
+
{:else if block.kind === 'quote'}
|
|
447
|
+
<blockquote>{@render articleBlocks(block.blocks)}</blockquote>
|
|
448
|
+
{:else if block.kind === 'image'}
|
|
449
|
+
<figure>
|
|
450
|
+
<!-- Without the editor's size the box stays 3:2 until the formatted text replaces it. -->
|
|
451
|
+
<img
|
|
452
|
+
src={block.src}
|
|
453
|
+
alt={block.alt}
|
|
454
|
+
width={block.width}
|
|
455
|
+
height={block.height}
|
|
456
|
+
loading="lazy"
|
|
457
|
+
decoding="async"
|
|
458
|
+
style={block.width && block.height ? undefined : 'aspect-ratio: 3 / 2; object-fit: contain'}
|
|
459
|
+
/>
|
|
460
|
+
{#if block.caption}
|
|
461
|
+
<figcaption>{block.caption}</figcaption>
|
|
462
|
+
{/if}
|
|
463
|
+
</figure>
|
|
464
|
+
{/if}
|
|
465
|
+
{/each}
|
|
466
|
+
{/snippet}
|
|
467
|
+
|
|
418
468
|
<section
|
|
419
469
|
{...attributes}
|
|
420
470
|
data-feature-part="BlogArticle"
|
|
@@ -528,11 +578,7 @@
|
|
|
528
578
|
bind:this={article.value}
|
|
529
579
|
class={['op-feature-prose']}
|
|
530
580
|
>
|
|
531
|
-
{
|
|
532
|
-
<p>
|
|
533
|
-
{paragraph}
|
|
534
|
-
</p>
|
|
535
|
-
{/each}
|
|
581
|
+
{@render articleBlocks(blocks.value)}
|
|
536
582
|
</div>
|
|
537
583
|
{/if}
|
|
538
584
|
{#each placements.value as placement, index (index)}
|
|
@@ -6,6 +6,8 @@ The details show one placed order in full. The order is handed to the component
|
|
|
6
6
|
|
|
7
7
|
Source: `src/lib/components/basklee/orders/OrderDetails.svelte`.
|
|
8
8
|
|
|
9
|
+
While nothing has left yet, the first step of the rail carries the order's own status word, Processing, in place of Placed: the status card and the rail name one stage, not two.
|
|
10
|
+
|
|
9
11
|
## Inputs
|
|
10
12
|
|
|
11
13
|
| Input | Type | Default |
|
|
@@ -177,6 +177,11 @@
|
|
|
177
177
|
if (step.state === 'partial' && step.key === 'delivered') {
|
|
178
178
|
return statuses.partlyDelivered;
|
|
179
179
|
}
|
|
180
|
+
// While nothing has left, the first step carries the order's own status
|
|
181
|
+
// word («Processing»): the card and the rail name one stage, not two.
|
|
182
|
+
if (step.key === 'placed' && step.current) {
|
|
183
|
+
return statuses.processing;
|
|
184
|
+
}
|
|
180
185
|
|
|
181
186
|
return labels.value.steps[step.key];
|
|
182
187
|
}
|
|
@@ -27,3 +27,9 @@ Source: `src/lib/components/basklee/storefront/StorefrontFooter.svelte`.
|
|
|
27
27
|
Navigation omits categories with `exclude_from_tree: true` and all their descendants. The full published catalog remains available for product main-category names, links and breadcrumbs.
|
|
28
28
|
|
|
29
29
|
В навигации скрываются категории с `exclude_from_tree: true` и все их подкатегории. Полный каталог опубликованных категорий сохраняется для названий, ссылок и цепочек основной категории товара.
|
|
30
|
+
|
|
31
|
+
## Powered by Basklee
|
|
32
|
+
|
|
33
|
+
The bottom line of the footer ends with a small link, «Powered by Basklee»: an `<a href="https://basklee.com">` that opens in a new tab and is marked `data-footer-part="PoweredBy"`. Its text is the `powered` label of `footerLabels` (English, Russian, Spanish). The link is external, so the navigation callback is not called for it.
|
|
34
|
+
|
|
35
|
+
Нижняя строка футера заканчивается маленькой ссылкой «Работает на Basklee»: это `<a href="https://basklee.com">`, она открывается в новой вкладке и отмечена `data-footer-part="PoweredBy"`. Её текст — подпись `powered` из `footerLabels` (английский, русский, испанский). Ссылка внешняя, поэтому обработчик навигации для неё не вызывается.
|
|
@@ -256,17 +256,35 @@
|
|
|
256
256
|
</a>
|
|
257
257
|
</nav>
|
|
258
258
|
</div>
|
|
259
|
-
<
|
|
259
|
+
<div
|
|
260
260
|
class={[
|
|
261
261
|
`
|
|
262
|
-
|
|
263
|
-
border-basklee-inverse-text/15
|
|
264
|
-
tracking-[0.08em]
|
|
262
|
+
flex flex-wrap items-baseline justify-between gap-x-6 gap-y-1 pt-6
|
|
263
|
+
border-0 border-t border-solid border-basklee-inverse-text/15
|
|
264
|
+
text-xs uppercase leading-6 tracking-[0.08em]
|
|
265
|
+
text-basklee-inverse-muted
|
|
265
266
|
`,
|
|
266
267
|
]}
|
|
267
268
|
>
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
<p class="m-0">
|
|
270
|
+
© {inputs.year}
|
|
271
|
+
{company.value} · {copy.value.rights}
|
|
272
|
+
</p>
|
|
273
|
+
<a
|
|
274
|
+
href="https://basklee.com"
|
|
275
|
+
target="_blank"
|
|
276
|
+
rel="noopener"
|
|
277
|
+
class={[
|
|
278
|
+
`
|
|
279
|
+
text-basklee-inverse-muted no-underline outline-none
|
|
280
|
+
hover:text-basklee-inverse-text
|
|
281
|
+
focus-visible:text-basklee-inverse-text
|
|
282
|
+
`,
|
|
283
|
+
]}
|
|
284
|
+
data-footer-part="PoweredBy"
|
|
285
|
+
>
|
|
286
|
+
{copy.value.powered}
|
|
287
|
+
</a>
|
|
288
|
+
</div>
|
|
271
289
|
</div>
|
|
272
290
|
</footer>
|
|
@@ -18,6 +18,8 @@ and `page`, so a reload or Back from a store's products opens the same list.
|
|
|
18
18
|
|
|
19
19
|
Source: `src/lib/components/basklee/stores/StorefrontStores.svelte`.
|
|
20
20
|
|
|
21
|
+
A phone number is shown as people read it: a number typed with its own spaces, brackets or dashes stays as typed, and a bare run of digits is grouped from the end (`+78120000078` reads `+7 812 000 00 78`). The dial link keeps the digits only.
|
|
22
|
+
|
|
21
23
|
## Inputs
|
|
22
24
|
|
|
23
25
|
| Input | Type | Default |
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
storeMapMarkers,
|
|
26
26
|
storeMarkerId,
|
|
27
27
|
storePhoneLink,
|
|
28
|
+
storePhoneText,
|
|
28
29
|
} from '@/lib/utils/basklee/storeDirectory';
|
|
29
30
|
import type { IApiPagination } from '@/lib/interfaces/basklee/accounts/IProfileData';
|
|
30
31
|
import type {
|
|
@@ -347,7 +348,7 @@
|
|
|
347
348
|
href={storePhoneLink(item.phone_number)}
|
|
348
349
|
class={['op-feature-link self-start']}
|
|
349
350
|
>
|
|
350
|
-
{item.phone_number}
|
|
351
|
+
{storePhoneText(item.phone_number)}
|
|
351
352
|
</a>
|
|
352
353
|
{/if}
|
|
353
354
|
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
DOMPurify as TPurifier,
|
|
5
5
|
UponSanitizeAttributeHookEvent,
|
|
6
6
|
} from 'dompurify';
|
|
7
|
-
import { htmlTextParagraphs } from '@/lib/utils/basklee/htmlText';
|
|
7
|
+
import { decodeEntities, htmlTextParagraphs } from '@/lib/utils/basklee/htmlText';
|
|
8
8
|
import { APP_ORIGIN, appMediaUrl } from '@/lib/utils/basklee/nativeApp';
|
|
9
9
|
|
|
10
10
|
type TStylePatterns = Record<string, RegExp>;
|
|
@@ -205,7 +205,7 @@ const youtubeEmbed =
|
|
|
205
205
|
/^https:\/\/(?:www\.)?youtube(?:-nocookie)?\.com\/embed\/([\w-]{11})(?:\?([^#]*))?$/i;
|
|
206
206
|
|
|
207
207
|
export const blogYoutubeAllow =
|
|
208
|
-
'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture
|
|
208
|
+
'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture';
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* The privacy-enhanced player address for a YouTube embed address, or an
|
|
@@ -455,3 +455,268 @@ export function safeBlogArticleHtml(
|
|
|
455
455
|
purifier.removeHook('afterSanitizeAttributes', prepareElementHook);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
+
|
|
459
|
+
const BLOCK_MEDIA_ORIGIN = APP_ORIGIN;
|
|
460
|
+
|
|
461
|
+
/*
|
|
462
|
+
* The server render (and the hydration that must match it) cannot run
|
|
463
|
+
* DOMPurify, so it shows the article as plain blocks built from the editor
|
|
464
|
+
* HTML: headings, paragraphs with their links, lists, quotes and pictures
|
|
465
|
+
* with captions. Nothing of the source markup is passed on: each block holds
|
|
466
|
+
* only text and checked addresses, and the component renders them with its
|
|
467
|
+
* own escaping. Search engines read the structure without scripts; the
|
|
468
|
+
* sanitized HTML replaces the blocks once the component is mounted.
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
export interface IBlogArticleInline {
|
|
472
|
+
text: string;
|
|
473
|
+
href?: string;
|
|
474
|
+
external?: boolean;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export type TBlogArticleBlock =
|
|
478
|
+
| { kind: 'heading'; level: 2 | 3 | 4; inline: IBlogArticleInline[] }
|
|
479
|
+
| { kind: 'paragraph'; inline: IBlogArticleInline[] }
|
|
480
|
+
| { kind: 'list'; ordered: boolean; items: IBlogArticleInline[][] }
|
|
481
|
+
| { kind: 'quote'; blocks: TBlogArticleBlock[] }
|
|
482
|
+
| { kind: 'image'; src: string; alt: string; caption: string; width?: number; height?: number };
|
|
483
|
+
|
|
484
|
+
const MAX_ARTICLE_BLOCKS = 600;
|
|
485
|
+
|
|
486
|
+
const skippedElements =
|
|
487
|
+
/<(script|style|template|iframe|noscript|svg|math|object|textarea|select|button|video|audio)\b[\s\S]*?<\/\1\s*>/gi;
|
|
488
|
+
|
|
489
|
+
function tagAttribute(attributes: string, name: string) {
|
|
490
|
+
const match = new RegExp(
|
|
491
|
+
`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+))`,
|
|
492
|
+
'i',
|
|
493
|
+
).exec(attributes);
|
|
494
|
+
|
|
495
|
+
return decodeEntities(match?.[1] ?? match?.[2] ?? match?.[3] ?? '').trim();
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// The scheme is checked without the characters a browser drops from an
|
|
499
|
+
// address (`java\tscript:` would run as javascript:).
|
|
500
|
+
function addressScheme(value: string) {
|
|
501
|
+
return /^([a-z][a-z\d+.-]*):/i
|
|
502
|
+
.exec(value.replace(/[\u0000- \u007f-\u009f]/g, ''))?.[1]
|
|
503
|
+
?.toLowerCase();
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function blockLink(value: string): Omit<IBlogArticleInline, 'text'> | undefined {
|
|
507
|
+
const scheme = addressScheme(value);
|
|
508
|
+
|
|
509
|
+
if (!value || value.startsWith('//') || (scheme && !['http', 'https', 'mailto', 'tel'].includes(scheme))) {
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const article = editorArticlePath.exec(value);
|
|
514
|
+
|
|
515
|
+
if (article) {
|
|
516
|
+
return { href: `/journal/${article[1]}` };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return scheme === 'http' || scheme === 'https'
|
|
520
|
+
? { href: value, external: true }
|
|
521
|
+
: { href: value };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// The editor's own picture size, when it wrote one: the server render reserves
|
|
525
|
+
// that box; without it the component keeps a 3:2 box (the guide's screenshots).
|
|
526
|
+
function blockImageSize(attributes: string) {
|
|
527
|
+
const width = Number(tagAttribute(attributes, 'width'));
|
|
528
|
+
const height = Number(tagAttribute(attributes, 'height'));
|
|
529
|
+
|
|
530
|
+
return Number.isInteger(width) && Number.isInteger(height) &&
|
|
531
|
+
width > 0 && height > 0 && width <= 10000 && height <= 10000
|
|
532
|
+
? { width, height }
|
|
533
|
+
: {};
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function blockImage(value: string, appOrigin: string) {
|
|
537
|
+
const scheme = addressScheme(value);
|
|
538
|
+
|
|
539
|
+
if (scheme === 'http' || scheme === 'https') {
|
|
540
|
+
return value;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return !scheme && value.startsWith('/') && !value.startsWith('//')
|
|
544
|
+
? appMediaUrl(value, appOrigin)
|
|
545
|
+
: '';
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function blockImageSizeOf(figure: { width?: number; height?: number }) {
|
|
549
|
+
return figure.width && figure.height ? { width: figure.width, height: figure.height } : {};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/** The article as plain blocks for the server render and the hydration. */
|
|
553
|
+
export function blogArticleBlocks(
|
|
554
|
+
value: string | undefined,
|
|
555
|
+
appOrigin = BLOCK_MEDIA_ORIGIN,
|
|
556
|
+
): TBlogArticleBlock[] {
|
|
557
|
+
const html = (value ?? '')
|
|
558
|
+
.replace(/<!--[\s\S]*?-->/g, ' ')
|
|
559
|
+
.replace(skippedElements, ' ');
|
|
560
|
+
const blocks: TBlogArticleBlock[] = [];
|
|
561
|
+
const quotes: TBlogArticleBlock[][] = [];
|
|
562
|
+
let inline: IBlogArticleInline[] = [];
|
|
563
|
+
let mode: 'heading' | 'paragraph' | 'item' | 'caption' = 'paragraph';
|
|
564
|
+
let level: 2 | 3 | 4 = 2;
|
|
565
|
+
let list: { ordered: boolean; items: IBlogArticleInline[][] } | undefined;
|
|
566
|
+
let link: Omit<IBlogArticleInline, 'text'> | undefined;
|
|
567
|
+
let figure: { src: string; alt: string; caption: string; width?: number; height?: number } | undefined;
|
|
568
|
+
let count = 0;
|
|
569
|
+
|
|
570
|
+
const target = () => quotes[quotes.length - 1] ?? blocks;
|
|
571
|
+
const push = (block: TBlogArticleBlock) => {
|
|
572
|
+
if (count < MAX_ARTICLE_BLOCKS) {
|
|
573
|
+
count += 1;
|
|
574
|
+
target().push(block);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
const flush = () => {
|
|
578
|
+
const parts = inline
|
|
579
|
+
.map((part) => ({ ...part, text: part.text.replace(/\s+/g, ' ') }))
|
|
580
|
+
.filter((part) => part.text);
|
|
581
|
+
|
|
582
|
+
inline = [];
|
|
583
|
+
if (parts.length) {
|
|
584
|
+
parts[0]!.text = parts[0]!.text.trimStart();
|
|
585
|
+
parts[parts.length - 1]!.text = parts[parts.length - 1]!.text.trimEnd();
|
|
586
|
+
}
|
|
587
|
+
const kept = parts.filter((part) => part.text);
|
|
588
|
+
|
|
589
|
+
if (!kept.length) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (mode === 'caption' && figure) {
|
|
593
|
+
figure.caption = `${figure.caption} ${kept.map((part) => part.text).join('')}`.trim();
|
|
594
|
+
} else if (list && mode === 'item') {
|
|
595
|
+
list.items.push(kept);
|
|
596
|
+
} else if (mode === 'heading') {
|
|
597
|
+
push({ kind: 'heading', level, inline: kept });
|
|
598
|
+
} else {
|
|
599
|
+
push({ kind: 'paragraph', inline: kept });
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
const closeList = () => {
|
|
603
|
+
if (list?.items.length) {
|
|
604
|
+
push({ kind: 'list', ordered: list.ordered, items: list.items });
|
|
605
|
+
}
|
|
606
|
+
list = undefined;
|
|
607
|
+
};
|
|
608
|
+
const closeFigure = () => {
|
|
609
|
+
if (figure?.src) {
|
|
610
|
+
push({ kind: 'image', src: figure.src, alt: figure.alt, caption: figure.caption, ...blockImageSizeOf(figure) });
|
|
611
|
+
}
|
|
612
|
+
figure = undefined;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
for (const token of html.matchAll(/<(\/?)([a-z][a-z\d]*)\b([^>]*)>|([^<]+)/gi)) {
|
|
616
|
+
const [, closing, rawName, attributes = '', text] = token;
|
|
617
|
+
|
|
618
|
+
if (text !== undefined) {
|
|
619
|
+
const decoded = decodeEntities(text);
|
|
620
|
+
const last = inline[inline.length - 1];
|
|
621
|
+
|
|
622
|
+
if (last && last.href === link?.href) {
|
|
623
|
+
last.text += decoded;
|
|
624
|
+
} else {
|
|
625
|
+
inline.push({ text: decoded, ...(link ?? {}) });
|
|
626
|
+
}
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const name = rawName!.toLowerCase();
|
|
631
|
+
|
|
632
|
+
if (closing) {
|
|
633
|
+
if (/^(?:h[1-6]|p|div|pre|tr|summary|li|figcaption|dt|dd)$/.test(name)) {
|
|
634
|
+
flush();
|
|
635
|
+
mode = list ? 'item' : 'paragraph';
|
|
636
|
+
} else if (name === 'ul' || name === 'ol') {
|
|
637
|
+
flush();
|
|
638
|
+
closeList();
|
|
639
|
+
mode = 'paragraph';
|
|
640
|
+
} else if (name === 'blockquote') {
|
|
641
|
+
flush();
|
|
642
|
+
closeList();
|
|
643
|
+
const quoted = quotes.pop();
|
|
644
|
+
|
|
645
|
+
if (quoted?.length) {
|
|
646
|
+
push({ kind: 'quote', blocks: quoted });
|
|
647
|
+
}
|
|
648
|
+
} else if (name === 'figure') {
|
|
649
|
+
flush();
|
|
650
|
+
closeFigure();
|
|
651
|
+
mode = 'paragraph';
|
|
652
|
+
} else if (name === 'a') {
|
|
653
|
+
link = undefined;
|
|
654
|
+
}
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (/^h[1-6]$/.test(name)) {
|
|
659
|
+
flush();
|
|
660
|
+
mode = 'heading';
|
|
661
|
+
level = Math.min(4, Math.max(2, Number(name[1]))) as 2 | 3 | 4;
|
|
662
|
+
} else if (/^(?:p|div|pre|tr|summary|section|article|details|dt|dd)$/.test(name)) {
|
|
663
|
+
flush();
|
|
664
|
+
mode = list ? 'item' : 'paragraph';
|
|
665
|
+
} else if (name === 'ul' || name === 'ol') {
|
|
666
|
+
flush();
|
|
667
|
+
if (!list) {
|
|
668
|
+
list = { ordered: name === 'ol', items: [] };
|
|
669
|
+
}
|
|
670
|
+
mode = 'item';
|
|
671
|
+
} else if (name === 'li') {
|
|
672
|
+
flush();
|
|
673
|
+
mode = 'item';
|
|
674
|
+
} else if (name === 'blockquote') {
|
|
675
|
+
flush();
|
|
676
|
+
closeList();
|
|
677
|
+
if (quotes.length < 3) {
|
|
678
|
+
quotes.push([]);
|
|
679
|
+
}
|
|
680
|
+
mode = 'paragraph';
|
|
681
|
+
} else if (name === 'figure') {
|
|
682
|
+
flush();
|
|
683
|
+
closeFigure();
|
|
684
|
+
figure = { src: '', alt: '', caption: '' };
|
|
685
|
+
} else if (name === 'figcaption') {
|
|
686
|
+
flush();
|
|
687
|
+
mode = 'caption';
|
|
688
|
+
} else if (name === 'img') {
|
|
689
|
+
const src = blockImage(tagAttribute(attributes, 'src'), appOrigin);
|
|
690
|
+
const alt = tagAttribute(attributes, 'alt');
|
|
691
|
+
|
|
692
|
+
if (!src) {
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (figure && !figure.src) {
|
|
696
|
+
Object.assign(figure, { src, alt, ...blockImageSize(attributes) });
|
|
697
|
+
} else {
|
|
698
|
+
flush();
|
|
699
|
+
push({ kind: 'image', src, alt, caption: '', ...blockImageSize(attributes) });
|
|
700
|
+
}
|
|
701
|
+
} else if (name === 'a') {
|
|
702
|
+
link = blockLink(tagAttribute(attributes, 'href'));
|
|
703
|
+
} else if (name === 'br' || name === 'td' || name === 'th') {
|
|
704
|
+
inline.push({ text: ' ', ...(link ?? {}) });
|
|
705
|
+
} else if (name === 'hr') {
|
|
706
|
+
flush();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
flush();
|
|
711
|
+
closeList();
|
|
712
|
+
closeFigure();
|
|
713
|
+
while (quotes.length) {
|
|
714
|
+
const quoted = quotes.pop();
|
|
715
|
+
|
|
716
|
+
if (quoted?.length) {
|
|
717
|
+
push({ kind: 'quote', blocks: quoted });
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return blocks;
|
|
722
|
+
}
|
|
@@ -19,6 +19,10 @@ export function browseLabels(locale: string) {
|
|
|
19
19
|
clear: 'Сбросить',
|
|
20
20
|
emptyTitle: 'Ничего не найдено',
|
|
21
21
|
emptyHint: 'Попробуйте изменить запрос или сбросить фильтры.',
|
|
22
|
+
emptyHintPlain: 'Проверьте написание или попробуйте слово покороче.',
|
|
23
|
+
emptyCategoryPlain: 'В этой категории пока нет товаров. Загляните в другие разделы каталога.',
|
|
24
|
+
editSearch: 'Изменить запрос',
|
|
25
|
+
browseCatalog: 'Открыть каталог',
|
|
22
26
|
emptyCategoryHint:
|
|
23
27
|
'В этой категории пока нет подходящих товаров. Попробуйте убрать фильтры или выбрать другую категорию.',
|
|
24
28
|
startTitle: 'Что вы ищете?',
|
|
@@ -67,6 +71,10 @@ export function browseLabels(locale: string) {
|
|
|
67
71
|
clear: 'Borrar',
|
|
68
72
|
emptyTitle: 'No se han encontrado productos',
|
|
69
73
|
emptyHint: 'Prueba otra búsqueda o borra los filtros.',
|
|
74
|
+
emptyHintPlain: 'Revisa la ortografía o prueba con una palabra más corta.',
|
|
75
|
+
emptyCategoryPlain: 'Aún no hay productos en esta categoría. Mira las demás secciones del catálogo.',
|
|
76
|
+
editSearch: 'Cambiar la búsqueda',
|
|
77
|
+
browseCatalog: 'Ver el catálogo',
|
|
70
78
|
emptyCategoryHint:
|
|
71
79
|
'Todavía no hay productos que coincidan en esta categoría. Prueba a quitar filtros o elige otra categoría.',
|
|
72
80
|
startTitle: '¿Qué estás buscando?',
|
|
@@ -115,6 +123,10 @@ export function browseLabels(locale: string) {
|
|
|
115
123
|
clear: 'Clear',
|
|
116
124
|
emptyTitle: 'No products found',
|
|
117
125
|
emptyHint: 'Try another search or clear the filters.',
|
|
126
|
+
emptyHintPlain: 'Check the spelling or try a shorter word.',
|
|
127
|
+
emptyCategoryPlain: 'There are no products in this category yet. Look through the rest of the catalogue.',
|
|
128
|
+
editSearch: 'Change the search',
|
|
129
|
+
browseCatalog: 'Browse the catalogue',
|
|
118
130
|
emptyCategoryHint:
|
|
119
131
|
'No matching products in this category yet. Try removing filters or choosing another category.',
|
|
120
132
|
startTitle: 'What are you looking for?',
|
|
@@ -59,6 +59,7 @@ const en = {
|
|
|
59
59
|
deliveryDiscount: 'Delivery discount',
|
|
60
60
|
total: 'Total',
|
|
61
61
|
promo: 'Promo code',
|
|
62
|
+
promoOptional: 'optional',
|
|
62
63
|
apply: 'Apply',
|
|
63
64
|
removePromo: 'Remove',
|
|
64
65
|
removePromoHint: 'Remove promo code',
|
|
@@ -186,6 +187,7 @@ const ru: typeof en = {
|
|
|
186
187
|
deliveryDiscount: 'Скидка на доставку',
|
|
187
188
|
total: 'Итого',
|
|
188
189
|
promo: 'Промокод',
|
|
190
|
+
promoOptional: 'необязательно',
|
|
189
191
|
apply: 'Применить',
|
|
190
192
|
removePromo: 'Удалить',
|
|
191
193
|
removePromoHint: 'Удалить промокод',
|
|
@@ -311,6 +313,7 @@ const es: typeof en = {
|
|
|
311
313
|
deliveryDiscount: 'Descuento en el envío',
|
|
312
314
|
total: 'Total',
|
|
313
315
|
promo: 'Código promocional',
|
|
316
|
+
promoOptional: 'opcional',
|
|
314
317
|
apply: 'Aplicar',
|
|
315
318
|
removePromo: 'Quitar',
|
|
316
319
|
removePromoHint: 'Quitar el código promocional',
|
|
@@ -36,6 +36,10 @@ const en = {
|
|
|
36
36
|
newsletter: 'Stop receiving newsletters',
|
|
37
37
|
products: 'Stop product availability emails',
|
|
38
38
|
unsubscribeDone: 'You have unsubscribed from these emails.',
|
|
39
|
+
invalidLinkHelp:
|
|
40
|
+
'No longer have that email? You can switch these emails off in your profile, or write to the shop.',
|
|
41
|
+
emailSettings: 'Email settings',
|
|
42
|
+
writeToShop: 'Contact the shop',
|
|
39
43
|
invalidLink:
|
|
40
44
|
'This link is incomplete. Open the unsubscribe link from your email.',
|
|
41
45
|
event: 'Take part in this offer',
|
|
@@ -86,6 +90,10 @@ const ru: typeof en = {
|
|
|
86
90
|
newsletter: 'Отказаться от новостной рассылки',
|
|
87
91
|
products: 'Отказаться от писем о наличии товаров',
|
|
88
92
|
unsubscribeDone: 'Вы отписались от этих писем.',
|
|
93
|
+
invalidLinkHelp:
|
|
94
|
+
'Письма уже нет? Отключить рассылку можно в профиле, или напишите в магазин.',
|
|
95
|
+
emailSettings: 'Настройки писем',
|
|
96
|
+
writeToShop: 'Написать в магазин',
|
|
89
97
|
invalidLink: 'Ссылка неполная. Откройте ссылку отписки из письма.',
|
|
90
98
|
event: 'Участвовать в акции',
|
|
91
99
|
eventDescription: 'Подтвердите участие, чтобы получить предложение по почте.',
|
|
@@ -135,6 +143,10 @@ const es: typeof en = {
|
|
|
135
143
|
newsletter: 'Dejar de recibir boletines',
|
|
136
144
|
products: 'Dejar de recibir correos de disponibilidad',
|
|
137
145
|
unsubscribeDone: 'Te has dado de baja de estos correos.',
|
|
146
|
+
invalidLinkHelp:
|
|
147
|
+
'¿Ya no tienes ese correo? Puedes desactivar estos correos en tu perfil o escribir a la tienda.',
|
|
148
|
+
emailSettings: 'Ajustes de correo',
|
|
149
|
+
writeToShop: 'Contactar con la tienda',
|
|
138
150
|
invalidLink:
|
|
139
151
|
'Este enlace está incompleto. Abre el enlace de baja desde tu correo.',
|
|
140
152
|
event: 'Participa en esta oferta',
|
|
@@ -11,6 +11,7 @@ const en = {
|
|
|
11
11
|
letter: 'Names starting with',
|
|
12
12
|
rating: 'Seller rating',
|
|
13
13
|
reviews: 'Reviews',
|
|
14
|
+
noRatings: 'No ratings yet',
|
|
14
15
|
since: 'Selling since',
|
|
15
16
|
hours: 'Opening hours',
|
|
16
17
|
phone: 'Phone',
|
|
@@ -75,6 +76,7 @@ const ru: typeof en = {
|
|
|
75
76
|
letter: 'Названия на букву',
|
|
76
77
|
rating: 'Рейтинг продавца',
|
|
77
78
|
reviews: 'Отзывы',
|
|
79
|
+
noRatings: 'Оценок пока нет',
|
|
78
80
|
since: 'Продаёт с',
|
|
79
81
|
hours: 'Часы работы',
|
|
80
82
|
phone: 'Телефон',
|
|
@@ -140,6 +142,7 @@ const es: typeof en = {
|
|
|
140
142
|
letter: 'Nombres que empiezan por',
|
|
141
143
|
rating: 'Valoración del vendedor',
|
|
142
144
|
reviews: 'Reseñas',
|
|
145
|
+
noRatings: 'Aún sin valoraciones',
|
|
143
146
|
since: 'Vende desde',
|
|
144
147
|
hours: 'Horario',
|
|
145
148
|
phone: 'Teléfono',
|
|
@@ -36,6 +36,7 @@ const en = {
|
|
|
36
36
|
activity: 'My activity',
|
|
37
37
|
},
|
|
38
38
|
logout: 'Logout',
|
|
39
|
+
logoutScope: 'on all devices',
|
|
39
40
|
addresses: {
|
|
40
41
|
title: 'My addresses',
|
|
41
42
|
description: 'Saved addresses for delivery.',
|
|
@@ -97,6 +98,9 @@ const en = {
|
|
|
97
98
|
paid_subs: 'Subscriptions',
|
|
98
99
|
empty: 'No payments in this category yet.',
|
|
99
100
|
unavailable: 'No payment methods are available.',
|
|
101
|
+
unavailableHint:
|
|
102
|
+
'The wallet cannot be topped up from your account right now: the shop offers no payment method for it. Orders can still be paid at checkout. If you expected to see a method here, write to the shop.',
|
|
103
|
+
contactShop: 'Write to the shop',
|
|
100
104
|
pay: 'Pay',
|
|
101
105
|
cancelInvoice: 'Cancel',
|
|
102
106
|
cancelQuestion: 'Cancel this unpaid invoice?',
|
|
@@ -171,6 +175,7 @@ const ru: typeof en = {
|
|
|
171
175
|
activity: 'Моя активность',
|
|
172
176
|
},
|
|
173
177
|
logout: 'Выйти',
|
|
178
|
+
logoutScope: 'на всех устройствах',
|
|
174
179
|
addresses: {
|
|
175
180
|
title: 'Мои адреса',
|
|
176
181
|
description: 'Сохранённые адреса для доставки.',
|
|
@@ -232,6 +237,9 @@ const ru: typeof en = {
|
|
|
232
237
|
paid_subs: 'Подписки',
|
|
233
238
|
empty: 'В этой категории пока нет платежей.',
|
|
234
239
|
unavailable: 'Нет доступных способов оплаты.',
|
|
240
|
+
unavailableHint:
|
|
241
|
+
'Сейчас пополнить кошелёк с вашего аккаунта нельзя: магазин не предлагает для этого способа оплаты. Заказы по-прежнему можно оплатить при оформлении. Если способ оплаты здесь должен быть, напишите магазину.',
|
|
242
|
+
contactShop: 'Написать магазину',
|
|
235
243
|
pay: 'Оплатить',
|
|
236
244
|
cancelInvoice: 'Отменить',
|
|
237
245
|
cancelQuestion: 'Отменить этот неоплаченный счёт?',
|
|
@@ -304,6 +312,7 @@ const es: typeof en = {
|
|
|
304
312
|
activity: 'Mi actividad',
|
|
305
313
|
},
|
|
306
314
|
logout: 'Cerrar sesión',
|
|
315
|
+
logoutScope: 'en todos los dispositivos',
|
|
307
316
|
addresses: {
|
|
308
317
|
title: 'Mis direcciones',
|
|
309
318
|
description: 'Direcciones guardadas para la entrega.',
|
|
@@ -365,6 +374,9 @@ const es: typeof en = {
|
|
|
365
374
|
paid_subs: 'Suscripciones',
|
|
366
375
|
empty: 'Todavía no hay pagos en esta categoría.',
|
|
367
376
|
unavailable: 'No hay métodos de pago disponibles.',
|
|
377
|
+
unavailableHint:
|
|
378
|
+
'Ahora no se puede recargar el monedero desde su cuenta: la tienda no ofrece ningún método de pago para ello. Los pedidos se pueden pagar al finalizar la compra. Si esperaba ver un método aquí, escriba a la tienda.',
|
|
379
|
+
contactShop: 'Escribir a la tienda',
|
|
368
380
|
pay: 'Pagar',
|
|
369
381
|
cancelInvoice: 'Cancelar',
|
|
370
382
|
cancelQuestion: '¿Cancelar esta factura sin pagar?',
|
|
@@ -12,6 +12,7 @@ export function footerLabels(locale: string) {
|
|
|
12
12
|
profile: 'Личный кабинет',
|
|
13
13
|
journal: 'Журнал',
|
|
14
14
|
rights: 'Все права защищены.',
|
|
15
|
+
powered: 'Работает на Basklee',
|
|
15
16
|
products: 'Товары',
|
|
16
17
|
discounts: 'Скидки',
|
|
17
18
|
new: 'Новинки',
|
|
@@ -29,6 +30,7 @@ export function footerLabels(locale: string) {
|
|
|
29
30
|
profile: 'Mi cuenta',
|
|
30
31
|
journal: 'Blog',
|
|
31
32
|
rights: 'Todos los derechos reservados.',
|
|
33
|
+
powered: 'Funciona con Basklee',
|
|
32
34
|
products: 'Productos',
|
|
33
35
|
discounts: 'Descuentos',
|
|
34
36
|
new: 'Novedades',
|
|
@@ -45,6 +47,7 @@ export function footerLabels(locale: string) {
|
|
|
45
47
|
profile: 'My account',
|
|
46
48
|
journal: 'Journal',
|
|
47
49
|
rights: 'All rights reserved.',
|
|
50
|
+
powered: 'Powered by Basklee',
|
|
48
51
|
products: 'Products',
|
|
49
52
|
discounts: 'Discounts',
|
|
50
53
|
new: 'New arrivals',
|
|
@@ -150,3 +150,55 @@ export function applyProfileAuthenticationData(
|
|
|
150
150
|
state.authEmail = '';
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* A language by its code, named in the language of the page («English»,
|
|
156
|
+
* «Español», «Русский»). The shop's own short names («Eng») do not tell a
|
|
157
|
+
* customer which language their order letters come in; `fallback` is used
|
|
158
|
+
* when the browser has no name for the code.
|
|
159
|
+
*/
|
|
160
|
+
export function profileLanguageName(code: string, locale: string, fallback: string) {
|
|
161
|
+
try {
|
|
162
|
+
const name = new Intl.DisplayNames([locale], { type: 'language' }).of(code);
|
|
163
|
+
|
|
164
|
+
if (name && name.toLowerCase() !== code.toLowerCase()) {
|
|
165
|
+
return name.charAt(0).toLocaleUpperCase(locale) + name.slice(1);
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
// An unknown code keeps the shop's own name.
|
|
169
|
+
}
|
|
170
|
+
return fallback;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Personal details typed and not saved yet. They stay in the page's memory
|
|
174
|
+
// while the customer visits other pages, so coming back to the profile shows
|
|
175
|
+
// what was typed. Memory only: a reload starts from the saved profile, the
|
|
176
|
+
// server keeps nothing, and a draft belongs to one customer ID.
|
|
177
|
+
export interface ProfileDetailsDraft {
|
|
178
|
+
first_name: string;
|
|
179
|
+
last_name: string;
|
|
180
|
+
dob: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const profileDrafts = new Map<number, ProfileDetailsDraft>();
|
|
184
|
+
|
|
185
|
+
export function readProfileDraft(customerId: number | undefined) {
|
|
186
|
+
return typeof window !== 'undefined' && customerId
|
|
187
|
+
? profileDrafts.get(customerId)
|
|
188
|
+
: undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// `null` drops the draft: the details were saved or the customer discarded them.
|
|
192
|
+
export function keepProfileDraft(
|
|
193
|
+
customerId: number | undefined,
|
|
194
|
+
draft: ProfileDetailsDraft | null,
|
|
195
|
+
) {
|
|
196
|
+
if (typeof window === 'undefined' || !customerId) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (draft) {
|
|
200
|
+
profileDrafts.set(customerId, { ...draft });
|
|
201
|
+
} else {
|
|
202
|
+
profileDrafts.delete(customerId);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -27,6 +27,11 @@ const en = {
|
|
|
27
27
|
email: 'Email address',
|
|
28
28
|
emailHint:
|
|
29
29
|
'Verify your address before receiving order updates and email notifications.',
|
|
30
|
+
emailConfirmed: 'Confirmed',
|
|
31
|
+
emailConfirmedHint:
|
|
32
|
+
'Order updates and notifications are sent to this address. To change it, type a new address and send a code.',
|
|
33
|
+
unsaved: 'You have unsaved changes.',
|
|
34
|
+
discard: 'Discard',
|
|
30
35
|
sendCode: 'Send',
|
|
31
36
|
sendCodeHint: 'Send verification code',
|
|
32
37
|
code: 'Verification code',
|
|
@@ -102,6 +107,11 @@ const ru: typeof en = {
|
|
|
102
107
|
email: 'Электронная почта',
|
|
103
108
|
emailHint:
|
|
104
109
|
'Подтвердите адрес для получения уведомлений о заказах и рассылки.',
|
|
110
|
+
emailConfirmed: 'Подтверждён',
|
|
111
|
+
emailConfirmedHint:
|
|
112
|
+
'На этот адрес приходят письма о заказах и уведомления. Чтобы сменить его, введите новый адрес и отправьте код.',
|
|
113
|
+
unsaved: 'Есть несохранённые изменения.',
|
|
114
|
+
discard: 'Отменить изменения',
|
|
105
115
|
sendCode: 'Отправить',
|
|
106
116
|
sendCodeHint: 'Отправить код подтверждения',
|
|
107
117
|
code: 'Код подтверждения',
|
|
@@ -178,6 +188,11 @@ const es: typeof en = {
|
|
|
178
188
|
email: 'Dirección de correo',
|
|
179
189
|
emailHint:
|
|
180
190
|
'Verifica tu dirección antes de recibir novedades de pedidos y notificaciones por correo.',
|
|
191
|
+
emailConfirmed: 'Confirmada',
|
|
192
|
+
emailConfirmedHint:
|
|
193
|
+
'Los avisos de pedidos y las notificaciones llegan a esta dirección. Para cambiarla, escriba una nueva y envíe un código.',
|
|
194
|
+
unsaved: 'Hay cambios sin guardar.',
|
|
195
|
+
discard: 'Descartar',
|
|
181
196
|
sendCode: 'Enviar',
|
|
182
197
|
sendCodeHint: 'Enviar código de verificación',
|
|
183
198
|
code: 'Código de verificación',
|
|
@@ -24,6 +24,8 @@ const en = {
|
|
|
24
24
|
productPhotos: 'Product photos',
|
|
25
25
|
openProductPhoto: 'Open the photo full screen',
|
|
26
26
|
empty: 'No reviews yet.',
|
|
27
|
+
emptyFiltered: 'No reviews match these filters.',
|
|
28
|
+
showAll: 'Show all reviews',
|
|
27
29
|
emptyImages: 'No customer photos yet.',
|
|
28
30
|
send: 'Submit',
|
|
29
31
|
save: 'Save',
|
|
@@ -103,6 +105,8 @@ const ru: typeof en = {
|
|
|
103
105
|
productPhotos: 'Фотографии товара',
|
|
104
106
|
openProductPhoto: 'Открыть фотографию на весь экран',
|
|
105
107
|
empty: 'Отзывов пока нет.',
|
|
108
|
+
emptyFiltered: 'Под эти фильтры не подходит ни один отзыв.',
|
|
109
|
+
showAll: 'Показать все отзывы',
|
|
106
110
|
emptyImages: 'Покупатели ещё не добавили фотографии.',
|
|
107
111
|
send: 'Отправить',
|
|
108
112
|
save: 'Сохранить',
|
|
@@ -183,6 +187,8 @@ const es: typeof en = {
|
|
|
183
187
|
productPhotos: 'Fotos del producto',
|
|
184
188
|
openProductPhoto: 'Abrir la foto a pantalla completa',
|
|
185
189
|
empty: 'Aún no hay reseñas.',
|
|
190
|
+
emptyFiltered: 'Ninguna reseña coincide con estos filtros.',
|
|
191
|
+
showAll: 'Ver todas las reseñas',
|
|
186
192
|
emptyImages: 'Aún no hay fotos de clientes.',
|
|
187
193
|
send: 'Enviar',
|
|
188
194
|
save: 'Guardar',
|
|
@@ -41,6 +41,99 @@ export function hasSellerFilters(filters: ISellerDirectoryFilters) {
|
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Where the seller directory is: its filters, order and page. The directory
|
|
45
|
+
// keeps it in the URL as `?name&rating&cats&sort&page`, so Back from a seller,
|
|
46
|
+
// a reload and a copied address return to the same list.
|
|
47
|
+
export interface SellerDirectoryLocation {
|
|
48
|
+
filters: ISellerDirectoryFilters;
|
|
49
|
+
page: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type SellerQueryValue = string | null | undefined | readonly (string | null)[];
|
|
53
|
+
|
|
54
|
+
const sellerLocationKeys = ['name', 'rating', 'cats', 'sort', 'page'];
|
|
55
|
+
|
|
56
|
+
function firstSellerQueryValue(value: SellerQueryValue) {
|
|
57
|
+
return Array.isArray(value) ? value[0] : (value as string | null | undefined);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function positiveSellerQueryNumber(value: string | null | undefined) {
|
|
61
|
+
const number = Number(value);
|
|
62
|
+
|
|
63
|
+
return Number.isSafeInteger(number) && number > 0 ? number : undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Unknown or damaged values fall back to the full list in the default order.
|
|
67
|
+
export function sellerLocationFromQuery(
|
|
68
|
+
query: Record<string, SellerQueryValue>,
|
|
69
|
+
): SellerDirectoryLocation {
|
|
70
|
+
const filters = emptySellerFilters();
|
|
71
|
+
const rating = positiveSellerQueryNumber(firstSellerQueryValue(query.rating));
|
|
72
|
+
const cats = (firstSellerQueryValue(query.cats) ?? '')
|
|
73
|
+
.split(',')
|
|
74
|
+
.map((part) => positiveSellerQueryNumber(part))
|
|
75
|
+
.filter((id): id is number => id !== undefined);
|
|
76
|
+
|
|
77
|
+
filters.seller_name = (firstSellerQueryValue(query.name) ?? '').slice(0, 200);
|
|
78
|
+
if (rating !== undefined && rating <= SELLER_RATING_MAXIMUM) {
|
|
79
|
+
filters.seller_rating_from = rating;
|
|
80
|
+
}
|
|
81
|
+
filters.seller_categories = [...new Set(cats)];
|
|
82
|
+
if (firstSellerQueryValue(query.sort) === 'low') {
|
|
83
|
+
filters.ordering = 'seller_raiting';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
filters,
|
|
88
|
+
page: positiveSellerQueryNumber(firstSellerQueryValue(query.page)) ?? 1,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The query of `next`: other parameters such as `locale` stay and defaults
|
|
93
|
+
// are left out, so the plain directory keeps its plain address.
|
|
94
|
+
export function sellerLocationQuery(
|
|
95
|
+
query: Record<string, SellerQueryValue>,
|
|
96
|
+
next: SellerDirectoryLocation,
|
|
97
|
+
) {
|
|
98
|
+
const result: Record<string, string> = {};
|
|
99
|
+
const name = next.filters.seller_name.trim();
|
|
100
|
+
|
|
101
|
+
for (const [key, value] of Object.entries(query)) {
|
|
102
|
+
const text = firstSellerQueryValue(value);
|
|
103
|
+
|
|
104
|
+
if (typeof text === 'string' && !sellerLocationKeys.includes(key)) {
|
|
105
|
+
result[key] = text;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (name) {
|
|
109
|
+
result.name = name;
|
|
110
|
+
}
|
|
111
|
+
if (next.filters.seller_rating_from !== null) {
|
|
112
|
+
result.rating = String(next.filters.seller_rating_from);
|
|
113
|
+
}
|
|
114
|
+
if (next.filters.seller_categories.length) {
|
|
115
|
+
result.cats = next.filters.seller_categories.join(',');
|
|
116
|
+
}
|
|
117
|
+
if (next.filters.ordering === 'seller_raiting') {
|
|
118
|
+
result.sort = 'low';
|
|
119
|
+
}
|
|
120
|
+
if (next.page > 1) {
|
|
121
|
+
result.page = String(next.page);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function sameSellerLocation(
|
|
128
|
+
left: SellerDirectoryLocation,
|
|
129
|
+
right: SellerDirectoryLocation,
|
|
130
|
+
) {
|
|
131
|
+
return (
|
|
132
|
+
left.page === right.page &&
|
|
133
|
+
JSON.stringify(left.filters) === JSON.stringify(right.filters)
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
44
137
|
export function sellerDirectoryRequest(
|
|
45
138
|
filters: ISellerDirectoryFilters,
|
|
46
139
|
page: number,
|
|
@@ -2,37 +2,37 @@ export function sessionLabels(locale: string) {
|
|
|
2
2
|
return locale.toLowerCase().startsWith('ru')
|
|
3
3
|
? {
|
|
4
4
|
title: 'Выход из аккаунта',
|
|
5
|
-
pending: 'Завершаем
|
|
5
|
+
pending: 'Завершаем сеансы на всех устройствах…',
|
|
6
6
|
hint: 'После выхода вы вернётесь на главную страницу.',
|
|
7
7
|
failed: 'Не удалось завершить выход',
|
|
8
8
|
retryHint:
|
|
9
9
|
'Повторите попытку. Выход подтверждается только ответом сервера.',
|
|
10
10
|
refreshFailed: 'Сеанс завершён. Не удалось загрузить магазин.',
|
|
11
11
|
retry: 'Повторить',
|
|
12
|
-
done: 'Вы вышли из аккаунта',
|
|
12
|
+
done: 'Вы вышли из аккаунта на всех устройствах',
|
|
13
13
|
home: 'Главная',
|
|
14
14
|
}
|
|
15
15
|
: locale.toLowerCase().startsWith('es') ? {
|
|
16
16
|
title: 'Cerrando sesión',
|
|
17
|
-
pending: '
|
|
17
|
+
pending: 'Cerrando tu sesión en todos los dispositivos…',
|
|
18
18
|
hint: 'Volverás a la página de inicio de la tienda.',
|
|
19
19
|
failed: 'No se ha podido cerrar la sesión',
|
|
20
20
|
retryHint: 'Inténtalo de nuevo. El cierre de sesión lo confirma el servidor.',
|
|
21
21
|
refreshFailed:
|
|
22
22
|
'Tu sesión ha terminado. No se ha podido recargar la tienda.',
|
|
23
23
|
retry: 'Reintentar',
|
|
24
|
-
done: 'Has cerrado la sesión',
|
|
24
|
+
done: 'Has cerrado la sesión en todos los dispositivos',
|
|
25
25
|
home: 'Inicio',
|
|
26
26
|
} : {
|
|
27
27
|
title: 'Signing out',
|
|
28
|
-
pending: 'Ending your
|
|
28
|
+
pending: 'Ending your sessions on all devices…',
|
|
29
29
|
hint: 'You will return to the storefront home page.',
|
|
30
30
|
failed: 'Could not finish signing out',
|
|
31
31
|
retryHint: 'Please try again. Sign-out is confirmed by the server.',
|
|
32
32
|
refreshFailed:
|
|
33
33
|
'Your session has ended. The storefront could not be reloaded.',
|
|
34
34
|
retry: 'Retry',
|
|
35
|
-
done: 'You are signed out',
|
|
35
|
+
done: 'You are signed out on all devices',
|
|
36
36
|
home: 'Home',
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -48,3 +48,29 @@ export function storeMapMarkers(
|
|
|
48
48
|
export function storePhoneLink(value: string) {
|
|
49
49
|
return `tel:${value.replace(/[^+0-9]/g, '')}`;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A store's telephone as people read it. A number typed with its own spaces,
|
|
54
|
+
* brackets or dashes is shown as typed; a bare run of digits («+78120000078»)
|
|
55
|
+
* is grouped from the end («+7 812 000 00 78»), the way the shop's contact
|
|
56
|
+
* page writes its number. The dial link keeps using `storePhoneLink`.
|
|
57
|
+
*/
|
|
58
|
+
export function storePhoneText(value: string) {
|
|
59
|
+
const text = value.trim();
|
|
60
|
+
|
|
61
|
+
if (!/^\+?\d{7,15}$/.test(text)) {
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
const digits = text.replace('+', '');
|
|
65
|
+
const groups = [digits.slice(-2), digits.slice(-4, -2)];
|
|
66
|
+
let rest = digits.slice(0, -4);
|
|
67
|
+
|
|
68
|
+
while (rest.length > 3) {
|
|
69
|
+
groups.push(rest.slice(-3));
|
|
70
|
+
rest = rest.slice(0, -3);
|
|
71
|
+
}
|
|
72
|
+
if (rest) {
|
|
73
|
+
groups.push(rest);
|
|
74
|
+
}
|
|
75
|
+
return `${text.startsWith('+') ? '+' : ''}${groups.reverse().join(' ')}`;
|
|
76
|
+
}
|
|
@@ -21,6 +21,7 @@ const en = {
|
|
|
21
21
|
intro:
|
|
22
22
|
'Choose a plan and a subscription period. Paid periods are charged to the account balance.',
|
|
23
23
|
noOffers: 'No subscription plans are available yet.',
|
|
24
|
+
toCatalog: 'Browse the catalogue',
|
|
24
25
|
reset: 'Reset',
|
|
25
26
|
support: 'Subscription support',
|
|
26
27
|
wallet: 'Top up balance',
|
|
@@ -53,6 +54,7 @@ const ru: typeof en = {
|
|
|
53
54
|
intro:
|
|
54
55
|
'Выберите тариф и период подписки. Платные периоды оплачиваются с баланса аккаунта.',
|
|
55
56
|
noOffers: 'Тарифов подписок пока нет.',
|
|
57
|
+
toCatalog: 'Открыть каталог',
|
|
56
58
|
reset: 'Сбросить',
|
|
57
59
|
support: 'Поддержка по подписке',
|
|
58
60
|
wallet: 'Пополнить баланс',
|
|
@@ -86,6 +88,7 @@ const es: typeof en = {
|
|
|
86
88
|
intro:
|
|
87
89
|
'Elige un plan y un periodo de suscripción. Los periodos de pago se cobran del saldo de la cuenta.',
|
|
88
90
|
noOffers: 'Todavía no hay planes de suscripción disponibles.',
|
|
91
|
+
toCatalog: 'Ver el catálogo',
|
|
89
92
|
reset: 'Restablecer',
|
|
90
93
|
support: 'Soporte de suscripciones',
|
|
91
94
|
wallet: 'Recargar saldo',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The chosen tab of an account page lives in the address as `?tab=`, so a
|
|
2
|
+
// reload, the browser's Back and a copied link open the view the customer
|
|
3
|
+
// chose. The first tab is the default and leaves the address plain.
|
|
4
|
+
type TabQueryValue = string | null | undefined | readonly (string | null)[];
|
|
5
|
+
|
|
6
|
+
// `tab` from the address; an unknown or missing value is the first tab.
|
|
7
|
+
export function tabFromQuery<T extends string>(
|
|
8
|
+
query: Record<string, TabQueryValue>,
|
|
9
|
+
tabs: readonly T[],
|
|
10
|
+
): T {
|
|
11
|
+
const raw = query.tab;
|
|
12
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
13
|
+
|
|
14
|
+
return tabs.find((tab) => tab === value) ?? tabs[0]!;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The query with `tab` chosen: other parameters such as `locale` stay.
|
|
18
|
+
export function tabQuery<T extends string>(
|
|
19
|
+
query: Record<string, TabQueryValue>,
|
|
20
|
+
tab: T,
|
|
21
|
+
tabs: readonly T[],
|
|
22
|
+
) {
|
|
23
|
+
const result: Record<string, string> = {};
|
|
24
|
+
|
|
25
|
+
for (const [key, raw] of Object.entries(query)) {
|
|
26
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
27
|
+
|
|
28
|
+
if (typeof value === 'string' && key !== 'tab' && key !== 'page') {
|
|
29
|
+
result[key] = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (tab !== tabs[0]) {
|
|
33
|
+
result.tab = tab;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// An unsent support message: its text, the attached files and the defect
|
|
2
|
+
// mark. It is kept in the page's memory while the customer moves around the
|
|
3
|
+
// shop, so leaving Support for another page and coming back does not lose
|
|
4
|
+
// what was written (the message form reads it when it opens).
|
|
5
|
+
//
|
|
6
|
+
// Memory only, on purpose: nothing is written to browser storage, so a
|
|
7
|
+
// reload or a closed tab starts clean and a shared computer keeps no text.
|
|
8
|
+
// On the server the memory belongs to every visitor at once, so there the
|
|
9
|
+
// functions keep nothing. A draft is the customer's own: its key starts
|
|
10
|
+
// with their ID, and another customer signing in on the same tab never
|
|
11
|
+
// sees it.
|
|
12
|
+
export interface TicketDraft {
|
|
13
|
+
text: string;
|
|
14
|
+
files: File[];
|
|
15
|
+
isDefect: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const drafts = new Map<string, TicketDraft>();
|
|
19
|
+
const inBrowser = typeof window !== 'undefined';
|
|
20
|
+
|
|
21
|
+
// `place` names the form: `new` for a common question, `new:item:15` for a
|
|
22
|
+
// conversation about an order item, `ticket:8` for a reply.
|
|
23
|
+
export function ticketDraftKey(customerId: number | undefined, place: string) {
|
|
24
|
+
return customerId ? `${customerId}:${place}` : '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function emptyTicketDraft(): TicketDraft {
|
|
28
|
+
return { text: '', files: [], isDefect: false };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isEmptyTicketDraft(draft: TicketDraft) {
|
|
32
|
+
return !draft.text.trim() && !draft.files.length && !draft.isDefect;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function readTicketDraft(key: string): TicketDraft {
|
|
36
|
+
const draft = inBrowser && key ? drafts.get(key) : undefined;
|
|
37
|
+
|
|
38
|
+
return draft ? { ...draft, files: [...draft.files] } : emptyTicketDraft();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// An emptied form leaves no draft behind.
|
|
42
|
+
export function keepTicketDraft(key: string, draft: TicketDraft) {
|
|
43
|
+
if (!inBrowser || !key) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (isEmptyTicketDraft(draft)) {
|
|
47
|
+
drafts.delete(key);
|
|
48
|
+
} else {
|
|
49
|
+
drafts.set(key, { ...draft, files: [...draft.files] });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The message was sent or the customer pressed Cancel.
|
|
54
|
+
export function dropTicketDraft(key: string) {
|
|
55
|
+
drafts.delete(key);
|
|
56
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { useBaskleeSearchScopeNames } from '@/lib/composables/useBaskleeSearchScopeNames.svelte';
|
|
13
13
|
import { useBaskleeStorefront } from '@/lib/composables/useBaskleeStorefront.svelte';
|
|
14
14
|
import { directoryLabels } from '@/lib/utils/basklee/directoryLabels';
|
|
15
|
-
import { storeAddress, storePhoneLink } from '@/lib/utils/basklee/storeDirectory';
|
|
15
|
+
import { storeAddress, storePhoneLink, storePhoneText } from '@/lib/utils/basklee/storeDirectory';
|
|
16
16
|
import { browseLabels } from '@/lib/utils/basklee/browseLabels';
|
|
17
17
|
import { productListLocationFromQuery } from '@/lib/utils/basklee/productListLocation';
|
|
18
18
|
import {
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
href={storePhoneLink(names.value.storeDetails.phone_number)}
|
|
202
202
|
class="w-fit text-inherit no-underline focus-visible:outline"
|
|
203
203
|
>
|
|
204
|
-
{names.value.storeDetails.phone_number}
|
|
204
|
+
{storePhoneText(names.value.storeDetails.phone_number)}
|
|
205
205
|
</a>
|
|
206
206
|
{/if}
|
|
207
207
|
{#if names.value.storeDetails.working_hours}
|