@r2digisolutions/ui 0.0.1 → 0.2.7
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/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/index.js +2 -0
- package/dist/stores/I18n.svelte.d.ts +10 -0
- package/dist/stores/I18n.svelte.js +34 -0
- package/dist/types/translates.type.d.ts +1 -0
- package/dist/types/translates.type.js +1 -0
- package/package.json +19 -10
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './stores/I18n.svelte.js';
|
|
2
|
+
export * from './settings/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from './stores/I18n.svelte.js';
|
|
2
|
+
export * from './settings/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { I18nTranslationType } from "../types/translates.type.js";
|
|
2
|
+
export declare class StoreI18n {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(currentLanguage: string, translations?: I18nTranslationType);
|
|
5
|
+
t: (key: string, params?: Record<string, string>) => string;
|
|
6
|
+
get language(): string;
|
|
7
|
+
set language(value: string);
|
|
8
|
+
get translations(): I18nTranslationType;
|
|
9
|
+
set translations(value: I18nTranslationType);
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class StoreI18n {
|
|
2
|
+
#language = $state("en");
|
|
3
|
+
#translations = $state({});
|
|
4
|
+
constructor(currentLanguage, translations = {}) {
|
|
5
|
+
this.#language = currentLanguage;
|
|
6
|
+
this.#translations = translations;
|
|
7
|
+
}
|
|
8
|
+
t = $derived.by(() => {
|
|
9
|
+
this.#language;
|
|
10
|
+
this.#translations;
|
|
11
|
+
return (key, params = {}) => {
|
|
12
|
+
const translations = this.#translations[this.#language];
|
|
13
|
+
const translation = translations[key];
|
|
14
|
+
if (!translation) {
|
|
15
|
+
return `--${key}--`;
|
|
16
|
+
}
|
|
17
|
+
return Object.entries(params).reduce((acc, [key, value]) => {
|
|
18
|
+
return acc.replace(`{${key}}`, value);
|
|
19
|
+
}, translation);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
get language() {
|
|
23
|
+
return this.#language;
|
|
24
|
+
}
|
|
25
|
+
set language(value) {
|
|
26
|
+
this.#language = value;
|
|
27
|
+
}
|
|
28
|
+
get translations() {
|
|
29
|
+
return this.#translations;
|
|
30
|
+
}
|
|
31
|
+
set translations(value) {
|
|
32
|
+
this.#translations = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type I18nTranslationType = Record<string, Record<string, string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r2digisolutions/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"private": false,
|
|
5
|
+
"packageManager": "pnpm@9.5.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
5
9
|
"scripts": {
|
|
6
10
|
"dev": "vite dev",
|
|
7
11
|
"build": "vite build && npm run package",
|
|
@@ -16,7 +20,10 @@
|
|
|
16
20
|
"test": "npm run test:unit -- --run && npm run test:e2e",
|
|
17
21
|
"test:e2e": "playwright test",
|
|
18
22
|
"storybook": "storybook dev -p 6006",
|
|
19
|
-
"build-storybook": "storybook build"
|
|
23
|
+
"build-storybook": "storybook build",
|
|
24
|
+
"changeset": "changeset",
|
|
25
|
+
"changeset:publish": "changeset publish",
|
|
26
|
+
"changeset:version": "changeset version"
|
|
20
27
|
},
|
|
21
28
|
"files": [
|
|
22
29
|
"dist",
|
|
@@ -45,16 +52,18 @@
|
|
|
45
52
|
"@playwright/test": "^1.49.1",
|
|
46
53
|
"@storybook/addon-essentials": "^8.4.7",
|
|
47
54
|
"@storybook/addon-interactions": "^8.4.7",
|
|
48
|
-
"@storybook/addon-svelte-csf": "
|
|
55
|
+
"@storybook/addon-svelte-csf": "5.0.0-next.21",
|
|
49
56
|
"@storybook/blocks": "^8.4.7",
|
|
50
57
|
"@storybook/svelte": "^8.4.7",
|
|
51
58
|
"@storybook/sveltekit": "^8.4.7",
|
|
52
59
|
"@storybook/test": "^8.4.7",
|
|
53
60
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
54
|
-
"@sveltejs/kit": "^2.15.
|
|
61
|
+
"@sveltejs/kit": "^2.15.2",
|
|
55
62
|
"@sveltejs/package": "^2.3.7",
|
|
56
63
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
64
|
+
"@vitest/browser": "^2.1.8",
|
|
57
65
|
"autoprefixer": "^10.4.20",
|
|
66
|
+
"changeset": "^0.2.6",
|
|
58
67
|
"eslint": "^9.17.0",
|
|
59
68
|
"eslint-config-prettier": "^9.1.0",
|
|
60
69
|
"eslint-plugin-svelte": "^2.46.1",
|
|
@@ -62,19 +71,19 @@
|
|
|
62
71
|
"prettier": "^3.4.2",
|
|
63
72
|
"prettier-plugin-svelte": "^3.3.2",
|
|
64
73
|
"prettier-plugin-tailwindcss": "^0.6.9",
|
|
65
|
-
"publint": "^0.
|
|
74
|
+
"publint": "^0.3.0",
|
|
66
75
|
"storybook": "^8.4.7",
|
|
67
|
-
"svelte": "^5.
|
|
68
|
-
"svelte-check": "^4.1.
|
|
76
|
+
"svelte": "^5.17.0",
|
|
77
|
+
"svelte-check": "^4.1.3",
|
|
69
78
|
"tailwindcss": "^3.4.17",
|
|
70
79
|
"typescript": "^5.7.2",
|
|
71
|
-
"typescript-eslint": "^8.19.
|
|
80
|
+
"typescript-eslint": "^8.19.1",
|
|
72
81
|
"vite": "^6.0.7",
|
|
73
82
|
"vitest": "^2.1.8"
|
|
74
83
|
},
|
|
75
84
|
"dependencies": {
|
|
76
85
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
77
|
-
"@tailwindcss/forms": "^0.5.
|
|
78
|
-
"@tailwindcss/typography": "^0.5.
|
|
86
|
+
"@tailwindcss/forms": "^0.5.10",
|
|
87
|
+
"@tailwindcss/typography": "^0.5.16"
|
|
79
88
|
}
|
|
80
89
|
}
|