rails_notion_like_multiselect 0.1.1

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.
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ pin 'rails_notion_multiselect_controller', to: 'rails_notion_multiselect_controller.js'
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsNotionLikeMultiselect
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def copy_javascript_controller
9
+ copy_file(
10
+ 'rails_notion_multiselect_controller.js',
11
+ 'app/javascript/controllers/rails_notion_multiselect_controller.js'
12
+ )
13
+ end
14
+
15
+ def add_to_stimulus_index
16
+ inject_into_file 'app/javascript/controllers/index.js', after: /import { application } from.*\n/ do
17
+ <<~JS
18
+ import RailsNotionMultiselectController from "./rails_notion_multiselect_controller"
19
+ application.register("rails-notion-multiselect", RailsNotionMultiselectController)
20
+ JS
21
+ end
22
+ end
23
+
24
+ def create_initializer
25
+ create_file 'config/initializers/rails_notion_like_multiselect.rb', <<~RUBY
26
+ # frozen_string_literal: true
27
+
28
+ RailsNotionLikeMultiselect.setup do |config|
29
+ # Default badge color for selected items
30
+ # Options: "blue", "green", "purple", "yellow", "red"
31
+ config.default_badge_color = "blue"
32
+ #{' '}
33
+ # Default placeholder text
34
+ config.default_placeholder = "Search or select..."
35
+ #{' '}
36
+ # Enable keyboard navigation
37
+ config.enable_keyboard_navigation = true
38
+ end
39
+ RUBY
40
+ end
41
+
42
+ def display_post_install
43
+ say "\n✅ Rails Notion-Like Multiselect has been installed!", :green
44
+ say "\nTo use the multiselect in your forms:", :yellow
45
+ say <<~USAGE
46
+
47
+ <%= multiselect_field(
48
+ form,
49
+ :field_name,
50
+ collection: @items,
51
+ selected: @selected_items,
52
+ allow_create: true,
53
+ placeholder: "Search or create...",
54
+ badge_color: "blue"
55
+ ) %>
56
+ USAGE
57
+
58
+ say "\n📚 For more options and examples, see: https://github.com/pageinteract/rails_notion_like_multiselect",
59
+ :cyan
60
+ end
61
+ end
62
+ end
63
+ end