Skip to content

Commit

Permalink
feat(generateRandomValue): added the ability to generate a random val…
Browse files Browse the repository at this point in the history
…ue (#117)
  • Loading branch information
NasgulNexus authored Sep 25, 2023
1 parent 7a5e8e8 commit f710ecb
Show file tree
Hide file tree
Showing 27 changed files with 296 additions and 66 deletions.
1 change: 1 addition & 0 deletions docs/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This component serves as the primary entry point for drawing dynamic forms.
| Monaco | `React.ComponentType<MonacoEditorProps>` | | [MonacoEditor](https://github.com/react-monaco-editor/react-monaco-editor) component for Monaco [Input](./config.md#inputs) |
| search | `string \| function` | | A string or function for performing a form search |
| withoutInsertFFDebounce | `boolean` | | Flag that disables the delay before inserting data into the final-form store |
| generateRandomValue | `function` | | Function that is necessary to generate a random value |

### Controller

Expand Down
57 changes: 29 additions & 28 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,35 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;

### StringSpec

| Property | Type | Required | Description |
| :------------------------- | :----------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| defaultValue | `string` | | Default value |
| type | `"string"` | yes | Entity type |
| required | `boolean` | | Can the value be `undefined` or `null` |
| maxLength | `bigint` | | Maximum string length |
| minLength | `bigint` | | Minimum string length |
| pattern | `string` | | RegExp to check the field value |
| patternError | `string` | | The text of the validation error by `pattern` |
| enum | `string[]` | | An array of valid values, for example for a select |
| description | `Record<string, string>` | | Easy-to-understand names for values from `enum` |
| 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 |
| viewSpec.disabled | `boolean` | | Is the field available for editing |
| viewSpec.type | `string` | yes | Key to define [Input](./config.md#inputs) for an entity |
| viewSpec.layout | `string` | | Key to define [Layout](./config.md#layouts) for an entity |
| viewSpec.layoutTitle | `string` | | Title for [Layout](./config.md#layouts) |
| viewSpec.layoutDescription | `string` | | Additional description/hint for [Layout](./config.md#layouts) |
| viewSpec.layoutOpen | `boolean` | | Expand [Layout](./config.md#layouts) at the first rendering |
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
| viewSpec.hideValues | `string[]` | | Values that are equated to empty, to exclude the rendering of unfilled fields (for example, for `enum` with `_UNSPECIFIED`) |
| viewSpec.sizeParams | `object` | | [Parameters](#sizeparams) that must be passed for an input with dimensions |
| viewSpec.monacoParams | `object` | | [Parameters](#monacoparams) that must be passed to Monaco editor |
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
| viewSpec.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input |
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
| viewSpec.hidden | `boolean` | | Hide field and view |
| viewSpec.textContentParams | `object` | | [Parameters](#textcontentparams) that must be passed to text content |
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
| Property | Type | Required | Description |
| :--------------------------------- | :----------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| defaultValue | `string` | | Default value |
| type | `"string"` | yes | Entity type |
| required | `boolean` | | Can the value be `undefined` or `null` |
| maxLength | `bigint` | | Maximum string length |
| minLength | `bigint` | | Minimum string length |
| pattern | `string` | | RegExp to check the field value |
| patternError | `string` | | The text of the validation error by `pattern` |
| enum | `string[]` | | An array of valid values, for example for a select |
| description | `Record<string, string>` | | Easy-to-understand names for values from `enum` |
| 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 |
| viewSpec.disabled | `boolean` | | Is the field available for editing |
| viewSpec.type | `string` | yes | Key to define [Input](./config.md#inputs) for an entity |
| viewSpec.layout | `string` | | Key to define [Layout](./config.md#layouts) for an entity |
| viewSpec.layoutTitle | `string` | | Title for [Layout](./config.md#layouts) |
| viewSpec.layoutDescription | `string` | | Additional description/hint for [Layout](./config.md#layouts) |
| viewSpec.layoutOpen | `boolean` | | Expand [Layout](./config.md#layouts) at the first rendering |
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
| viewSpec.hideValues | `string[]` | | Values that are equated to empty, to exclude the rendering of unfilled fields (for example, for `enum` with `_UNSPECIFIED`) |
| viewSpec.sizeParams | `object` | | [Parameters](#sizeparams) that must be passed for an input with dimensions |
| viewSpec.monacoParams | `object` | | [Parameters](#monacoparams) that must be passed to Monaco editor |
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
| viewSpec.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input |
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
| viewSpec.hidden | `boolean` | | Hide field and view |
| viewSpec.textContentParams | `object` | | [Parameters](#textcontentparams) that must be passed to text content |
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
| viewSpec.generateRandomValueButton | `boolean` | | Shows a button that allows you to generate a random value depending on the passed [function generateRandomValue](./lib.md#dynamicfield) |

#### SizeParams

Expand Down
Loading

0 comments on commit f710ecb

Please sign in to comment.