Skip to content

Commit 219ca92

Browse files
authored
feat(hidden): added a new hidden option (#110)
1 parent 4298d13 commit 219ca92

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

docs/spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
3131
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
3232
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
3333
| viewSpec.addButtonPosition | `"down"/"right"` | | The location of the button adding a new element to the array. Default value "down". |
34-
| viewSpec.hideInput | `boolean` | | Hide input |
34+
| viewSpec.hidden | `boolean` | | Hide field and view |
3535
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
3636

3737
### BooleanSpec
@@ -49,7 +49,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
4949
| viewSpec.layoutDescription | `string` | | Additional description/hint for [Layout](./config.md#layouts) |
5050
| viewSpec.layoutOpen | `boolean` | | Expand [Layout](./config.md#layouts) at the first rendering |
5151
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
52-
| viewSpec.hideInput | `boolean` | | Hide input |
52+
| viewSpec.hidden | `boolean` | | Hide field and view |
5353

5454
### NumberSpec
5555

@@ -71,7 +71,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
7171
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
7272
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
7373
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
74-
| viewSpec.hideInput | `boolean` | | Hide input |
74+
| viewSpec.hidden | `boolean` | | Hide field and view |
7575

7676
### ObjectSpec
7777

@@ -93,7 +93,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
9393
| viewSpec.link | `any` | | A field containing information for forming a [link](#link) for a value |
9494
| viewSpec.oneOfParams | `object` | | [Parameters](#oneofparams) that must be passed to oneof input |
9595
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
96-
| viewSpec.hideInput | `boolean` | | Hide input |
96+
| viewSpec.hidden | `boolean` | | Hide field and view |
9797

9898
### StringSpec
9999

@@ -122,7 +122,7 @@ type Spec = ArraySpec | BooleanSpec | NumberSpec | ObjectSpec | StringSpec;
122122
| viewSpec.placeholder | `string` | | A short hint displayed in the field before the user enters the value |
123123
| viewSpec.fileInput | `object` | | [Parameters](#FileInput) that must be passed to file input |
124124
| viewSpec.copy | `boolean` | | For `true`, will add a copy value button |
125-
| viewSpec.hideInput | `boolean` | | Hide input |
125+
| viewSpec.hidden | `boolean` | | Hide field and view |
126126
| viewSpec.textContentParams | `object` | | [Parameters](#textcontentparams) that must be passed to text content |
127127
| viewSpec.selectParams | `object` | | [Parameters](#selectparams) additional options for the selector |
128128

src/lib/core/components/Form/Controller.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const Controller = <Value extends FieldValue, SpecType extends Spec>({
6363
__mirror,
6464
);
6565

66-
if (_.isString(name) && isCorrectSpec(spec) && !spec.viewSpec.hideInput) {
66+
if (_.isString(name) && isCorrectSpec(spec) && !spec.viewSpec.hidden) {
6767
return withSearch(render(renderProps));
6868
}
6969

src/lib/core/components/View/ViewController.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ export const ViewController = <SpecType extends Spec>({
1919
const {viewEntity, Layout} = useComponents(spec, config);
2020
const render = useRender({name, value, spec, viewEntity, Layout, Link});
2121

22-
return <>{render}</>;
22+
if (!spec.viewSpec.hidden) {
23+
return <React.Fragment>{render}</React.Fragment>;
24+
}
25+
26+
return null;
2327
};

src/lib/core/types/specs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ArraySpec<LinkType = any> {
3131
link?: LinkType;
3232
placeholder?: string;
3333
addButtonPosition?: 'down' | 'right';
34-
hideInput?: boolean;
34+
hidden?: boolean;
3535
selectParams?: {
3636
filterPlaceholder?: string;
3737
meta?: Record<string, string>;
@@ -52,7 +52,7 @@ export interface BooleanSpec<LinkType = any> {
5252
layoutDescription?: string;
5353
layoutOpen?: boolean;
5454
link?: LinkType;
55-
hideInput?: boolean;
55+
hidden?: boolean;
5656
};
5757
}
5858

@@ -74,7 +74,7 @@ export interface NumberSpec<LinkType = any> {
7474
link?: LinkType;
7575
placeholder?: string;
7676
copy?: boolean;
77-
hideInput?: boolean;
77+
hidden?: boolean;
7878
};
7979
}
8080

@@ -98,7 +98,7 @@ export interface ObjectSpec<LinkType = any> {
9898
toggler?: 'select' | 'radio' | 'card';
9999
};
100100
placeholder?: string;
101-
hideInput?: boolean;
101+
hidden?: boolean;
102102
};
103103
}
104104

@@ -132,7 +132,7 @@ export interface StringSpec<LinkType = any> {
132132
};
133133
hideValues?: string[];
134134
placeholder?: string;
135-
hideInput?: boolean;
135+
hidden?: boolean;
136136
textContentParams?: {
137137
themeLabel?: LabelProps['theme'];
138138
text: string;

src/stories/components/InputPreview/constants.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ const table: ArraySpec = {
252252
},
253253
};
254254

255-
const hideInput: BooleanSpec = {
255+
const hidden: BooleanSpec = {
256256
type: SpecTypes.Boolean,
257-
viewSpec: {type: 'base', layout: 'row', layoutTitle: 'Hide input'},
257+
viewSpec: {type: 'base', layout: 'row', layoutTitle: 'Hidden'},
258258
};
259259

260260
const textContentParams: ObjectSpec = {
@@ -443,7 +443,7 @@ export const getArrayOptions = (): ObjectSpec => ({
443443
table,
444444
placeholder,
445445
addButtonPosition,
446-
hideInput,
446+
hidden,
447447
selectParams,
448448
},
449449
[
@@ -458,7 +458,7 @@ export const getArrayOptions = (): ObjectSpec => ({
458458
'table',
459459
'placeholder',
460460
'addButtonPosition',
461-
'hideInput',
461+
'hidden',
462462
'selectParams',
463463
],
464464
),
@@ -493,7 +493,7 @@ export const getBooleanOptions = (): ObjectSpec => ({
493493
layoutTitle,
494494
layoutDescription,
495495
layoutOpen,
496-
hideInput,
496+
hidden,
497497
},
498498
[
499499
'disabled',
@@ -502,7 +502,7 @@ export const getBooleanOptions = (): ObjectSpec => ({
502502
'layoutTitle',
503503
'layoutDescription',
504504
'layoutOpen',
505-
'hideInput',
505+
'hidden',
506506
],
507507
),
508508
},
@@ -532,7 +532,7 @@ export const getNumberOptions = (): ObjectSpec => ({
532532
layoutOpen,
533533
placeholder,
534534
copy,
535-
hideInput,
535+
hidden,
536536
},
537537
[
538538
'disabled',
@@ -543,7 +543,7 @@ export const getNumberOptions = (): ObjectSpec => ({
543543
'layoutOpen',
544544
'placeholder',
545545
'copy',
546-
'hideInput',
546+
'hidden',
547547
],
548548
),
549549
},
@@ -573,7 +573,7 @@ export const getObjectOptions = (): ObjectSpec => ({
573573
order,
574574
oneOfParams,
575575
placeholder,
576-
hideInput,
576+
hidden,
577577
},
578578
[
579579
'disabled',
@@ -585,7 +585,7 @@ export const getObjectOptions = (): ObjectSpec => ({
585585
'order',
586586
'oneOfParams',
587587
'placeholder',
588-
'hideInput',
588+
'hidden',
589589
],
590590
),
591591
},
@@ -625,7 +625,7 @@ export const getStringOptions = (): ObjectSpec => ({
625625
placeholder,
626626
fileInput,
627627
copy,
628-
hideInput,
628+
hidden,
629629
selectParams,
630630
},
631631
[
@@ -641,7 +641,7 @@ export const getStringOptions = (): ObjectSpec => ({
641641
'placeholder',
642642
'fileInput',
643643
'copy',
644-
'hideInput',
644+
'hidden',
645645
'selectParams',
646646
],
647647
),

0 commit comments

Comments
 (0)