-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyUI | ||
class MaskedInput < Base | ||
def view_template | ||
Input(type: "text", **attrs) | ||
end | ||
|
||
private | ||
|
||
def default_attrs | ||
{data: {controller: "ruby-ui--masked-input"}} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
import { MaskInput } from "maska"; | ||
|
||
// Connects to data-controller="ruby-ui--masked-input" | ||
export default class extends Controller { | ||
connect() { | ||
new MaskInput(this.element) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class RubyUI::MaskedInputTest < Minitest::Test | ||
include Phlex::Testing::ViewHelper | ||
|
||
def test_render | ||
output = phlex_context do | ||
RubyUI.MaskedInput(data: {maska: "#####-###"}) | ||
end | ||
|
||
assert_match(/<input type="text"/, output) | ||
assert_match(/data-controller="ruby-ui--masked-input"/, output) | ||
assert_match(/data-maska="#####-###"/, output) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters