diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e72de..0f52fad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed * [BREAKING] The API of Flowbite::InputField::RadioButton now follows the same structure as the other components for hints. Instead of passing a String (`hint: "This is the hint"`) you now have to pass a Hash that's passed along to the Hint component (i.e. `hint: {content: "This is the hint"}`), allowing you to customize other options (eg HTML attributes like class) as well. +* [BREAKING] Flowbite::Input::Field has been renamed to Flowbite::Input. All individual input components now use that as their superclass. This matches the class hierarchy of Flowbite::InputField::* classes better and allows Flowbite::Input to automagically appear in the documentation. ### Fixed diff --git a/app/components/flowbite/input.rb b/app/components/flowbite/input.rb new file mode 100644 index 0000000..2a84b6b --- /dev/null +++ b/app/components/flowbite/input.rb @@ -0,0 +1,152 @@ +# frozen_string_literal: true + +module Flowbite + # The individual input form element used in forms - without labels, error + # messages, hints, etc. + # + # Use this when you want to render an input field on its own without any + # surrounding elements, i.e. as a building block in more complex input + # components. + # + # To render a complete input field with labels and error messages, use + # {Flowbite::InputField} instead. + # + # By default this renders a text input field. To render other types of input + # fields, use one of the subclasses, such as {Flowbite::Input::Checkbox} or + # {Flowbite::Input::Textarea}. + class Input < ViewComponent::Base + SIZES = { + sm: ["px-2.5", "py-2", "text-sm"], + default: ["px-3", "py-2.5", "text-sm"], + lg: ["px-3.5", "py-3", "text-base"] + }.freeze + + STATES = [ + DEFAULT = :default, + DISABLED = :disabled, + ERROR = :error + ].freeze + + attr_reader :options, :size, :style + + class << self + # @return [Array] The CSS classes to apply to the input field + # given the specified +size+, +state+, and +style+. + def classes(size: :default, state: :default, style: :default) + style = styles.fetch(style) + state_classes = style.fetch(state) + state_classes + sizes.fetch(size) + end + + # Returns the sizes this Input supports. + # + # This is effectively the {SIZES} constant, but provided as a method to + # return the constant from the current class, not the superclass. + # + # @return [Hash] A hash mapping size names to their corresponding CSS + # classes. + def sizes + const_get(:SIZES) + end + + # @return [Flowbite::Styles] The available styles for this input field. + def styles + # rubocop:disable Layout/LineLength + Flowbite::Styles.from_hash( + { + default: { + default: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-heading", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "placeholder:text-body"], + disabled: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-fg-disabled", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "cursor-not-allowed", "placeholder:text-fg-disabled"], + error: ["bg-danger-soft", "border", "border-danger-subtle", "text-fg-danger-strong", "rounded-base", "focus:ring-danger", "focus:border-danger", "block", "w-full", "shadow-xs", "placeholder:text-fg-danger-strong"] + } + }.freeze + ) + # rubocop:enable Layout/LineLength + end + end + + # @param attribute [Symbol] The attribute on the form's object this input + # field is for. + # + # @param form [ActionView::Helpers::FormBuilder] The form builder this + # input field is part of. + # + # @param class [String, Array] Additional CSS classes to apply to + # the input field. + # + # @param disabled [Boolean] Whether the input field should be disabled. + # + # @param options [Hash] Additional HTML attributes to pass to the input + # field. For example, you can use this to set placeholder text by + # passing +options: {placeholder: "Enter your name"}+ + # + # @param size [Symbol] The size of the input field. Can be one of +:sm+, + # +:default+, or +:lg+. + def initialize(attribute:, form:, class: nil, disabled: false, options: {}, size: :default) + @attribute = attribute + @class = Array.wrap(binding.local_variable_get(:class)) + @disabled = disabled + @form = form + @options = options || {} + @object = form.object + @size = size + end + + # Returns the HTML to use for the actual input field element. + def call + @form.send( + input_field_type, + @attribute, + **input_options + ) + end + + # Returns the CSS classes to apply to the input field + # + # @return [Array] An array of CSS classes. + def classes + self.class.classes(size: size, state: state) + @class + end + + # Returns the name of the method used to generate HTML for the input field + # + # @return [Symbol] The form helper method name to call on +form+. + def input_field_type + :text_field + end + + protected + + # @return [Boolean] Returns true if the field is disabled + def disabled? + !!@disabled + end + + # Returns true if the object has errors. Returns false if there is no + # object. + # + # @return [Boolean] true if there are errors, false otherwise. + def errors? + return false unless @object + + @object.errors.include?(@attribute.intern) + end + + private + + # Returns the options argument for the input field + def input_options + { + class: classes, + disabled: disabled? + }.merge(options) + end + + def state + return DISABLED if disabled? + return ERROR if errors? + + DEFAULT + end + end +end diff --git a/app/components/flowbite/input/checkbox.rb b/app/components/flowbite/input/checkbox.rb index 0f38f0d..7721519 100644 --- a/app/components/flowbite/input/checkbox.rb +++ b/app/components/flowbite/input/checkbox.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true module Flowbite - module Input + class Input # The checkbox component can be used to receive one or more selected options # from the user in the form of a square box available in multiple styles, # sizes, colors, and variants coded with the utility classes from Tailwind # CSS and with support for dark mode. # # https://flowbite.com/docs/forms/checkbox/ - class Checkbox < Field + class Checkbox < Input DEFAULT_CHECKED_VALUE = "1" DEFAULT_UNCHECKED_VALUE = "0" diff --git a/app/components/flowbite/input/date.rb b/app/components/flowbite/input/date.rb index 749d764..f27621e 100644 --- a/app/components/flowbite/input/date.rb +++ b/app/components/flowbite/input/date.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Date < Field + class Input + class Date < Input def input_field_type :date_field end diff --git a/app/components/flowbite/input/date_time.rb b/app/components/flowbite/input/date_time.rb index 93f551a..404a81c 100644 --- a/app/components/flowbite/input/date_time.rb +++ b/app/components/flowbite/input/date_time.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class DateTime < Field + class Input + class DateTime < Input def input_field_type :datetime_field end diff --git a/app/components/flowbite/input/email.rb b/app/components/flowbite/input/email.rb index 066e1e7..beabb4a 100644 --- a/app/components/flowbite/input/email.rb +++ b/app/components/flowbite/input/email.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Email < Field + class Input + class Email < Input # Returns the name of the method used to generate HTML for the input field def input_field_type :email_field diff --git a/app/components/flowbite/input/field.rb b/app/components/flowbite/input/field.rb deleted file mode 100644 index 2cc1c6a..0000000 --- a/app/components/flowbite/input/field.rb +++ /dev/null @@ -1,154 +0,0 @@ -# frozen_string_literal: true - -module Flowbite - module Input - # The individual input form element used in forms - without labels, error - # messages, hints, etc. - # - # Use this when you want to render an input field on its own without any - # surrounding elements, i.e. as a building block in more complex input - # components. - # - # To render a complete input field with labels and error messages, use - # {Flowbite::InputField} instead. - # - # By default this renders a text input field. To render other types of input - # fields, use one of the subclasses, such as {Flowbite::Input::Checkbox} or - # {Flowbite::Input::Textarea}. - class Field < ViewComponent::Base - SIZES = { - sm: ["px-2.5", "py-2", "text-sm"], - default: ["px-3", "py-2.5", "text-sm"], - lg: ["px-3.5", "py-3", "text-base"] - }.freeze - - STATES = [ - DEFAULT = :default, - DISABLED = :disabled, - ERROR = :error - ].freeze - - attr_reader :options, :size, :style - - class << self - # @return [Array] The CSS classes to apply to the input field - # given the specified +size+, +state+, and +style+. - def classes(size: :default, state: :default, style: :default) - style = styles.fetch(style) - state_classes = style.fetch(state) - state_classes + sizes.fetch(size) - end - - # Returns the sizes this Field supports. - # - # This is effectively the {SIZES} constant, but provided as a method to - # return the constant from the current class, not the superclass. - # - # @return [Hash] A hash mapping size names to their corresponding CSS - # classes. - def sizes - const_get(:SIZES) - end - - # @return [Flowbite::Styles] The available styles for this input field. - def styles - # rubocop:disable Layout/LineLength - Flowbite::Styles.from_hash( - { - default: { - default: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-heading", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "placeholder:text-body"], - disabled: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-fg-disabled", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "cursor-not-allowed", "placeholder:text-fg-disabled"], - error: ["bg-danger-soft", "border", "border-danger-subtle", "text-fg-danger-strong", "rounded-base", "focus:ring-danger", "focus:border-danger", "block", "w-full", "shadow-xs", "placeholder:text-fg-danger-strong"] - } - }.freeze - ) - # rubocop:enable Layout/LineLength - end - end - - # @param attribute [Symbol] The attribute on the form's object this input - # field is for. - # - # @param form [ActionView::Helpers::FormBuilder] The form builder this - # input field is part of. - # - # @param class [String, Array] Additional CSS classes to apply to - # the input field. - # - # @param disabled [Boolean] Whether the input field should be disabled. - # - # @param options [Hash] Additional HTML attributes to pass to the input - # field. For example, you can use this to set placeholder text by - # passing +options: {placeholder: "Enter your name"}+ - # - # @param size [Symbol] The size of the input field. Can be one of +:sm+, - # +:default+, or +:lg+. - def initialize(attribute:, form:, class: nil, disabled: false, options: {}, size: :default) - @attribute = attribute - @class = Array.wrap(binding.local_variable_get(:class)) - @disabled = disabled - @form = form - @options = options || {} - @object = form.object - @size = size - end - - # Returns the HTML to use for the actual input field element. - def call - @form.send( - input_field_type, - @attribute, - **input_options - ) - end - - # Returns the CSS classes to apply to the input field - # - # @return [Array] An array of CSS classes. - def classes - self.class.classes(size: size, state: state) + @class - end - - # Returns the name of the method used to generate HTML for the input field - # - # @return [Symbol] The form helper method name to call on +form+. - def input_field_type - :text_field - end - - protected - - # @return [Boolean] Returns true if the field is disabled - def disabled? - !!@disabled - end - - # Returns true if the object has errors. Returns false if there is no - # object. - # - # @return [Boolean] true if there are errors, false otherwise. - def errors? - return false unless @object - - @object.errors.include?(@attribute.intern) - end - - private - - # Returns the options argument for the input field - def input_options - { - class: classes, - disabled: disabled? - }.merge(options) - end - - def state - return DISABLED if disabled? - return ERROR if errors? - - DEFAULT - end - end - end -end diff --git a/app/components/flowbite/input/file.rb b/app/components/flowbite/input/file.rb index 77414a0..a1815be 100644 --- a/app/components/flowbite/input/file.rb +++ b/app/components/flowbite/input/file.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class File < Field + class Input + class File < Input SIZES = { sm: ["text-sm"], default: ["text-sm"], diff --git a/app/components/flowbite/input/hint.rb b/app/components/flowbite/input/hint.rb index 2189682..9e60cb2 100644 --- a/app/components/flowbite/input/hint.rb +++ b/app/components/flowbite/input/hint.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Flowbite - module Input + class Input # A hint element for input fields. # # Provides additional context or instructions for the user. diff --git a/app/components/flowbite/input/label.rb b/app/components/flowbite/input/label.rb index 817a783..c33b798 100644 --- a/app/components/flowbite/input/label.rb +++ b/app/components/flowbite/input/label.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Flowbite - module Input + class Input # https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-label class Label < ViewComponent::Base STATES = [ diff --git a/app/components/flowbite/input/number.rb b/app/components/flowbite/input/number.rb index 9e33232..52ff904 100644 --- a/app/components/flowbite/input/number.rb +++ b/app/components/flowbite/input/number.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Number < Field + class Input + class Number < Input def input_field_type :number_field end diff --git a/app/components/flowbite/input/password.rb b/app/components/flowbite/input/password.rb index c820f1f..5421afa 100644 --- a/app/components/flowbite/input/password.rb +++ b/app/components/flowbite/input/password.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Password < Field + class Input + class Password < Input def input_field_type :password_field end diff --git a/app/components/flowbite/input/phone.rb b/app/components/flowbite/input/phone.rb index 684b5d8..845c588 100644 --- a/app/components/flowbite/input/phone.rb +++ b/app/components/flowbite/input/phone.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Phone < Field + class Input + class Phone < Input def input_field_type :phone_field end diff --git a/app/components/flowbite/input/radio_button.rb b/app/components/flowbite/input/radio_button.rb index 3d2facc..8b41374 100644 --- a/app/components/flowbite/input/radio_button.rb +++ b/app/components/flowbite/input/radio_button.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true module Flowbite - module Input + class Input # The radio button component can be used to allow the user to choose a # single option from one or more available options. # # https://flowbite.com/docs/forms/radio/ - class RadioButton < Field + class RadioButton < Input class << self # Radio buttons only have their default size. def sizes diff --git a/app/components/flowbite/input/select.rb b/app/components/flowbite/input/select.rb index 9d03b58..e57a479 100644 --- a/app/components/flowbite/input/select.rb +++ b/app/components/flowbite/input/select.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true module Flowbite - module Input + class Input # The `Select` component renders a select input field for use in forms. # # https://flowbite.com/docs/forms/select/ # # Wraps `ActionView::Helpers::FormOptionsHelper#select`: https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select - class Select < Field + class Select < Input SIZES = { sm: ["px-2.5", "py-2", "text-sm"], default: ["px-3", "py-2.5", "text-sm"], diff --git a/app/components/flowbite/input/textarea.rb b/app/components/flowbite/input/textarea.rb index c29ff7e..f5743ca 100644 --- a/app/components/flowbite/input/textarea.rb +++ b/app/components/flowbite/input/textarea.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Textarea < Field + class Input + class Textarea < Input class << self # rubocop:disable Layout/LineLength def styles diff --git a/app/components/flowbite/input/url.rb b/app/components/flowbite/input/url.rb index b3be083..5b29640 100644 --- a/app/components/flowbite/input/url.rb +++ b/app/components/flowbite/input/url.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Flowbite - module Input - class Url < Field + class Input + class Url < Input # Returns the name of the method used to generate HTML for the input field def input_field_type :url_field diff --git a/app/components/flowbite/input/validation_error.rb b/app/components/flowbite/input/validation_error.rb index 887d23f..4543a55 100644 --- a/app/components/flowbite/input/validation_error.rb +++ b/app/components/flowbite/input/validation_error.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Flowbite - module Input + class Input class ValidationError < ViewComponent::Base class << self def classes(state: :default, style: :default) diff --git a/app/components/flowbite/input_field.rb b/app/components/flowbite/input_field.rb index d9cd34b..7b63f58 100644 --- a/app/components/flowbite/input_field.rb +++ b/app/components/flowbite/input_field.rb @@ -17,7 +17,7 @@ module Flowbite # {Flowbite::InputField::Email}, etc. # # To render an input without labels or error messages etc, see - # {Flowbite::Input::Field} instead and one of its subclasses. + # {Flowbite::Input} instead and one of its subclasses. # # @example Basic usage # @@ -58,7 +58,7 @@ module Flowbite # # @viewcomponent_slot [Flowbite::Input::Hint] hint Helper text displayed # below the input field to provide additional context or instructions. - # @viewcomponent_slot [Flowbite::Input::Field] input The input element itself. + # @viewcomponent_slot [Flowbite::Input] input The input element itself. # Usually auto-generated based on the input type subclass. # @viewcomponent_slot [Flowbite::Input::Label] label The label for the input # field, rendered above the input element. @@ -99,7 +99,7 @@ def errors # @param input [Hash] A hash with options for the input component. # These are passed to the input component's constructor, see the # documentation for whatever input component is being used. - # See {Flowbite::Input::Field}. + # See {Flowbite::Input}. # @option input [Hash] options Additional HTML attributes to pass to # the input element. # @@ -129,7 +129,7 @@ def initialize(attribute:, form:, class: nil, disabled: false, hint: nil, input: end def input_component - ::Flowbite::Input::Field + ::Flowbite::Input end protected diff --git a/demo/.yardoc/checksums b/demo/.yardoc/checksums index 5fde68c..d24145b 100644 --- a/demo/.yardoc/checksums +++ b/demo/.yardoc/checksums @@ -1,46 +1,46 @@ app/components/flowbite/card.rb fb108e57eb6e0ce250db89c409f3f79ed4e7fe70 app/components/flowbite/link.rb 7c83a929ccbe4035def17fe928aff4e042dc2999 +app/components/flowbite/input.rb 6fbe49459aa61f71e7fb72688372223189167ac7 app/components/flowbite/style.rb ef063360cc99cd7a6b8e67a7693326bb5dfb0e42 app/components/flowbite/toast.rb 20c14599e8a9f33cf36450edbad59b3dbeaf6bbd app/components/flowbite/button.rb 6ae7681d3b842d73aa99cddfa5a9b107ede7fea4 app/components/flowbite/styles.rb 929c42e428ba5a8e16efacaae0f35380e2f5f95c -app/components/flowbite/input/url.rb 2ad9461aaa799e0ce457279df1bd63641b845e95 -app/components/flowbite/breadcrumb.rb e04fc0fb7b5e845a95a80052cb2996ba5eb7a144 +app/components/flowbite/input/url.rb f1046824f9b06c8df8e0f567979321b82baac6fa +app/components/flowbite/breadcrumb.rb 95b9f165154d4a3e4029fe33b7663d7d7302ba98 app/components/flowbite/card/title.rb 8067aa1e027c725896b063b67364aecfbf2f7d4e -app/components/flowbite/input/date.rb 5b93e5b98eef5e6e54ef18e74c72fb8746bac48b -app/components/flowbite/input/file.rb fde42ca92377f212397f350cca288a9c80de7b8a -app/components/flowbite/input/hint.rb 2ecfb38cf362bd50c91a1891dbeaeed13ff03cb2 +app/components/flowbite/input/date.rb 3b47f26b5622267e772c0d42d37655336ddf0169 +app/components/flowbite/input/file.rb 538334cde553b4c74456716e35353c6c26467646 +app/components/flowbite/input/hint.rb 4a01c2838005d1b3f4ad165734199b7be3d9ae8f app/components/flowbite/toast/icon.rb 87333f4c5fb5fb0ab9797cbf54ab27f29c464f18 app/components/flowbite/button/pill.rb 5200da68b3fdd353db3780550b932f4037a7c999 -app/components/flowbite/input/email.rb 7d3756a7d20328231fea9b91b08ab246cc19b284 -app/components/flowbite/input/field.rb bbf3d364756265202e6d7a15d80d3b78635ff39c -app/components/flowbite/input/label.rb 315bf0397120f1ab77e41aa2482bf38af43dc218 -app/components/flowbite/input/phone.rb c6f0ef1f93a8b6e1a750a698ecfb38a0262836c1 -app/components/flowbite/input_field.rb cf76edc4cc9407eacb32db45d20b3c559abe4fb6 -app/components/flowbite/input/number.rb 90798faaf83afc96d880904e640c5ad3a4e53281 -app/components/flowbite/input/select.rb f2504afaac8a95b0350b7cd13217a36e37a7af9c +app/components/flowbite/input/email.rb c89f74f38cdefce5c05bac458b39d56a9ba4aa35 +app/components/flowbite/input/label.rb d71e843b267f35f10c3627e950408493a9afa97c +app/components/flowbite/input/phone.rb 0dfe3e9a83c4fb9f558405a20601649c7b08922a +app/components/flowbite/input_field.rb 4e6b2c2c744d54a8c645b31098a3aee60d402f43 +app/components/flowbite/input/number.rb a33580788ad91308b85955fdb44d37883329dd4e +app/components/flowbite/input/select.rb 9f1a6406efdda2e29d479117a35c2a924bd888c2 app/components/flowbite/button/outline.rb 2829cf352a03c00dd99a56a05181c4e1a6794d18 -app/components/flowbite/input/checkbox.rb 6102546a7d3ecc15d8365444c51b8236aea503a6 -app/components/flowbite/input/password.rb a25f6a942c51960bc4d2e1a5b3922e6bdaac64c0 -app/components/flowbite/input/textarea.rb 9acc6202df28909993fd984479af686f46da6f38 -app/components/flowbite/breadcrumb_item.rb d7e802764edce7341a279a0a50d2600a517e0f8c -app/components/flowbite/input/date_time.rb ac19cace72a0bca01064d96cdd0cacd791010170 +app/components/flowbite/input/checkbox.rb 500f109206a47997bf2bc0732399297a92005dc0 +app/components/flowbite/input/password.rb 39a4c2bb2684a0a310175307bd1bdfd9c99c6cd1 +app/components/flowbite/input/textarea.rb 538661583e03f489a7972e0ee0ed8a1852263933 +app/components/flowbite/breadcrumb/item.rb ffed2375fc8ae3adcddd5316ccce352d118f5048 +app/components/flowbite/input/date_time.rb bcab025ce4ddd5eeb83ead8692722e2e1c7bf57a app/components/flowbite/input_field/url.rb f996ebbec1d25ad845bc319185d6c26ffef8623f app/components/flowbite/input_field/date.rb aa5cc03287db78709f20d33d35eb0ddf7b8bcdc5 app/components/flowbite/input_field/file.rb b8aa76b7bc85279f1ca361e430048c87b602e5ff app/components/flowbite/input_field/text.rb c665255d76b903b5c4fba1dc843f4106a6318fd8 app/components/flowbite/input_field/email.rb 1f027480bcf14c93880c525d4a8bc00154b58f94 app/components/flowbite/input_field/phone.rb 6a3da98a2dded98b1c4d14c2419077fc9dec7dfd -app/components/flowbite/input/radio_button.rb 40ea73beb1d0fe939b29df1cee5a566966157b9e +app/components/flowbite/input/radio_button.rb 60ccac6862b459b89f9f3335246a51d83ae4af63 app/components/flowbite/input_field/number.rb 32dce4e2bb586f64229dc78b541700df829068c7 app/components/flowbite/input_field/select.rb 1f9788b5fff4be2b65184e73e739da8fa9de0264 app/components/flowbite/breadcrumb/home_icon.rb bd2e47a31a793a79f20bd792a2a7e2dd8094fc5d app/components/flowbite/input_field/checkbox.rb 4cbc6f541842838234189b383f813b164a06379b app/components/flowbite/input_field/password.rb 37e592f55f258cc4b81859d48763b9c0eff12f61 app/components/flowbite/input_field/textarea.rb 52626e199b25b723b4d5355028d6bc3d7a167cd1 -app/components/flowbite/breadcrumb_item/first.rb 329e12fe74148850c98d14d333bd94be95216f32 +app/components/flowbite/breadcrumb/item/first.rb 0d755f7f7fbf6980b4667b8b723d4dce94ca2224 app/components/flowbite/input_field/date_time.rb 0a17d49d70f3ba820fee0f8930115540f12d72e2 -app/components/flowbite/input/validation_error.rb 8536d2116ed276871df806e04a739218a01d62e7 -app/components/flowbite/breadcrumb_item/current.rb bcab74f021197c3286dff7d3ffb8528d676101bd +app/components/flowbite/input/validation_error.rb b6221a7a542136dc05d0053bda61061c7d4829d8 +app/components/flowbite/breadcrumb/item/current.rb 73551aac4b45f3045e14ccdc74187e419d099176 app/components/flowbite/input_field/radio_button.rb adc482ad312c4c16b206bb10e566e96d709a7a2f -app/components/flowbite/breadcrumb/separator_icon.rb 3196954c737ecb774ab8afbc71a59a83e89e87c1 +app/components/flowbite/breadcrumb/separator_icon.rb 8da534df60fe32aaf972515f0c2c0687cb770992 diff --git a/demo/.yardoc/object_types b/demo/.yardoc/object_types index 746653f..dbe993c 100644 Binary files a/demo/.yardoc/object_types and b/demo/.yardoc/object_types differ diff --git a/demo/.yardoc/objects/root.dat b/demo/.yardoc/objects/root.dat index af3a982..5abd3a7 100644 Binary files a/demo/.yardoc/objects/root.dat and b/demo/.yardoc/objects/root.dat differ diff --git a/test/components/input/field_test.rb b/test/components/input/field_test.rb index 101d8d7..fa0d84b 100644 --- a/test/components/input/field_test.rb +++ b/test/components/input/field_test.rb @@ -2,7 +2,7 @@ require "support/models" -class Flowbite::Input::FieldTest < Minitest::Test +class Flowbite::InputTest < Minitest::Test include ViewComponent::TestHelpers def setup @@ -12,14 +12,14 @@ def setup end def test_renders_a_text_input - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title)) assert_component_rendered assert_selector("input[type='text'][name='book[title]'][value='The Great Gatsby']") end def test_renders_with_default_state - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title)) assert_component_rendered assert_selector("input[name='book[title]'].border-default-medium") @@ -27,42 +27,42 @@ def test_renders_with_default_state def test_renders_in_error_state @book.errors.add(:title, :invalid) - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title)) assert_component_rendered assert_selector("input[name='book[title]'].border-danger-subtle") end def test_renders_in_disabled_state - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title, disabled: true)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title, disabled: true)) assert_component_rendered assert_selector("input[name='book[title]'][disabled].bg-neutral-secondary-medium.border.border-default-medium.text-fg-disabled.cursor-not-allowed") end def test_renders_with_sm_size - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title, size: :sm)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title, size: :sm)) assert_component_rendered assert_selector("input[name='book[title]'].px-2\\.5.py-2.text-sm") end def test_renders_with_lg_size - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title, size: :lg)) + render_inline(Flowbite::Input.new(form: @form, attribute: :title, size: :lg)) assert_component_rendered assert_selector("input[name='book[title]'].px-3\\.5.py-3.text-base") end def test_adds_attributes_to_input - render_inline(Flowbite::Input::Field.new(form: @form, attribute: :title, options: {placeholder: "Enter title"})) + render_inline(Flowbite::Input.new(form: @form, attribute: :title, options: {placeholder: "Enter title"})) assert_component_rendered assert_selector("input[name='book[title]'][placeholder='Enter title']") end def test_adds_class_attribute_to_existing_classes - render_inline(Flowbite::Input::Field.new(class: "custom-class", form: @form, attribute: :title)) + render_inline(Flowbite::Input.new(class: "custom-class", form: @form, attribute: :title)) assert_selector("input[name='book[title]'].bg-neutral-secondary-medium.custom-class") end