Current section

41 Versions

Jump to

Compare versions

4 files changed
+17 additions
-4 deletions
  @@ -1,7 +1,7 @@
1 1 {<<"links">>,
2 2 [{<<"GitHub">>,<<"https://github.com/phcurado/daisy_ui_components">>}]}.
3 3 {<<"name">>,<<"daisy_ui_components">>}.
4 - {<<"version">>,<<"0.4.1">>}.
4 + {<<"version">>,<<"0.4.2">>}.
5 5 {<<"description">>,<<"DaisyUI component library for LiveView">>}.
6 6 {<<"elixir">>,<<"~> 1.14">>}.
7 7 {<<"app">>,<<"daisy_ui_components">>}.
  @@ -76,7 +76,7 @@ defmodule DaisyUIComponents.Form do
76 76 |> assign(:errors, Enum.map(errors, &translate(&1)))
77 77 |> assign_new(:name, fn -> if assigns.multiple, do: field.name <> "[]", else: field.name end)
78 78 |> assign_new(:value, fn -> field.value end)
79 - |> assign(:color, fn -> assigns.errors != [] && "error" end)
79 + |> assign_new(:color, fn -> assigns.errors != [] && "error" end)
80 80 |> form_input()
81 81 end
  @@ -22,7 +22,7 @@ defmodule DaisyUIComponents.Input do
22 22 attr :id, :any, default: nil
23 23 # attr :name, :any
24 24 attr :label, :string
25 - attr :value, :any, default: nil
25 + attr :value, :any
26 26
27 27 attr :type, :string,
28 28 default: "text",
  @@ -69,6 +69,7 @@ defmodule DaisyUIComponents.Input do
69 69 def input(%{type: "checkbox"} = assigns) do
70 70 assigns =
71 71 assigns
72 + |> assign_new(:value, fn -> nil end)
72 73 |> assign_new(:checked, fn ->
73 74 Phoenix.HTML.Form.normalize_value("checkbox", assigns[:value])
74 75 end)
  @@ -79,6 +80,10 @@ defmodule DaisyUIComponents.Input do
79 80 end
80 81
81 82 def input(%{type: "select"} = assigns) do
83 + assigns =
84 + assigns
85 + |> assign_new(:value, fn -> nil end)
86 +
82 87 ~H"""
83 88 <.select id={@id} class={@class} color={@color} bordered={@bordered} multiple={@multiple} {@rest}>
84 89 <option :if={@prompt} value="">{@prompt}</option>
  @@ -101,6 +106,10 @@ defmodule DaisyUIComponents.Input do
101 106 end
102 107
103 108 def input(%{type: "range"} = assigns) do
109 + assigns =
110 + assigns
111 + |> assign_new(:value, fn -> nil end)
112 +
104 113 ~H"""
105 114 <.range
106 115 id={@id}
  @@ -114,6 +123,10 @@ defmodule DaisyUIComponents.Input do
114 123
115 124 # All other inputs text, datetime-local, url, password, etc. are handled here...
116 125 def input(assigns) do
126 + assigns =
127 + assigns
128 + |> assign_new(:value, fn -> nil end)
129 +
117 130 ~H"""
118 131 <.text_input
119 132 id={@id}
  @@ -2,7 +2,7 @@ defmodule DaisyUIComponents.MixProject do
2 2 use Mix.Project
3 3
4 4 @source_url "https://github.com/phcurado/daisy_ui_components"
5 - @version "0.4.1"
5 + @version "0.4.2"
6 6
7 7 def project do
8 8 [