Skip to content

Commit 535fc4f

Browse files
committed
Add notice renderer
1 parent e84fdde commit 535fc4f

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/renderers/StringNotice.tsx

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from "react";
2+
3+
import { SimpleNode } from "@blinkforms/core/simpleNodes";
4+
5+
import {
6+
FormContext,
7+
NodeError,
8+
NodeStringSchema,
9+
} from "@blinkforms/core/schemaTypes";
10+
11+
export default class StringNotice extends SimpleNode<string, NodeStringSchema> {
12+
getInitialValue() {
13+
return "null";
14+
}
15+
16+
isOutputAvailable(): boolean {
17+
return false;
18+
}
19+
20+
validateCustom(): Array<NodeError> {
21+
return [];
22+
}
23+
24+
renderSimple(value: string, context: FormContext) {
25+
return (
26+
<div>
27+
{this.getSchema().value}
28+
</div>
29+
);
30+
}
31+
}

src/renderers/defaultReactHandlerProvider.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import ObjectDefault from "./ObjectDefault";
2+
23
import StringDefault from "./StringDefault";
4+
import StringNotice from "./StringNotice";
35

46
import ArrayDefault from "./ArrayDefault";
57
import ArrayTuple from "./ArrayTuple";
@@ -10,6 +12,7 @@ export default {
1012
},
1113
STRING: {
1214
default: StringDefault,
15+
notice: StringNotice,
1316
},
1417
OBJECT: {
1518
default: ObjectDefault,

stories/basicForm.stories.js

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ storiesOf('Basic form', module)
2626
title: "Your last name",
2727
minLength: 3,
2828
},
29+
"notice": {
30+
type: "string",
31+
ui: "notice",
32+
value: "Hello!",
33+
},
2934
"array": {
3035
type: "array",
3136
ui: "tuple",

0 commit comments

Comments
 (0)