defmodule MoonWeb.Pages.Components.Select.SingleSelectPage do
@moduledoc false
use MoonWeb, :live_view
alias Moon.Components.Form
alias Moon.Components.Field
alias Moon.Components.Select.SingleSelect
alias MoonWeb.Components.ExampleAndCode
alias MoonWeb.Components.Page
alias MoonWeb.Pages.Tutorials.AddDataUsingForm.User
alias MoonWeb.Components.ComponentPageDescription
alias MoonWeb.Components.PropsTable
alias Moon.Components.Button
data(breadcrumbs, :any,
default: [
%{
to: "#",
name: "Components"
},
%{
to: "/components/select/single-select",
name: "Single Select"
}
]
)
data(props_info_array, :list,
default: [
%{
:name => ~c"id",
:type => ~c"string ",
:required => ~c"Yes",
:default => ~c"-",
:description => ~c""
},
%{
:name => ~c"label",
:type => ~c"string",
:required => ~c"No",
:default => ~c"-",
:description => ~c""
},
%{
:name => ~c"options",
:type => ~c"list",
:required => ~c"Yes",
:default => ~c"-",
:description => ~c"Options for the select"
},
%{
:name => ~c"value",
:type => ~c"any",
:required => ~c"No",
:default => ~c"-",
:description => ~c"Default selected value"
},
%{
:name => ~c"disabled",
:type => ~c"boolean",
:required => ~c"No",
:default => ~c"false",
:description => ~c"Whether the component is disabled"
},
%{
:name => ~c"size",
:type => ~c"sm | md | lg | xl",
:required => ~c"No",
:default => ~c"md",
:description => ~c"Size variant"
},
%{
:name => ~c"popover_placement",
:type =>
~c"top-start | top | top-end | right-start | right | right-end | bottom-start | bottom | bottom-end | left-start | left | left-end",
:required => ~c"-",
:default => ~c"bottom-start",
:description => ~c"Location of where the dropdown appears"
},
%{
:name => ~c"popover_class",
:type => ~c"string",
:required => ~c"No",
:default => ~c"-",
:description => ~c"Css class for the dropdown"
},
%{
:name => ~c"placeholder",
:type => ~c"string",
:required => ~c"No",
:default => ~c"-",
:description => ~c"String to display when there is no value selected"
},
%{
:name => ~c"background_color",
:type => ~c"string ",
:required => ~c"No",
:default => ~c"gohan",
:description => ~c""
},
%{
:name => ~c"hint_text_slot",
:type => ~c"slot",
:required => ~c"No",
:default => ~c"-",
:description => ~c"Inform message under select"
},
%{
:name => ~c"has_error",
:type => ~c"boolean",
:required => ~c"No",
:default => ~c"-",
:description => ~c"If the component is in error mode"
},
%{
:name => ~c"use_error_tag",
:type => ~c"boolean",
:required => ~c"No",
:default => ~c"-",
:description => ~c"Whether to use the built in ErrorTag in place of the hint slot"
},
%{
:name => ~c"selected_value_class",
:type => ~c"css_class",
:required => ~c"No",
:default => ~c"-",
:description => ~c"Css class for the displayed selected value"
}
]
)
data(latest_params, :any, default: nil)
data(latest_params2, :any, default: nil)
data(search_string, :string, default: "")
def mount(_params, _session, socket) do
initial_params = %{permissions: [1, 2], role: 1}
user = %User{}
user_changeset = User.changeset(user, initial_params)
{:ok,
assign(socket,
user: user,
user_changeset: user_changeset,
user_changeset2: user_changeset,
options: User.available_roles(),
searched_options: User.available_roles(),
options_with_left_icon: User.available_roles_with_left_icon_flag(),
searched_options_with_left_icon: User.available_roles_with_left_icon_flag(),
options_with_right_icon: User.available_roles_with_right_icon(),
searched_options_with_right_icon: User.available_roles_with_right_icon(),
options_with_both_icons: User.available_roles_with_left_icon_flag_and_right_icon(),
searched_options_with_both_icons:
User.available_roles_with_left_icon_flag_and_right_icon(),
gender_options: User.gender_options(),
search_string: ""
)}
end
def handle_params(_params, uri, socket) do
{:noreply, assign(socket, uri: uri)}
end
def render(assigns) do
~F"""
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}
@latest_params = {inspect(@latest_params, pretty: true)}