@r2digisolutions/ui 0.24.9 → 0.25.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.
@@ -48,7 +48,7 @@
48
48
  const ACTION_W = 56;
49
49
  const EXPAND_W = 40;
50
50
 
51
- const manager = new DataTableManager<T>(options);
51
+ const manager = new DataTableManager<T>(() => options);
52
52
 
53
53
  let filterValues = $state<Record<string, any>>({});
54
54
  let container: HTMLDivElement | null = $state(null);
@@ -11,7 +11,7 @@ export declare class DataTableManager<T extends {
11
11
  forcedHidden: SvelteSet<string>;
12
12
  expanded: SvelteSet<any>;
13
13
  lastWidth: number | null;
14
- constructor(opts: TDataTableTableOptions<T>);
14
+ constructor(options: () => TDataTableTableOptions<T>);
15
15
  setMeasuredWidths(map: Record<string, number>): void;
16
16
  get columns(): import("./types.js").TDataTableColumnDef<T>[];
17
17
  getColumn(id: string): import("./types.js").TDataTableColumnDef<T>;
@@ -1,5 +1,6 @@
1
1
  import { SvelteSet } from 'svelte/reactivity';
2
2
  import { normalize, defaultAccessor, compareValues, applyFilterOp } from './utils.js';
3
+ import { untrack } from 'svelte';
3
4
  export class DataTableManager {
4
5
  options = $state({
5
6
  perPage: 10,
@@ -30,7 +31,8 @@ export class DataTableManager {
30
31
  forcedHidden = new SvelteSet();
31
32
  expanded = new SvelteSet();
32
33
  lastWidth = $state(null);
33
- constructor(opts) {
34
+ constructor(options) {
35
+ const opts = options();
34
36
  const columns = normalize(opts.columns);
35
37
  this.options = ({
36
38
  ...opts,
@@ -44,6 +46,17 @@ export class DataTableManager {
44
46
  filters: opts.initialFilters ?? [],
45
47
  visibleColumns: columns.map((c) => c.id),
46
48
  });
49
+ $effect(() => {
50
+ const new_options = options();
51
+ untrack(() => {
52
+ const columns = normalize(new_options.columns);
53
+ this.options = {
54
+ ...new_options,
55
+ columns
56
+ };
57
+ this.load();
58
+ });
59
+ });
47
60
  }
48
61
  setMeasuredWidths(map) {
49
62
  this.measured = map;
@@ -20,7 +20,7 @@ interface Base<TValue = unknown> {
20
20
  currentTarget: HTMLInputElement;
21
21
  }) => void;
22
22
  }
23
- export interface ITextInputProps extends Base<string | null> {
23
+ export interface ITextInputProps extends Base<string | null | number> {
24
24
  type: 'text';
25
25
  minlength?: number;
26
26
  maxlength?: number;
@@ -2,7 +2,6 @@ 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;
6
5
  init({ language, translations }: {
7
6
  language: string;
8
7
  translations: I18nTranslationType;
@@ -11,4 +10,5 @@ export declare class StoreI18n {
11
10
  set language(value: string);
12
11
  get translations(): I18nTranslationType;
13
12
  set translations(value: I18nTranslationType);
13
+ get t(): (key: string, params?: Record<string, string>) => string;
14
14
  }
@@ -6,23 +6,12 @@ export class StoreI18n {
6
6
  this.#language = currentLanguage;
7
7
  this.#translations = translations;
8
8
  }
9
- t = $derived.by(() => {
10
- this.#language;
11
- this.#translations;
12
- return (key, params = {}) => {
13
- const translations = this.#translations?.[this.#language || this.#defaultLanguage];
14
- const translation = this.#getTranslationValue(translations, key);
15
- if (!translation || typeof translation !== "string") {
16
- return `--${key}--`;
17
- }
18
- return Object.entries(params).reduce((acc, [key, value]) => {
19
- return acc.replace(`{${key}}`, value);
20
- }, translation);
21
- };
22
- });
23
9
  init({ language, translations }) {
24
10
  this.#language = language;
25
- this.#translations = translations;
11
+ this.#translations = {
12
+ ...this.#translations,
13
+ ...translations
14
+ };
26
15
  }
27
16
  #getTranslationValue(translations, key) {
28
17
  // Intentar primero como clave plana
@@ -43,4 +32,18 @@ export class StoreI18n {
43
32
  set translations(value) {
44
33
  this.#translations = value;
45
34
  }
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
+ }
46
49
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@r2digisolutions/ui",
3
- "version": "0.24.9",
3
+ "version": "0.25.0",
4
4
  "private": false,
5
- "packageManager": "bun@1.2.23",
5
+ "packageManager": "bun@1.3.1",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -48,42 +48,42 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@changesets/cli": "^2.29.7",
51
- "@chromatic-com/storybook": "^4.1.1",
52
- "@eslint/compat": "^1.4.0",
53
- "@playwright/test": "^1.56.0",
51
+ "@chromatic-com/storybook": "^4.1.2",
52
+ "@eslint/compat": "^1.4.1",
53
+ "@playwright/test": "^1.56.1",
54
54
  "@storybook/addon-essentials": "^8.6.14",
55
55
  "@storybook/addon-interactions": "^8.6.14",
56
56
  "@storybook/addon-svelte-csf": "5.0.10",
57
57
  "@storybook/blocks": "^8.6.14",
58
- "@storybook/svelte": "^9.1.10",
59
- "@storybook/sveltekit": "^9.1.10",
58
+ "@storybook/svelte": "^10.0.1",
59
+ "@storybook/sveltekit": "^10.0.1",
60
60
  "@storybook/test": "^8.6.14",
61
61
  "@sveltejs/adapter-static": "^3.0.10",
62
- "@sveltejs/kit": "^2.46.1",
62
+ "@sveltejs/kit": "^2.48.3",
63
63
  "@sveltejs/package": "^2.5.4",
64
64
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
65
- "@tailwindcss/postcss": "^4.1.14",
65
+ "@tailwindcss/postcss": "^4.1.16",
66
66
  "@testing-library/svelte": "^5.2.8",
67
- "@vitest/browser": "^3.2.4",
67
+ "@vitest/browser": "^4.0.5",
68
68
  "changeset": "^0.2.6",
69
- "eslint": "^9.37.0",
69
+ "eslint": "^9.38.0",
70
70
  "eslint-config-prettier": "^10.1.8",
71
- "eslint-plugin-svelte": "^3.12.4",
71
+ "eslint-plugin-svelte": "^3.12.5",
72
72
  "globals": "^16.4.0",
73
- "jsdom": "^27.0.0",
74
- "lucide-svelte": "^0.545.0",
73
+ "jsdom": "^27.0.1",
74
+ "lucide-svelte": "^0.548.0",
75
75
  "prettier": "^3.6.2",
76
76
  "prettier-plugin-svelte": "^3.4.0",
77
- "prettier-plugin-tailwindcss": "^0.6.14",
78
- "publint": "^0.3.14",
79
- "storybook": "^9.1.10",
80
- "svelte": "^5.39.9",
81
- "svelte-check": "^4.3.2",
82
- "tailwindcss": "^4.1.14",
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
83
  "typescript": "^5.9.3",
84
- "typescript-eslint": "^8.46.0",
85
- "vite": "^7.1.9",
86
- "vitest": "^3.2.4"
84
+ "typescript-eslint": "^8.46.2",
85
+ "vite": "^7.1.12",
86
+ "vitest": "^4.0.5"
87
87
  },
88
88
  "dependencies": {
89
89
  "@tailwindcss/container-queries": "^0.1.1",