@dynamicforms/vue-forms 0.17.1 → 0.18.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/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { ComponentOptionsMixin } from 'vue';
2
2
  import { ComponentProvideOptions } from 'vue';
3
+ import { ComputedRef } from 'vue';
3
4
  import { DefineComponent } from 'vue';
4
5
  import { PublicProps } from 'vue';
5
6
  import { Ref } from 'vue';
7
+ import { TranslateStringsCallback } from '@dynamicforms/translatable';
6
8
 
7
9
  /**
8
10
  * Thrown from a handler to end the run it is in. What the trigger answers with is the exception itself rather than
@@ -155,11 +157,13 @@ export declare interface ActionValue {
155
157
  declare type AllowedValues<T> = T[] | Ref<T[]> | (() => T[]);
156
158
 
157
159
  /**
158
- * Depending on the useMarkdownInValidators setting, return either markdown or a plain string error message
160
+ * Depending on the useMarkdownInValidators setting, return either markdown or a plain string error message. A
161
+ * Ref is stripped/wrapped on read rather than once here, so a translated template re-applies the same choice
162
+ * as its text changes.
159
163
  * @param mdErrorString markdown source to optionally be stripped
160
- * @return MdString or string
164
+ * @return MdString or string, or a ComputedRef of either where `mdErrorString` is itself a Ref
161
165
  */
162
- export declare function buildErrorMessage(mdErrorString: string): string | MdString;
166
+ export declare function buildErrorMessage<T extends string | Ref<string>>(mdErrorString: T): T extends Ref<string> ? ComputedRef<string | MdString> : string | MdString;
163
167
 
164
168
  export declare type ClassType = string | string[] | Record<string, boolean>;
165
169
 
@@ -1000,6 +1004,9 @@ declare namespace Form {
1000
1004
  NullableList,
1001
1005
  Validators,
1002
1006
  buildErrorMessage,
1007
+ translatedMessage,
1008
+ strings,
1009
+ translateStrings,
1003
1010
  isSimpleComponentDef,
1004
1011
  isCallableFunction,
1005
1012
  MdString,
@@ -1499,6 +1506,19 @@ export declare class Statement {
1499
1506
  collectFields(): Set<FieldBase>;
1500
1507
  }
1501
1508
 
1509
+ export declare const strings: {
1510
+ Required: string;
1511
+ MinValue: string;
1512
+ MaxValue: string;
1513
+ ValueInRange: string;
1514
+ MinLength: string;
1515
+ MaxLength: string;
1516
+ LengthInRange: string;
1517
+ Pattern: string;
1518
+ InAllowedValues: string;
1519
+ ValidationFailed: string;
1520
+ };
1521
+
1502
1522
  declare class Transaction {
1503
1523
  private readonly participants;
1504
1524
  /** what a rollback has to put back beyond the state slots, newest last */
@@ -1609,6 +1629,22 @@ export declare interface TransactionControl {
1609
1629
  rollback(): never;
1610
1630
  }
1611
1631
 
1632
+ /** A built-in validator's default message, translated and reactive to a later `translateStrings` call. */
1633
+ export declare function translatedMessage(key: keyof typeof strings): ComputedRef<string | MdString>;
1634
+
1635
+ export declare const translateStrings: (cb: TranslateStringsCallback< {
1636
+ Required: string;
1637
+ MinValue: string;
1638
+ MaxValue: string;
1639
+ ValueInRange: string;
1640
+ MinLength: string;
1641
+ MaxLength: string;
1642
+ LengthInRange: string;
1643
+ Pattern: string;
1644
+ InAllowedValues: string;
1645
+ ValidationFailed: string;
1646
+ }>) => void;
1647
+
1612
1648
  declare const TxAnnounceValue: unique symbol;
1613
1649
 
1614
1650
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dynamicforms/vue-forms",
3
3
  "private": false,
4
- "version": "0.17.1",
4
+ "version": "0.18.0",
5
5
  "type": "module",
6
6
  "description": "A lightweight Vue.js library for form state management with built-in validation, conditional logic, nested structures, and a rich event system. UI-agnostic and TypeScript-first.",
7
7
  "author": "Jure Erzno\u017enik",
@@ -55,6 +55,7 @@
55
55
  "node": ">=22"
56
56
  },
57
57
  "dependencies": {
58
+ "@dynamicforms/translatable": "^0.1.0",
58
59
  "lodash-es": "^4.17.21"
59
60
  },
60
61
  "peerDependencies": {
@@ -68,7 +69,7 @@
68
69
  "@typescript-eslint/eslint-plugin": "^8.67.0",
69
70
  "@typescript-eslint/parser": "^8.67.0",
70
71
  "@vitejs/plugin-vue": "^6",
71
- "@vitest/coverage-v8": "^3",
72
+ "@vitest/coverage-v8": "^4",
72
73
  "@vue/test-utils": "^2.2.4",
73
74
  "@vue/tsconfig": "^0.7.0",
74
75
  "baseline-browser-mapping": "^2.8.31",
@@ -85,10 +86,9 @@
85
86
  "prettier": "^3.9.6",
86
87
  "rollup-plugin-visualizer": "^5.14.0",
87
88
  "typescript": "^5",
88
- "vite": "^7",
89
+ "vite": "^8",
89
90
  "vite-plugin-dts": "^4",
90
- "vite-plugin-eslint": "^1.8.1",
91
- "vitest": "^3",
91
+ "vitest": "^4",
92
92
  "vue-eslint-parser": "^10.4.1",
93
93
  "vue-markdown-render": "^2.3.0",
94
94
  "vue-tsc": "^2"