@r2digisolutions/ui 0.25.0 → 0.25.4

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.
@@ -2,6 +2,7 @@ import type { I18nTranslationType } from "../types/translates.type.js";
2
2
  export declare class StoreI18n {
3
3
  #private;
4
4
  constructor(currentLanguage: string, translations?: I18nTranslationType);
5
+ t: (key: string, params?: Record<string, string>) => string;
5
6
  init({ language, translations }: {
6
7
  language: string;
7
8
  translations: I18nTranslationType;
@@ -10,5 +11,4 @@ export declare class StoreI18n {
10
11
  set language(value: string);
11
12
  get translations(): I18nTranslationType;
12
13
  set translations(value: I18nTranslationType);
13
- get t(): (key: string, params?: Record<string, string>) => string;
14
14
  }
@@ -6,12 +6,21 @@ export class StoreI18n {
6
6
  this.#language = currentLanguage;
7
7
  this.#translations = translations;
8
8
  }
9
+ t = $derived.by(() => {
10
+ return (key, params = {}) => {
11
+ const translations = this.#translations?.[this.#language || this.#defaultLanguage];
12
+ const translation = this.#getTranslationValue(translations, key);
13
+ if (!translation || typeof translation !== "string") {
14
+ return `--${key}--`;
15
+ }
16
+ return Object.entries(params).reduce((acc, [key, value]) => {
17
+ return acc.replace(`{${key}}`, value);
18
+ }, translation);
19
+ };
20
+ });
9
21
  init({ language, translations }) {
10
22
  this.#language = language;
11
- this.#translations = {
12
- ...this.#translations,
13
- ...translations
14
- };
23
+ this.#translations = translations;
15
24
  }
16
25
  #getTranslationValue(translations, key) {
17
26
  // Intentar primero como clave plana
@@ -32,18 +41,4 @@ export class StoreI18n {
32
41
  set translations(value) {
33
42
  this.#translations = value;
34
43
  }
35
- get t() {
36
- this.#language;
37
- this.#translations;
38
- return (key, params = {}) => {
39
- const translations = this.#translations?.[this.#language || this.#defaultLanguage];
40
- const translation = this.#getTranslationValue(translations, key);
41
- if (!translation || typeof translation !== "string") {
42
- return `--${key}--`;
43
- }
44
- return Object.entries(params).reduce((acc, [key, value]) => {
45
- return acc.replace(`{${key}}`, value);
46
- }, translation);
47
- };
48
- }
49
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/ui",
3
- "version": "0.25.0",
3
+ "version": "0.25.4",
4
4
  "private": false,
5
5
  "packageManager": "bun@1.3.1",
6
6
  "publishConfig": {
@@ -44,50 +44,50 @@
44
44
  }
45
45
  },
46
46
  "peerDependencies": {
47
- "svelte": "^5.0.0"
47
+ "svelte": "5.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@changesets/cli": "^2.29.7",
51
- "@chromatic-com/storybook": "^4.1.2",
52
- "@eslint/compat": "^1.4.1",
53
- "@playwright/test": "^1.56.1",
54
- "@storybook/addon-essentials": "^8.6.14",
55
- "@storybook/addon-interactions": "^8.6.14",
50
+ "@changesets/cli": "2.29.7",
51
+ "@chromatic-com/storybook": "4.1.2",
52
+ "@eslint/compat": "1.4.1",
53
+ "@playwright/test": "1.56.1",
54
+ "@storybook/addon-essentials": "8.6.14",
55
+ "@storybook/addon-interactions": "8.6.14",
56
56
  "@storybook/addon-svelte-csf": "5.0.10",
57
- "@storybook/blocks": "^8.6.14",
58
- "@storybook/svelte": "^10.0.1",
59
- "@storybook/sveltekit": "^10.0.1",
60
- "@storybook/test": "^8.6.14",
61
- "@sveltejs/adapter-static": "^3.0.10",
62
- "@sveltejs/kit": "^2.48.3",
63
- "@sveltejs/package": "^2.5.4",
64
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
65
- "@tailwindcss/postcss": "^4.1.16",
66
- "@testing-library/svelte": "^5.2.8",
67
- "@vitest/browser": "^4.0.5",
68
- "changeset": "^0.2.6",
69
- "eslint": "^9.38.0",
70
- "eslint-config-prettier": "^10.1.8",
71
- "eslint-plugin-svelte": "^3.12.5",
72
- "globals": "^16.4.0",
73
- "jsdom": "^27.0.1",
74
- "lucide-svelte": "^0.548.0",
75
- "prettier": "^3.6.2",
76
- "prettier-plugin-svelte": "^3.4.0",
77
- "prettier-plugin-tailwindcss": "^0.7.1",
78
- "publint": "^0.3.15",
79
- "storybook": "^10.0.1",
80
- "svelte": "^5.43.0",
81
- "svelte-check": "^4.3.3",
82
- "tailwindcss": "^4.1.16",
83
- "typescript": "^5.9.3",
84
- "typescript-eslint": "^8.46.2",
85
- "vite": "^7.1.12",
86
- "vitest": "^4.0.5"
57
+ "@storybook/blocks": "8.6.14",
58
+ "@storybook/svelte": "10.0.2",
59
+ "@storybook/sveltekit": "10.0.2",
60
+ "@storybook/test": "8.6.14",
61
+ "@sveltejs/adapter-static": "3.0.10",
62
+ "@sveltejs/kit": "2.48.3",
63
+ "@sveltejs/package": "2.5.4",
64
+ "@sveltejs/vite-plugin-svelte": "6.2.1",
65
+ "@tailwindcss/postcss": "4.1.16",
66
+ "@testing-library/svelte": "5.2.8",
67
+ "@vitest/browser": "4.0.5",
68
+ "changeset": "0.2.6",
69
+ "eslint": "9.38.0",
70
+ "eslint-config-prettier": "10.1.8",
71
+ "eslint-plugin-svelte": "3.13.0",
72
+ "globals": "16.4.0",
73
+ "jsdom": "27.0.1",
74
+ "lucide-svelte": "0.548.0",
75
+ "prettier": "3.6.2",
76
+ "prettier-plugin-svelte": "3.4.0",
77
+ "prettier-plugin-tailwindcss": "0.7.1",
78
+ "publint": "0.3.15",
79
+ "storybook": "10.0.2",
80
+ "svelte": "5.43.2",
81
+ "svelte-check": "4.3.3",
82
+ "tailwindcss": "4.1.16",
83
+ "typescript": "5.9.3",
84
+ "typescript-eslint": "8.46.2",
85
+ "vite": "7.1.12",
86
+ "vitest": "4.0.5"
87
87
  },
88
88
  "dependencies": {
89
- "@tailwindcss/container-queries": "^0.1.1",
90
- "@tailwindcss/forms": "^0.5.10",
91
- "@tailwindcss/typography": "^0.5.19"
89
+ "@tailwindcss/container-queries": "0.1.1",
90
+ "@tailwindcss/forms": "0.5.10",
91
+ "@tailwindcss/typography": "0.5.19"
92
92
  }
93
93
  }