From 90059b664638777eda9fd79e25380eb6dcaf8367 Mon Sep 17 00:00:00 2001 From: ej9x Date: Mon, 3 Dec 2018 16:14:30 +0300 Subject: [PATCH] fix(atoms): fix passing the rest in the form fields --- src/atoms/dataEntry/Checkbox/Checkbox.js | 2 +- .../dataEntry/CheckboxField/CheckboxField.js | 12 ++- src/atoms/dataEntry/InputField/InputField.js | 21 ++++- .../RadioGroupField/RadioGroupField.js | 18 +++- .../__snapshots__/storyshots.test.js.snap | 86 +++++++++++++------ 5 files changed, 102 insertions(+), 37 deletions(-) diff --git a/src/atoms/dataEntry/Checkbox/Checkbox.js b/src/atoms/dataEntry/Checkbox/Checkbox.js index b1de5076..3a26aafd 100644 --- a/src/atoms/dataEntry/Checkbox/Checkbox.js +++ b/src/atoms/dataEntry/Checkbox/Checkbox.js @@ -16,7 +16,7 @@ type CheckboxProps = { checked?: boolean, /** when error then show error styles */ hasError?: boolean, - /** when error then show disabled styles */ + /** show disabled styles */ disabled?: boolean, /** callback to change chcked state */ diff --git a/src/atoms/dataEntry/CheckboxField/CheckboxField.js b/src/atoms/dataEntry/CheckboxField/CheckboxField.js index f7331b3f..9d8be590 100644 --- a/src/atoms/dataEntry/CheckboxField/CheckboxField.js +++ b/src/atoms/dataEntry/CheckboxField/CheckboxField.js @@ -14,6 +14,10 @@ type CheckboxFieldProps = {| input?: InputType, /** form meta object */ meta?: MetaType, + /** color of the check */ + color ?: 'primary' | 'secondary', + /** show disabled styles */ + disabled ?: boolean, |}; const CheckboxField = ({ @@ -21,16 +25,16 @@ const CheckboxField = ({ stretch, input = {}, meta = {}, + disabled, + color, ...rest }: CheckboxFieldProps) => { const { name, value, onChange, onFocus, onBlur } = input; - const hasError = formUtils.hasError(meta); return ( - + ); diff --git a/src/atoms/dataEntry/InputField/InputField.js b/src/atoms/dataEntry/InputField/InputField.js index 13f414c5..69fd16c6 100644 --- a/src/atoms/dataEntry/InputField/InputField.js +++ b/src/atoms/dataEntry/InputField/InputField.js @@ -22,6 +22,8 @@ type InputFieldProps = {| hideErrorIndicator?: boolean, /** align of the input value */ align?: 'center' | 'left' | 'right', + /** input placeholder */ + placeholder?: string, /** form input object */ input?: InputType, /** form meta object */ @@ -45,11 +47,14 @@ const InputField = ({ hideErrorIndicator, hideErrorLabel, input = {}, + insideRef, label, maxLength, meta = {}, + placeholder, square, stretch, + width, ...rest }: InputFieldProps) => { const { name, value, onChange, onFocus, onBlur } = input; @@ -57,19 +62,29 @@ const InputField = ({ const hasError = formUtils.hasError(meta); return ( - + ); diff --git a/src/atoms/dataEntry/RadioGroupField/RadioGroupField.js b/src/atoms/dataEntry/RadioGroupField/RadioGroupField.js index 15b52f66..71d93779 100644 --- a/src/atoms/dataEntry/RadioGroupField/RadioGroupField.js +++ b/src/atoms/dataEntry/RadioGroupField/RadioGroupField.js @@ -2,10 +2,11 @@ import React from 'react'; -import type { InputType, MetaType } from '../formTypes'; import * as formUtils from '../../../utils/forms'; import { Radio } from '../Radio'; import { FormField } from '../Form/FormField'; +import type { PropSizes } from '../../../types'; +import type { InputType, MetaType } from '../formTypes'; type RadioGroupFieldProps = { /** Grop.Item components */ @@ -16,15 +17,22 @@ type RadioGroupFieldProps = { input?: InputType, /** form meta object */ meta?: MetaType, + /** offset between radio items */ + gap?: PropSizes, + /** direction of the radio items */ + direction?: 'row' | 'column', /** options to define radio items */ options?: ({ value: any, label: string }) => void, }; const RadioGroupField = ({ children, + direction, + gap, hideErrorLabel, input = {}, meta = {}, + options, ...rest }: RadioGroupFieldProps) => { const { name, value, onChange } = input; @@ -32,12 +40,14 @@ const RadioGroupField = ({ const hasError = formUtils.hasError(meta); return ( - + { children } diff --git a/storybook/__tests__/__snapshots__/storyshots.test.js.snap b/storybook/__tests__/__snapshots__/storyshots.test.js.snap index 30b4e415..7b392807 100644 --- a/storybook/__tests__/__snapshots__/storyshots.test.js.snap +++ b/storybook/__tests__/__snapshots__/storyshots.test.js.snap @@ -4752,6 +4752,7 @@ exports[`Storyshots ATOMS/DATA ENTRY/Form with form error 1`] = ` >