@dmitryvim/form-builder 0.2.26 → 0.2.28

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.
@@ -0,0 +1,62 @@
1
+ import type { FileAccept } from "../../types/schema.js";
2
+ export interface FileUploadConstraints {
3
+ maxCount: number;
4
+ allowedExtensions: string[];
5
+ allowedMimes: string[];
6
+ maxSize: number;
7
+ }
8
+ /**
9
+ * Extract allowed file extensions from the `accept` schema property.
10
+ * Returns lowercase extension strings without leading dots.
11
+ * Convention: this getter normalizes to lowercase; checkers assume the list is normalized.
12
+ */
13
+ export declare function getAllowedExtensions(accept: FileAccept | undefined): string[];
14
+ /**
15
+ * Return true if fileName's extension is in the allowed list,
16
+ * or if the list is empty (no restriction).
17
+ */
18
+ export declare function isFileExtensionAllowed(fileName: string, allowedExtensions: string[]): boolean;
19
+ /**
20
+ * Return true if a byte count is within the size limit.
21
+ * maxSizeMB === Infinity means no limit.
22
+ */
23
+ export declare function isSizeWithinLimit(bytes: number, maxSizeMB: number): boolean;
24
+ /**
25
+ * Return true if file is within the size limit.
26
+ * maxSizeMB === Infinity means no limit.
27
+ */
28
+ export declare function isFileSizeAllowed(file: File, maxSizeMB: number): boolean;
29
+ /**
30
+ * Extract allowed MIME types from the `accept` schema property.
31
+ * Returns empty array for the legacy string form (no mime in that form).
32
+ * Returns empty array when accept is undefined or has no mime key.
33
+ * Convention: this getter normalizes to lowercase; checkers assume the list is normalized.
34
+ */
35
+ export declare function getAllowedMimes(accept: FileAccept | undefined): string[];
36
+ /**
37
+ * Return true if mimeType is allowed by the allowedMimes list.
38
+ * Empty allowedMimes = no mime restriction → always return true.
39
+ * Supports wildcards (image/*, application/*, etc.).
40
+ * Comparison is case-insensitive per RFC 2045.
41
+ *
42
+ * Convention: allowedMimes is assumed to be pre-normalized to lowercase
43
+ * (by getAllowedMimes). Only mimeType (the host-provided input) is lowercased here.
44
+ */
45
+ export declare function isMimeAllowed(mimeType: string, allowedMimes: string[]): boolean;
46
+ /**
47
+ * Infer MIME type from a resource ID's filename extension.
48
+ * Returns "application/octet-stream" when the extension is unrecognised.
49
+ * This is the single source of truth for the extension→mime mapping used by
50
+ * prefill, handleInitialFileData, and the API-update path.
51
+ */
52
+ export declare function inferMimeFromResourceId(resourceId: string): string;
53
+ /**
54
+ * Seed resourceIndex with inferred metadata for a single resource ID.
55
+ * Skips IDs that already have an entry (does not overwrite authoritative data).
56
+ * Sets inferredFromExtension: true so that mime validation is skipped at submit time.
57
+ */
58
+ export declare function seedInferredResource(resourceId: string, resourceIndex: Map<string, any>): void;
59
+ /**
60
+ * Add prefill resource IDs to resourceIndex with type inferred from filename extension.
61
+ */
62
+ export declare function addPrefillFilesToIndex(initialFiles: string[], resourceIndex: Map<string, any>): void;
@@ -0,0 +1,44 @@
1
+ import type { State } from "../../types/state.js";
2
+ export declare const TILE_SIZE = "160px";
3
+ /**
4
+ * Create a base square tile element (TILE_SIZE × TILE_SIZE).
5
+ * Applies .fb-tile so theme variables control background/radius.
6
+ */
7
+ export declare function createFileTile(): HTMLElement;
8
+ /**
9
+ * Show an inline error message below the nearest .space-y-2 ancestor.
10
+ */
11
+ export declare function showFileError(container: HTMLElement, message: string): void;
12
+ /**
13
+ * Remove any inline file error message below the nearest .space-y-2 ancestor.
14
+ */
15
+ export declare function clearFileError(container: HTMLElement): void;
16
+ /**
17
+ * Render (or replace) a delete-overlay with a centred "Delete" button on a tile.
18
+ * Used by the single-file edit-mode path.
19
+ */
20
+ export declare function addDeleteButton(container: HTMLElement, state: State, onDelete: () => void): void;
21
+ /**
22
+ * Find the hidden <input type="file"> picker by traversing up to the
23
+ * nearest [data-files-wrapper] ancestor.
24
+ */
25
+ export declare function findFilePicker(container: HTMLElement): HTMLInputElement | null;
26
+ /**
27
+ * Build a compact uploading-state tile (spinner + filename label).
28
+ */
29
+ export declare function createUploadingTile(fileName: string, state: State): HTMLElement;
30
+ /**
31
+ * Ensure a .fb-tiles-wrap + .fb-add-tile scaffold exists inside `list`.
32
+ * When the field starts empty, the list only has a .fb-file-dropzone; this
33
+ * function replaces it with the tile-row layout so upload placeholders land
34
+ * in the correct flex container.
35
+ */
36
+ export declare function ensureTilesWrap(list: HTMLElement): HTMLElement;
37
+ /**
38
+ * Render a placeholder empty-container (single-file edit mode).
39
+ */
40
+ export declare function setEmptyFileContainer(fileContainer: HTMLElement, state: State, hint?: string): void;
41
+ /**
42
+ * Set up drag-and-drop on an element, calling dropHandler with the dropped FileList.
43
+ */
44
+ export declare function setupDragAndDrop(element: HTMLElement, dropHandler: (files: FileList) => void): void;
@@ -0,0 +1,49 @@
1
+ import type { FormBuilderInstance } from "../../instance/FormBuilderInstance.js";
2
+ import type { State } from "../../types/state.js";
3
+ import type { FileElement, FilesElement } from "../../types/index.js";
4
+ /**
5
+ * Handle a library pick action for a MULTI-file field.
6
+ *
7
+ * End-to-end handler (mirrors upload.ts pattern):
8
+ * 1. Calls pickExistingFiles with context
9
+ * 2. Validates, deduplicates, enforces slot limit
10
+ * 3. Registers in resourceIndex, mutates resourceIds array
11
+ * 4. Updates data-resource-ids attribute
12
+ * 5. Calls updateCallback() to re-render tiles
13
+ * 6. Fires triggerOnChange
14
+ *
15
+ * @param state Form builder state
16
+ * @param element File / FilesElement schema definition
17
+ * @param wrapper The [data-files-wrapper] element
18
+ * @param fieldPath Bracket-notation field path (e.g. "slides[2].image")
19
+ * @param resourceIds The mutable live array of current resource IDs (mutated in-place)
20
+ * @param maxCount Maximum files allowed (Infinity = no limit)
21
+ * @param updateCallback Re-render callback (same pattern as upload.ts)
22
+ * @param instance FormBuilderInstance (for onChange events)
23
+ */
24
+ export declare function handleLibraryPickMulti(state: State, element: FileElement | FilesElement, wrapper: HTMLElement, fieldPath: string, resourceIds: string[], maxCount: number, updateCallback: () => void, instance: FormBuilderInstance): Promise<void>;
25
+ /**
26
+ * Handle a library pick action for a SINGLE-file field.
27
+ *
28
+ * End-to-end handler (mirrors upload.ts and handleLibraryPickMulti patterns):
29
+ * 1. Calls pickExistingFiles with context
30
+ * 2. Validates the first returned resource
31
+ * 3. Registers in resourceIndex
32
+ * 4. Creates/updates the hidden input inside fileWrapper (only on success — not on cancel)
33
+ * 5. Calls renderCallback(resourceId) to render the tile
34
+ * 6. Fires triggerOnChange
35
+ *
36
+ * The hidden input is managed here (not in the caller) to mirror how
37
+ * handleFileSelect in upload.ts manages it, and to match the multi-file
38
+ * pattern where data-resource-ids is updated inside handleLibraryPickMulti.
39
+ *
40
+ * @param state Form builder state
41
+ * @param element FileElement schema definition
42
+ * @param container The .file-preview-container element
43
+ * @param fileWrapper The .space-y-2 wrapper that contains the hidden input
44
+ * @param pathKey Field name / bracket-notation path for the hidden input
45
+ * @param fieldPath Bracket-notation field path (for onChange context)
46
+ * @param renderCallback Called with the accepted resource ID; caller renders the tile
47
+ * @param instance FormBuilderInstance (for onChange events)
48
+ */
49
+ export declare function handleLibraryPickSingle(state: State, element: FileElement, container: HTMLElement, fileWrapper: HTMLElement, pathKey: string, fieldPath: string, renderCallback: (resourceId: string) => Promise<void>, instance: FormBuilderInstance): Promise<void>;
@@ -0,0 +1,69 @@
1
+ import type { State } from "../../types/state.js";
2
+ import type { ResourceMetadata } from "../../types/config.js";
3
+ import type { FileDeps } from "./upload.js";
4
+ export interface TileActionOptions {
5
+ canRemove: boolean;
6
+ removeHandler: (() => void) | null;
7
+ state: State;
8
+ resourceId: string;
9
+ fileName: string;
10
+ /**
11
+ * The resource metadata. Used both to drive capability gating (a local
12
+ * `meta.file` is a valid download/open source even without network handlers)
13
+ * and as a fallback at click time so the user can always download/open a
14
+ * just-uploaded file.
15
+ */
16
+ meta?: ResourceMetadata;
17
+ }
18
+ /**
19
+ * Build a horizontal row of icon-only action buttons for a file tile.
20
+ * Download and Open-in-new-tab are capability-gated — they're rendered only
21
+ * when the configured handlers (or a local meta.file) can fulfil them.
22
+ * Remove is rendered only in edit mode.
23
+ */
24
+ export declare function createTileActions(options: TileActionOptions): HTMLElement;
25
+ export declare function releaseLocalFileUrl(file: File | undefined | null): void;
26
+ /**
27
+ * Populate a single-file edit-mode container with a file preview.
28
+ * Handles both local (pre-upload) Files and uploaded resource IDs.
29
+ */
30
+ export declare function renderFilePreview(container: HTMLElement, resourceId: string, state: State, options?: {
31
+ fileName?: string;
32
+ isReadonly?: boolean;
33
+ deps?: FileDeps | null;
34
+ }): Promise<void>;
35
+ /**
36
+ * Build and return a compact 160×160 readonly tile for a single resource.
37
+ * Click opens the resource via getDownloadUrl / getThumbnail / downloadFile.
38
+ * Action icon buttons (download, open, optional remove) appear on hover.
39
+ */
40
+ export declare function renderFilePreviewReadonly(resourceId: string, state: State, fileName?: string, options?: {
41
+ canRemove?: boolean;
42
+ removeHandler?: (() => void) | null;
43
+ }): Promise<HTMLElement>;
44
+ /**
45
+ * Render (or replace) the single-file edit container with a compact 160×160 tile.
46
+ * Called after a file is selected/uploaded, or when the field has prefill data.
47
+ * Mirrors renderFilePreviewReadonly but always includes a remove (✕) action button.
48
+ *
49
+ * Delegates entirely to renderFilePreviewReadonly with canRemove:true.
50
+ * getThumbnail (if configured) provides image/video thumbnails; otherwise the
51
+ * standard icon fallback is shown — same UX as the post-upload path had before.
52
+ *
53
+ * Local image files (just-uploaded, meta.file still set) are treated as uploaded
54
+ * resources: getThumbnail is tried first; if absent the 🖼️ icon is shown.
55
+ * This avoids running FileReader in single-file edit mode (consistent behaviour).
56
+ *
57
+ * Video files (local or uploaded) are NOT handled here; the caller keeps them
58
+ * on the old native-<video> path (see render-edit.ts and upload.ts).
59
+ *
60
+ * The outer `fileContainer` wrapper is cleared and the tile inserted as its only child.
61
+ * Removing the tile restores the dropzone via deps.onRemove().
62
+ */
63
+ export declare function renderSingleFileEditTile(fileContainer: HTMLElement, resourceId: string, state: State, deps: FileDeps): Promise<void>;
64
+ /**
65
+ * Populate a tile element with thumbnail / icon content for a resource.
66
+ * Used by renderResourcePills for both edit and readonly multi-file tiles.
67
+ * actionsEl: pre-built action button group to attach to the tile (and zoom popup).
68
+ */
69
+ export declare function fillTileContent(tile: HTMLElement, rid: string, meta: ResourceMetadata | undefined, state: State, actionsEl?: HTMLElement): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import type { State } from "../../types/state.js";
2
+ import type { FileElement, FilesElement, RenderContext } from "../../types/index.js";
3
+ export { TILE_SIZE } from "./dom.js";
4
+ export interface RenderPillsOptions {
5
+ container: HTMLElement;
6
+ rids: string[] | null;
7
+ state: State;
8
+ onRemove: ((rid: string) => void) | null;
9
+ hint?: string;
10
+ countInfo?: string;
11
+ maxCount?: number;
12
+ isReadonly?: boolean;
13
+ onLibraryPick?: (() => void) | null;
14
+ }
15
+ export declare function renderResourcePills(opts: RenderPillsOptions): void;
16
+ export declare function renderFileElementEdit(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
17
+ export declare function renderFilesElementEdit(element: FilesElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
18
+ export declare function renderMultipleFileElementEdit(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
@@ -0,0 +1,23 @@
1
+ import type { State } from "../../types/state.js";
2
+ import type { FileElement, FilesElement, RenderContext } from "../../types/index.js";
3
+ /**
4
+ * Render a compact 160×160 readonly tile for a single-file field.
5
+ * If no prefill: shows a styled empty placeholder.
6
+ */
7
+ export declare function renderFileElementReadonly(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
8
+ /**
9
+ * Render a tile row for a readonly multi-file field.
10
+ *
11
+ * Issue 2 fix: exactly N tile elements for N files — no hidden pill stubs.
12
+ * The [data-files-wrapper] element carries data-resource-ids so validation
13
+ * can read IDs without touching the tile DOM.
14
+ */
15
+ export declare function renderMultiFileReadonly(rids: string[], state: State, wrapper: HTMLElement, pathKey: string, marginTop?: string): void;
16
+ /**
17
+ * Render legacy `files` element in readonly mode.
18
+ */
19
+ export declare function renderFilesElementReadonly(element: FilesElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
20
+ /**
21
+ * Render `file` element with `multiple:true` in readonly mode.
22
+ */
23
+ export declare function renderMultipleFileElementReadonly(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
@@ -0,0 +1 @@
1
+ export declare function ensureFileStyles(): void;
@@ -0,0 +1,25 @@
1
+ import type { State } from "../../types/state.js";
2
+ import type { FormBuilderInstance } from "../../instance/FormBuilderInstance.js";
3
+ import { type FileUploadConstraints } from "./constraints.js";
4
+ export interface FileDeps {
5
+ picker: HTMLInputElement;
6
+ fileUploadHandler: () => void;
7
+ dragHandler: (files: FileList) => void;
8
+ setupDrop?: (container: HTMLElement) => void;
9
+ /** Called by the tile's remove button in single-file edit mode */
10
+ onRemove?: () => void;
11
+ }
12
+ export interface HandleFileSelectOptions {
13
+ file: File;
14
+ container: HTMLElement;
15
+ fieldName: string;
16
+ state: State;
17
+ deps?: FileDeps | null;
18
+ instance?: FormBuilderInstance | null;
19
+ allowedExtensions?: string[];
20
+ allowedMimes?: string[];
21
+ maxSizeMB?: number;
22
+ }
23
+ export declare function handleFileSelect(opts: HandleFileSelectOptions): Promise<void>;
24
+ export declare function setupFilesDropHandler(filesContainer: HTMLElement, resourceIds: string[], state: State, updateCallback: () => void, constraints: FileUploadConstraints, pathKey?: string, instance?: FormBuilderInstance | null): void;
25
+ export declare function setupFilesPickerHandler(filesPicker: HTMLInputElement, resourceIds: string[], state: State, updateCallback: () => void, constraints: FileUploadConstraints, pathKey?: string, instance?: FormBuilderInstance | null): void;
@@ -0,0 +1,13 @@
1
+ import type { Element, ValidationResult } from "../../types/index.js";
2
+ import type { ComponentContext } from "../../types/index.js";
3
+ /**
4
+ * Read the resource ID list for a multi-file field.
5
+ * Source of truth: `data-resource-ids` JSON attribute on [data-files-wrapper].
6
+ * Throws if the attribute is present but unparseable — that indicates a render bug.
7
+ */
8
+ export declare function readMultiFileResourceIds(scopeRoot: HTMLElement, fullKey: string): string[];
9
+ /**
10
+ * Validate file field and return extracted value with errors.
11
+ * Reads from state (resourceIndex + data-resource-ids attribute) — no DOM shape dependency.
12
+ */
13
+ export declare function validateFileElement(element: Element, key: string, context: ComponentContext): ValidationResult;
@@ -1,31 +1,9 @@
1
- import type { FileElement, FilesElement, RenderContext, ComponentContext, ValidationResult, Element } from "../types/index.js";
2
- import type { State } from "../types/state.js";
3
- interface FileDeps {
4
- picker: HTMLInputElement;
5
- fileUploadHandler: () => void;
6
- dragHandler: (files: FileList) => void;
7
- }
8
- export declare function getAllowedExtensions(accept: string | {
9
- extensions: string[];
10
- } | undefined): string[];
11
- export declare function isFileExtensionAllowed(fileName: string, allowedExtensions: string[]): boolean;
12
- export declare function isFileSizeAllowed(file: File, maxSizeMB: number): boolean;
13
- export declare function renderFilePreview(container: HTMLElement, resourceId: string, state: State, options?: {
14
- fileName?: string;
15
- isReadonly?: boolean;
16
- deps?: FileDeps | null;
17
- }): Promise<void>;
18
- export declare function renderFilePreviewReadonly(resourceId: string, state: State, fileName?: string): Promise<HTMLElement>;
19
- export declare function renderResourcePills(container: HTMLElement, rids: string[] | null, state: State, onRemove: ((rid: string) => void) | null, hint?: string, countInfo?: string): void;
1
+ import type { FileElement, FilesElement, RenderContext, ComponentContext, Element } from "../types/index.js";
2
+ export { getAllowedExtensions, isFileExtensionAllowed, isFileSizeAllowed } from "./file/constraints.js";
3
+ export { renderFilePreview, renderFilePreviewReadonly } from "./file/preview.js";
4
+ export { renderResourcePills } from "./file/render-edit.js";
5
+ export { validateFileElement } from "./file/validate.js";
20
6
  export declare function renderFileElement(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
21
7
  export declare function renderFilesElement(element: FilesElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
22
8
  export declare function renderMultipleFileElement(element: FileElement, ctx: RenderContext, wrapper: HTMLElement, pathKey: string): void;
23
- /**
24
- * Validate file field and return extracted value with errors
25
- */
26
- export declare function validateFileElement(element: Element, key: string, context: ComponentContext): ValidationResult;
27
- /**
28
- * Update file field value in DOM without re-render
29
- */
30
9
  export declare function updateFileField(element: Element, fieldPath: string, value: any, context: ComponentContext): void;
31
- export {};
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { FormBuilderInstance } from "./instance/FormBuilderInstance.js";
7
7
  import { validateSchema } from "./utils/validation.js";
8
- export type { SelectOption, ElementAction, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, FileElement, FilesElement, ContainerElement, GroupElement, RichInputElement, Element, Schema, ExternalAction, FormData, RenderContext, Translations, Locale, Config, ResourceMetadata, State, } from "./types/index.js";
8
+ export type { SelectOption, ElementAction, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, FileElement, FilesElement, ContainerElement, GroupElement, RichInputElement, Element, Schema, ExternalAction, FormData, RenderContext, Translations, Locale, Config, ResourceMetadata, PickedResource, State, } from "./types/index.js";
9
9
  export type { Theme } from "./styles/theme.js";
10
10
  export { defaultTheme, exampleThemes } from "./styles/theme.js";
11
11
  /**
@@ -1,5 +1,15 @@
1
1
  import type { Theme } from "../styles/theme.js";
2
2
  import type { TableMerge } from "./schema.js";
3
+ /**
4
+ * A file resource returned by the host's library picker.
5
+ * The host validates/provides these fields; the library re-validates on resolve.
6
+ */
7
+ export interface PickedResource {
8
+ resourceId: string;
9
+ name: string;
10
+ type: string;
11
+ size: number;
12
+ }
3
13
  export interface Translations {
4
14
  removeElement: string;
5
15
  clickDragText: string;
@@ -7,6 +17,8 @@ export interface Translations {
7
17
  noFileSelected: string;
8
18
  noFilesSelected: string;
9
19
  downloadButton: string;
20
+ downloadFile: string;
21
+ openInNewTab: string;
10
22
  changeButton: string;
11
23
  placeholderText: string;
12
24
  previewAlt: string;
@@ -27,6 +39,12 @@ export interface Translations {
27
39
  fileCountSingle: string;
28
40
  fileCountPlural: string;
29
41
  fileCountRange: string;
42
+ uploadingFile: string;
43
+ filesCounter: string;
44
+ fromLibrary: string;
45
+ libraryEmpty: string;
46
+ libraryHint: string;
47
+ pickerError: string;
30
48
  required: string;
31
49
  minItems: string;
32
50
  maxItems: string;
@@ -41,6 +59,7 @@ export interface Translations {
41
59
  minFiles: string;
42
60
  maxFiles: string;
43
61
  invalidFileExtension: string;
62
+ invalidFileMime: string;
44
63
  fileTooLarge: string;
45
64
  filesLimitExceeded: string;
46
65
  unsupportedFieldType: string;
@@ -86,6 +105,17 @@ export interface Config {
86
105
  readonly: boolean;
87
106
  locale: Locale;
88
107
  translations: Record<string, Partial<Translations>>;
108
+ pickExistingFiles: ((context: {
109
+ fieldPath: string;
110
+ mode: "single" | "multiple";
111
+ accept?: {
112
+ extensions?: string[];
113
+ mime?: string[];
114
+ };
115
+ maxSizeMB?: number;
116
+ remainingSlots?: number;
117
+ selectedResourceIds?: string[];
118
+ }) => Promise<PickedResource[]>) | null;
89
119
  parseTableFile: ((file: File) => Promise<{
90
120
  cells: string[][];
91
121
  merges?: TableMerge[];
@@ -98,4 +128,11 @@ export interface ResourceMetadata {
98
128
  size: number;
99
129
  uploadedAt: Date;
100
130
  file?: File;
131
+ /**
132
+ * True when `type` was inferred from the filename extension rather than
133
+ * provided authoritatively by the host (e.g. via uploadFile or pickExistingFiles).
134
+ * When true, mime validation is skipped at submit time because we cannot
135
+ * validate against fabricated data — extension validation still applies.
136
+ */
137
+ inferredFromExtension?: boolean;
101
138
  }
@@ -1,4 +1,4 @@
1
1
  export type { SelectOption, ElementAction, EnableCondition, BaseElement, TextElement, TextareaElement, NumberElement, SelectElement, SwitcherElement, FileElement, FilesElement, ColourElement, SliderElement, ContainerElement, GroupElement, TableElement, TableMerge, TableData, RichInputElement, Element, Schema, ExternalAction, FormData, RenderContext, } from "./schema.js";
2
- export type { Translations, Locale, Config, ResourceMetadata, } from "./config.js";
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";
@@ -76,24 +76,31 @@ export interface SelectElement extends BaseElement {
76
76
  minCount?: number;
77
77
  maxCount?: number;
78
78
  }
79
+ /**
80
+ * File accept constraint — either a legacy comma-separated string (e.g. ".jpg,.png")
81
+ * or a structured object with extension list, mime list, or both.
82
+ * `undefined` on the schema field is handled by the optional `?` marker.
83
+ */
84
+ export type FileAccept = string | {
85
+ extensions?: string[];
86
+ mime?: string[];
87
+ };
79
88
  export interface FileElement extends BaseElement {
80
89
  type: "file";
81
- accept?: string | {
82
- extensions: string[];
83
- };
90
+ accept?: FileAccept;
84
91
  maxSize?: number;
85
92
  multiple?: boolean;
86
93
  minCount?: number;
87
94
  maxCount?: number;
95
+ disableLibrary?: boolean;
88
96
  }
89
97
  export interface FilesElement extends BaseElement {
90
98
  type: "files";
91
- accept?: string | {
92
- extensions: string[];
93
- };
99
+ accept?: FileAccept;
94
100
  maxSize?: number;
95
101
  minCount?: number;
96
102
  maxCount?: number;
103
+ disableLibrary?: boolean;
97
104
  }
98
105
  export interface ContainerElement extends BaseElement {
99
106
  type: "container";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.26",
6
+ "version": "0.2.28",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "./dist/cjs/index.cjs",
9
9
  "module": "./dist/esm/index.js",