You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Split types.ts into internalTypes.ts and publicTypes.ts for better organization
- Make type definitions public by separating public API types from internal-only types
- Rename types for consistency (with backward compatibility aliases):
- CardComponentPropsType → CardComponentProps
- CardComponentType → CardComponent
- InputSelectDataType → InputSelectData
- SectionPropsType → SectionProps
- CardModalType → CardModal
- Export public types from index.ts for better API discoverability
- Keep types.ts as the main import point for all types (re-exports from publicTypes.ts and internalTypes.ts)
- Improve build configuration and tooling
Documentation updates:
- Update Mods.md to show how to import types from the package instead of inline definitions
- Update Usage.md to use new type names and improve custom form input examples
- Replace email example with comprehensive phone number example in Usage.md
- Update all documentation screenshots with fresh captures from live application
- Update screenshots: array.png, array2.png, card.png, collapsed.png, dependency1.png, dependency2.png, modal.png, reference.png, section.png
- Remove visualDemo.gif as it is no longer referenced in documentation
@@ -4,106 +4,63 @@ Mods provide for the customization of the Form Builder component, such as the de
4
4
5
5
## Type Definition
6
6
7
-
Type definitions are available via [TypeScript](https://github.com/microsoft/TypeScript).
8
-
9
-
The type definition for Mods is as follows:
7
+
All types used in mods are exported from the package and can be imported directly. When you import types from the package, TypeScript automatically provides type checking.
`tooltipDescriptions` and `labels` describe how some of the labels and tooltips in the Form Builder are to be customized. `showFormHead` is a boolean which controls whether the top section of the Form Builder, which contains inputs for the Form Name and Form Description, are show. It is set to `true` by default.
26
+
### Mods
55
27
56
-
A single `FormInput` has a type definition `FormInputType` as follows:
28
+
The `Mods` type is the main interface for customizing the Form Builder. It includes:
57
29
58
-
```typescript
59
-
interfaceFormInputType {
60
-
displayName:string;
61
-
// given a data and ui schema, determine if the object is of this input type
62
-
matchIf:Array<MatchType>;
63
-
// allowed keys for ui:options
64
-
possibleOptions?:Array<string>;
65
-
defaultDataSchema: {
66
-
[key:string]:any;
67
-
};
68
-
defaultUiSchema: {
69
-
[key:string]:any;
70
-
};
71
-
// the data schema type
72
-
type:DataType;
73
-
// inputs on the preview card
74
-
cardBody:CardComponentType;
75
-
// inputs for the modal
76
-
modalBody?:CardComponentType;
77
-
}
78
-
```
30
+
-`customFormInputs?: Record<string, FormInput>` - Define custom form input types
-`tooltipDescriptions?: { ... }` - Customize tooltip text (see [Tooltips and Labels](#tooltips-and-labels) section)
33
+
-`labels?: ModLabels` - Customize label text (see [Tooltips and Labels](#tooltips-and-labels) section)
34
+
-`showFormHead?: boolean` - Control visibility of the form header (default: `true`)
35
+
-`deactivatedFormInputs?: Array<string>` - Hide specific default input types
36
+
-`newElementDefaultDataOptions?: DataOptions` - Set default options for new form elements
37
+
-`newElementDefaultUiSchema?: UiSchemaProperty | Record<string, unknown>` - Set default UI schema for new form elements
79
38
80
-
The `displayName` is the full name of the desired form input. For example, **Short Answer** is the `displayName` for the `shortAnswer` form input.
39
+
**Additional types:**
40
+
-`AddFormObjectParameters` - Used in `components.add` callback to add form elements programmatically (see [Usage documentation](Usage.md#customizing-add-buttons) for details)
41
+
-`DataOptions` - Type for `newElementDefaultDataOptions`, includes `title`, `type`, `description`, `$ref`, and `default` properties
81
42
82
-
`matchIf` is an array of scenarios that will cause the `FormBuilder` to recognize a piece of Data and UI schema as this custom input type. For more information, see the *Matching Algorithm* section on this page.
43
+
### FormInput
83
44
84
-
`possibleOptions` is the set of possible values that can appear after `ui:option` in the UI schema for this component.
45
+
The `FormInput` type defines a custom form input. Key properties:
85
46
86
-
`defaultDataSchema` is the data schema that gets filled into the component when a user switches to this input type. This default data schema must be a match in the `matchIf` array, or otherwise when the user switches to the Input Type, it will be immediately unrecognzied and instead be captured by the next applicable input type.
47
+
-`displayName: string` - The full name shown in the Input Type dropdown (e.g., "Short Answer")
48
+
-`matchIf: Array<Match>` - Array of matching criteria to identify this input type (see [Matching Algorithm](#matching-algorithm) section)
49
+
-`possibleOptions?: Array<string>` - Allowed keys for `ui:options` in the UI schema
50
+
-`defaultDataSchema: JsonSchemaProperty | Record<string, unknown>` - Default data schema when switching to this input type (must match one of the `matchIf` criteria)
51
+
-`defaultUiSchema: UiSchemaProperty | Record<string, unknown>` - Default UI schema when switching to this input type (must match one of the `matchIf` criteria)
52
+
-`type: DataType` - The JSON Schema data type (see `DataType` below)
53
+
-`cardBody: CardComponent` - React component rendered in the expanded card
54
+
-`modalBody?: CardComponent` - Optional React component rendered in the modal (pencil icon)
87
55
88
-
`defaultUiSchema` is the ui schema that gets filled into the component when a user switches to this input type. It functions similarly to the `defaultDataSchema`, and must pass the requirements in `matchIf`.
56
+
### DataType
89
57
90
-
`type` is the Data Schema type that this input type defaults to. While a custom form input can have multiple types (would need to be defined in the `matchIf` array), this refers to the type that gets assigned immediately after a user selects this input type in the dropdown. The possible `DataType` options supported by `react-jsonschema-form` are as follows:
58
+
The `DataType` is a union type representing JSON Schema data types supported by `react-jsonschema-form`:
`cardBody` refers to a React component that gets rendered in the card itself, when expanded. This React component gets a set of `Parameters` that provide additional information about the FormInput, such as the `title` or the `default` properties. For more information, see the *Parameters* section.
104
-
105
-
`cardModal` refers to the React component that appears inside the modal that appears when the form builder clicks on the pencil icon. This React component also receives the same `Parameters` object, which is explained in further detail in the *Parameters* section.
106
-
107
64
The `FormBuilder` component takes a prop `mods`, which is a `Mods` type object.
108
65
109
66
## Custom Form Inputs
@@ -116,87 +73,38 @@ Custom input types are encoded in exactly the same way the Default input types a
116
73
117
74
### Matching Algorithm
118
75
119
-
The `matchIf` array in a `FormInput` contains a series of `MatchType` objects, which represent different possible 'scenarios' that the `FormBuilder` may encounter when parsing a set of Data and UI Schema. The `MatchType` is defined as follows:
120
-
121
-
```typescript
122
-
interfaceMatchType {
123
-
types:Array<DataType>;
124
-
widget?:string;
125
-
field?:string;
126
-
format?:string;
127
-
$ref?:boolean;
128
-
enum?:boolean;
129
-
}
130
-
```
76
+
The `matchIf` array in a `FormInput` contains a series of `Match` objects, which represent different possible 'scenarios' that the `FormBuilder` may encounter when parsing a set of Data and UI Schema. The `Match` type is exported and can be imported from the package.
131
77
132
-
`types` refers to the set of possible input types that can register in a particular scenario.
78
+
**Match properties:**
133
79
134
-
`widget` is the value for the key `ui:widget` that can exist in the UI schema for this scenario.
80
+
-`types: Array<DataType>` - The set of possible JSON Schema data types that can register in this scenario
81
+
-`widget?: string` - The value for `ui:widget` that can exist in the UI schema for this scenario
82
+
-`field?: string` - The value for `ui:field` that can exist in the UI schema for this scenario
83
+
-`format?: string` - The value for `format` that can exist in the Data schema for this scenario
84
+
-`$ref?: boolean` - If `true`, matches when the data schema has a `$ref` property (reference to a definition)
85
+
-`enum?: boolean` - If `true`, matches when the data schema has an `enum` property
135
86
136
-
`field` is the value for the key `ui:field` that can exist in the UI schema for this scenario.
137
-
138
-
`format` is the value for the key `format` that can exist in the Data schema for this scenario.
139
-
140
-
`$ref` is a boolean that evaluates to true if, in this scenario, the input type is a reference to a field in `definitions` in the Data Schema (in other words, the data schema has a property `$ref`).
141
-
142
-
`enum` is a boolean that evaluates to true if the component has a property `enum` in the Data Schema.
87
+
Import the type from the package to see its complete definition.
143
88
144
89
### Component Types
145
90
146
-
`cardBody` and `modalBody` are components whose props have a type of `CardComponentType`:
91
+
`cardBody` and `modalBody` are components whose props have a type of `CardComponent`. Both `CardComponent` and `CardComponentProps` are exported and can be imported from the package.
Import the types from the package to see their complete definitions.
198
106
199
-
It can hold any number of keys pointing to specific values. One common example is `default`, which stores the default value specified by the builder for this `FormInput`.
107
+
One common example is the `default` property, which stores the default value specified by the builder for this `FormInput`.
0 commit comments