mini-sharp-mod 0.0.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 +7 -0
- data/mini-sharp-mod.gemspec +12 -0
- data/simple_form-5.4.1/CHANGELOG.md +259 -0
- data/simple_form-5.4.1/MIT-LICENSE +21 -0
- data/simple_form-5.4.1/README.md +1334 -0
- data/simple_form-5.4.1/lib/generators/simple_form/USAGE +3 -0
- data/simple_form-5.4.1/lib/generators/simple_form/install_generator.rb +42 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/README +10 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.erb +15 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.haml +12 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.slim +11 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form.rb +176 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +372 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +122 -0
- data/simple_form-5.4.1/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +31 -0
- data/simple_form-5.4.1/lib/simple_form/action_view_extensions/builder.rb +38 -0
- data/simple_form-5.4.1/lib/simple_form/action_view_extensions/form_helper.rb +72 -0
- data/simple_form-5.4.1/lib/simple_form/components/errors.rb +74 -0
- data/simple_form-5.4.1/lib/simple_form/components/hints.rb +24 -0
- data/simple_form-5.4.1/lib/simple_form/components/html5.rb +33 -0
- data/simple_form-5.4.1/lib/simple_form/components/label_input.rb +34 -0
- data/simple_form-5.4.1/lib/simple_form/components/labels.rb +88 -0
- data/simple_form-5.4.1/lib/simple_form/components/maxlength.rb +35 -0
- data/simple_form-5.4.1/lib/simple_form/components/min_max.rb +41 -0
- data/simple_form-5.4.1/lib/simple_form/components/minlength.rb +35 -0
- data/simple_form-5.4.1/lib/simple_form/components/pattern.rb +27 -0
- data/simple_form-5.4.1/lib/simple_form/components/placeholders.rb +17 -0
- data/simple_form-5.4.1/lib/simple_form/components/readonly.rb +23 -0
- data/simple_form-5.4.1/lib/simple_form/components.rb +24 -0
- data/simple_form-5.4.1/lib/simple_form/error_notification.rb +49 -0
- data/simple_form-5.4.1/lib/simple_form/form_builder.rb +723 -0
- data/simple_form-5.4.1/lib/simple_form/helpers/autofocus.rb +12 -0
- data/simple_form-5.4.1/lib/simple_form/helpers/disabled.rb +16 -0
- data/simple_form-5.4.1/lib/simple_form/helpers/readonly.rb +16 -0
- data/simple_form-5.4.1/lib/simple_form/helpers/required.rb +36 -0
- data/simple_form-5.4.1/lib/simple_form/helpers/validators.rb +66 -0
- data/simple_form-5.4.1/lib/simple_form/helpers.rb +13 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/base.rb +232 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/block_input.rb +15 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/boolean_input.rb +108 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/collection_check_boxes_input.rb +22 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/collection_input.rb +122 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/collection_radio_buttons_input.rb +59 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/collection_select_input.rb +17 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/color_input.rb +14 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/date_time_input.rb +39 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/file_input.rb +12 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/grouped_collection_select_input.rb +54 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/hidden_input.rb +20 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/numeric_input.rb +20 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/password_input.rb +14 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/priority_input.rb +37 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/range_input.rb +15 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/rich_text_area_input.rb +14 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/string_input.rb +25 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/text_input.rb +14 -0
- data/simple_form-5.4.1/lib/simple_form/inputs/weekday_input.rb +14 -0
- data/simple_form-5.4.1/lib/simple_form/inputs.rb +27 -0
- data/simple_form-5.4.1/lib/simple_form/map_type.rb +17 -0
- data/simple_form-5.4.1/lib/simple_form/railtie.rb +19 -0
- data/simple_form-5.4.1/lib/simple_form/tags.rb +73 -0
- data/simple_form-5.4.1/lib/simple_form/version.rb +4 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers/builder.rb +80 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers/leaf.rb +29 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers/many.rb +74 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers/root.rb +43 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers/single.rb +27 -0
- data/simple_form-5.4.1/lib/simple_form/wrappers.rb +10 -0
- data/simple_form-5.4.1/lib/simple_form.rb +340 -0
- metadata +109 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module SimpleForm
|
|
3
|
+
module Wrappers
|
|
4
|
+
# A wrapper is an object that holds several components and render them.
|
|
5
|
+
# A component may be any object that responds to `render`.
|
|
6
|
+
# This API allows inputs/components to be easily wrapped, removing the
|
|
7
|
+
# need to modify the code only to wrap input in an extra tag.
|
|
8
|
+
#
|
|
9
|
+
# `Many` represents a wrapper around several components at the same time.
|
|
10
|
+
# It may optionally receive a namespace, allowing it to be configured
|
|
11
|
+
# on demand on input generation.
|
|
12
|
+
class Many
|
|
13
|
+
attr_reader :namespace, :defaults, :components
|
|
14
|
+
|
|
15
|
+
def initialize(namespace, components, defaults = {})
|
|
16
|
+
@namespace = namespace
|
|
17
|
+
@components = components
|
|
18
|
+
@defaults = defaults
|
|
19
|
+
@defaults[:tag] = :div unless @defaults.key?(:tag)
|
|
20
|
+
@defaults[:class] = Array(@defaults[:class])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def render(input)
|
|
24
|
+
content = "".html_safe
|
|
25
|
+
options = input.options
|
|
26
|
+
|
|
27
|
+
components.each do |component|
|
|
28
|
+
next if options[component.namespace] == false
|
|
29
|
+
rendered = component.render(input)
|
|
30
|
+
content.safe_concat rendered.to_s if rendered
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
wrap(input, options, content)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def find(name)
|
|
37
|
+
return self if namespace == name
|
|
38
|
+
|
|
39
|
+
@components.each do |c|
|
|
40
|
+
if c.is_a?(Symbol)
|
|
41
|
+
return nil if c == namespace
|
|
42
|
+
elsif value = c.find(name)
|
|
43
|
+
return value
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def wrap(input, options, content)
|
|
53
|
+
return content if options[namespace] == false
|
|
54
|
+
return if defaults[:unless_blank] && content.empty?
|
|
55
|
+
|
|
56
|
+
tag = (namespace && options[:"#{namespace}_tag"]) || @defaults[:tag]
|
|
57
|
+
return content unless tag
|
|
58
|
+
|
|
59
|
+
klass = html_classes(input, options)
|
|
60
|
+
opts = html_options(options)
|
|
61
|
+
opts[:class] = (klass << opts[:class]).join(' ').strip unless klass.empty?
|
|
62
|
+
input.template.content_tag(tag, content, opts)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def html_options(options)
|
|
66
|
+
(@defaults[:html] || {}).merge(options[:"#{namespace}_html"] || {})
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def html_classes(input, options)
|
|
70
|
+
@defaults[:class].dup
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module SimpleForm
|
|
3
|
+
module Wrappers
|
|
4
|
+
# `Root` is the root wrapper for all components. It is special cased to
|
|
5
|
+
# always have a namespace and to add special html classes.
|
|
6
|
+
class Root < Many
|
|
7
|
+
attr_reader :options
|
|
8
|
+
|
|
9
|
+
def initialize(*args)
|
|
10
|
+
super(:wrapper, *args)
|
|
11
|
+
@options = @defaults.except(:tag, :class, :error_class, :hint_class)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def render(input)
|
|
15
|
+
input.options.reverse_merge!(@options)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Provide a fallback if name cannot be found.
|
|
20
|
+
def find(name)
|
|
21
|
+
super || SimpleForm::Wrappers::Many.new(name, [Leaf.new(name)])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def html_classes(input, options)
|
|
27
|
+
css = options[:wrapper_class] ? Array(options[:wrapper_class]) : @defaults[:class]
|
|
28
|
+
css += SimpleForm.additional_classes_for(:wrapper) do
|
|
29
|
+
input.additional_classes + [input.input_class]
|
|
30
|
+
end
|
|
31
|
+
css << html_class(:error_class, options) { input.has_errors? }
|
|
32
|
+
css << html_class(:hint_class, options) { input.has_hint? }
|
|
33
|
+
css << html_class(:valid_class, options) { input.valid? }
|
|
34
|
+
css.compact
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def html_class(key, options)
|
|
38
|
+
css = (options[:"wrapper_#{key}"] || @defaults[key])
|
|
39
|
+
css if css && yield
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module SimpleForm
|
|
3
|
+
module Wrappers
|
|
4
|
+
# `Single` is an optimization for a wrapper that has only one component.
|
|
5
|
+
class Single < Many
|
|
6
|
+
def initialize(name, wrapper_options = {}, options = {})
|
|
7
|
+
@component = Leaf.new(name, options)
|
|
8
|
+
|
|
9
|
+
super(name, [@component], wrapper_options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def render(input)
|
|
13
|
+
options = input.options
|
|
14
|
+
if options[namespace] != false
|
|
15
|
+
content = @component.render(input)
|
|
16
|
+
wrap(input, options, content) if content
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def html_options(options)
|
|
23
|
+
%i[label input].include?(namespace) ? {} : super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module SimpleForm
|
|
3
|
+
module Wrappers
|
|
4
|
+
autoload :Builder, 'simple_form/wrappers/builder'
|
|
5
|
+
autoload :Many, 'simple_form/wrappers/many'
|
|
6
|
+
autoload :Root, 'simple_form/wrappers/root'
|
|
7
|
+
autoload :Single, 'simple_form/wrappers/single'
|
|
8
|
+
autoload :Leaf, 'simple_form/wrappers/leaf'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'action_view'
|
|
3
|
+
require 'action_pack'
|
|
4
|
+
require 'simple_form/action_view_extensions/form_helper'
|
|
5
|
+
require 'simple_form/action_view_extensions/builder'
|
|
6
|
+
require 'active_support/core_ext/hash/slice'
|
|
7
|
+
require 'active_support/core_ext/hash/except'
|
|
8
|
+
require 'active_support/core_ext/hash/reverse_merge'
|
|
9
|
+
|
|
10
|
+
module SimpleForm
|
|
11
|
+
extend ActiveSupport::Autoload
|
|
12
|
+
|
|
13
|
+
autoload :Helpers
|
|
14
|
+
autoload :Wrappers
|
|
15
|
+
|
|
16
|
+
eager_autoload do
|
|
17
|
+
autoload :Components
|
|
18
|
+
autoload :ErrorNotification
|
|
19
|
+
autoload :FormBuilder
|
|
20
|
+
autoload :Inputs
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.eager_load!
|
|
24
|
+
super
|
|
25
|
+
SimpleForm::Inputs.eager_load!
|
|
26
|
+
SimpleForm::Components.eager_load!
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
CUSTOM_INPUT_DEPRECATION_WARN = <<-WARN
|
|
30
|
+
%{name} method now accepts a `wrapper_options` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from:
|
|
31
|
+
|
|
32
|
+
def %{name}
|
|
33
|
+
|
|
34
|
+
to
|
|
35
|
+
|
|
36
|
+
def %{name}(wrapper_options)
|
|
37
|
+
|
|
38
|
+
See https://github.com/heartcombo/simple_form/pull/997 for more information.
|
|
39
|
+
WARN
|
|
40
|
+
|
|
41
|
+
FILE_METHODS_DEPRECATION_WARN = <<-WARN
|
|
42
|
+
[SIMPLE_FORM] SimpleForm.file_methods is deprecated and has no effect.
|
|
43
|
+
|
|
44
|
+
Since version 5, Simple Form now supports automatically discover of file inputs for the following Gems: activestorage, carrierwave, paperclip, refile and shrine.
|
|
45
|
+
If you are using a custom method that is not from one of the supported Gems, please change your forms to pass the input type explicitly:
|
|
46
|
+
|
|
47
|
+
<%= form.input :avatar, as: :file %>
|
|
48
|
+
|
|
49
|
+
See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-form-cve-2019-16676 for more information.
|
|
50
|
+
WARN
|
|
51
|
+
|
|
52
|
+
@@configured = false
|
|
53
|
+
|
|
54
|
+
def self.configured? #:nodoc:
|
|
55
|
+
@@configured
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.deprecator
|
|
59
|
+
@deprecator ||= ActiveSupport::Deprecation.new("5.3", "SimpleForm")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
## CONFIGURATION OPTIONS
|
|
63
|
+
|
|
64
|
+
# Method used to tidy up errors.
|
|
65
|
+
mattr_accessor :error_method
|
|
66
|
+
@@error_method = :first
|
|
67
|
+
|
|
68
|
+
# Default tag used for error notification helper.
|
|
69
|
+
mattr_accessor :error_notification_tag
|
|
70
|
+
@@error_notification_tag = :p
|
|
71
|
+
|
|
72
|
+
# CSS class to add for error notification helper.
|
|
73
|
+
mattr_accessor :error_notification_class
|
|
74
|
+
@@error_notification_class = :error_notification
|
|
75
|
+
|
|
76
|
+
# Series of attempts to detect a default label method for collection.
|
|
77
|
+
mattr_accessor :collection_label_methods
|
|
78
|
+
@@collection_label_methods = %i[to_label name title to_s]
|
|
79
|
+
|
|
80
|
+
# Series of attempts to detect a default value method for collection.
|
|
81
|
+
mattr_accessor :collection_value_methods
|
|
82
|
+
@@collection_value_methods = %i[id to_s]
|
|
83
|
+
|
|
84
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
|
85
|
+
mattr_accessor :collection_wrapper_tag
|
|
86
|
+
@@collection_wrapper_tag = nil
|
|
87
|
+
|
|
88
|
+
# You can define the class to use on all collection wrappers, defaulting to none.
|
|
89
|
+
mattr_accessor :collection_wrapper_class
|
|
90
|
+
@@collection_wrapper_class = nil
|
|
91
|
+
|
|
92
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
|
93
|
+
# defaulting to span. Please note that when using :boolean_style = :nested,
|
|
94
|
+
# SimpleForm will force this option to be a :label.
|
|
95
|
+
mattr_accessor :item_wrapper_tag
|
|
96
|
+
@@item_wrapper_tag = :span
|
|
97
|
+
|
|
98
|
+
# You can define the class to use on all item wrappers, defaulting to none.
|
|
99
|
+
mattr_accessor :item_wrapper_class
|
|
100
|
+
@@item_wrapper_class = nil
|
|
101
|
+
|
|
102
|
+
# How the label text should be generated altogether with the required text.
|
|
103
|
+
mattr_accessor :label_text
|
|
104
|
+
@@label_text = ->(label, required, explicit_label) { "#{required} #{label}" }
|
|
105
|
+
|
|
106
|
+
# You can define the class to be used on all labels. Defaults to none.
|
|
107
|
+
mattr_accessor :label_class
|
|
108
|
+
@@label_class = nil
|
|
109
|
+
|
|
110
|
+
# Define the way to render check boxes / radio buttons with labels.
|
|
111
|
+
# inline: input + label (default)
|
|
112
|
+
# nested: label > input
|
|
113
|
+
mattr_accessor :boolean_style
|
|
114
|
+
@@boolean_style = :inline
|
|
115
|
+
|
|
116
|
+
# DEPRECATED: You can define the class to be used on all forms. Default is
|
|
117
|
+
# simple_form.
|
|
118
|
+
mattr_reader :form_class
|
|
119
|
+
@@form_class = :simple_form
|
|
120
|
+
|
|
121
|
+
# You can define the default class to be used on all forms. Can be overridden
|
|
122
|
+
# with `html: { :class }`. Defaults to none.
|
|
123
|
+
mattr_accessor :default_form_class
|
|
124
|
+
@@default_form_class = nil
|
|
125
|
+
|
|
126
|
+
# You can define which elements should obtain additional classes.
|
|
127
|
+
mattr_accessor :generate_additional_classes_for
|
|
128
|
+
@@generate_additional_classes_for = %i[wrapper label input]
|
|
129
|
+
|
|
130
|
+
# Whether attributes are required by default or not.
|
|
131
|
+
mattr_accessor :required_by_default
|
|
132
|
+
@@required_by_default = true
|
|
133
|
+
|
|
134
|
+
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
|
135
|
+
mattr_accessor :browser_validations
|
|
136
|
+
@@browser_validations = true
|
|
137
|
+
|
|
138
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
|
139
|
+
# to match as key, and the input type that will be used when the field name
|
|
140
|
+
# matches the regexp as value, such as { /count/ => :integer }.
|
|
141
|
+
mattr_accessor :input_mappings
|
|
142
|
+
@@input_mappings = nil
|
|
143
|
+
|
|
144
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
|
145
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
|
146
|
+
# e.g { string: :string_wrapper, boolean: :boolean_wrapper }
|
|
147
|
+
# You can also set a wrapper mapping per form basis.
|
|
148
|
+
# e.g simple_form_for(@foo, wrapper_mappings: { check_boxes: :bootstrap_checkbox })
|
|
149
|
+
mattr_accessor :wrapper_mappings
|
|
150
|
+
@@wrapper_mappings = nil
|
|
151
|
+
|
|
152
|
+
# Namespaces where SimpleForm should look for custom input classes that override
|
|
153
|
+
# default inputs. Namespaces are given as string to allow lazy loading inputs.
|
|
154
|
+
# e.g. config.custom_inputs_namespaces << "CustomInputs"
|
|
155
|
+
# will try to find CustomInputs::NumericInput when an :integer
|
|
156
|
+
# field is called.
|
|
157
|
+
mattr_accessor :custom_inputs_namespaces
|
|
158
|
+
@@custom_inputs_namespaces = []
|
|
159
|
+
|
|
160
|
+
# Default priority for time_zone inputs.
|
|
161
|
+
mattr_accessor :time_zone_priority
|
|
162
|
+
@@time_zone_priority = nil
|
|
163
|
+
|
|
164
|
+
# Default priority for country inputs.
|
|
165
|
+
mattr_accessor :country_priority
|
|
166
|
+
@@country_priority = nil
|
|
167
|
+
|
|
168
|
+
# When off, do not use translations in labels. Disabling translation in
|
|
169
|
+
# hints and placeholders can be done manually in the wrapper API.
|
|
170
|
+
mattr_accessor :translate_labels
|
|
171
|
+
@@translate_labels = true
|
|
172
|
+
|
|
173
|
+
# Automatically discover new inputs in Rails' autoload path.
|
|
174
|
+
mattr_accessor :inputs_discovery
|
|
175
|
+
@@inputs_discovery = true
|
|
176
|
+
|
|
177
|
+
# Cache SimpleForm inputs discovery.
|
|
178
|
+
mattr_accessor :cache_discovery
|
|
179
|
+
@@cache_discovery = defined?(Rails.env) && !Rails.env.development?
|
|
180
|
+
|
|
181
|
+
# Adds a class to each generated button, mostly for compatibility.
|
|
182
|
+
mattr_accessor :button_class
|
|
183
|
+
@@button_class = 'button'
|
|
184
|
+
|
|
185
|
+
# Override the default ActiveModelHelper behaviour of wrapping the input.
|
|
186
|
+
# This gets taken care of semantically by adding an error class to the wrapper tag
|
|
187
|
+
# containing the input.
|
|
188
|
+
mattr_accessor :field_error_proc
|
|
189
|
+
@@field_error_proc = proc do |html_tag, instance_tag|
|
|
190
|
+
html_tag
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Adds a class to each generated inputs
|
|
194
|
+
mattr_accessor :input_class
|
|
195
|
+
@@input_class = nil
|
|
196
|
+
|
|
197
|
+
# Defines if an input wrapper class should be included or not
|
|
198
|
+
mattr_accessor :include_default_input_wrapper_class
|
|
199
|
+
@@include_default_input_wrapper_class = true
|
|
200
|
+
|
|
201
|
+
# Define the default class of the input wrapper of the boolean input.
|
|
202
|
+
mattr_accessor :boolean_label_class
|
|
203
|
+
@@boolean_label_class = 'checkbox'
|
|
204
|
+
|
|
205
|
+
## WRAPPER CONFIGURATION
|
|
206
|
+
# The default wrapper to be used by the FormBuilder.
|
|
207
|
+
mattr_accessor :default_wrapper
|
|
208
|
+
@@default_wrapper = :default
|
|
209
|
+
@@wrappers = {} #:nodoc:
|
|
210
|
+
|
|
211
|
+
mattr_accessor :i18n_scope
|
|
212
|
+
@@i18n_scope = 'simple_form'
|
|
213
|
+
|
|
214
|
+
mattr_accessor :input_field_error_class
|
|
215
|
+
@@input_field_error_class = nil
|
|
216
|
+
|
|
217
|
+
mattr_accessor :input_field_valid_class
|
|
218
|
+
@@input_field_valid_class = nil
|
|
219
|
+
|
|
220
|
+
# Retrieves a given wrapper
|
|
221
|
+
def self.wrapper(name)
|
|
222
|
+
@@wrappers[name.to_s] or raise WrapperNotFound, "Couldn't find wrapper with name #{name}"
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Raised when fails to find a given wrapper name
|
|
226
|
+
class WrapperNotFound < StandardError
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Define a new wrapper using SimpleForm::Wrappers::Builder
|
|
230
|
+
# and store it in the given name.
|
|
231
|
+
def self.wrappers(*args, &block)
|
|
232
|
+
if block_given?
|
|
233
|
+
options = args.extract_options!
|
|
234
|
+
name = args.first || :default
|
|
235
|
+
@@wrappers[name.to_s] = build(options, &block)
|
|
236
|
+
else
|
|
237
|
+
@@wrappers
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Builds a new wrapper using SimpleForm::Wrappers::Builder.
|
|
242
|
+
def self.build(options = {})
|
|
243
|
+
options[:tag] = :div if options[:tag].nil?
|
|
244
|
+
builder = SimpleForm::Wrappers::Builder.new(options)
|
|
245
|
+
yield builder
|
|
246
|
+
SimpleForm::Wrappers::Root.new(builder.to_a, options)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
wrappers class: :input, hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
|
|
250
|
+
b.use :html5
|
|
251
|
+
|
|
252
|
+
b.use :min_max
|
|
253
|
+
b.use :maxlength
|
|
254
|
+
b.use :minlength
|
|
255
|
+
b.use :placeholder
|
|
256
|
+
b.optional :pattern
|
|
257
|
+
b.optional :readonly
|
|
258
|
+
|
|
259
|
+
b.use :label_input
|
|
260
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
|
261
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def self.additional_classes_for(component)
|
|
265
|
+
generate_additional_classes_for.include?(component) ? yield : []
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
## SETUP
|
|
269
|
+
|
|
270
|
+
def self.default_input_size=(*)
|
|
271
|
+
SimpleForm.deprecator.warn "[SIMPLE_FORM] SimpleForm.default_input_size= is deprecated and has no effect", caller
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def self.form_class=(value)
|
|
275
|
+
SimpleForm.deprecator.warn "[SIMPLE_FORM] SimpleForm.form_class= is deprecated and will be removed in 4.x. Use SimpleForm.default_form_class= instead", caller
|
|
276
|
+
@@form_class = value
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def self.file_methods=(file_methods)
|
|
280
|
+
SimpleForm.deprecator.warn(FILE_METHODS_DEPRECATION_WARN, caller)
|
|
281
|
+
@@file_methods = file_methods
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def self.file_methods
|
|
285
|
+
SimpleForm.deprecator.warn(FILE_METHODS_DEPRECATION_WARN, caller)
|
|
286
|
+
@@file_methods
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Default way to setup Simple Form. Run rails generate simple_form:install
|
|
290
|
+
# to create a fresh initializer with all configuration values.
|
|
291
|
+
def self.setup
|
|
292
|
+
@@configured = true
|
|
293
|
+
yield self
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Includes a component to be used by Simple Form. Methods defined in a
|
|
297
|
+
# component will be exposed to be used in the wrapper as Simple::Components
|
|
298
|
+
#
|
|
299
|
+
# Examples
|
|
300
|
+
#
|
|
301
|
+
# # The application needs to tell where the components will be.
|
|
302
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
|
303
|
+
#
|
|
304
|
+
# # Create a custom component in the path specified above.
|
|
305
|
+
# # lib/components/input_group_component.rb
|
|
306
|
+
# module InputGroupComponent
|
|
307
|
+
# def prepend
|
|
308
|
+
# ...
|
|
309
|
+
# end
|
|
310
|
+
#
|
|
311
|
+
# def append
|
|
312
|
+
# ...
|
|
313
|
+
# end
|
|
314
|
+
# end
|
|
315
|
+
#
|
|
316
|
+
# SimpleForm.setup do |config|
|
|
317
|
+
# # Create a wrapper using the custom component.
|
|
318
|
+
# config.wrappers :input_group, tag: :div, error_class: :error do |b|
|
|
319
|
+
# b.use :label
|
|
320
|
+
# b.optional :prepend
|
|
321
|
+
# b.use :input
|
|
322
|
+
# b.use :append
|
|
323
|
+
# end
|
|
324
|
+
# end
|
|
325
|
+
#
|
|
326
|
+
# # Using the custom component in the form.
|
|
327
|
+
# <%= simple_form_for @blog, wrapper: input_group do |f| %>
|
|
328
|
+
# <%= f.input :title, prepend: true %>
|
|
329
|
+
# <% end %>
|
|
330
|
+
#
|
|
331
|
+
def self.include_component(component)
|
|
332
|
+
if Module === component
|
|
333
|
+
SimpleForm::Inputs::Base.include(component)
|
|
334
|
+
else
|
|
335
|
+
raise TypeError, "SimpleForm.include_component expects a module but got: #{component.class}"
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
require 'simple_form/railtie' if defined?(Rails)
|
metadata
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mini-sharp-mod
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on simple_form
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- mini-sharp-mod.gemspec
|
|
20
|
+
- simple_form-5.4.1/CHANGELOG.md
|
|
21
|
+
- simple_form-5.4.1/MIT-LICENSE
|
|
22
|
+
- simple_form-5.4.1/README.md
|
|
23
|
+
- simple_form-5.4.1/lib/generators/simple_form/USAGE
|
|
24
|
+
- simple_form-5.4.1/lib/generators/simple_form/install_generator.rb
|
|
25
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/README
|
|
26
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.erb
|
|
27
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.haml
|
|
28
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.slim
|
|
29
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form.rb
|
|
30
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
|
|
31
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
|
|
32
|
+
- simple_form-5.4.1/lib/generators/simple_form/templates/config/locales/simple_form.en.yml
|
|
33
|
+
- simple_form-5.4.1/lib/simple_form.rb
|
|
34
|
+
- simple_form-5.4.1/lib/simple_form/action_view_extensions/builder.rb
|
|
35
|
+
- simple_form-5.4.1/lib/simple_form/action_view_extensions/form_helper.rb
|
|
36
|
+
- simple_form-5.4.1/lib/simple_form/components.rb
|
|
37
|
+
- simple_form-5.4.1/lib/simple_form/components/errors.rb
|
|
38
|
+
- simple_form-5.4.1/lib/simple_form/components/hints.rb
|
|
39
|
+
- simple_form-5.4.1/lib/simple_form/components/html5.rb
|
|
40
|
+
- simple_form-5.4.1/lib/simple_form/components/label_input.rb
|
|
41
|
+
- simple_form-5.4.1/lib/simple_form/components/labels.rb
|
|
42
|
+
- simple_form-5.4.1/lib/simple_form/components/maxlength.rb
|
|
43
|
+
- simple_form-5.4.1/lib/simple_form/components/min_max.rb
|
|
44
|
+
- simple_form-5.4.1/lib/simple_form/components/minlength.rb
|
|
45
|
+
- simple_form-5.4.1/lib/simple_form/components/pattern.rb
|
|
46
|
+
- simple_form-5.4.1/lib/simple_form/components/placeholders.rb
|
|
47
|
+
- simple_form-5.4.1/lib/simple_form/components/readonly.rb
|
|
48
|
+
- simple_form-5.4.1/lib/simple_form/error_notification.rb
|
|
49
|
+
- simple_form-5.4.1/lib/simple_form/form_builder.rb
|
|
50
|
+
- simple_form-5.4.1/lib/simple_form/helpers.rb
|
|
51
|
+
- simple_form-5.4.1/lib/simple_form/helpers/autofocus.rb
|
|
52
|
+
- simple_form-5.4.1/lib/simple_form/helpers/disabled.rb
|
|
53
|
+
- simple_form-5.4.1/lib/simple_form/helpers/readonly.rb
|
|
54
|
+
- simple_form-5.4.1/lib/simple_form/helpers/required.rb
|
|
55
|
+
- simple_form-5.4.1/lib/simple_form/helpers/validators.rb
|
|
56
|
+
- simple_form-5.4.1/lib/simple_form/inputs.rb
|
|
57
|
+
- simple_form-5.4.1/lib/simple_form/inputs/base.rb
|
|
58
|
+
- simple_form-5.4.1/lib/simple_form/inputs/block_input.rb
|
|
59
|
+
- simple_form-5.4.1/lib/simple_form/inputs/boolean_input.rb
|
|
60
|
+
- simple_form-5.4.1/lib/simple_form/inputs/collection_check_boxes_input.rb
|
|
61
|
+
- simple_form-5.4.1/lib/simple_form/inputs/collection_input.rb
|
|
62
|
+
- simple_form-5.4.1/lib/simple_form/inputs/collection_radio_buttons_input.rb
|
|
63
|
+
- simple_form-5.4.1/lib/simple_form/inputs/collection_select_input.rb
|
|
64
|
+
- simple_form-5.4.1/lib/simple_form/inputs/color_input.rb
|
|
65
|
+
- simple_form-5.4.1/lib/simple_form/inputs/date_time_input.rb
|
|
66
|
+
- simple_form-5.4.1/lib/simple_form/inputs/file_input.rb
|
|
67
|
+
- simple_form-5.4.1/lib/simple_form/inputs/grouped_collection_select_input.rb
|
|
68
|
+
- simple_form-5.4.1/lib/simple_form/inputs/hidden_input.rb
|
|
69
|
+
- simple_form-5.4.1/lib/simple_form/inputs/numeric_input.rb
|
|
70
|
+
- simple_form-5.4.1/lib/simple_form/inputs/password_input.rb
|
|
71
|
+
- simple_form-5.4.1/lib/simple_form/inputs/priority_input.rb
|
|
72
|
+
- simple_form-5.4.1/lib/simple_form/inputs/range_input.rb
|
|
73
|
+
- simple_form-5.4.1/lib/simple_form/inputs/rich_text_area_input.rb
|
|
74
|
+
- simple_form-5.4.1/lib/simple_form/inputs/string_input.rb
|
|
75
|
+
- simple_form-5.4.1/lib/simple_form/inputs/text_input.rb
|
|
76
|
+
- simple_form-5.4.1/lib/simple_form/inputs/weekday_input.rb
|
|
77
|
+
- simple_form-5.4.1/lib/simple_form/map_type.rb
|
|
78
|
+
- simple_form-5.4.1/lib/simple_form/railtie.rb
|
|
79
|
+
- simple_form-5.4.1/lib/simple_form/tags.rb
|
|
80
|
+
- simple_form-5.4.1/lib/simple_form/version.rb
|
|
81
|
+
- simple_form-5.4.1/lib/simple_form/wrappers.rb
|
|
82
|
+
- simple_form-5.4.1/lib/simple_form/wrappers/builder.rb
|
|
83
|
+
- simple_form-5.4.1/lib/simple_form/wrappers/leaf.rb
|
|
84
|
+
- simple_form-5.4.1/lib/simple_form/wrappers/many.rb
|
|
85
|
+
- simple_form-5.4.1/lib/simple_form/wrappers/root.rb
|
|
86
|
+
- simple_form-5.4.1/lib/simple_form/wrappers/single.rb
|
|
87
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
88
|
+
licenses:
|
|
89
|
+
- MIT
|
|
90
|
+
metadata:
|
|
91
|
+
source_code_uri: https://github.com/Andrey78/mini-sharp-mod
|
|
92
|
+
rdoc_options: []
|
|
93
|
+
require_paths:
|
|
94
|
+
- lib
|
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
requirements: []
|
|
106
|
+
rubygems_version: 3.6.2
|
|
107
|
+
specification_version: 4
|
|
108
|
+
summary: Research test
|
|
109
|
+
test_files: []
|