Skip to content

Commit

Permalink
Added Doc.InputType.Decimal and Doc.InputType.DecimalUnchecked (#260)
Browse files Browse the repository at this point in the history
* Added Doc.InputType.Decimal and Doc.InputType.DecimalUnchecked

* build WS-Update

* Reverted improper PackageReference.

* Added Math.JS dependency

* Use System.Decimal.TryParse
  • Loading branch information
diegopego committed Jan 13, 2023
1 parent 2bc962a commit 45bec61
Show file tree
Hide file tree
Showing 16 changed files with 1,306 additions and 1,037 deletions.
2 changes: 2 additions & 0 deletions WebSharper.UI.CSharp.Templating/CodeGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ let buildHoleMethods (typeName: string) (holeName: HoleName) (holeDef: HoleDefin
s "Var<WebSharper.UI.Client.CheckedInput<int>>" "VarInt" "x"
sv "Var<double>" "VarFloatUnchecked" "x"
s "Var<WebSharper.UI.Client.CheckedInput<double>>" "VarFloat" "x"
sv "Var<decimal>" "VarDecimalUnchecked" "x"
s "Var<WebSharper.UI.Client.CheckedInput<decimal>>" "VarDecimal" "x"
|]
| HoleKind.Var ValTy.Bool ->
[|
Expand Down
8 changes: 8 additions & 0 deletions WebSharper.UI.CSharp/HTML.Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ module Html =
[<Inline; CompiledName "input">]
let FloatInput(var, [<ParamArray>] attrs: Attr[]) =
Client.Doc.InputType.FloatUnchecked attrs var

/// Input box with type="number".
/// If the input box is blank, the value is set to 0.
/// If the input is not parseable as a decimal, the value is unchanged from its last valid value.
/// It is advised to use DecimalInput instead for better user experience.
[<Inline; CompiledName "input">]
let DecimalInput(var, [<ParamArray>] attrs: Attr[]) =
Client.Doc.InputType.DecimalUnchecked attrs var

/// Input text area.
[<Inline; CompiledName "textarea">]
Expand Down

0 comments on commit 45bec61

Please sign in to comment.