Skip to content

Commit eaf944c

Browse files
authored
Add MaskedInput component (#130)
* Add MaskedInput component * Update ruby ui version
1 parent de9cbea commit eaf944c

File tree

6 files changed

+66
-23
lines changed

6 files changed

+66
-23
lines changed

Gemfile.lock

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GIT
1414

1515
GIT
1616
remote: https://github.com/ruby-ui/ruby_ui.git
17-
revision: 6fb08c975c3f9f162fb3f510f5b42372dfeb9fc7
17+
revision: 992944de9fcead84da66ff5a6f6c8662a021acae
1818
branch: main
1919
specs:
2020
ruby_ui (1.0.0.pre.alpha.4)
@@ -172,6 +172,7 @@ GEM
172172
matrix (0.4.2)
173173
method_source (1.1.0)
174174
mini_mime (1.1.5)
175+
mini_portile2 (2.8.7)
175176
minitest (5.25.1)
176177
msgpack (1.7.3)
177178
net-imap (0.5.0)
@@ -184,17 +185,8 @@ GEM
184185
net-smtp (0.5.0)
185186
net-protocol
186187
nio4r (2.7.4)
187-
nokogiri (1.16.7-aarch64-linux)
188-
racc (~> 1.4)
189-
nokogiri (1.16.7-arm-linux)
190-
racc (~> 1.4)
191-
nokogiri (1.16.7-arm64-darwin)
192-
racc (~> 1.4)
193-
nokogiri (1.16.7-x86-linux)
194-
racc (~> 1.4)
195-
nokogiri (1.16.7-x86_64-darwin)
196-
racc (~> 1.4)
197-
nokogiri (1.16.7-x86_64-linux)
188+
nokogiri (1.16.7)
189+
mini_portile2 (~> 2.8.2)
198190
racc (~> 1.4)
199191
parallel (1.26.3)
200192
parser (3.3.6.0)
@@ -284,16 +276,8 @@ GEM
284276
rexml (~> 3.2, >= 3.2.5)
285277
rubyzip (>= 1.2.2, < 3.0)
286278
websocket (~> 1.0)
287-
sqlite3 (2.2.0-aarch64-linux-gnu)
288-
sqlite3 (2.2.0-aarch64-linux-musl)
289-
sqlite3 (2.2.0-arm-linux-gnu)
290-
sqlite3 (2.2.0-arm-linux-musl)
291-
sqlite3 (2.2.0-arm64-darwin)
292-
sqlite3 (2.2.0-x86-linux-gnu)
293-
sqlite3 (2.2.0-x86-linux-musl)
294-
sqlite3 (2.2.0-x86_64-darwin)
295-
sqlite3 (2.2.0-x86_64-linux-gnu)
296-
sqlite3 (2.2.0-x86_64-linux-musl)
279+
sqlite3 (2.2.0)
280+
mini_portile2 (~> 2.8.0)
297281
standard (1.41.1)
298282
language_server-protocol (~> 3.17.0.2)
299283
lint_roller (~> 1.0)

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def link
134134
render Docs::LinkView.new
135135
end
136136

137+
def masked_input
138+
render Docs::MaskedInputView.new
139+
end
140+
137141
def pagination
138142
render Docs::PaginationView.new
139143
end

app/views/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def components
8686
{name: "Input", path: helpers.docs_input_path},
8787
{name: "Hover Card", path: helpers.docs_hover_card_path},
8888
{name: "Link", path: helpers.docs_link_path},
89+
{name: "Masked Input", path: helpers.masked_input_path},
8990
{name: "Pagination", path: helpers.docs_pagination_path, badge: "New"},
9091
{name: "Popover", path: helpers.docs_popover_path},
9192
{name: "Select", path: helpers.docs_select_path, badge: "New"},

app/views/docs/masked_input_view.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::MaskedInputView < ApplicationView
4+
def view_template
5+
component = "MaskedInput"
6+
7+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8+
render Docs::Header.new(title: "MaskedInput", description: "Displays a form input field with applied mask.")
9+
10+
Heading(level: 2) { "Usage" }
11+
12+
Text do
13+
plain "For advanced usage, check out the "
14+
InlineLink(href: "https://beholdr.github.io/maska/v3", target: "_blank") { "Maska website" }
15+
plain "."
16+
end
17+
18+
render Docs::VisualCodeExample.new(title: "Phone number", context: self) do
19+
<<~RUBY
20+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
21+
MaskedInput(data: {maska: "(##) #####-####"})
22+
end
23+
RUBY
24+
end
25+
26+
render Docs::VisualCodeExample.new(title: "Hex color code", context: self) do
27+
<<~RUBY
28+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
29+
MaskedInput(data: {maska: "!#HHHHHH", maska_tokens: "H:[0-9a-fA-F]"})
30+
end
31+
RUBY
32+
end
33+
34+
render Docs::VisualCodeExample.new(title: "CPF / CNPJ", context: self) do
35+
<<~RUBY
36+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
37+
MaskedInput(data: {maska: "['###.###.###-##', '##.###.###/####-##']"})
38+
end
39+
RUBY
40+
end
41+
42+
render Docs::ComponentsTable.new(component_references(component, Docs::VisualCodeExample.collected_code), component_files(component))
43+
end
44+
end
45+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
get "hover_card", to: "docs#hover_card", as: :docs_hover_card
4242
get "input", to: "docs#input", as: :docs_input
4343
get "link", to: "docs#link", as: :docs_link
44+
get "masked_input", to: "docs#masked_input", as: :masked_input
4445
get "pagination", to: "docs#pagination", as: :docs_pagination
4546
get "popover", to: "docs#popover", as: :docs_popover
4647
get "select", to: "docs#select", as: :docs_select

yarn.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ lru-cache@^10.2.0:
726726
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
727727
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
728728

729+
maska@^3.0.3:
730+
version "3.0.3"
731+
resolved "https://registry.yarnpkg.com/maska/-/maska-3.0.3.tgz#36e3c2c77bf35db09842f318315c590e2855a9ce"
732+
integrity sha512-ItFbuqVeBKk1JmC4QCRxKeNaX+Ym/oMUYZVXwvAPKAwMeO4bYZpIGjNWOcZy+L8YXQaPvCZ68+5eYpGRdyaA8w==
733+
729734
merge2@^1.3.0:
730735
version "1.4.1"
731736
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
@@ -950,13 +955,14 @@ reusify@^1.0.4:
950955

951956
ruby_ui_js@ruby-ui/ruby_ui:
952957
version "1.0.0-alpha.4"
953-
resolved "https://codeload.github.com/ruby-ui/ruby_ui/tar.gz/6fb08c975c3f9f162fb3f510f5b42372dfeb9fc7"
958+
resolved "https://codeload.github.com/ruby-ui/ruby_ui/tar.gz/992944de9fcead84da66ff5a6f6c8662a021acae"
954959
dependencies:
955960
"@floating-ui/dom" "^1.6.8"
956961
"@hotwired/stimulus" "^3.2.2"
957962
chart.js "^4.4.1"
958963
date-fns "^2.30.0"
959964
fuse.js "^7.0.0"
965+
maska "^3.0.3"
960966
motion "^10.16.4"
961967
mustache "^4.2.0"
962968
tippy.js "^6.3.7"
@@ -991,6 +997,7 @@ source-map-js@^1.2.0, source-map-js@^1.2.1:
991997
integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==
992998

993999
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
1000+
name string-width-cjs
9941001
version "4.2.3"
9951002
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
9961003
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -1009,6 +1016,7 @@ string-width@^5.0.1, string-width@^5.1.2:
10091016
strip-ansi "^7.0.1"
10101017

10111018
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1019+
name strip-ansi-cjs
10121020
version "6.0.1"
10131021
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
10141022
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==

0 commit comments

Comments
 (0)