svelte-intlayer 8.8.0 → 8.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/useLocale.d.ts +2 -2
- package/dist/client/useLocaleStorage.d.ts +2 -2
- package/dist/format/useCompact.d.ts +1 -1
- package/dist/format/useCurrency.d.ts +1 -1
- package/dist/format/useDate.d.ts +1 -1
- package/dist/format/useList.d.ts +1 -1
- package/dist/format/useNumber.d.ts +1 -1
- package/dist/format/usePercentage.d.ts +1 -1
- package/dist/format/useRelativeTime.d.ts +1 -1
- package/dist/format/useUnit.d.ts +1 -1
- package/dist/renderIntlayerNode.d.ts +3 -3
- package/dist/renderIntlayerNode.js +28 -1
- package/package.json +6 -6
|
@@ -26,7 +26,7 @@ type useLocaleProps = {
|
|
|
26
26
|
export declare const useLocale: ({ isCookieEnabled, onLocaleChange, }?: useLocaleProps) => {
|
|
27
27
|
locale: import("svelte/store").Readable<LocalesValues>;
|
|
28
28
|
setLocale: (locale: LocalesValues) => void;
|
|
29
|
-
defaultLocale: import("
|
|
30
|
-
availableLocales: import("
|
|
29
|
+
defaultLocale: import("intlayer").Locale;
|
|
30
|
+
availableLocales: import("intlayer").Locale[];
|
|
31
31
|
};
|
|
32
32
|
export {};
|
|
@@ -2,13 +2,13 @@ import type { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the locale cookie
|
|
4
4
|
*/
|
|
5
|
-
export declare const localeInStorage: import("
|
|
5
|
+
export declare const localeInStorage: import("intlayer").Locale | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use localeInStorage instead
|
|
8
8
|
*
|
|
9
9
|
* Get the locale cookie
|
|
10
10
|
*/
|
|
11
|
-
export declare const localeCookie: import("
|
|
11
|
+
export declare const localeCookie: import("intlayer").Locale | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Set the locale cookie
|
|
14
14
|
*/
|
package/dist/format/useDate.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* A store containing a date/time formatting function bound to the active locale.
|
|
6
6
|
*/
|
|
7
7
|
export declare const useDate: () => import("svelte/store").Readable<(date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
|
|
8
|
-
locale?: import("
|
|
8
|
+
locale?: import("intlayer").LocalesValues;
|
|
9
9
|
}) | undefined) => string>;
|
package/dist/format/useList.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare const useList: () => import("svelte/store").Readable<(values: (st
|
|
|
3
3
|
type?: "conjunction" | "disjunction" | "unit";
|
|
4
4
|
style?: "long" | "short" | "narrow";
|
|
5
5
|
} & {
|
|
6
|
-
locale?: import("
|
|
6
|
+
locale?: import("intlayer").LocalesValues;
|
|
7
7
|
}) | undefined) => string>;
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* A store containing a number formatting function bound to the active locale.
|
|
6
6
|
*/
|
|
7
7
|
export declare const useNumber: () => import("svelte/store").Readable<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
|
|
8
|
-
locale?: import("
|
|
8
|
+
locale?: import("intlayer").LocalesValues;
|
|
9
9
|
}) | undefined) => string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useRelativeTime: () => import("svelte/store").Readable<(from: string | number | Date, to?: string | number | Date | undefined, options?: (Intl.RelativeTimeFormatOptions & {
|
|
2
|
-
locale?: import("
|
|
2
|
+
locale?: import("intlayer").LocalesValues;
|
|
3
3
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
4
4
|
}) | undefined) => string>;
|
package/dist/format/useUnit.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ type IntlayerNodeProps = {
|
|
|
4
4
|
props: Record<string, any>;
|
|
5
5
|
additionalProps?: Record<string, any>;
|
|
6
6
|
};
|
|
7
|
-
export type IntlayerNode<T
|
|
7
|
+
export type IntlayerNode<T, AdditionalProps = Record<string, any>> = {
|
|
8
8
|
new (...args: any[]): any;
|
|
9
9
|
(anchor: any, props: any): any;
|
|
10
10
|
value: T;
|
|
11
|
-
} &
|
|
12
|
-
export declare const renderIntlayerNode: <T
|
|
11
|
+
} & AdditionalProps & T;
|
|
12
|
+
export declare const renderIntlayerNode: <T, AdditionalProps = Record<string, any>>(args: IntlayerNodeProps) => IntlayerNode<T, AdditionalProps>;
|
|
13
13
|
export {};
|
|
@@ -34,10 +34,37 @@ export const renderIntlayerNode = (args) => {
|
|
|
34
34
|
configurable: true,
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(Node, 'toString', {
|
|
37
|
-
value: () => args.value
|
|
37
|
+
value: () => String(args.value ?? ''),
|
|
38
38
|
writable: true,
|
|
39
39
|
configurable: true,
|
|
40
40
|
});
|
|
41
|
+
Object.defineProperty(Node, 'valueOf', {
|
|
42
|
+
value: () => args.value,
|
|
43
|
+
writable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(Node, Symbol.toPrimitive, {
|
|
47
|
+
value: () => args.value ?? '',
|
|
48
|
+
writable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
});
|
|
51
|
+
// Delegate native methods from the underlying value to Node (any type).
|
|
52
|
+
if (args.value !== null && args.value !== undefined) {
|
|
53
|
+
const valObj = Object(args.value); // Safely boxes primitives (e.g., 50 -> Number object)
|
|
54
|
+
const proto = Object.getPrototypeOf(valObj);
|
|
55
|
+
for (const prop of Object.getOwnPropertyNames(proto)) {
|
|
56
|
+
if (prop === 'constructor' || prop in Node)
|
|
57
|
+
continue;
|
|
58
|
+
const valProp = valObj[prop]; // read from instance so length/index values are correct
|
|
59
|
+
if (typeof valProp === 'function') {
|
|
60
|
+
Object.defineProperty(Node, prop, {
|
|
61
|
+
value: valProp.bind(args.value),
|
|
62
|
+
writable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
41
68
|
if (args.additionalProps) {
|
|
42
69
|
Object.assign(Node, args.additionalProps);
|
|
43
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@intlayer/api": "8.
|
|
86
|
-
"@intlayer/config": "8.
|
|
87
|
-
"@intlayer/core": "8.
|
|
88
|
-
"@intlayer/editor": "8.
|
|
89
|
-
"@intlayer/types": "8.
|
|
85
|
+
"@intlayer/api": "8.9.0",
|
|
86
|
+
"@intlayer/config": "8.9.0",
|
|
87
|
+
"@intlayer/core": "8.9.0",
|
|
88
|
+
"@intlayer/editor": "8.9.0",
|
|
89
|
+
"@intlayer/types": "8.9.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@sveltejs/adapter-auto": "7.0.1",
|