File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import DialogController from "./dialog/dialog_controller";
1616import DropdownMenuController from "./dropdown_menu/dropdown_menu_controller" ;
1717import FormFieldController from "./form/form_field_controller" ;
1818import HoverCardController from "./hover_card/hover_card_controller" ;
19+ import MaskedInputController from "./masked_input/masked_input_controller" ;
1920import PopoverController from "./popover/popover_controller" ;
2021import TabsController from "./tabs/tabs_controller" ;
2122import ThemeToggleController from "./theme_toggle/theme_toggle_controller" ;
@@ -51,6 +52,7 @@ function initialize(application) {
5152 registerIfNotExists ( "ruby-ui--dropdown-menu" , DropdownMenuController ) ;
5253 registerIfNotExists ( "ruby-ui--form-field" , FormFieldController ) ;
5354 registerIfNotExists ( "ruby-ui--hover-card" , HoverCardController ) ;
55+ registerIfNotExists ( "ruby-ui--masked-input" , MaskedInputController ) ;
5456 registerIfNotExists ( "ruby-ui--popover" , PopoverController ) ;
5557 registerIfNotExists ( "ruby-ui--tabs" , TabsController ) ;
5658 registerIfNotExists ( "ruby-ui--theme-toggle" , ThemeToggleController ) ;
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module RubyUI
4+ class MaskedInput < Base
5+ def view_template
6+ Input ( type : "text" , **attrs )
7+ end
8+
9+ private
10+
11+ def default_attrs
12+ { data : { controller : "ruby-ui--masked-input" } }
13+ end
14+ end
15+ end
Original file line number Diff line number Diff line change 1+ import { Controller } from "@hotwired/stimulus" ;
2+ import { MaskInput } from "maska" ;
3+
4+ // Connects to data-controller="ruby-ui--masked-input"
5+ export default class extends Controller {
6+ connect ( ) {
7+ new MaskInput ( this . element )
8+ }
9+ }
Original file line number Diff line number Diff line change 2828 "chart.js" : " ^4.4.1" ,
2929 "date-fns" : " ^2.30.0" ,
3030 "fuse.js" : " ^7.0.0" ,
31+ "maska" : " ^3.0.3" ,
3132 "motion" : " ^10.16.4" ,
3233 "mustache" : " ^4.2.0" ,
3334 "tippy.js" : " ^6.3.7"
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require "test_helper"
4+
5+ class RubyUI ::MaskedInputTest < Minitest ::Test
6+ include Phlex ::Testing ::ViewHelper
7+
8+ def test_render
9+ output = phlex_context do
10+ RubyUI . MaskedInput ( data : { maska : "#####-###" } )
11+ end
12+
13+ assert_match ( /<input type="text"/ , output )
14+ assert_match ( /data-controller="ruby-ui--masked-input"/ , output )
15+ assert_match ( /data-maska="#####-###"/ , output )
16+ end
17+ end
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ hey-listen@^1.0.8:
126126 resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68"
127127 integrity sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==
128128
129+ maska@^3.0.3 :
130+ version "3.0.3"
131+ resolved "https://registry.yarnpkg.com/maska/-/maska-3.0.3.tgz#36e3c2c77bf35db09842f318315c590e2855a9ce"
132+ integrity sha512-ItFbuqVeBKk1JmC4QCRxKeNaX+Ym/oMUYZVXwvAPKAwMeO4bYZpIGjNWOcZy+L8YXQaPvCZ68+5eYpGRdyaA8w==
133+
129134motion@^10.16.4 :
130135 version "10.18.0"
131136 resolved "https://registry.yarnpkg.com/motion/-/motion-10.18.0.tgz#8fd035cc3a668800fe7e2479568eeb98af484ab3"
You can’t perform that action at this time.
0 commit comments