jupiter-dynamic-forms
Version:
Framework-agnostic dynamic form builder for XBRL entrypoints using Web Components. Supports Angular 14+, React, Vue, and vanilla HTML.
203 lines • 5.2 kB
TypeScript
/**
* XBRL Dynamic Form Schema Types
* Defines the structure for JSON-driven form generation
*/
export interface XBRLFormSchema {
version: string;
formId: string;
title: string;
description?: string;
sections: FormSection[];
globalValidation?: ValidationRule[];
metadata?: Record<string, any>;
}
export interface FormSection {
id: string;
title: string;
description?: string;
expanded?: boolean;
concepts: ConceptTree[];
columns?: FormColumn[];
validation?: ValidationRule[];
metadata?: Record<string, any>;
}
export interface ConceptTree {
id: string;
originalConceptId: string;
name: string;
label: string;
description?: string;
level: number;
parentId?: string;
children?: ConceptTree[];
fields: FormField[];
collapsed?: boolean;
abstract?: boolean;
periodType?: 'instant' | 'duration';
}
export interface FormField {
id: string;
conceptId: string;
columnId: string;
type: FieldType;
label: string;
placeholder?: string;
required?: boolean;
disabled?: boolean;
validation?: ValidationRule[];
defaultValue?: any;
options?: FieldOption[];
attributes?: Record<string, any>;
periodStartDate?: string;
periodEndDate?: string;
}
export interface FormColumn {
id: string;
title: string;
description?: string;
type: 'base' | 'dimension';
dimensionData?: DimensionData;
order: number;
removable?: boolean;
}
export interface DimensionData {
dimensionId: string;
axisId?: string;
memberId?: string;
memberValue: string;
memberLabel: string;
axis?: string;
axisLabel?: string;
memberKey?: string;
dimensionIdKey?: string;
hasTypedMembers?: boolean;
typedMemberId?: string;
typedMembers?: Array<{
axisId: string;
axisLabel: string;
typedMemberId: string;
memberLabel: string;
}>;
combinations?: Array<{
axisId: string;
axisLabel: string;
memberId: string;
memberLabel: string;
}>;
}
export type FieldType = 'text' | 'number' | 'decimal' | 'date' | 'datetime' | 'boolean' | 'select' | 'multiselect' | 'textarea' | 'currency' | 'percentage' | 'email' | 'url' | 'tel';
export interface FieldOption {
value: string | number | boolean;
label: string;
disabled?: boolean;
}
export interface ValidationRule {
type: ValidationType;
value?: any;
message: string;
severity?: 'error' | 'warning' | 'info';
}
export type ValidationType = 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'email' | 'url' | 'custom';
export interface FormData {
[conceptId: string]: {
[columnId: string]: any;
};
}
export interface SubmissionEntry {
conceptId: string;
value: any;
period: {
type: 'instant' | 'duration';
date?: string;
startDate?: string;
endDate?: string;
};
dimension?: string;
typedMembers?: {
[axisId: string]: {
value: string;
memberName: string;
};
};
}
export type SubmissionData = SubmissionEntry[];
export interface ValidationError {
fieldId: string;
conceptId: string;
columnId: string;
message: string;
severity: 'error' | 'warning' | 'info';
rule: ValidationRule;
}
export interface FormState {
data: FormData;
errors: ValidationError[];
touched: Set<string>;
dirty: boolean;
valid: boolean;
submitted: boolean;
}
export interface FormEvents {
'field-change': CustomEvent<{
fieldId: string;
conceptId: string;
columnId: string;
value: any;
oldValue: any;
}>;
'field-focus': CustomEvent<{
fieldId: string;
conceptId: string;
columnId: string;
}>;
'field-blur': CustomEvent<{
fieldId: string;
conceptId: string;
columnId: string;
}>;
'section-expand': CustomEvent<{
sectionId: string;
expanded: boolean;
}>;
'concept-expand': CustomEvent<{
conceptId: string;
expanded: boolean;
}>;
'column-add': CustomEvent<{
column: FormColumn;
}>;
'column-remove': CustomEvent<{
columnId: string;
}>;
'form-submit': CustomEvent<{
data: FormData;
submissionData: SubmissionData;
valid: boolean;
errors: ValidationError[];
}>;
'form-save-draft': CustomEvent<{
data: FormData;
draftData: SubmissionData;
valid: boolean;
errors: ValidationError[];
}>;
'form-reset': CustomEvent<{}>;
'validation-error': CustomEvent<{
errors: ValidationError[];
}>;
}
export interface ComponentConfig {
theme?: 'light' | 'dark' | 'auto';
locale?: string;
dateFormat?: string;
numberFormat?: Intl.NumberFormatOptions;
currencyCode?: string;
showValidationSummary?: boolean;
collapsibleSections?: boolean;
collapsibleConcepts?: boolean;
enableColumnManagement?: boolean;
maxColumns?: number;
autoSave?: boolean;
autoSaveInterval?: number;
}
//# sourceMappingURL=types.d.ts.map