@dmitryvim/form-builder 0.3.3 → 0.4.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.
@@ -64,7 +64,7 @@ export declare function handleLibraryPickMulti(opts: HandleLibraryPickMultiOptio
64
64
  * @param state Form builder state
65
65
  * @param element FileElement schema definition
66
66
  * @param container The .file-preview-container element
67
- * @param fileWrapper The .space-y-2 wrapper that contains the hidden input
67
+ * @param fileWrapper The .fb-row wrapper that contains the hidden input
68
68
  * @param pathKey Field name / bracket-notation path for the hidden input
69
69
  * @param fieldPath Bracket-notation field path (for onChange context)
70
70
  * @param renderCallback Called with the accepted resource ID; caller renders the tile
@@ -6,7 +6,9 @@ export declare function renderMultipleTextareaElement(element: TextareaElement,
6
6
  */
7
7
  export declare function validateTextareaElement(element: TextareaElement, key: string, context: ComponentContext): ValidationResult;
8
8
  /**
9
- * Update textarea field - delegates to text updater since they share update logic,
10
- * then triggers resize on autoExpand textareas.
9
+ * Update textarea field - delegates to text updater since they share update
10
+ * logic, then triggers resize so auto-expand recomputes height for the new
11
+ * value. As of v0.4.0 auto-expand is always on, so the resize event is
12
+ * dispatched unconditionally.
11
13
  */
12
14
  export declare function updateTextareaField(element: TextareaElement, fieldPath: string, value: any, context: ComponentContext): void;
@@ -88,6 +88,9 @@ export interface Theme {
88
88
  labelSectionFontSize: string;
89
89
  labelSectionLetterSpacing: string;
90
90
  labelSectionTextTransform: string;
91
+ labelFontSize: string;
92
+ labelLineHeight: string;
93
+ labelMarginBottom: string;
91
94
  }
92
95
  export declare const defaultTheme: Theme;
93
96
  /**
@@ -1,4 +1,4 @@
1
- export type { SelectOption, ElementAction, EnableCondition, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, SwitcherElement, BooleanElement, FileElement, FilesElement, ColourElement, SliderElement, ContainerElement, GroupElement, TableElement, TableMerge, TableData, RichInputElement, MarkdownElement, Element, Schema, ExternalAction, FormData, RenderContext, } from "./schema.js";
1
+ export type { SelectOption, ElementAction, ElementSize, ElementWidth, EnableCondition, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, SwitcherElement, BooleanElement, FileElement, FilesElement, ColourElement, SliderElement, ContainerElement, GroupElement, TableElement, TableMerge, TableData, RichInputElement, MarkdownElement, Element, Schema, ExternalAction, FormData, RenderContext, } from "./schema.js";
2
2
  export type { Translations, Locale, Config, ResourceMetadata, PickedResource, } from "./config.js";
3
3
  export type { State } from "./state.js";
4
4
  export type { ComponentContext, ValidationResult, ComponentValidator, ComponentUpdater, ComponentOperations, } from "./component-operations.js";
@@ -36,6 +36,20 @@ export interface EnableCondition {
36
36
  equals?: any;
37
37
  scope?: "relative" | "absolute";
38
38
  }
39
+ /**
40
+ * Visual density token applied to input-bearing elements. Controls
41
+ * padding/font-size via the `.fb-size-{token}` class on the field wrapper.
42
+ * Defaults to `"md"`. Larger sizes (`lg`/`xl`) suit hero forms; smaller
43
+ * sizes (`sm`/`xs`) suit dense admin tables.
44
+ */
45
+ export type ElementSize = "xs" | "sm" | "md" | "lg" | "xl";
46
+ /**
47
+ * Horizontal slot the element occupies within its container's flex-wrap row.
48
+ * Defaults to `"full"` (own row). Mixing widths (e.g. `[1/2, 1/2, full]`)
49
+ * lets a single container hold both partial-column and full-width fields.
50
+ * Widths in one row should sum to ≤ 1; remainders leave whitespace.
51
+ */
52
+ export type ElementWidth = "1/3" | "1/2" | "2/3" | "full";
39
53
  export interface BaseElement {
40
54
  type: string;
41
55
  key: string;
@@ -48,6 +62,10 @@ export interface BaseElement {
48
62
  default?: any;
49
63
  actions?: ElementAction[];
50
64
  enableIf?: EnableCondition;
65
+ /** Visual density. Default: "md". See {@link ElementSize}. */
66
+ size?: ElementSize;
67
+ /** Horizontal slot within container row. Default: "full". See {@link ElementWidth}. */
68
+ width?: ElementWidth;
51
69
  }
52
70
  export interface TextElement extends BaseElement {
53
71
  type: "text";
@@ -70,6 +88,11 @@ export interface TextareaElement extends BaseElement {
70
88
  multiple?: boolean;
71
89
  minCount?: number;
72
90
  maxCount?: number;
91
+ /**
92
+ * @deprecated As of v0.4.0 auto-expand is always on for textarea. This flag
93
+ * is ignored (kept only to avoid breaking existing schemas that set it).
94
+ * Use `rows` to set the initial visible row count.
95
+ */
73
96
  autoExpand?: boolean;
74
97
  addLabel?: string;
75
98
  }
@@ -53,7 +53,9 @@ export declare function ensureThemingHooks(doc: Document): void;
53
53
  * where width hasn't moved — otherwise our own height writes would feed back
54
54
  * into the observer.
55
55
  */
56
- export declare function applyAutoExpand(textarea: HTMLTextAreaElement): void;
56
+ export declare function applyAutoExpand(textarea: HTMLTextAreaElement, options?: {
57
+ minRows?: number;
58
+ }): void;
57
59
  /**
58
60
  * Enforce single-line semantics on a textarea: block the Enter key and
59
61
  * strip newlines from pasted content. Used to render <textarea rows=1> as
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.3",
6
+ "version": "0.4.0",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "./dist/cjs/index.cjs",
9
9
  "module": "./dist/esm/index.js",
@@ -52,23 +52,23 @@
52
52
  "url": "git+https://github.com/picazru/form-builder.git"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/core": "^7.28.5",
56
- "@babel/preset-env": "^7.28.5",
57
- "@eslint/js": "^9.35.0",
58
- "@rollup/plugin-commonjs": "^25.0.8",
59
- "@rollup/plugin-node-resolve": "^15.2.3",
60
- "@rollup/plugin-replace": "^6.0.2",
61
- "@types/node": "^20.0.0",
62
- "babel-jest": "^30.2.0",
63
- "eslint": "^9.35.0",
64
- "jest": "^29.0.0",
65
- "jest-environment-jsdom": "^29.7.0",
66
- "prettier": "^3.0.0",
67
- "rollup": "^4.24.3",
68
- "rollup-plugin-esbuild": "^6.1.0",
69
- "serve": "^14.0.0",
70
- "tsup": "^8.2.4",
71
- "typescript": "^5.0.0",
72
- "typescript-eslint": "^8.0.0"
55
+ "@babel/core": "^7.29.0",
56
+ "@babel/preset-env": "^7.29.5",
57
+ "@eslint/js": "^10.0.1",
58
+ "@rollup/plugin-commonjs": "^29.0.2",
59
+ "@rollup/plugin-node-resolve": "^16.0.3",
60
+ "@rollup/plugin-replace": "^6.0.3",
61
+ "@types/node": "^25.8.0",
62
+ "babel-jest": "^30.4.1",
63
+ "eslint": "^10.4.0",
64
+ "jest": "^30.4.2",
65
+ "jest-environment-jsdom": "^30.4.1",
66
+ "prettier": "^3.8.3",
67
+ "rollup": "^4.60.4",
68
+ "rollup-plugin-esbuild": "^6.2.1",
69
+ "serve": "^14.2.6",
70
+ "tsup": "^8.5.1",
71
+ "typescript": "^6.0.3",
72
+ "typescript-eslint": "^8.59.3"
73
73
  }
74
74
  }