Skip to content

Commit f710ecb

Browse files
authored
feat(generateRandomValue): added the ability to generate a random value (#117)
1 parent 7a5e8e8 commit f710ecb

27 files changed

+296
-66
lines changed

docs/lib.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This component serves as the primary entry point for drawing dynamic forms.
1818
| Monaco | `React.ComponentType<MonacoEditorProps>` | | [MonacoEditor](https://github.com/react-monaco-editor/react-monaco-editor) component for Monaco [Input](./config.md#inputs) |
1919
| search | `string \| function` | | A string or function for performing a form search |
2020
| withoutInsertFFDebounce | `boolean` | | Flag that disables the delay before inserting data into the final-form store |
21+
| generateRandomValue | `function` | | Function that is necessary to generate a random value |
2122

2223
### Controller
2324

docs/spec.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,35 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
9797

9898
### StringSpec
9999

100-
| Property | Type | Required | Description |
101-
| :------------------------- | :----------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
102-
| defaultValue | `string` | | Default value |
103-
| type | `"string"` | yes | Entity type |
104-
| required | `boolean` | | Can the value be `undefined` or `null` |
105-
| maxLength | `bigint` | | Maximum string length |
106-
| minLength | `bigint` | | Minimum string length |
107-
| pattern | `string` | | RegExp to check the field value |
108-
| patternError | `string` | | The text of the validation error by `pattern` |
109-
| enum | `string[]` | | An array of valid values, for example for a select |
110-
| description | `Record<string, string>` | | Easy-to-understand names for values from `enum` |
111-
| validator | `string` | | The key for determining the [validator](./config.md#validators) for the entity, if the value is empty, the base [validator](./config.md#validators) from the entity config will be used |
112-
| viewSpec.disabled | `boolean` | | Is the field available for editing |
113-
| viewSpec.type | `string` | yes | Key to define [Input](./config.md#inputs) for an entity |
114-
| viewSpec.layout | `string` | | Key to define [Layout](./config.md#layouts) for an entity |
115-
| viewSpec.layoutTitle | `string` | | Title for [Layout](./config.md#layouts) |
116-
| viewSpec.layoutDescription | `string` | | Additional description/hint for [Layout](./config.md#layouts) |
117-
| viewSpec.layoutOpen | `boolean` | | Expand [Layout](./config.md#layouts) at the first rendering |
118-
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
119-
| viewSpec.hideValues | `string[]` | | Values that are equated to empty, to exclude the rendering of unfilled fields (for example, for `enum` with `_UNSPECIFIED`) |
120-
| viewSpec.sizeParams | `object` | | [Parameters](#sizeparams) that must be passed for an input with dimensions |
121-
| viewSpec.monacoParams | `object` | | [Parameters](#monacoparams) that must be passed to Monaco editor |
122-
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
123-
| viewSpec.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input |
124-
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
125-
| viewSpec.hidden | `boolean` | | Hide field and view |
126-
| viewSpec.textContentParams | `object` | | [Parameters](#textcontentparams) that must be passed to text content |
127-
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
100+
| Property | Type | Required | Description |
101+
| :--------------------------------- | :----------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
102+
| defaultValue | `string` | | Default value |
103+
| type | `"string"` | yes | Entity type |
104+
| required | `boolean` | | Can the value be `undefined` or `null` |
105+
| maxLength | `bigint` | | Maximum string length |
106+
| minLength | `bigint` | | Minimum string length |
107+
| pattern | `string` | | RegExp to check the field value |
108+
| patternError | `string` | | The text of the validation error by `pattern` |
109+
| enum | `string[]` | | An array of valid values, for example for a select |
110+
| description | `Record<string, string>` | | Easy-to-understand names for values from `enum` |
111+
| validator | `string` | | The key for determining the [validator](./config.md#validators) for the entity, if the value is empty, the base [validator](./config.md#validators) from the entity config will be used |
112+
| viewSpec.disabled | `boolean` | | Is the field available for editing |
113+
| viewSpec.type | `string` | yes | Key to define [Input](./config.md#inputs) for an entity |
114+
| viewSpec.layout | `string` | | Key to define [Layout](./config.md#layouts) for an entity |
115+
| viewSpec.layoutTitle | `string` | | Title for [Layout](./config.md#layouts) |
116+
| viewSpec.layoutDescription | `string` | | Additional description/hint for [Layout](./config.md#layouts) |
117+
| viewSpec.layoutOpen | `boolean` | | Expand [Layout](./config.md#layouts) at the first rendering |
118+
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
119+
| viewSpec.hideValues | `string[]` | | Values that are equated to empty, to exclude the rendering of unfilled fields (for example, for `enum` with `_UNSPECIFIED`) |
120+
| viewSpec.sizeParams | `object` | | [Parameters](#sizeparams) that must be passed for an input with dimensions |
121+
| viewSpec.monacoParams | `object` | | [Parameters](#monacoparams) that must be passed to Monaco editor |
122+
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
123+
| viewSpec.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input |
124+
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
125+
| viewSpec.hidden | `boolean` | | Hide field and view |
126+
| viewSpec.textContentParams | `object` | | [Parameters](#textcontentparams) that must be passed to text content |
127+
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
128+
| viewSpec.generateRandomValueButton | `boolean` | | Shows a button that allows you to generate a random value depending on the passed [function generateRandomValue](./lib.md#dynamicfield) |
128129

129130
#### SizeParams
130131

0 commit comments

Comments
 (0)