Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit d401dd7

Browse files
authored
[Feature] Add DataTable docs and interactive demo (#463)
* [Feature] Add DataTable and NativeSelect component docs Add documentation pages for the new DataTable component family (v1.2.0) with interactive demo featuring search, sort, pagination, column visibility, row selection, and bulk actions. Also copies NativeSelect component (DataTable dependency) and updates layout/preview for better table rendering. * Update Gemfile.lock to match current Gemfile * Fix test to only GET docs routes, skip POST bulk actions
1 parent 24d87d5 commit d401dd7

33 files changed

Lines changed: 1539 additions & 58 deletions

Gemfile.lock

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ GIT
1414

1515
GIT
1616
remote: https://github.com/ruby-ui/ruby_ui.git
17-
revision: 856136f40bc4d5be942e39506e56fb08348afc93
17+
revision: a3e5c8488b11a4c15caf2f2391181f8f057a589f
1818
branch: main
1919
specs:
20-
ruby_ui (1.1.0)
20+
ruby_ui (1.2.0)
2121

2222
GEM
2323
remote: https://rubygems.org/
2424
specs:
25-
action_text-trix (2.1.18)
25+
action_text-trix (2.1.15)
2626
railties
2727
actioncable (8.1.3)
2828
actionpack (= 8.1.3)
@@ -100,9 +100,9 @@ GEM
100100
public_suffix (>= 2.0.2, < 7.0)
101101
ast (2.4.3)
102102
base64 (0.3.0)
103-
bigdecimal (4.1.2)
103+
bigdecimal (3.3.1)
104104
bindex (0.8.1)
105-
bootsnap (1.23.0)
105+
bootsnap (1.19.0)
106106
msgpack (~> 1.2)
107107
builder (3.3.0)
108108
capybara (3.40.0)
@@ -115,35 +115,34 @@ GEM
115115
regexp_parser (>= 1.5, < 3.0)
116116
xpath (~> 3.2)
117117
coderay (1.1.3)
118-
concurrent-ruby (1.3.6)
119-
connection_pool (3.0.2)
118+
concurrent-ruby (1.3.5)
119+
connection_pool (2.5.4)
120120
crass (1.0.6)
121121
cssbundling-rails (1.4.3)
122122
railties (>= 6.0.0)
123-
date (3.5.1)
124-
debug (1.11.1)
123+
date (3.5.0)
124+
debug (1.11.0)
125125
irb (~> 1.10)
126126
reline (>= 0.3.8)
127127
drb (2.2.3)
128-
erb (6.0.2)
128+
erb (6.0.0)
129129
erubi (1.13.1)
130130
globalid (1.3.0)
131131
activesupport (>= 6.1)
132-
i18n (1.14.8)
132+
i18n (1.14.7)
133133
concurrent-ruby (~> 1.0)
134-
io-console (0.8.2)
135-
irb (1.17.0)
134+
io-console (0.8.1)
135+
irb (1.15.3)
136136
pp (>= 0.6.0)
137-
prism (>= 1.3.0)
138137
rdoc (>= 4.0.0)
139138
reline (>= 0.4.2)
140139
jsbundling-rails (1.3.1)
141140
railties (>= 6.0.0)
142-
json (2.19.4)
141+
json (2.15.1)
143142
language_server-protocol (3.17.0.5)
144143
lint_roller (1.1.0)
145144
logger (1.7.0)
146-
loofah (2.25.1)
145+
loofah (2.24.1)
147146
crass (~> 1.0.2)
148147
nokogiri (>= 1.12.0)
149148
lucide-rails (0.7.4)
@@ -159,11 +158,9 @@ GEM
159158
method_source (1.1.0)
160159
mini_mime (1.1.5)
161160
mini_portile2 (2.8.9)
162-
minitest (6.0.4)
163-
drb (~> 2.0)
164-
prism (~> 1.5)
161+
minitest (5.26.2)
165162
msgpack (1.8.0)
166-
net-imap (0.6.3)
163+
net-imap (0.5.12)
167164
date
168165
net-protocol
169166
net-pop (0.1.2)
@@ -173,19 +170,19 @@ GEM
173170
net-smtp (0.5.1)
174171
net-protocol
175172
nio4r (2.7.5)
176-
nokogiri (1.19.2)
173+
nokogiri (1.18.10)
177174
mini_portile2 (~> 2.8.2)
178175
racc (~> 1.4)
179-
nokogiri (1.19.2-x86_64-linux-gnu)
176+
nokogiri (1.18.10-x86_64-linux-gnu)
180177
racc (~> 1.4)
181178
parallel (1.27.0)
182-
parser (3.3.10.1)
179+
parser (3.3.9.0)
183180
ast (~> 2.4.1)
184181
racc
185182
pp (0.6.3)
186183
prettyprint
187184
prettyprint (0.2.0)
188-
prism (1.9.0)
185+
prism (1.6.0)
189186
propshaft (1.3.2)
190187
actionpack (>= 7.0.0)
191188
activesupport (>= 7.0.0)
@@ -194,20 +191,20 @@ GEM
194191
coderay (~> 1.1)
195192
method_source (~> 1.0)
196193
reline (>= 0.6.0)
197-
psych (5.3.1)
194+
psych (5.2.6)
198195
date
199196
stringio
200197
public_suffix (6.0.1)
201198
puma (7.2.0)
202199
nio4r (~> 2.0)
203200
racc (1.8.1)
204-
rack (3.2.6)
205-
rack-session (2.1.2)
201+
rack (3.2.4)
202+
rack-session (2.1.1)
206203
base64 (>= 0.1.0)
207204
rack (>= 3.0.0)
208205
rack-test (2.2.0)
209206
rack (>= 1.3)
210-
rackup (2.3.1)
207+
rackup (2.2.1)
211208
rack (>= 3)
212209
rails (8.1.3)
213210
actioncable (= 8.1.3)
@@ -227,8 +224,8 @@ GEM
227224
activesupport (>= 5.0.0)
228225
minitest
229226
nokogiri (>= 1.6)
230-
rails-html-sanitizer (1.7.0)
231-
loofah (~> 2.25)
227+
rails-html-sanitizer (1.6.2)
228+
loofah (~> 2.21)
232229
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
233230
railties (8.1.3)
234231
actionpack (= 8.1.3)
@@ -241,39 +238,39 @@ GEM
241238
zeitwerk (~> 2.6)
242239
rainbow (3.1.1)
243240
rake (13.3.1)
244-
rdoc (7.2.0)
241+
rdoc (6.15.1)
245242
erb
246243
psych (>= 4.0.0)
247244
tsort
248-
regexp_parser (2.11.3)
245+
regexp_parser (2.11.2)
249246
reline (0.6.3)
250247
io-console (~> 0.5)
251248
rexml (3.4.4)
252249
rouge (4.7.0)
253250
rss (0.3.2)
254251
rexml
255-
rubocop (1.84.2)
252+
rubocop (1.81.7)
256253
json (~> 2.3)
257254
language_server-protocol (~> 3.17.0.2)
258255
lint_roller (~> 1.1.0)
259256
parallel (~> 1.10)
260257
parser (>= 3.3.0.2)
261258
rainbow (>= 2.2.2, < 4.0)
262259
regexp_parser (>= 2.9.3, < 3.0)
263-
rubocop-ast (>= 1.49.0, < 2.0)
260+
rubocop-ast (>= 1.47.1, < 2.0)
264261
ruby-progressbar (~> 1.7)
265262
unicode-display_width (>= 2.4.0, < 4.0)
266-
rubocop-ast (1.49.0)
263+
rubocop-ast (1.48.0)
267264
parser (>= 3.3.7.2)
268-
prism (~> 1.7)
269-
rubocop-performance (1.26.1)
265+
prism (~> 1.4)
266+
rubocop-performance (1.25.0)
270267
lint_roller (~> 1.1)
271268
rubocop (>= 1.75.0, < 2.0)
272-
rubocop-ast (>= 1.47.1, < 2.0)
269+
rubocop-ast (>= 1.38.0, < 2.0)
273270
ruby-progressbar (1.13.0)
274271
rubyzip (3.2.2)
275272
securerandom (0.4.1)
276-
selenium-webdriver (4.43.0)
273+
selenium-webdriver (4.38.0)
277274
base64 (~> 0.2)
278275
logger (~> 1.4)
279276
rexml (~> 3.2, >= 3.2.5)
@@ -283,25 +280,25 @@ GEM
283280
sqlite3 (2.9.3)
284281
mini_portile2 (~> 2.8.0)
285282
sqlite3 (2.9.3-x86_64-linux-gnu)
286-
standard (1.54.0)
283+
standard (1.52.0)
287284
language_server-protocol (~> 3.17.0.2)
288285
lint_roller (~> 1.0)
289-
rubocop (~> 1.84.0)
286+
rubocop (~> 1.81.7)
290287
standard-custom (~> 1.0.0)
291288
standard-performance (~> 1.8)
292289
standard-custom (1.0.2)
293290
lint_roller (~> 1.0)
294291
rubocop (~> 1.50)
295-
standard-performance (1.9.0)
292+
standard-performance (1.8.0)
296293
lint_roller (~> 1.1)
297-
rubocop-performance (~> 1.26.0)
294+
rubocop-performance (~> 1.25.0)
298295
stimulus-rails (1.3.4)
299296
railties (>= 6.0.0)
300-
stringio (3.2.0)
297+
stringio (3.1.8)
301298
tailwind_merge (1.4.0)
302299
sin_lru_redux (~> 2.5)
303-
thor (1.5.0)
304-
timeout (0.6.1)
300+
thor (1.4.0)
301+
timeout (0.4.4)
305302
tsort (0.2.0)
306303
turbo-rails (2.0.23)
307304
actionpack (>= 7.1.0)
@@ -310,21 +307,22 @@ GEM
310307
concurrent-ruby (~> 1.0)
311308
unicode-display_width (3.2.0)
312309
unicode-emoji (~> 4.1)
313-
unicode-emoji (4.2.0)
310+
unicode-emoji (4.1.0)
314311
uri (1.1.1)
315312
useragent (0.16.11)
316-
web-console (4.3.0)
317-
actionview (>= 8.0.0)
313+
web-console (4.2.1)
314+
actionview (>= 6.0.0)
315+
activemodel (>= 6.0.0)
318316
bindex (>= 0.4.0)
319-
railties (>= 8.0.0)
317+
railties (>= 6.0.0)
320318
websocket (1.2.11)
321319
websocket-driver (0.8.0)
322320
base64
323321
websocket-extensions (>= 0.1.0)
324322
websocket-extensions (0.1.5)
325323
xpath (3.2.0)
326324
nokogiri (~> 1.8)
327-
zeitwerk (2.7.5)
325+
zeitwerk (2.7.3)
328326

329327
PLATFORMS
330328
ruby
@@ -359,4 +357,4 @@ RUBY VERSION
359357
ruby 3.4.7p58
360358

361359
BUNDLED WITH
362-
2.6.4
360+
2.6.9

app/components/docs/visual_code_example.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ def render_preview_tab(&block)
7878
end
7979

8080
def iframe_preview
81-
div(class: "relative aspect-[4/2.5] w-full overflow-hidden rounded-md border", data: {controller: "iframe-theme"}) do
82-
div(class: "absolute inset-0 hidden w-[1600px] bg-background md:block") do
81+
div(class: "relative min-h-[500px] w-full overflow-hidden rounded-md border", data: {controller: "iframe-theme"}) do
82+
div(class: "absolute inset-0 hidden w-full bg-background md:block") do
8383
iframe(src: @src, class: "size-full", data: {iframe_theme_target: "iframe"})
8484
end
8585
end
8686
end
8787

8888
def raw_preview
8989
div(class: "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 relative rounded-md border") do
90-
div(class: "preview flex min-h-[350px] w-full justify-center p-10 items-center") do
90+
div(class: "preview min-h-[350px] w-full p-6") do
9191
decoded_code = CGI.unescapeHTML(@display_code)
9292
@context.instance_eval(decoded_code)
9393
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class DataTable < Base
5+
register_element :turbo_frame, tag: "turbo-frame"
6+
7+
def initialize(id:, **attrs)
8+
@id = id
9+
super(**attrs)
10+
end
11+
12+
def view_template(&block)
13+
turbo_frame(id: @id, target: "_top") do
14+
div(**attrs) do
15+
yield if block
16+
end
17+
end
18+
end
19+
20+
private
21+
22+
def default_attrs
23+
{
24+
class: "w-full space-y-4",
25+
data: {controller: "ruby-ui--data-table"}
26+
}
27+
end
28+
end
29+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class DataTableBulkActions < Base
5+
def view_template(&)
6+
div(**attrs, &)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
class: "hidden items-center gap-2",
14+
data: {"ruby-ui--data-table-target": "bulkActions"}
15+
}
16+
end
17+
end
18+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class DataTableColumnToggle < Base
5+
def initialize(columns:, **attrs)
6+
@columns = columns
7+
super(**attrs)
8+
end
9+
10+
def view_template
11+
div(**attrs) do
12+
render RubyUI::DropdownMenu.new do
13+
render RubyUI::DropdownMenuTrigger.new do
14+
render RubyUI::Button.new(variant: :outline, size: :sm) do
15+
plain "Columns"
16+
# inline chevron-down SVG (lucide 24px, 1px stroke)
17+
svg(
18+
xmlns: "http://www.w3.org/2000/svg",
19+
width: "16",
20+
height: "16",
21+
viewBox: "0 0 24 24",
22+
fill: "none",
23+
stroke: "currentColor",
24+
stroke_width: "2",
25+
stroke_linecap: "round",
26+
stroke_linejoin: "round",
27+
class: "w-4 h-4 ml-1"
28+
) do |s|
29+
s.polyline(points: "6 9 12 15 18 9")
30+
end
31+
end
32+
end
33+
render RubyUI::DropdownMenuContent.new do
34+
@columns.each do |col|
35+
label(class: "flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent") do
36+
input(
37+
type: "checkbox",
38+
checked: true,
39+
class: "h-4 w-4 rounded border border-input accent-primary cursor-pointer",
40+
data: {
41+
column_key: col[:key].to_s,
42+
action: "change->ruby-ui--data-table-column-visibility#toggle"
43+
}
44+
)
45+
span { plain col[:label] }
46+
end
47+
end
48+
end
49+
end
50+
end
51+
end
52+
53+
private
54+
55+
def default_attrs
56+
{
57+
class: "relative",
58+
data: {controller: "ruby-ui--data-table-column-visibility"}
59+
}
60+
end
61+
end
62+
end

0 commit comments

Comments
 (0)