-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d163de6
commit 8714f9d
Showing
6 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
bau-ui/examples/bau-storybook/src/pages/input/input-controlled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Context } from "@grucloud/bau-ui/context"; | ||
import button from "@grucloud/bau-ui/button"; | ||
import input from "@grucloud/bau-ui/input"; | ||
import form from "@grucloud/bau-ui/form"; | ||
|
||
export default (context: Context) => { | ||
const { bau } = context; | ||
const { article, footer, label } = bau.tags; | ||
|
||
const Input = input(context); | ||
const Form = form(context); | ||
const ButtonSubmit = button(context, { variant: "solid", color: "primary" }); | ||
|
||
return () => { | ||
const inputState = bau.state(""); | ||
const disableButtonState = bau.derive(() => inputState.val == ""); | ||
|
||
const oninput = (event: any) => (inputState.val = event.target.value); | ||
const onsubmit = (event: any) => { | ||
event.preventDefault(); | ||
//const payload = Object.fromEntries(new FormData(event.currentTarget)); | ||
alert(inputState.val); | ||
}; | ||
|
||
return Form( | ||
{ onsubmit }, | ||
article( | ||
label( | ||
"Input", | ||
Input({ | ||
name: "my-input", | ||
placeholder: "Enter Text", | ||
value: inputState, | ||
oninput, | ||
}) | ||
) | ||
), | ||
footer( | ||
ButtonSubmit({ type: "submit", disabled: disableButtonState }, "Submit") | ||
) | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters