@dmitryvim/form-builder 0.2.11 → 0.2.12

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.
@@ -11,7 +11,7 @@ export declare function renderFilePreview(container: HTMLElement, resourceId: st
11
11
  deps?: FileDeps | null;
12
12
  }): Promise<void>;
13
13
  export declare function renderFilePreviewReadonly(resourceId: string, state: State, fileName?: string): Promise<HTMLElement>;
14
- export declare function renderResourcePills(container: HTMLElement, rids: string[] | null, state: State, onRemove: ((rid: string) => void) | null): void;
14
+ export declare function renderResourcePills(container: HTMLElement, rids: string[] | null, state: State, onRemove: ((rid: string) => void) | null, hint?: string, countInfo?: string): void;
15
15
  export declare function renderFileElement(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
16
16
  export declare function renderFilesElement(element: FilesElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
17
17
  export declare function renderMultipleFileElement(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
@@ -1,4 +1,5 @@
1
1
  import type { TextElement, RenderContext, ComponentContext, ValidationResult } from "../types/index.js";
2
+ export declare function createCharCounter(element: TextElement, input: HTMLInputElement | HTMLTextAreaElement, isTextarea?: boolean): HTMLElement;
2
3
  export declare function renderTextElement(element: TextElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
3
4
  export declare function renderMultipleTextElement(element: TextElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
4
5
  /**
@@ -5,6 +5,7 @@ import type { State, Config } from "../types/index.js";
5
5
  export declare const defaultConfig: Config;
6
6
  /**
7
7
  * Create a new isolated state object for a FormBuilderInstance
8
+ * Uses deep merge for translations to preserve default en/ru fallbacks
8
9
  */
9
10
  export declare function createInstanceState(config?: Partial<Config>): State;
10
11
  /**
@@ -1,16 +1,47 @@
1
1
  import type { Theme } from "../styles/theme.js";
2
2
  export interface Translations {
3
- addElement: string;
4
3
  removeElement: string;
5
- uploadText: string;
6
- dragDropText: string;
7
- dragDropTextSingle: string;
8
4
  clickDragText: string;
5
+ clickDragTextMultiple: string;
9
6
  noFileSelected: string;
10
7
  noFilesSelected: string;
11
8
  downloadButton: string;
9
+ changeButton: string;
10
+ placeholderText: string;
11
+ previewAlt: string;
12
+ previewUnavailable: string;
13
+ previewError: string;
14
+ videoNotSupported: string;
15
+ hintLengthRange: string;
16
+ hintMaxLength: string;
17
+ hintMinLength: string;
18
+ hintValueRange: string;
19
+ hintMaxValue: string;
20
+ hintMinValue: string;
21
+ hintMaxSize: string;
22
+ hintFormats: string;
23
+ hintRequired: string;
24
+ hintOptional: string;
25
+ hintPattern: string;
26
+ fileCountSingle: string;
27
+ fileCountPlural: string;
28
+ fileCountRange: string;
29
+ required: string;
30
+ minItems: string;
31
+ maxItems: string;
32
+ minLength: string;
33
+ maxLength: string;
34
+ minValue: string;
35
+ maxValue: string;
36
+ patternMismatch: string;
37
+ invalidPattern: string;
38
+ notANumber: string;
39
+ invalidHexColour: string;
40
+ minFiles: string;
41
+ maxFiles: string;
42
+ unsupportedFieldType: string;
12
43
  }
13
- export type Locale = "en" | "ru";
44
+ export type Locale = "en" | "ru" | (string & {});
14
45
  export interface Config {
15
46
  uploadFile: ((file: File) => Promise<string>) | null;
16
47
  downloadFile: ((resourceId: string, fileName: string) => void) | null;
@@ -36,7 +67,7 @@ export interface Config {
36
67
  maxPreviewSize: string;
37
68
  readonly: boolean;
38
69
  locale: Locale;
39
- translations: Record<Locale, Translations>;
70
+ translations: Record<string, Partial<Translations>>;
40
71
  theme: Partial<Theme>;
41
72
  }
42
73
  export interface ResourceMetadata {
@@ -1,4 +1,9 @@
1
1
  export declare function isPlainObject(obj: any): obj is Record<string, any>;
2
+ /**
3
+ * Escape HTML special characters to prevent XSS
4
+ * Use when inserting user-controlled or translated content via innerHTML
5
+ */
6
+ export declare function escapeHtml(text: string): string;
2
7
  export declare function pathJoin(base: string, key: string): string;
3
8
  export declare function pretty(obj: any): string;
4
9
  export declare function clear(node: HTMLElement): void;
@@ -1,8 +1,13 @@
1
1
  import type { State } from "../types/state.js";
2
2
  /**
3
- * Get translated string for a key
3
+ * Get translated string for a key with optional interpolation
4
4
  * @param key Translation key
5
5
  * @param state Form state containing locale and translations
6
- * @returns Translated string or key if not found
6
+ * @param params Optional parameters for interpolation (e.g., {min: 5, max: 10})
7
+ * @returns Translated string with interpolated values, or key if not found
8
+ *
9
+ * @example
10
+ * // Template: "Minimum {min} items required"
11
+ * t('minItems', state, { min: 3 }) // => "Minimum 3 items required"
7
12
  */
8
- export declare function t(key: string, state: State): string;
13
+ export declare function t(key: string, state: State, params?: Record<string, string | number>): string;
@@ -1,2 +1,3 @@
1
- export declare function makeFieldHint(element: any): string;
1
+ import type { State } from "../types/state.js";
2
+ export declare function makeFieldHint(element: any, state: State): string;
2
3
  export declare function validateSchema(schema: any): string[];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.11",
6
+ "version": "0.2.12",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "./dist/cjs/index.cjs",
9
9
  "module": "./dist/esm/index.js",