From 28337d90c3cd7b686f210db5ab5bde79b371bb66 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Mon, 9 Sep 2024 15:35:21 +0200 Subject: [PATCH] feat: add `Form.disableIf` [Fable.Form][Fable.Form.Simple.Bulma] Fix #45 --- packages/Fable.Form.Simple.Bulma/Form.fs | 9 +++++++++ packages/Fable.Form/Base.fs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/Fable.Form.Simple.Bulma/Form.fs b/packages/Fable.Form.Simple.Bulma/Form.fs index 1c4c58e..3406976 100644 --- a/packages/Fable.Form.Simple.Bulma/Form.fs +++ b/packages/Fable.Form.Simple.Bulma/Form.fs @@ -80,6 +80,15 @@ module Form = Base.disable form + /// + /// Disable a form based on a condition + /// + /// The condition to check + /// The form to disable + /// A new form which has been marked as disabled if the condition is true + let disableIf (condition: bool) (form: Form<'Values, 'A>) : Form<'Values, 'A> = + Base.disableIf condition form + /// /// Fill a form andThen fill another one. /// diff --git a/packages/Fable.Form/Base.fs b/packages/Fable.Form/Base.fs index b313e12..555553e 100644 --- a/packages/Fable.Form/Base.fs +++ b/packages/Fable.Form/Base.fs @@ -314,6 +314,22 @@ let disable (form: Form<'Values, 'Output, 'Field>) : Form<'Values, 'Output, 'Fie } ) +/// +/// Disable a form based on a condition +/// +/// The condition to check +/// The form to disable +/// A new form which has been marked as disabled if the condition is true +let disableIf + (condition: bool) + (form: Form<'Values, 'Output, 'Field>) + : Form<'Values, 'Output, 'Field> + = + if condition then + disable form + else + form + /// /// Transform the 'output' of a form ///