File tree Expand file tree Collapse file tree
javascript/controllers/ruby_ui Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33@plugin "@tailwindcss/forms" ;
44@plugin "@tailwindcss/typography" ;
55
6+ /* Include classes from the local gem components rendered by the docs app. */
7+ @source "../../../../gem/lib/ruby_ui" ;
68
79@import "tw-animate-css" ;
810
Original file line number Diff line number Diff line change @@ -9,10 +9,16 @@ def view_template
99 img ( src : image_url ( "logo.svg" ) , class : "h-4 block dark:hidden" )
1010 img ( src : image_url ( "logo_dark.svg" ) , class : "h-4 hidden dark:block" )
1111 span ( class : "sr-only" ) { "RubyUI" }
12- Badge ( class : "ml-2 whitespace-nowrap bg-black text-white hover:bg-black/90 px-1.5 py-0.5 rounded-full text-xs font-semibold" ) { "1.0" }
12+ Badge ( class : "ml-2 whitespace-nowrap bg-black text-white hover:bg-black/90 px-1.5 py-0.5 rounded-full text-xs font-semibold" ) { ruby_ui_version }
1313 }
1414 end
1515 end
16+
17+ private
18+
19+ def ruby_ui_version
20+ RubyUI ::VERSION . split ( "." ) . first ( 2 ) . join ( "." )
21+ end
1622 end
1723 end
1824end
Original file line number Diff line number Diff line change @@ -13,18 +13,30 @@ export default class extends Controller {
1313 } ;
1414
1515 connect ( ) {
16+ this . selectedIndex = - 1 ;
17+
18+ if ( ! this . hasInputTarget ) {
19+ return ;
20+ }
21+
1622 this . inputTarget . focus ( ) ;
1723 this . searchIndex = this . buildSearchIndex ( ) ;
1824 this . toggleVisibility ( this . emptyTargets , false ) ;
19- this . selectedIndex = - 1 ;
2025
21- if ( this . openValue ) {
26+ if ( this . openValue && this . hasContentTarget ) {
2227 this . open ( ) ;
2328 }
2429 }
2530
2631 open ( e ) {
27- e . preventDefault ( ) ;
32+ if ( e ) {
33+ e . preventDefault ( ) ;
34+ }
35+
36+ if ( ! this . hasContentTarget ) {
37+ return ;
38+ }
39+
2840 document . body . insertAdjacentHTML ( "beforeend" , this . contentTarget . innerHTML ) ;
2941 // prevent scroll on body
3042 document . body . classList . add ( "overflow-hidden" ) ;
Original file line number Diff line number Diff line change @@ -13,18 +13,30 @@ export default class extends Controller {
1313 } ;
1414
1515 connect ( ) {
16+ this . selectedIndex = - 1 ;
17+
18+ if ( ! this . hasInputTarget ) {
19+ return ;
20+ }
21+
1622 this . inputTarget . focus ( ) ;
1723 this . searchIndex = this . buildSearchIndex ( ) ;
1824 this . toggleVisibility ( this . emptyTargets , false ) ;
19- this . selectedIndex = - 1 ;
2025
21- if ( this . openValue ) {
26+ if ( this . openValue && this . hasContentTarget ) {
2227 this . open ( ) ;
2328 }
2429 }
2530
2631 open ( e ) {
27- e . preventDefault ( ) ;
32+ if ( e ) {
33+ e . preventDefault ( ) ;
34+ }
35+
36+ if ( ! this . hasContentTarget ) {
37+ return ;
38+ }
39+
2840 document . body . insertAdjacentHTML ( "beforeend" , this . contentTarget . innerHTML ) ;
2941 // prevent scroll on body
3042 document . body . classList . add ( "overflow-hidden" ) ;
You can’t perform that action at this time.
0 commit comments