Class: PhlexKit::MaskedInput

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/masked_input/masked_input.rb

Overview

Text input with an inline mask. Ported from ruby_ui's RubyUI::MaskedInput — ruby_ui uses the maska JS lib; PhlexKit ships a small dependency-free mask controller (#=digit, A=letter, *=any) driven by a data-mask attribute. Swap in maska by replacing masked_input_controller.js if you need its full feature set.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ MaskedInput

Returns a new instance of MaskedInput.



7
# File 'app/components/phlex_kit/masked_input/masked_input.rb', line 7

def initialize(**attrs) = (@attrs = attrs)

Instance Method Details

#view_templateObject



8
9
10
# File 'app/components/phlex_kit/masked_input/masked_input.rb', line 8

def view_template
  render PhlexKit::Input.new(type: "text", **mix({ data: { controller: "phlex-kit--masked-input" } }, @attrs))
end