ruby_ui 1.0.0.pre.alpha.4 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/lib/generators/ruby_ui/component_generator.rb +94 -0
- data/lib/generators/ruby_ui/dependencies.yml +74 -0
- data/lib/generators/ruby_ui/install/install_generator.rb +89 -0
- data/lib/generators/ruby_ui/install/templates/ruby_ui.rb.erb +18 -0
- data/lib/generators/ruby_ui/install/templates/tailwind.css.erb +156 -0
- data/lib/generators/ruby_ui/javascript_utils.rb +57 -0
- data/lib/{rbui → ruby_ui}/accordion/accordion.rb +1 -1
- data/lib/{rbui → ruby_ui}/accordion/accordion_content.rb +2 -2
- data/lib/ruby_ui/accordion/accordion_controller.js +97 -0
- data/lib/{rbui → ruby_ui}/accordion/accordion_default_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/accordion/accordion_default_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/accordion/accordion_icon.rb +2 -2
- data/lib/{rbui → ruby_ui}/accordion/accordion_item.rb +4 -4
- data/lib/{rbui → ruby_ui}/accordion/accordion_trigger.rb +3 -2
- data/lib/{rbui → ruby_ui}/alert/alert.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert/alert_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert/alert_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_action.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_cancel.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_content.rb +5 -5
- data/lib/ruby_ui/alert_dialog/alert_dialog_controller.js +31 -0
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_footer.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_header.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/aspect_ratio/aspect_ratio.rb +1 -1
- data/lib/{rbui → ruby_ui}/avatar/avatar.rb +2 -2
- data/lib/{rbui → ruby_ui}/avatar/avatar_fallback.rb +1 -1
- data/lib/{rbui → ruby_ui}/avatar/avatar_image.rb +1 -1
- data/lib/{rbui → ruby_ui}/badge/badge.rb +2 -2
- data/lib/{rbui → ruby_ui}/base.rb +1 -8
- data/lib/ruby_ui/breadcrumb/breadcrumb.rb +17 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_ellipsis.rb +39 -0
- data/lib/{rbui/typography/typography_list_item.rb → ruby_ui/breadcrumb/breadcrumb_item.rb} +3 -3
- data/lib/ruby_ui/breadcrumb/breadcrumb_link.rb +22 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_list.rb +17 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_page.rb +19 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_separator.rb +38 -0
- data/lib/{rbui → ruby_ui}/button/button.rb +13 -13
- data/lib/ruby_ui/calendar/calendar.rb +39 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_body.rb +2 -2
- data/lib/ruby_ui/calendar/calendar_controller.js +249 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_days.rb +14 -14
- data/lib/{rbui → ruby_ui}/calendar/calendar_header.rb +1 -1
- data/lib/ruby_ui/calendar/calendar_input_controller.js +8 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_next.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_prev.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_title.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_weekdays.rb +2 -2
- data/lib/{rbui → ruby_ui}/card/card.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_title.rb +1 -1
- data/lib/ruby_ui/carousel/carousel.rb +44 -0
- data/lib/ruby_ui/carousel/carousel_content.rb +23 -0
- data/lib/ruby_ui/carousel/carousel_controller.js +60 -0
- data/lib/ruby_ui/carousel/carousel_item.rb +23 -0
- data/lib/ruby_ui/carousel/carousel_next.rb +48 -0
- data/lib/ruby_ui/carousel/carousel_previous.rb +49 -0
- data/lib/{rbui → ruby_ui}/chart/chart.rb +3 -3
- data/lib/ruby_ui/chart/chart_controller.js +103 -0
- data/lib/{rbui → ruby_ui}/checkbox/checkbox.rb +4 -4
- data/lib/{rbui → ruby_ui}/checkbox/checkbox_group.rb +2 -2
- data/lib/ruby_ui/checkbox/checkbox_group_controller.js +21 -0
- data/lib/{rbui → ruby_ui}/clipboard/clipboard.rb +6 -6
- data/lib/ruby_ui/clipboard/clipboard_controller.js +54 -0
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_popover.rb +2 -2
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_source.rb +2 -2
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/codeblock/codeblock.rb +7 -10
- data/lib/{rbui → ruby_ui}/collapsible/collapsible.rb +3 -3
- data/lib/{rbui → ruby_ui}/collapsible/collapsible_content.rb +2 -2
- data/lib/ruby_ui/collapsible/collapsible_controller.js +47 -0
- data/lib/{rbui → ruby_ui}/collapsible/collapsible_trigger.rb +2 -2
- data/lib/ruby_ui/combobox/combobox.rb +26 -0
- data/lib/ruby_ui/combobox/combobox_checkbox.rb +25 -0
- data/lib/ruby_ui/combobox/combobox_controller.js +176 -0
- data/lib/{rbui/combobox/combobox_empty.rb → ruby_ui/combobox/combobox_empty_state.rb} +3 -3
- data/lib/ruby_ui/combobox/combobox_item.rb +25 -0
- data/lib/ruby_ui/combobox/combobox_list.rb +18 -0
- data/lib/ruby_ui/combobox/combobox_list_group.rb +20 -0
- data/lib/ruby_ui/combobox/combobox_popover.rb +30 -0
- data/lib/ruby_ui/combobox/combobox_radio.rb +26 -0
- data/lib/{rbui → ruby_ui}/combobox/combobox_search_input.rb +22 -25
- data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +25 -0
- data/lib/{rbui → ruby_ui}/combobox/combobox_trigger.rb +26 -21
- data/lib/{rbui → ruby_ui}/command/command.rb +1 -1
- data/lib/ruby_ui/command/command_controller.js +136 -0
- data/lib/{rbui → ruby_ui}/command/command_dialog.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_dialog_content.rb +6 -6
- data/lib/{rbui → ruby_ui}/command/command_dialog_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/command/command_empty.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_group.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_input.rb +3 -3
- data/lib/{rbui → ruby_ui}/command/command_item.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_list.rb +1 -1
- data/lib/{rbui → ruby_ui}/context_menu/context_menu.rb +2 -2
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_content.rb +2 -2
- data/lib/ruby_ui/context_menu/context_menu_controller.js +144 -0
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_item.rb +3 -3
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_label.rb +2 -2
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_separator.rb +1 -1
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/dialog/dialog.rb +3 -3
- data/lib/{rbui → ruby_ui}/dialog/dialog_content.rb +9 -9
- data/lib/ruby_ui/dialog/dialog_controller.js +32 -0
- data/lib/{rbui → ruby_ui}/dialog/dialog_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_footer.rb +2 -2
- data/lib/{rbui → ruby_ui}/dialog/dialog_header.rb +2 -2
- data/lib/{rbui → ruby_ui}/dialog/dialog_middle.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu.rb +4 -4
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_content.rb +2 -2
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_controller.js +120 -0
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_item.rb +3 -3
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_separator.rb +1 -1
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/form/form.rb +1 -1
- data/lib/{rbui → ruby_ui}/form/form_field.rb +2 -2
- data/lib/ruby_ui/form/form_field_controller.js +61 -0
- data/lib/{rbui → ruby_ui}/form/form_field_error.rb +2 -2
- data/lib/{rbui → ruby_ui}/form/form_field_hint.rb +1 -1
- data/lib/{rbui → ruby_ui}/form/form_field_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/hover_card/hover_card.rb +3 -3
- data/lib/{rbui → ruby_ui}/hover_card/hover_card_content.rb +2 -2
- data/lib/ruby_ui/hover_card/hover_card_controller.js +144 -0
- data/lib/{rbui → ruby_ui}/hover_card/hover_card_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/input/input.rb +3 -3
- data/lib/{rbui → ruby_ui}/link/link.rb +13 -13
- data/lib/ruby_ui/masked_input/masked_input.rb +15 -0
- data/lib/ruby_ui/masked_input/masked_input_controller.js +9 -0
- data/lib/{rbui → ruby_ui}/pagination/pagination.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_ellipsis.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_item.rb +4 -4
- data/lib/{rbui → ruby_ui}/popover/popover.rb +4 -4
- data/lib/{rbui → ruby_ui}/popover/popover_content.rb +2 -2
- data/lib/ruby_ui/popover/popover_controller.js +107 -0
- data/lib/{rbui → ruby_ui}/popover/popover_trigger.rb +2 -2
- data/lib/ruby_ui/progress/progress.rb +37 -0
- data/lib/ruby_ui/radio_button/radio_button.rb +25 -0
- data/lib/{rbui → ruby_ui}/select/select.rb +5 -5
- data/lib/{rbui → ruby_ui}/select/select_content.rb +3 -3
- data/lib/ruby_ui/select/select_controller.js +171 -0
- data/lib/{rbui → ruby_ui}/select/select_group.rb +1 -1
- data/lib/{rbui → ruby_ui}/select/select_input.rb +4 -4
- data/lib/{rbui → ruby_ui}/select/select_item.rb +4 -4
- data/lib/ruby_ui/select/select_item_controller.js +11 -0
- data/lib/{rbui → ruby_ui}/select/select_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/select/select_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/select/select_value.rb +3 -3
- data/lib/ruby_ui/separator/separator.rb +38 -0
- data/lib/{rbui → ruby_ui}/sheet/sheet.rb +2 -2
- data/lib/{rbui → ruby_ui}/sheet/sheet_content.rb +8 -8
- data/lib/ruby_ui/sheet/sheet_content_controller.js +7 -0
- data/lib/ruby_ui/sheet/sheet_controller.js +9 -0
- data/lib/{rbui → ruby_ui}/sheet/sheet_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_middle.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/shortcut_key/shortcut_key.rb +1 -1
- data/lib/ruby_ui/skeleton/skeleton.rb +17 -0
- data/lib/ruby_ui/switch/switch.rb +24 -0
- data/lib/{rbui → ruby_ui}/table/table.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_body.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_caption.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_cell.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_head.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_row.rb +1 -1
- data/lib/{rbui → ruby_ui}/tabs/tabs.rb +3 -3
- data/lib/{rbui → ruby_ui}/tabs/tabs_content.rb +2 -2
- data/lib/ruby_ui/tabs/tabs_controller.js +45 -0
- data/lib/{rbui → ruby_ui}/tabs/tabs_list.rb +1 -1
- data/lib/{rbui → ruby_ui}/tabs/tabs_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/textarea/textarea.rb +3 -3
- data/lib/{rbui → ruby_ui}/theme_toggle/theme_toggle.rb +4 -4
- data/lib/ruby_ui/theme_toggle/theme_toggle_controller.js +30 -0
- data/lib/{rbui → ruby_ui}/tooltip/tooltip.rb +3 -3
- data/lib/{rbui → ruby_ui}/tooltip/tooltip_content.rb +3 -3
- data/lib/ruby_ui/tooltip/tooltip_controller.js +37 -0
- data/lib/{rbui → ruby_ui}/tooltip/tooltip_trigger.rb +2 -2
- data/lib/ruby_ui/typography/heading.rb +60 -0
- data/lib/{rbui/typography/typography_inline_code.rb → ruby_ui/typography/inline_code.rb} +2 -2
- data/lib/{rbui/typography/typography_inline_link.rb → ruby_ui/typography/inline_link.rb} +2 -2
- data/lib/ruby_ui/typography/text.rb +53 -0
- data/lib/{rbui → ruby_ui}/typography/typography_blockquote.rb +1 -1
- data/lib/ruby_ui.rb +5 -1
- metadata +208 -173
- data/lib/generators/rbui/base_generator.rb +0 -17
- data/lib/generators/rbui/component_generator.rb +0 -137
- data/lib/generators/rbui/install/install_generator.rb +0 -194
- data/lib/rbui/calendar/calendar.rb +0 -39
- data/lib/rbui/combobox/combobox.rb +0 -24
- data/lib/rbui/combobox/combobox_content.rb +0 -31
- data/lib/rbui/combobox/combobox_group.rb +0 -38
- data/lib/rbui/combobox/combobox_input.rb +0 -22
- data/lib/rbui/combobox/combobox_item.rb +0 -53
- data/lib/rbui/combobox/combobox_list.rb +0 -29
- data/lib/rbui/combobox/combobox_separator.rb +0 -15
- data/lib/rbui/combobox/combobox_value.rb +0 -27
- data/lib/rbui/radio_button/radio_button.rb +0 -22
- data/lib/rbui/railtie.rb +0 -52
- data/lib/rbui/typography/typography_h1.rb +0 -17
- data/lib/rbui/typography/typography_h2.rb +0 -17
- data/lib/rbui/typography/typography_h3.rb +0 -17
- data/lib/rbui/typography/typography_h4.rb +0 -17
- data/lib/rbui/typography/typography_large.rb +0 -17
- data/lib/rbui/typography/typography_lead.rb +0 -17
- data/lib/rbui/typography/typography_list.rb +0 -47
- data/lib/rbui/typography/typography_muted.rb +0 -17
- data/lib/rbui/typography/typography_p.rb +0 -17
- data/lib/rbui/typography/typography_small.rb +0 -17
- data/lib/rbui/version.rb +0 -5
- data/lib/rbui.rb +0 -57
@@ -1,194 +0,0 @@
|
|
1
|
-
require "net/http"
|
2
|
-
|
3
|
-
# TODO: make ejctectec components work without the gem
|
4
|
-
module RBUI
|
5
|
-
module Generators
|
6
|
-
class InstallGenerator < RBUI::Generators::BaseGenerator
|
7
|
-
namespace "rbui:install"
|
8
|
-
|
9
|
-
if defined?(Rails::Generators::Base)
|
10
|
-
source_root File.expand_path("templates", __dir__)
|
11
|
-
|
12
|
-
def confirm_installation
|
13
|
-
return if yes?("You need tailwindcss installed. Continue? (y/n)")
|
14
|
-
say "Installation cancelled.", :red
|
15
|
-
exit
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_phlex_rails
|
19
|
-
say "Checking for Phlex Rails"
|
20
|
-
if gem_installed?("phlex-rails")
|
21
|
-
say "Phlex Rails is already installed", :green
|
22
|
-
else
|
23
|
-
say "Adding Phlex Rails"
|
24
|
-
run "bundle add phlex-rails --version=\"~> 1.2.1\""
|
25
|
-
end
|
26
|
-
|
27
|
-
say "Adding tailwind_merge"
|
28
|
-
run "bundle add tailwind_merge"
|
29
|
-
|
30
|
-
say "run phlex install"
|
31
|
-
run "bin/rails generate phlex:install"
|
32
|
-
end
|
33
|
-
|
34
|
-
def install_stuff
|
35
|
-
# make default option no
|
36
|
-
# extend the yes func to have a default option y/(n) and also allow for enter to accedpt the default
|
37
|
-
|
38
|
-
if ENV["TEST_DATA"] == "true"
|
39
|
-
say "Do you want to set up the dev test data?"
|
40
|
-
say "Add index controller"
|
41
|
-
run "bin/rails generate controller static index --no-helper --no-assets --no-test-framework --no-jbuilder"
|
42
|
-
|
43
|
-
say "Add index view"
|
44
|
-
run "bin/rails g phlex:view Static::Index"
|
45
|
-
|
46
|
-
append_to_file "app/controllers/static_controller.rb", after: " def index" do
|
47
|
-
# remove view because phlex is removing view
|
48
|
-
"\n render Static::IndexView"
|
49
|
-
end
|
50
|
-
|
51
|
-
template "index_view.rb", "app/views/static/index_view.rb", force: true
|
52
|
-
|
53
|
-
say "Add index route"
|
54
|
-
append_to_file "config/routes.rb", after: "Rails.application.routes.draw do" do
|
55
|
-
"\n root to: \"static#index\"\n"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
tailwind_config_path = Rails.root.join("config/tailwind.config.js")
|
60
|
-
if !File.exist?(tailwind_config_path)
|
61
|
-
say "Tailwind CSS is required for RBUI", :red
|
62
|
-
end
|
63
|
-
|
64
|
-
say "Add rbui initializer"
|
65
|
-
template "base_store_initializer.rb", "config/initializers/rbui.rb"
|
66
|
-
|
67
|
-
if using_importmap?
|
68
|
-
say "Using importmaps, adding tailwind-animate"
|
69
|
-
run "bin/importmap pin tailwindcss-animate"
|
70
|
-
|
71
|
-
# Remove the default pin
|
72
|
-
gsub_file "config/importmap.rb", /^pin "tailwindcss-animate".*$\n/, ""
|
73
|
-
|
74
|
-
# Add the vendor-specific pin
|
75
|
-
append_to_file "config/importmap.rb" do
|
76
|
-
'pin "tailwindcss-animate", to: "tailwindcss-animate.js", preload: true' + "\n"
|
77
|
-
end
|
78
|
-
|
79
|
-
else
|
80
|
-
say "Not using importmaps, adding tailwind-animate via yarn"
|
81
|
-
run "yarn add tailwindcss-animate"
|
82
|
-
end
|
83
|
-
|
84
|
-
# check if tailwind.config is in config dir or in root or ask to specify a path
|
85
|
-
say "update tailwind.config.js"
|
86
|
-
template "tailwind.config.js", "config/tailwind.config.js", force: true, assigns: {using_importmap: using_importmap?}
|
87
|
-
|
88
|
-
say "Add CSS variables"
|
89
|
-
template "application.tailwind.css", "app/assets/stylesheets/application.tailwind.css", force: true
|
90
|
-
end
|
91
|
-
|
92
|
-
def pin_rbui_js
|
93
|
-
stimulus_path = Rails.root.join("app/javascript/application.js")
|
94
|
-
package_name = "rbui-js"
|
95
|
-
|
96
|
-
say "Add RBUI Stimulus controllers"
|
97
|
-
# run "mkdir -p app/javascript/controllers/rbui-js"
|
98
|
-
template "index.js", "app/components/rbui/index.js"
|
99
|
-
|
100
|
-
if using_importmap?
|
101
|
-
gsub_file "app/components/rbui/index.js", /^import { application }.*$/ do
|
102
|
-
'import { application } from "controllers/application";'
|
103
|
-
end
|
104
|
-
|
105
|
-
append_to_file Rails.root.join("config/initializers/assets.rb") do
|
106
|
-
"Rails.application.config.assets.paths << Rails.root.join(\"app/components\")\n"
|
107
|
-
end
|
108
|
-
|
109
|
-
say "Pin #{package_name}"
|
110
|
-
append_to_file Rails.root.join("config/importmap.rb") do
|
111
|
-
"pin_all_from \"app/components/rbui\", under: \"rbui\"\n"
|
112
|
-
end
|
113
|
-
|
114
|
-
run "bin/importmap pin #{package_name}"
|
115
|
-
append_to_file stimulus_path, "\nimport \"rbui\";\n"
|
116
|
-
|
117
|
-
manifest_path = Rails.root.join("app/assets/config/manifest.js")
|
118
|
-
if File.exist?(manifest_path)
|
119
|
-
append_to_file manifest_path, "\n//= link rbui/index.js\n"
|
120
|
-
end
|
121
|
-
|
122
|
-
fix_import_maps!
|
123
|
-
else
|
124
|
-
say "Add rbui-js package"
|
125
|
-
run "yarn add #{package_name}"
|
126
|
-
|
127
|
-
append_to_file stimulus_path, "\nimport \"../components/rbui\";\n"
|
128
|
-
|
129
|
-
run "yarn build"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def include_rbui
|
134
|
-
message = "Include RBUI in your global component layout?\n This allows to call RBUI.Button {\"button\"} / RBUI::Button.new {\"button\"} with Button {\"button\"} (y/n)"
|
135
|
-
if yes?(message)
|
136
|
-
say "Add RBUI to your global component layout"
|
137
|
-
insert_into_file "app/views/application_view.rb", after: "class ApplicationView < ApplicationComponent\n" do
|
138
|
-
" include RBUI\n"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
else
|
144
|
-
def self.source_root
|
145
|
-
File.expand_path("templates", __dir__)
|
146
|
-
end
|
147
|
-
|
148
|
-
def add_stylesheet_link
|
149
|
-
puts "This generator can only be run in a Rails environment."
|
150
|
-
end
|
151
|
-
|
152
|
-
def revoke
|
153
|
-
puts "This generator can only be run in a Rails environment."
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
private
|
158
|
-
|
159
|
-
def fix_import_maps!
|
160
|
-
importmap_config_path = Rails.root.join("config/importmap.rb")
|
161
|
-
|
162
|
-
gsub_file importmap_config_path, /^pin "date-fns".*$/ do
|
163
|
-
'pin "date-fns", to: "https://ga.jspm.io/npm:date-fns@3.3.1/index.mjs"'
|
164
|
-
end
|
165
|
-
run "bin/importmap pin @popperjs/core@2.11.8/+esm --from jsdelivr"
|
166
|
-
|
167
|
-
run "mv vendor/javascript/@popperjs--core--+esm.js vendor/javascript/stupid-popper-lib-2024.js"
|
168
|
-
|
169
|
-
append_to_file importmap_config_path do
|
170
|
-
'pin "@popperjs/core", to: "stupid-popper-lib-2024.js"'
|
171
|
-
end
|
172
|
-
|
173
|
-
uri = URI "https://ga.jspm.io/npm:chart.js@3.9.1/dist/chart.min.js"
|
174
|
-
request = Net::HTTP::Get.new uri
|
175
|
-
|
176
|
-
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
|
177
|
-
http.request(request)
|
178
|
-
}
|
179
|
-
|
180
|
-
File.write(Rails.root.join("vendor/javascript/chart.js--auto.js"), response.body) if response.is_a?(Net::HTTPSuccess)
|
181
|
-
|
182
|
-
append_to_file Rails.root.join("app/views/layouts/application.html.erb"), before: "</body>" do
|
183
|
-
"<script>
|
184
|
-
window.process = { env: { NODE_ENV: 'production'} }
|
185
|
-
</script>"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def gem_installed?(name)
|
190
|
-
Gem::Specification.find_all_by_name(name).any?
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class Calendar < Base
|
5
|
-
def initialize(selected_date: nil, input_id: nil, date_format: "yyyy-MM-dd", **attrs)
|
6
|
-
@selected_date = selected_date
|
7
|
-
@input_id = input_id
|
8
|
-
@date_format = date_format
|
9
|
-
super(**attrs)
|
10
|
-
end
|
11
|
-
|
12
|
-
def view_template
|
13
|
-
div(**attrs) do
|
14
|
-
RBUI.CalendarHeader do
|
15
|
-
RBUI.CalendarTitle
|
16
|
-
RBUI.CalendarPrev
|
17
|
-
RBUI.CalendarNext
|
18
|
-
end
|
19
|
-
RBUI.CalendarBody # Where the calendar is rendered (Weekdays and Days)
|
20
|
-
RBUI.CalendarWeekdays # Template for the weekdays
|
21
|
-
RBUI.CalendarDays # Template for the days
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def default_attrs
|
28
|
-
{
|
29
|
-
class: "p-3 space-y-4",
|
30
|
-
data: {
|
31
|
-
controller: "rbui--calendar",
|
32
|
-
rbui__calendar_selected_date_value: @selected_date&.to_s,
|
33
|
-
rbui__calendar_format_value: @date_format,
|
34
|
-
rbui__calendar_rbui__calendar_input_outlet: @input_id
|
35
|
-
}
|
36
|
-
}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class Combobox < Base
|
5
|
-
def view_template(&)
|
6
|
-
div(**attrs, &)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
data: {
|
14
|
-
controller: "rbui--combobox",
|
15
|
-
rbui__combobox_open_value: "false",
|
16
|
-
action: "click@window->rbui--combobox#onClickOutside",
|
17
|
-
rbui__combobox_rbui__combobox_content_outlet: ".combobox-content",
|
18
|
-
rbui__combobox_rbui__combobox_item_outlet: ".combobox-item"
|
19
|
-
},
|
20
|
-
class: "group/combobox w-full relative"
|
21
|
-
}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class ComboboxContent < Base
|
5
|
-
def initialize(**attrs)
|
6
|
-
@id = "content#{SecureRandom.hex(4)}"
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
def view_template(&)
|
11
|
-
div(**attrs) do
|
12
|
-
div(class: "min-w-max max-h-[300px] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-out group-data-[rbui--combobox-open-value=true]/combobox:animate-in fade-out-0 group-data-[rbui--combobox-open-value=true]/combobox:fade-in-0 zoom-out-95 group-data-[rbui--combobox-open-value=true]/combobox:zoom-in-95 slide-in-from-top-2", &)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def default_attrs
|
19
|
-
{
|
20
|
-
id: @id,
|
21
|
-
role: "listbox",
|
22
|
-
data: {
|
23
|
-
controller: "rbui--combobox-content",
|
24
|
-
rbui__combobox_target: "content",
|
25
|
-
action: "keydown.enter->rbui--combobox#onKeyEnter keydown.esc->rbui--combobox#onEscKey keydown.down->rbui--combobox#onKeyDown keydown.up->rbui--combobox#onKeyUp"
|
26
|
-
},
|
27
|
-
class: "combobox-content hidden w-full absolute top-0 left-0 z-50"
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class ComboboxGroup < Base
|
5
|
-
def initialize(heading: nil, **attrs)
|
6
|
-
@heading = heading
|
7
|
-
super(**attrs)
|
8
|
-
end
|
9
|
-
|
10
|
-
def view_template(&block)
|
11
|
-
div(**attrs) do
|
12
|
-
render_header if @heading
|
13
|
-
render_items(&block)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def render_header
|
20
|
-
div(group_heading: @heading, class: "px-2 py-1.5 text-xs font-medium text-muted-foreground") { @heading }
|
21
|
-
end
|
22
|
-
|
23
|
-
def render_items(&)
|
24
|
-
div(group_items: "", role: "group", &)
|
25
|
-
end
|
26
|
-
|
27
|
-
def default_attrs
|
28
|
-
{
|
29
|
-
class: "overflow-hidden p-1 text-foreground",
|
30
|
-
role: "presentation",
|
31
|
-
data: {
|
32
|
-
value: @heading,
|
33
|
-
rbui__combobox_content_target: "group"
|
34
|
-
}
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class ComboboxInput < Base
|
5
|
-
def view_template
|
6
|
-
input(**attrs)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
class: "hidden",
|
14
|
-
data: {
|
15
|
-
rbui__combobox_target: "input",
|
16
|
-
rbui__form_field_target: "input",
|
17
|
-
action: "change->rbui--form-field#onChange invalid->rbui--form-field#onInvalid"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class ComboboxItem < Base
|
5
|
-
def initialize(value: nil, **attrs)
|
6
|
-
@value = value
|
7
|
-
super(**attrs)
|
8
|
-
end
|
9
|
-
|
10
|
-
def view_template(&block)
|
11
|
-
div(**attrs) do
|
12
|
-
div(class: "invisible group-aria-selected:visible") { icon }
|
13
|
-
block.call
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def icon
|
20
|
-
svg(
|
21
|
-
xmlns: "http://www.w3.org/2000/svg",
|
22
|
-
viewbox: "0 0 24 24",
|
23
|
-
fill: "none",
|
24
|
-
stroke: "currentColor",
|
25
|
-
class: "mr-2 h-4 w-4",
|
26
|
-
stroke_width: "2",
|
27
|
-
stroke_linecap: "round",
|
28
|
-
stroke_linejoin: "round"
|
29
|
-
) do |s|
|
30
|
-
s.path(
|
31
|
-
d: "M20 6 9 17l-5-5"
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def default_attrs
|
37
|
-
{
|
38
|
-
role: "option",
|
39
|
-
tabindex: "0",
|
40
|
-
class:
|
41
|
-
"combobox-item group relative flex cursor-pointer select-none items-center gap-x-2 rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground aria-[current]:bg-accent aria-[current]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
42
|
-
data: {
|
43
|
-
value: @value,
|
44
|
-
rbui__combobox_target: "item",
|
45
|
-
rbui__combobox_content_target: "item",
|
46
|
-
controller: "rbui--combobox-item",
|
47
|
-
action: "click->rbui--combobox#onItemSelected"
|
48
|
-
},
|
49
|
-
aria_selected: "false"
|
50
|
-
}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "securerandom"
|
4
|
-
|
5
|
-
module RBUI
|
6
|
-
class ComboboxList < Base
|
7
|
-
def initialize(**attrs)
|
8
|
-
@id = "list#{SecureRandom.hex(4)}"
|
9
|
-
super
|
10
|
-
end
|
11
|
-
|
12
|
-
def view_template(&)
|
13
|
-
div(**attrs, &)
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def default_attrs
|
19
|
-
{
|
20
|
-
id: @id,
|
21
|
-
data: {
|
22
|
-
rbui__combobox_target: "list"
|
23
|
-
},
|
24
|
-
role: "listbox",
|
25
|
-
tabindex: "-1"
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class ComboboxValue < Base
|
5
|
-
def initialize(placeholder: nil, **attrs)
|
6
|
-
@placeholder = placeholder
|
7
|
-
super(**attrs)
|
8
|
-
end
|
9
|
-
|
10
|
-
def view_template(&block)
|
11
|
-
span(**attrs) do
|
12
|
-
block ? block.call : @placeholder
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def default_attrs
|
19
|
-
{
|
20
|
-
data: {
|
21
|
-
rbui__combobox_target: "value"
|
22
|
-
},
|
23
|
-
class: "pointer-events-none"
|
24
|
-
}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class RadioButton < Base
|
5
|
-
def view_template
|
6
|
-
input(**attrs)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
type: "radio",
|
14
|
-
data: {
|
15
|
-
rbui__form_field_target: "input",
|
16
|
-
action: "input->rbui--form-field#onInput invalid->rbui--form-field#onInvalid"
|
17
|
-
},
|
18
|
-
class: "h-4 w-4 p-0 border-primary rounded-full flex-none"
|
19
|
-
}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/rbui/railtie.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module RBUI
|
2
|
-
if defined?(Rails)
|
3
|
-
class Railtie < ::Rails::Railtie
|
4
|
-
generators do
|
5
|
-
require_relative "../generators/rbui/install/install_generator"
|
6
|
-
|
7
|
-
config.app_generators do |g|
|
8
|
-
g.templates.unshift File.expand_path("../templates", __FILE__)
|
9
|
-
end
|
10
|
-
|
11
|
-
initializer "rbui.set_generator_namespace" do
|
12
|
-
Rails::Generators.namespace(RBUI::Generators, as: "rbui")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Add component loading
|
17
|
-
config.to_prepare do
|
18
|
-
# Define the path to the RBUI components
|
19
|
-
rbui_components_path = Rails.root.join("app/components/rbui")
|
20
|
-
|
21
|
-
# Check if the RBUI components directory exists
|
22
|
-
if Dir.exist?(rbui_components_path)
|
23
|
-
# Find all Ruby files in the RBUI components directory and its subdirectories
|
24
|
-
Dir[rbui_components_path.join("**", "*.rb")].each do |file|
|
25
|
-
# Get the relative path of the file from the RBUI components directory
|
26
|
-
relative_path = Pathname.new(file).relative_path_from(rbui_components_path)
|
27
|
-
|
28
|
-
# Convert the file path to a component name
|
29
|
-
# e.g., "form/input.rb" becomes ["Form", "Input"]
|
30
|
-
component_name_parts = relative_path.to_s.chomp(".rb").split("/").map(&:camelize)
|
31
|
-
|
32
|
-
# Create the full component name with RBUI namespace
|
33
|
-
# e.g., "RBUI::Form::Input"
|
34
|
-
full_component_name = "RBUI::#{component_name_parts.join("::")}"
|
35
|
-
|
36
|
-
begin
|
37
|
-
# Check if the component is already defined
|
38
|
-
if defined?(full_component_name.constantize)
|
39
|
-
# If it's defined, load (or reload) the file
|
40
|
-
load file
|
41
|
-
end
|
42
|
-
rescue NameError
|
43
|
-
# If the constant isn't defined (i.e., the component doesn't exist),
|
44
|
-
# we'll skip this file and move to the next one
|
45
|
-
next
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class TypographyH1 < Base
|
5
|
-
def view_template(&)
|
6
|
-
h1(**attrs, &)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
class: "scroll-m-20 text-3xl font-bold leading-normal lg:leading-normal tracking-tight lg:text-4xl"
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class TypographyH2 < Base
|
5
|
-
def view_template(&)
|
6
|
-
h2(**attrs, &)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
class: "scroll-m-20 text-2xl font-semibold tracking-tight transition-colors first:mt-0 pb-4 border-b"
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RBUI
|
4
|
-
class TypographyH3 < Base
|
5
|
-
def view_template(&)
|
6
|
-
h3(**attrs, &)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def default_attrs
|
12
|
-
{
|
13
|
-
class: "scroll-m-20 text-xl font-semibold tracking-tight"
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|