-module(glaze@basecoat@command). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/glaze/basecoat/command.gleam"). -export([command/3, command_styled/3, dialog/3, header/2, search_input/4, menu/3, menu_with_empty/4, item/2, item_with_shortcut/3, item_disabled/2, item_link/3, group/2, separator/0, disabled/0, filter/1, keywords/1, force_show/0, open_script/1, close_script/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Basecoat documentation: \n" "\n" " Fast, composable command menu for quick navigation and actions.\n" "\n" " **Note**: This component requires JavaScript from Basecoat.\n" "\n" " ## Anatomy\n" "\n" " A command menu usually includes a search input and a menu of items grouped\n" " into sections.\n" "\n" " ## Recipe\n" "\n" " ```gleam\n" " import glaze/basecoat/command\n" " import lustre/element/html\n" "\n" " fn my_command() {\n" " command.command(\"my-command\", [], [\n" " command.group(\"Suggestions\", [\n" " command.item([], [html.text(\"Calendar\")]),\n" " command.item([], [html.text(\"Search Emoji\")]),\n" " ]),\n" " ])\n" " }\n" " ```\n" "\n" " ## References\n" "\n" " - MDN ARIA `combobox` role: \n" " - MDN ARIA `menu` role: \n" " - MDN ARIA `menuitem` role: \n" " - MDN ``: \n" ). -file("src/glaze/basecoat/command.gleam", 40). -spec command( binary(), list(lustre@vdom@vattr:attribute(QTC)), list(lustre@vdom@vnode:element(QTC)) ) -> lustre@vdom@vnode:element(QTC). command(Id, Attrs, Children) -> lustre@element@html:'div'( lists:append( [lustre@attribute:id(Id), lustre@attribute:class(<<"command"/utf8>>), lustre@attribute:aria_label(<<"Command menu"/utf8>>)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 58). -spec command_styled( binary(), list(lustre@vdom@vattr:attribute(QTI)), list(lustre@vdom@vnode:element(QTI)) ) -> lustre@vdom@vnode:element(QTI). command_styled(Id, Attrs, Children) -> lustre@element@html:'div'( lists:append( [lustre@attribute:id(Id), lustre@attribute:class( <<"command rounded-lg border shadow-md"/utf8>> ), lustre@attribute:aria_label(<<"Command menu"/utf8>>)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 76). -spec dialog( binary(), list(lustre@vdom@vattr:attribute(QTO)), list(lustre@vdom@vnode:element(QTO)) ) -> lustre@vdom@vnode:element(QTO). dialog(Id, Attrs, Children) -> lustre@element@html:dialog( lists:append( [lustre@attribute:id(Id), lustre@attribute:class(<<"command-dialog"/utf8>>), lustre@attribute:aria_label(<<"Command menu"/utf8>>), lustre@attribute:attribute( <<"onclick"/utf8>>, <<"if (event.target === this) this.close()"/utf8>> )], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 95). -spec header( list(lustre@vdom@vattr:attribute(QTU)), list(lustre@vdom@vnode:element(QTU)) ) -> lustre@vdom@vnode:element(QTU). header(Attrs, Children) -> lustre@element@html:header(Attrs, Children). -file("src/glaze/basecoat/command.gleam", 102). -spec search_input( binary(), binary(), binary(), list(lustre@vdom@vattr:attribute(QUA)) ) -> lustre@vdom@vnode:element(QUA). search_input(Id, Placeholder, Menu_id, Attrs) -> lustre@element@html:input( lists:append( [lustre@attribute:type_(<<"text"/utf8>>), lustre@attribute:id(Id), lustre@attribute:placeholder(Placeholder), lustre@attribute:autocomplete(<<"off"/utf8>>), lustre@attribute:autocorrect(false), lustre@attribute:spellcheck(false), lustre@attribute:aria_autocomplete(<<"list"/utf8>>), lustre@attribute:role(<<"combobox"/utf8>>), lustre@attribute:aria_expanded(true), lustre@attribute:aria_controls(Menu_id)], Attrs ) ). -file("src/glaze/basecoat/command.gleam", 125). -spec menu( binary(), list(lustre@vdom@vattr:attribute(QUE)), list(lustre@vdom@vnode:element(QUE)) ) -> lustre@vdom@vnode:element(QUE). menu(Id, Attrs, Children) -> lustre@element@html:'div'( lists:append( [lustre@attribute:id(Id), lustre@attribute:role(<<"menu"/utf8>>), lustre@attribute:aria_orientation(<<"vertical"/utf8>>), lustre@attribute:class(<<"scrollbar"/utf8>>)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 144). -spec menu_with_empty( binary(), binary(), list(lustre@vdom@vattr:attribute(QUK)), list(lustre@vdom@vnode:element(QUK)) ) -> lustre@vdom@vnode:element(QUK). menu_with_empty(Id, Empty_message, Attrs, Children) -> lustre@element@html:'div'( lists:append( [lustre@attribute:id(Id), lustre@attribute:role(<<"menu"/utf8>>), lustre@attribute:aria_orientation(<<"vertical"/utf8>>), lustre@attribute:data(<<"empty"/utf8>>, Empty_message), lustre@attribute:class(<<"scrollbar"/utf8>>)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 165). -spec item( list(lustre@vdom@vattr:attribute(QUQ)), list(lustre@vdom@vnode:element(QUQ)) ) -> lustre@vdom@vnode:element(QUQ). item(Attrs, Children) -> lustre@element@html:'div'( lists:append([lustre@attribute:role(<<"menuitem"/utf8>>)], Attrs), Children ). -file("src/glaze/basecoat/command.gleam", 172). -spec item_with_shortcut( binary(), list(lustre@vdom@vattr:attribute(QUW)), list(lustre@vdom@vnode:element(QUW)) ) -> lustre@vdom@vnode:element(QUW). item_with_shortcut(Shortcut, Attrs, Children) -> lustre@element@html:'div'( lists:append([lustre@attribute:role(<<"menuitem"/utf8>>)], Attrs), lists:append( Children, [lustre@element@html:kbd( [lustre@attribute:class( <<"ml-auto text-muted-foreground bg-transparent tracking-widest"/utf8>> )], [lustre@element@html:text(Shortcut)] )] ) ). -file("src/glaze/basecoat/command.gleam", 192). -spec item_disabled( list(lustre@vdom@vattr:attribute(QVC)), list(lustre@vdom@vnode:element(QVC)) ) -> lustre@vdom@vnode:element(QVC). item_disabled(Attrs, Children) -> lustre@element@html:'div'( lists:append( [lustre@attribute:role(<<"menuitem"/utf8>>), lustre@attribute:aria_disabled(true)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 205). -spec item_link( binary(), list(lustre@vdom@vattr:attribute(QVI)), list(lustre@vdom@vnode:element(QVI)) ) -> lustre@vdom@vnode:element(QVI). item_link(Href, Attrs, Children) -> lustre@element@html:a( lists:append( [lustre@attribute:href(Href), lustre@attribute:role(<<"menuitem"/utf8>>)], Attrs ), Children ). -file("src/glaze/basecoat/command.gleam", 216). -spec group(binary(), list(lustre@vdom@vnode:element(QVO))) -> lustre@vdom@vnode:element(QVO). group(Label, Items) -> Label_id = <<"group-label-"/utf8, Label/binary>>, lustre@element@html:'div'( [lustre@attribute:role(<<"group"/utf8>>), lustre@attribute:aria_labelledby(Label_id)], lists:append( [lustre@element@html:span( [lustre@attribute:role(<<"heading"/utf8>>), lustre@attribute:id(Label_id)], [lustre@element@html:text(Label)] )], Items ) ). -file("src/glaze/basecoat/command.gleam", 231). -spec separator() -> lustre@vdom@vnode:element(any()). separator() -> lustre@element@html:hr([lustre@attribute:role(<<"separator"/utf8>>)]). -file("src/glaze/basecoat/command.gleam", 235). -spec disabled() -> lustre@vdom@vattr:attribute(any()). disabled() -> lustre@attribute:aria_disabled(true). -file("src/glaze/basecoat/command.gleam", 239). -spec filter(binary()) -> lustre@vdom@vattr:attribute(any()). filter(Text) -> lustre@attribute:data(<<"filter"/utf8>>, Text). -file("src/glaze/basecoat/command.gleam", 243). -spec keywords(binary()) -> lustre@vdom@vattr:attribute(any()). keywords(Text) -> lustre@attribute:data(<<"keywords"/utf8>>, Text). -file("src/glaze/basecoat/command.gleam", 247). -spec force_show() -> lustre@vdom@vattr:attribute(any()). force_show() -> lustre@attribute:data(<<"force"/utf8>>, <<""/utf8>>). -file("src/glaze/basecoat/command.gleam", 251). -spec open_script(binary()) -> binary(). open_script(Dialog_id) -> <<<<"document.getElementById('"/utf8, Dialog_id/binary>>/binary, "').showModal()"/utf8>>. -file("src/glaze/basecoat/command.gleam", 255). -spec close_script(binary()) -> binary(). close_script(Dialog_id) -> <<<<"document.getElementById('"/utf8, Dialog_id/binary>>/binary, "').close()"/utf8>>.