@dmitryvim/form-builder 0.2.9 → 0.2.10

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.
@@ -83,6 +83,10 @@ export declare class FormBuilderInstance {
83
83
  * Handle prefill hint click - updates container fields with hint values
84
84
  */
85
85
  private handlePrefillHintClick;
86
+ /**
87
+ * Create root-level prefill hints UI
88
+ */
89
+ private createRootPrefillHints;
86
90
  /**
87
91
  * Render form from schema
88
92
  */
@@ -133,7 +137,7 @@ export declare class FormBuilderInstance {
133
137
  */
134
138
  private updateFieldValue;
135
139
  /**
136
- * Re-evaluate all conditional fields (displayIf) based on current form data
140
+ * Re-evaluate all conditional fields (enableIf) based on current form data
137
141
  * This is called automatically when form data changes (via onChange events)
138
142
  */
139
143
  private reevaluateConditionalFields;
@@ -1,4 +1,4 @@
1
- export type { SelectOption, ElementAction, DisplayCondition, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, FileElement, FilesElement, ColourElement, SliderElement, ContainerElement, GroupElement, Element, Schema, ExternalAction, FormData, RenderContext, } from "./schema.js";
1
+ export type { SelectOption, ElementAction, EnableCondition, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, FileElement, FilesElement, ColourElement, SliderElement, ContainerElement, GroupElement, Element, Schema, ExternalAction, FormData, RenderContext, } from "./schema.js";
2
2
  export type { Translations, Locale, Config, ResourceMetadata, } from "./config.js";
3
3
  export type { State } from "./state.js";
4
4
  export type { ComponentContext, ValidationResult, ComponentValidator, ComponentUpdater, ComponentOperations, } from "./component-operations.js";
@@ -14,12 +14,13 @@ export interface PrefillHint {
14
14
  values: Record<string, any>;
15
15
  }
16
16
  /**
17
- * Conditional display configuration for elements
17
+ * Conditional enable configuration for elements
18
18
  * Initially supports equals operator, designed for extensibility
19
19
  */
20
- export interface DisplayCondition {
20
+ export interface EnableCondition {
21
21
  key: string;
22
22
  equals?: any;
23
+ scope?: "relative" | "absolute";
23
24
  }
24
25
  export interface BaseElement {
25
26
  type: string;
@@ -31,7 +32,7 @@ export interface BaseElement {
31
32
  hidden?: boolean;
32
33
  default?: any;
33
34
  actions?: ElementAction[];
34
- displayIf?: DisplayCondition;
35
+ enableIf?: EnableCondition;
35
36
  }
36
37
  export interface TextElement extends BaseElement {
37
38
  type: "text";
@@ -130,6 +131,8 @@ export type Element = TextElement | TextareaElement | NumberElement | SelectElem
130
131
  export interface Schema {
131
132
  version?: string;
132
133
  elements: Element[];
134
+ columns?: 1 | 2 | 3 | 4;
135
+ prefillHints?: PrefillHint[];
133
136
  }
134
137
  export interface ExternalAction {
135
138
  key: string;
@@ -0,0 +1,18 @@
1
+ import type { EnableCondition } from "../types/index.js";
2
+ /**
3
+ * Get value from nested object path
4
+ * Supports nested paths: "address.city"
5
+ * Supports array indices: "items[0].name", "contacts[1].email"
6
+ * @param data - Form data object
7
+ * @param path - Dot notation path with optional array indices
8
+ * @returns The value at the path, or undefined if not found
9
+ */
10
+ export declare function getValueByPath(data: any, path: string): any;
11
+ /**
12
+ * Evaluate an enable condition against form data
13
+ * @param condition - Enable condition to evaluate
14
+ * @param formData - Root form data (for absolute scope)
15
+ * @param containerData - Container instance data (for relative scope, optional)
16
+ * @returns true if condition is met (field should be enabled), false otherwise
17
+ */
18
+ export declare function evaluateEnableCondition(condition: EnableCondition, formData: Record<string, any>, containerData?: Record<string, any>): boolean;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.9",
6
+ "version": "0.2.10",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "./dist/cjs/index.cjs",
9
9
  "module": "./dist/esm/index.js",