diff --git a/docs/input-props-map.md b/docs/input-props-map.md new file mode 100644 index 00000000..0bb44171 --- /dev/null +++ b/docs/input-props-map.md @@ -0,0 +1,11 @@ +## Supported input props map + +| Config type | Config name | Storybook | Type | Original component | +| :---------- | :---------- | :----------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- | :----------------------------------------------------------------------------- | +| `array` | `select` | [Select](https://preview.gravity-ui.com/dynamic-forms/?path=/story/array-select--select) | [MultiSelectProps](../src/lib/kit/components/Inputs/MultiSelect/MultiSelect.tsx#L10) | https://github.com/gravity-ui/uikit/tree/main/src/components/Select | +| `boolean` | `base` | [Checkbox](https://preview.gravity-ui.com/dynamic-forms/?path=/story/boolean-base--base) | [CheckboxProps](../src/lib/kit/components/Inputs/Checkbox/Checkbox.tsx#L12) | https://github.com/gravity-ui/uikit/tree/main/src/components/Checkbox | +| `number` | `base` | [Text](https://preview.gravity-ui.com/dynamic-forms/?path=/story/number-base--base) | [TextProps](../src/lib/kit/components/Inputs/Text/Text.tsx#L9) | https://github.com/gravity-ui/uikit/tree/main/src/components/Text | +| `string` | `base` | [Text](https://preview.gravity-ui.com/dynamic-forms/?path=/story/string-base--base) | [TextProps](../src/lib/kit/components/Inputs/Text/Text.tsx#L9) | https://github.com/gravity-ui/uikit/tree/main/src/components/Text | +| `string` | `password` | [Text](https://preview.gravity-ui.com/dynamic-forms/?path=/story/string-password--password) | [TextProps](../src/lib/kit/components/Inputs/Text/Text.tsx#L9) | https://github.com/gravity-ui/uikit/tree/main/src/components/Text | +| `string` | `select` | [Select](https://preview.gravity-ui.com/dynamic-forms/?path=/story/string-select--select) | [SelectProps](../src/lib/kit/components/Inputs/Select/Select.tsx#L12) | https://github.com/gravity-ui/uikit/tree/main/src/components/Select | +| `string` | `textarea` | [TextArea](https://preview.gravity-ui.com/dynamic-forms/?path=/story/string-textarea--text-area) | [TextAreaProps](../src/lib/kit/components/Inputs/TextArea/TextArea.tsx#L7) | https://github.com/gravity-ui/uikit/tree/main/src/components/controls/TextArea | diff --git a/docs/spec.md b/docs/spec.md index e44813e6..837f5a3c 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -33,6 +33,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | viewSpec.addButtonPosition | `"down"/"right"` | | The location of the button adding a new element to the array. Default value "down". | | viewSpec.hidden | `boolean` | | Hide field and view | | viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector | +| viewSpec.inputProps | `object` | | [InputProps](./input-props-map.md) Additional properties for internal input components | ### BooleanSpec @@ -50,6 +51,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | 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.hidden | `boolean` | | Hide field and view | +| viewSpec.inputProps | `object` | | [InputProps](./input-props-map.md) Additional properties for internal input components | ### NumberSpec @@ -72,6 +74,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value | | viewSpec.copy | `boolean` | | For `true`, will add a copy value button | | viewSpec.hidden | `boolean` | | Hide field and view | +| viewSpec.inputProps | `object` | | [InputProps](./input-props-map.md) Additional properties for internal input components | ### ObjectSpec @@ -127,6 +130,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | 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) | +| viewSpec.inputProps | `object` | | [InputProps](./input-props-map.md) Additional properties for internal input components | #### SizeParams diff --git a/src/lib/kit/components/Inputs/Checkbox/Checkbox.tsx b/src/lib/kit/components/Inputs/Checkbox/Checkbox.tsx index 493ac261..ecf75da7 100644 --- a/src/lib/kit/components/Inputs/Checkbox/Checkbox.tsx +++ b/src/lib/kit/components/Inputs/Checkbox/Checkbox.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import {Checkbox as CheckboxBase} from '@gravity-ui/uikit'; +import {Checkbox as CheckboxBase, CheckboxProps as CheckboxBaseProps} from '@gravity-ui/uikit'; import {BooleanInput} from '../../../../core'; import {block} from '../../../utils'; @@ -9,7 +9,13 @@ import './Checkbox.scss'; const b = block('checkbox'); -export const Checkbox: BooleanInput = ({name, input, spec}) => { +export interface CheckboxProps + extends Omit< + CheckboxBaseProps, + 'checked' | 'onChange' | 'onBlur' | 'onFocus' | 'disabled' | 'qa' + > {} + +export const Checkbox: BooleanInput = ({name, input, spec, inputProps}) => { const {value, onBlur, onChange, onFocus} = input; const handleChange = React.useCallback( @@ -20,6 +26,7 @@ export const Checkbox: BooleanInput = ({name, input, spec}) => { return (