tam_select 1.2.4 → 1.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +164 -0
- data/README.md +325 -340
- data/app/assets/tailwind/tam_select/engine.css +4 -0
- data/config/importmap.rb +4 -0
- data/examples/playground.html +740 -0
- data/examples/tam-select.bundle.js +2328 -0
- data/lib/generators/tam_select/install_generator.rb +105 -37
- data/lib/generators/tam_select/legacy_copies.json +48 -0
- data/lib/generators/tam_select/templates/tam_select.rb +8 -0
- data/lib/generators/tam_select/templates/tam_select_controller.js +3 -26
- data/lib/generators/tam_select/update_generator.rb +13 -0
- data/lib/tam_select/default_select.rb +108 -0
- data/lib/tam_select/engine.rb +50 -0
- data/lib/tam_select/version.rb +1 -1
- data/lib/tam_select.rb +1 -0
- data/package.json +21 -5
- data/rails/app/controllers/concerns/tam_select_paginatable.rb +9 -3
- data/rails/app/helpers/tam_select_helper.rb +13 -2
- data/rails/app/inputs/tam_select_input.rb +19 -4
- data/rails/app/javascript/controllers/tam_select_controller.d.ts +21 -0
- data/rails/app/javascript/controllers/tam_select_controller.js +55 -2
- data/src/tam-select.d.ts +347 -0
- data/src/tam-select.js +1785 -146
- metadata +18 -7
- data/lib/generators/tam_select/templates/tam_select_helper.rb +0 -17
- data/lib/generators/tam_select/templates/tam_select_input.rb +0 -30
- data/lib/generators/tam_select/templates/tam_select_paginatable.rb +0 -32
- /data/{lib/generators/tam_select/templates → rails/app/controllers/concerns}/tam_select_remote.rb +0 -0
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tam_select
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tamiru Hailu
|
|
@@ -50,33 +50,44 @@ executables: []
|
|
|
50
50
|
extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
|
52
52
|
files:
|
|
53
|
+
- CHANGELOG.md
|
|
53
54
|
- LICENSE
|
|
54
55
|
- README.md
|
|
55
56
|
- Rakefile
|
|
57
|
+
- app/assets/tailwind/tam_select/engine.css
|
|
58
|
+
- config/importmap.rb
|
|
56
59
|
- examples/form.html.erb
|
|
60
|
+
- examples/playground.html
|
|
57
61
|
- examples/regions_controller.rb
|
|
62
|
+
- examples/tam-select.bundle.js
|
|
58
63
|
- lib/generators/tam_select/install_generator.rb
|
|
64
|
+
- lib/generators/tam_select/legacy_copies.json
|
|
65
|
+
- lib/generators/tam_select/templates/tam_select.rb
|
|
59
66
|
- lib/generators/tam_select/templates/tam_select_controller.js
|
|
60
|
-
- lib/generators/tam_select/templates/tam_select_helper.rb
|
|
61
|
-
- lib/generators/tam_select/templates/tam_select_input.rb
|
|
62
|
-
- lib/generators/tam_select/templates/tam_select_paginatable.rb
|
|
63
|
-
- lib/generators/tam_select/templates/tam_select_remote.rb
|
|
64
67
|
- lib/generators/tam_select/templates/tam_select_remote_controller.rb
|
|
68
|
+
- lib/generators/tam_select/update_generator.rb
|
|
65
69
|
- lib/tam_select.rb
|
|
70
|
+
- lib/tam_select/default_select.rb
|
|
66
71
|
- lib/tam_select/engine.rb
|
|
67
72
|
- lib/tam_select/version.rb
|
|
68
73
|
- package.json
|
|
69
74
|
- rails/app/controllers/concerns/tam_select_paginatable.rb
|
|
75
|
+
- rails/app/controllers/concerns/tam_select_remote.rb
|
|
70
76
|
- rails/app/helpers/tam_select_helper.rb
|
|
71
77
|
- rails/app/inputs/tam_select_input.rb
|
|
78
|
+
- rails/app/javascript/controllers/tam_select_controller.d.ts
|
|
72
79
|
- rails/app/javascript/controllers/tam_select_controller.js
|
|
80
|
+
- src/tam-select.d.ts
|
|
73
81
|
- src/tam-select.js
|
|
74
82
|
homepage: https://github.com/tamiru/tam_select
|
|
75
83
|
licenses:
|
|
76
84
|
- MIT
|
|
77
85
|
metadata:
|
|
78
86
|
source_code_uri: https://github.com/tamiru/tam_select
|
|
79
|
-
changelog_uri: https://github.com/tamiru/tam_select/
|
|
87
|
+
changelog_uri: https://github.com/tamiru/tam_select/blob/main/CHANGELOG.md
|
|
88
|
+
bug_tracker_uri: https://github.com/tamiru/tam_select/issues
|
|
89
|
+
funding_uri: https://github.com/sponsors/tamiru
|
|
90
|
+
allowed_push_host: https://rubygems.org
|
|
80
91
|
rubygems_mfa_required: 'true'
|
|
81
92
|
rdoc_options: []
|
|
82
93
|
require_paths:
|
|
@@ -92,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
103
|
- !ruby/object:Gem::Version
|
|
93
104
|
version: '0'
|
|
94
105
|
requirements: []
|
|
95
|
-
rubygems_version: 4.0.
|
|
106
|
+
rubygems_version: 4.0.20
|
|
96
107
|
specification_version: 4
|
|
97
108
|
summary: An accessible select component for Ruby on Rails
|
|
98
109
|
test_files: []
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module TamSelectHelper
|
|
2
|
-
def tam_select_tag(name, option_tags = nil, options: {}, html_options: {}, &block)
|
|
3
|
-
data = (html_options[:data] ||= {})
|
|
4
|
-
data[:controller] = (data[:controller].to_s.split + ["tam-select"]).uniq.join(" ")
|
|
5
|
-
data[:tam_select_options_value] = options.to_json
|
|
6
|
-
select_tag(name, option_tags, html_options, &block)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def tam_select_options(**overrides)
|
|
10
|
-
{
|
|
11
|
-
searchable: true,
|
|
12
|
-
clearable: true,
|
|
13
|
-
creatable: false,
|
|
14
|
-
placeholder: "Select…"
|
|
15
|
-
}.merge(overrides)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class TamSelectInput < SimpleForm::Inputs::CollectionSelectInput
|
|
2
|
-
def input(wrapper_options = nil)
|
|
3
|
-
attributes = merge_wrapper_options(input_html_options, wrapper_options)
|
|
4
|
-
label_method, value_method = detect_collection_methods
|
|
5
|
-
tam_options = attributes.delete(:tam_options) || {}
|
|
6
|
-
data = attributes[:data] ||= {}
|
|
7
|
-
data[:controller] = (data[:controller].to_s.split + ["tam-select"]).uniq.join(" ")
|
|
8
|
-
data[:tam_select_options_value] = defaults.merge(tam_options).to_json
|
|
9
|
-
|
|
10
|
-
@builder.collection_select(
|
|
11
|
-
attribute_name,
|
|
12
|
-
collection,
|
|
13
|
-
value_method,
|
|
14
|
-
label_method,
|
|
15
|
-
input_options,
|
|
16
|
-
attributes
|
|
17
|
-
)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def defaults
|
|
23
|
-
{
|
|
24
|
-
searchable: options.fetch(:searchable, true),
|
|
25
|
-
creatable: options.fetch(:creatable, false),
|
|
26
|
-
clearable: options.fetch(:clearable, true),
|
|
27
|
-
placeholder: options[:placeholder] || options[:prompt] || "Select…"
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module TamSelectPaginatable
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
private
|
|
5
|
-
|
|
6
|
-
def tam_select_payload(scope, label:, value: :id, detail: nil, meta: nil, image: nil, per_page: 20)
|
|
7
|
-
page = [params.fetch(:page, 1).to_i, 1].max
|
|
8
|
-
records = scope.limit(per_page + 1).offset((page - 1) * per_page).to_a
|
|
9
|
-
has_more = records.length > per_page
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
items: records.first(per_page).map do |record|
|
|
13
|
-
{
|
|
14
|
-
value: tam_select_record_value(record, value).to_s,
|
|
15
|
-
label: tam_select_record_value(record, label).to_s,
|
|
16
|
-
detail: detail && tam_select_record_value(record, detail).to_s,
|
|
17
|
-
meta: meta && tam_select_record_value(record, meta).to_s,
|
|
18
|
-
image: image && tam_select_record_value(record, image).to_s
|
|
19
|
-
}.compact
|
|
20
|
-
end,
|
|
21
|
-
pagination: {
|
|
22
|
-
page: page,
|
|
23
|
-
next_page: has_more ? page + 1 : nil,
|
|
24
|
-
has_more: has_more
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def tam_select_record_value(record, resolver)
|
|
30
|
-
resolver.respond_to?(:call) ? resolver.call(record) : record.public_send(resolver)
|
|
31
|
-
end
|
|
32
|
-
end
|
/data/{lib/generators/tam_select/templates → rails/app/controllers/concerns}/tam_select_remote.rb
RENAMED
|
File without changes
|