diff --git a/docs/spec.md b/docs/spec.md index 81d610e6..2677892b 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -31,7 +31,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value | | viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value | | viewSpec.addButtonPosition | `"down"/"right"` | | The location of the button adding a new element to the array. Default value "down". | -| viewSpec.hideInput | `boolean` | | Hide input | +| viewSpec.hidden | `boolean` | | Hide field and view | | viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector | ### BooleanSpec @@ -49,7 +49,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | 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.hideInput | `boolean` | | Hide input | +| viewSpec.hidden | `boolean` | | Hide field and view | ### NumberSpec @@ -71,7 +71,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value | | 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.hideInput | `boolean` | | Hide input | +| viewSpec.hidden | `boolean` | | Hide field and view | ### ObjectSpec @@ -93,7 +93,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec; | viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value | | viewSpec.oneOfParams | `object` | | [Parameters](#oneofparams) that must be passed to oneof input | | viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value | -| viewSpec.hideInput | `boolean` | | Hide input | +| viewSpec.hidden | `boolean` | | Hide field and view | ### StringSpec @@ -122,7 +122,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.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input | | viewSpec.copy | `boolean` | | For `true`, will add a copy value button | -| viewSpec.hideInput | `boolean` | | Hide input | +| 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 | diff --git a/src/lib/core/components/Form/Controller.tsx b/src/lib/core/components/Form/Controller.tsx index c5c94508..ce77ca4f 100644 --- a/src/lib/core/components/Form/Controller.tsx +++ b/src/lib/core/components/Form/Controller.tsx @@ -63,7 +63,7 @@ export const Controller = ({ __mirror, ); - if (_.isString(name) && isCorrectSpec(spec) && !spec.viewSpec.hideInput) { + if (_.isString(name) && isCorrectSpec(spec) && !spec.viewSpec.hidden) { return withSearch(render(renderProps)); } diff --git a/src/lib/core/components/View/ViewController.tsx b/src/lib/core/components/View/ViewController.tsx index b17996c9..45fb2439 100644 --- a/src/lib/core/components/View/ViewController.tsx +++ b/src/lib/core/components/View/ViewController.tsx @@ -19,5 +19,9 @@ export const ViewController = ({ const {viewEntity, Layout} = useComponents(spec, config); const render = useRender({name, value, spec, viewEntity, Layout, Link}); - return <>{render}; + if (!spec.viewSpec.hidden) { + return {render}; + } + + return null; }; diff --git a/src/lib/core/types/specs.ts b/src/lib/core/types/specs.ts index cc7d50c5..435266dd 100644 --- a/src/lib/core/types/specs.ts +++ b/src/lib/core/types/specs.ts @@ -31,7 +31,7 @@ export interface ArraySpec { link?: LinkType; placeholder?: string; addButtonPosition?: 'down' | 'right'; - hideInput?: boolean; + hidden?: boolean; selectParams?: { filterPlaceholder?: string; meta?: Record; @@ -52,7 +52,7 @@ export interface BooleanSpec { layoutDescription?: string; layoutOpen?: boolean; link?: LinkType; - hideInput?: boolean; + hidden?: boolean; }; } @@ -74,7 +74,7 @@ export interface NumberSpec { link?: LinkType; placeholder?: string; copy?: boolean; - hideInput?: boolean; + hidden?: boolean; }; } @@ -98,7 +98,7 @@ export interface ObjectSpec { toggler?: 'select' | 'radio' | 'card'; }; placeholder?: string; - hideInput?: boolean; + hidden?: boolean; }; } @@ -132,7 +132,7 @@ export interface StringSpec { }; hideValues?: string[]; placeholder?: string; - hideInput?: boolean; + hidden?: boolean; textContentParams?: { themeLabel?: LabelProps['theme']; text: string; diff --git a/src/stories/components/InputPreview/constants.ts b/src/stories/components/InputPreview/constants.ts index b4b6f850..b98625aa 100644 --- a/src/stories/components/InputPreview/constants.ts +++ b/src/stories/components/InputPreview/constants.ts @@ -252,9 +252,9 @@ const table: ArraySpec = { }, }; -const hideInput: BooleanSpec = { +const hidden: BooleanSpec = { type: SpecTypes.Boolean, - viewSpec: {type: 'base', layout: 'row', layoutTitle: 'Hide input'}, + viewSpec: {type: 'base', layout: 'row', layoutTitle: 'Hidden'}, }; const textContentParams: ObjectSpec = { @@ -443,7 +443,7 @@ export const getArrayOptions = (): ObjectSpec => ({ table, placeholder, addButtonPosition, - hideInput, + hidden, selectParams, }, [ @@ -458,7 +458,7 @@ export const getArrayOptions = (): ObjectSpec => ({ 'table', 'placeholder', 'addButtonPosition', - 'hideInput', + 'hidden', 'selectParams', ], ), @@ -493,7 +493,7 @@ export const getBooleanOptions = (): ObjectSpec => ({ layoutTitle, layoutDescription, layoutOpen, - hideInput, + hidden, }, [ 'disabled', @@ -502,7 +502,7 @@ export const getBooleanOptions = (): ObjectSpec => ({ 'layoutTitle', 'layoutDescription', 'layoutOpen', - 'hideInput', + 'hidden', ], ), }, @@ -532,7 +532,7 @@ export const getNumberOptions = (): ObjectSpec => ({ layoutOpen, placeholder, copy, - hideInput, + hidden, }, [ 'disabled', @@ -543,7 +543,7 @@ export const getNumberOptions = (): ObjectSpec => ({ 'layoutOpen', 'placeholder', 'copy', - 'hideInput', + 'hidden', ], ), }, @@ -573,7 +573,7 @@ export const getObjectOptions = (): ObjectSpec => ({ order, oneOfParams, placeholder, - hideInput, + hidden, }, [ 'disabled', @@ -585,7 +585,7 @@ export const getObjectOptions = (): ObjectSpec => ({ 'order', 'oneOfParams', 'placeholder', - 'hideInput', + 'hidden', ], ), }, @@ -625,7 +625,7 @@ export const getStringOptions = (): ObjectSpec => ({ placeholder, fileInput, copy, - hideInput, + hidden, selectParams, }, [ @@ -641,7 +641,7 @@ export const getStringOptions = (): ObjectSpec => ({ 'placeholder', 'fileInput', 'copy', - 'hideInput', + 'hidden', 'selectParams', ], ),