formhell 0.1.5

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,127 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentType } from 'react';
3
+
4
+ type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
5
+ interface JSONSchema {
6
+ $id?: string;
7
+ $schema?: string;
8
+ $ref?: string;
9
+ title?: string;
10
+ description?: string;
11
+ type?: JSONSchemaType | JSONSchemaType[];
12
+ enum?: unknown[];
13
+ default?: unknown;
14
+ multipleOf?: number;
15
+ minimum?: number;
16
+ maximum?: number;
17
+ exclusiveMinimum?: number;
18
+ exclusiveMaximum?: number;
19
+ minProperties?: number;
20
+ maxProperties?: number;
21
+ deprecated?: boolean;
22
+ readOnly?: boolean;
23
+ writeOnly?: boolean;
24
+ examples?: unknown[];
25
+ properties?: Record<string, JSONSchema>;
26
+ patternProperties?: Record<string, JSONSchema>;
27
+ required?: string[];
28
+ dependentRequired?: Record<string, string[]>;
29
+ dependentSchemas?: Record<string, JSONSchema>;
30
+ items?: JSONSchema | boolean;
31
+ prefixItems?: JSONSchema[];
32
+ unevaluatedItems?: JSONSchema;
33
+ additionalProperties?: boolean | JSONSchema;
34
+ unevaluatedProperties?: JSONSchema;
35
+ propertyNames?: JSONSchema;
36
+ oneOf?: JSONSchema[];
37
+ anyOf?: JSONSchema[];
38
+ allOf?: JSONSchema[];
39
+ not?: JSONSchema;
40
+ if?: JSONSchema;
41
+ then?: JSONSchema;
42
+ else?: JSONSchema;
43
+ [key: string]: unknown;
44
+ }
45
+ type OutputData = unknown;
46
+ type PeerSchemasInput = JSONSchema[] | Record<string, JSONSchema>;
47
+
48
+ interface FieldComponentProps<TValue = unknown> {
49
+ label: string;
50
+ required: boolean;
51
+ pointer: string;
52
+ schema: JSONSchema;
53
+ value: TValue;
54
+ disabled?: boolean;
55
+ controls?: ReactNode;
56
+ onChange: (next: TValue) => void;
57
+ }
58
+ interface SchemaFormObjectProps extends FieldComponentProps<Record<string, unknown>> {
59
+ children: ReactNode;
60
+ }
61
+ interface SchemaFormArrayProps extends FieldComponentProps<unknown[]> {
62
+ itemsSchema?: JSONSchema;
63
+ itemSchemas?: JSONSchema[];
64
+ canAddItem?: boolean;
65
+ canRemoveItems?: boolean;
66
+ renderItem: (index: number, pointer: string, value: unknown) => ReactNode;
67
+ createDefaultItem: () => unknown;
68
+ }
69
+ type SchemaPointerWidget = ComponentType<any>;
70
+ interface SchemaFormWidgets {
71
+ [schemaPointer: string]: SchemaPointerWidget | undefined;
72
+ String?: ComponentType<FieldComponentProps<string>>;
73
+ Select?: ComponentType<FieldComponentProps<unknown>>;
74
+ Boolean?: ComponentType<FieldComponentProps<boolean>>;
75
+ Number?: ComponentType<FieldComponentProps<number | undefined>>;
76
+ Integer?: ComponentType<FieldComponentProps<number | undefined>>;
77
+ Null?: ComponentType<FieldComponentProps<null>>;
78
+ Object?: ComponentType<SchemaFormObjectProps>;
79
+ Array?: ComponentType<SchemaFormArrayProps>;
80
+ }
81
+ interface SchemaFormOptions {
82
+ defaults?: "all" | "required-only";
83
+ }
84
+ interface SchemaFormProps {
85
+ schema: JSONSchema;
86
+ peerSchemas?: PeerSchemasInput;
87
+ getSchema?: (requestedSchema: string) => Promise<JSONSchema>;
88
+ widgets?: SchemaFormWidgets;
89
+ options?: SchemaFormOptions;
90
+ data?: OutputData;
91
+ onChange?: (data: OutputData, validationErrors: SchemaFormValidationError[], fieldPointer: string, prev: any, next: any) => void;
92
+ }
93
+ interface SchemaFormValidationError {
94
+ message: string;
95
+ source: "schema" | "peerSchemas" | "ref-resolution" | "data";
96
+ }
97
+ interface SchemaBuilderProps {
98
+ schema?: JSONSchema;
99
+ domain?: string;
100
+ onChange?: (schema: JSONSchema, validationErrors: SchemaBuilderValidationError[]) => void;
101
+ }
102
+ interface SchemaBuilderHelperContentEntry {
103
+ longDetails: string;
104
+ label?: string;
105
+ }
106
+ type SchemaBuilderHelperContent = Record<string, string | SchemaBuilderHelperContentEntry>;
107
+ interface SchemaBuilderHelperProps {
108
+ debounceMs?: number;
109
+ maxResults?: number;
110
+ placeholder?: string;
111
+ initialQuery?: string;
112
+ helpContent?: SchemaBuilderHelperContent;
113
+ }
114
+ interface SchemaBuilderValidationError {
115
+ message: string;
116
+ keyword?: string;
117
+ instancePath?: string;
118
+ schemaPath?: string;
119
+ source: "schema" | "json-parse";
120
+ }
121
+
122
+ declare function SchemaForm({ schema, peerSchemas, getSchema, widgets, options, data, onChange }: SchemaFormProps): react.JSX.Element;
123
+
124
+ declare function SchemaBuilderHelper({ debounceMs, maxResults, placeholder, initialQuery, helpContent }: SchemaBuilderHelperProps): react.JSX.Element;
125
+ declare function SchemaBuilder({ schema, domain, onChange }: SchemaBuilderProps): react.JSX.Element;
126
+
127
+ export { type FieldComponentProps, type JSONSchema, type JSONSchemaType, type OutputData, type PeerSchemasInput, SchemaBuilder, SchemaBuilderHelper, type SchemaBuilderHelperContent, type SchemaBuilderHelperContentEntry, type SchemaBuilderHelperProps, type SchemaBuilderProps, type SchemaBuilderValidationError, SchemaForm, type SchemaFormOptions, type SchemaFormProps, type SchemaFormValidationError, type SchemaFormWidgets };