accomadesc 0.4.14 → 0.4.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/dist/Pricing.svelte +7 -4
- package/dist/SiteState.svelte.d.ts +3 -1
- package/dist/SiteState.svelte.js +20 -10
- package/package.json +12 -12
package/dist/Pricing.svelte
CHANGED
|
@@ -49,7 +49,10 @@
|
|
|
49
49
|
const formatAdditionalPersonPrice = (price: number, termsRef: string | undefined): string => {
|
|
50
50
|
if (formatFunc && translateFunc) {
|
|
51
51
|
let terms = '';
|
|
52
|
-
if (termsRef)
|
|
52
|
+
if (termsRef) {
|
|
53
|
+
terms = translateFunc(termsRef);
|
|
54
|
+
if (!terms) terms = termsRef;
|
|
55
|
+
}
|
|
53
56
|
let formattedPrice = formatMoneyFunc?.(price);
|
|
54
57
|
return formatFunc('additionalPersonPrice', {
|
|
55
58
|
price: formattedPrice,
|
|
@@ -124,13 +127,13 @@
|
|
|
124
127
|
const formatExtraPersonCol = (entry: PricingEntry): string => {
|
|
125
128
|
let result = '<div style="display:flex; column-gap: 2rem; padding-left:1rem;flex-wrap: wrap;">';
|
|
126
129
|
|
|
127
|
-
if (entry.additionalPersonPrice1) {
|
|
130
|
+
if (entry.additionalPersonPrice1 && entry.additionalPersonText1) {
|
|
128
131
|
result += `<span>${formatAdditionalPersonPrice(entry.additionalPersonPrice1, entry.additionalPersonText1)}</span>`;
|
|
129
132
|
}
|
|
130
|
-
if (entry.additionalPersonPrice2) {
|
|
133
|
+
if (entry.additionalPersonPrice2 && entry.additionalPersonText2) {
|
|
131
134
|
result += `<span>${formatAdditionalPersonPrice(entry.additionalPersonPrice2, entry.additionalPersonText2)}</span>`;
|
|
132
135
|
}
|
|
133
|
-
if (entry.additionalPersonPrice3) {
|
|
136
|
+
if (entry.additionalPersonPrice3 && entry.additionalPersonText3) {
|
|
134
137
|
result += `<span>${formatAdditionalPersonPrice(entry.additionalPersonPrice3, entry.additionalPersonText3)}</span>`;
|
|
135
138
|
}
|
|
136
139
|
result += '</div>';
|
|
@@ -8,6 +8,7 @@ interface FullTranslation {
|
|
|
8
8
|
site: Record<string, string>;
|
|
9
9
|
}
|
|
10
10
|
export declare class SiteState implements I18nFacade {
|
|
11
|
+
#private;
|
|
11
12
|
_getSiteConfigFn: () => SiteConfig;
|
|
12
13
|
get fullTranslations(): Record<string, FullTranslation>;
|
|
13
14
|
get calendarTranslations(): Record<string, OccuplanTranslations>;
|
|
@@ -22,11 +23,12 @@ export declare class SiteState implements I18nFacade {
|
|
|
22
23
|
get formats(): Record<string, FormatSpec>;
|
|
23
24
|
selectedTheme: 'light' | 'dark';
|
|
24
25
|
selectedThemeInitialized: boolean;
|
|
25
|
-
constructor(getSiteConfig: () => SiteConfig, lang: string | undefined);
|
|
26
|
+
constructor(getSiteConfig: () => SiteConfig, lang: string | undefined, defaultFormats?: Record<string, FormatSpec>);
|
|
26
27
|
updateCurrentLang: (lang: string) => string;
|
|
27
28
|
translateFunc: (ref: string) => string;
|
|
28
29
|
formatFunc: (ref: string, props: Record<string, unknown>) => string;
|
|
29
30
|
formatDateFunc: (d: DateTime | string) => string;
|
|
31
|
+
formatMoneyFunc: (value: number) => string;
|
|
30
32
|
translateWithLangFunc: (ref: string, lang: string) => string;
|
|
31
33
|
}
|
|
32
34
|
export {};
|
package/dist/SiteState.svelte.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
2
|
import { format } from './helpers/format.js';
|
|
3
|
+
import { MoneyFormats } from './helpers/moneyFormats.js';
|
|
3
4
|
export class SiteState {
|
|
4
5
|
_getSiteConfigFn;
|
|
5
6
|
//fullTranslations: Record<string, FullTranslation> = $derived(this._getSiteConfigFn().lang.translations);
|
|
@@ -46,10 +47,12 @@ export class SiteState {
|
|
|
46
47
|
get formats() {
|
|
47
48
|
return this._getSiteConfigFn().lang.formats;
|
|
48
49
|
}
|
|
50
|
+
#defaultFormats;
|
|
49
51
|
selectedTheme = $state('light');
|
|
50
52
|
selectedThemeInitialized = $state(false);
|
|
51
|
-
constructor(getSiteConfig, lang) {
|
|
53
|
+
constructor(getSiteConfig, lang, defaultFormats) {
|
|
52
54
|
this._getSiteConfigFn = getSiteConfig;
|
|
55
|
+
this.#defaultFormats = defaultFormats;
|
|
53
56
|
if (!lang || !getSiteConfig().lang.supportedLangs.includes(lang)) {
|
|
54
57
|
this.currentLang = getSiteConfig().lang.defaultLang;
|
|
55
58
|
}
|
|
@@ -71,11 +74,8 @@ export class SiteState {
|
|
|
71
74
|
};
|
|
72
75
|
formatFunc = (ref, props) => {
|
|
73
76
|
const langFormats = this.formats[this.currentLang];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return '[UNDEF]';
|
|
77
|
-
}
|
|
78
|
-
const fString = langFormats[ref];
|
|
77
|
+
const defaultLangFormats = this.#defaultFormats?.[this.currentLang];
|
|
78
|
+
const fString = langFormats?.[ref] ?? defaultLangFormats?.[ref];
|
|
79
79
|
if (!fString) {
|
|
80
80
|
console.warn(`[Missing formatFunc: ${ref}]`);
|
|
81
81
|
return '[UNDEF]';
|
|
@@ -87,12 +87,14 @@ export class SiteState {
|
|
|
87
87
|
if (!d)
|
|
88
88
|
return this.translateFunc('invalid');
|
|
89
89
|
const formatSpecs = this.formats[this.currentLang];
|
|
90
|
-
|
|
90
|
+
const defaultFormatSpecs = this.#defaultFormats?.[this.currentLang];
|
|
91
|
+
const effectiveFormat = formatSpecs ?? defaultFormatSpecs;
|
|
92
|
+
if (!effectiveFormat) {
|
|
91
93
|
return this.translateFunc('invalid');
|
|
92
94
|
}
|
|
93
95
|
let f = 'yyyy-MM-dd';
|
|
94
|
-
if (
|
|
95
|
-
f =
|
|
96
|
+
if (effectiveFormat.dateFormat) {
|
|
97
|
+
f = effectiveFormat.dateFormat;
|
|
96
98
|
}
|
|
97
99
|
let date;
|
|
98
100
|
if (typeof d === 'string')
|
|
@@ -101,7 +103,15 @@ export class SiteState {
|
|
|
101
103
|
date = d;
|
|
102
104
|
if (!date.isValid)
|
|
103
105
|
return this.translateFunc('invalid');
|
|
104
|
-
return date.setLocale(
|
|
106
|
+
return date.setLocale(effectiveFormat.locale).toFormat(f);
|
|
107
|
+
};
|
|
108
|
+
formatMoneyFunc = (value) => {
|
|
109
|
+
const scaled = value / 100.0;
|
|
110
|
+
const fmt = MoneyFormats[this.currentLang] ?? MoneyFormats['en'];
|
|
111
|
+
if (!fmt) {
|
|
112
|
+
return String(scaled);
|
|
113
|
+
}
|
|
114
|
+
return fmt.format(scaled);
|
|
105
115
|
};
|
|
106
116
|
translateWithLangFunc = (ref, lang) => {
|
|
107
117
|
const translation = this.translations[lang];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accomadesc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.16",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"!dist/**/*.test.*",
|
|
@@ -25,31 +25,31 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@playwright/test": "^1.59.1",
|
|
28
|
-
"@sveltejs/adapter-auto": "^
|
|
28
|
+
"@sveltejs/adapter-auto": "^7.0.1",
|
|
29
29
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
30
|
-
"@sveltejs/kit": "^2.
|
|
30
|
+
"@sveltejs/kit": "^2.58.0",
|
|
31
31
|
"@sveltejs/package": "^2.5.7",
|
|
32
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
32
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
33
33
|
"@testing-library/dom": "^10.4.1",
|
|
34
34
|
"@testing-library/jest-dom": "^6.9.1",
|
|
35
35
|
"@testing-library/svelte": "^5.3.1",
|
|
36
36
|
"@types/luxon": "^3.7.1",
|
|
37
37
|
"@types/node": "^25.6.0",
|
|
38
|
-
"@vitest/ui": "^4.1.
|
|
38
|
+
"@vitest/ui": "^4.1.5",
|
|
39
39
|
"gdpr-cooco-banner": "^0.0.13",
|
|
40
|
-
"jsdom": "^
|
|
41
|
-
"prettier": "^3.8.
|
|
40
|
+
"jsdom": "^29.0.2",
|
|
41
|
+
"prettier": "^3.8.3",
|
|
42
42
|
"prettier-plugin-svelte": "^3.5.1",
|
|
43
43
|
"publint": "^0.3.18",
|
|
44
|
-
"svelte": "^5.55.
|
|
44
|
+
"svelte": "^5.55.5",
|
|
45
45
|
"svelte-check": "^4.4.6",
|
|
46
|
-
"typescript": "^
|
|
47
|
-
"vite": "^
|
|
48
|
-
"vitest": "^4.1.
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vite": "^8.0.10",
|
|
48
|
+
"vitest": "^4.1.5"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@fontsource/raleway": "^5.2.8",
|
|
52
|
-
"@twicpics/components": "^0.
|
|
52
|
+
"@twicpics/components": "^0.33.0",
|
|
53
53
|
"@types/leaflet": "^1.9.21",
|
|
54
54
|
"leaflet": "^1.9.4",
|
|
55
55
|
"luxon": "^3.7.2"
|