ariadne_view_components 0.0.59 → 0.0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/LICENSE.txt +661 -49
- data/README.md +52 -4
- data/app/assets/javascripts/ariadne_view_components.js +98 -7
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css +1 -7
- data/app/components/ariadne/base_component.rb +79 -27
- data/app/components/ariadne/behaviors/tooltipable.rb +120 -0
- data/app/components/ariadne/conditional_wrapper.rb +21 -0
- data/app/components/ariadne/form/base_component.rb +74 -0
- data/app/components/ariadne/form/base_input_component.rb +60 -0
- data/app/components/ariadne/form/caption/component.html.erb +10 -0
- data/app/components/ariadne/form/caption/component.rb +29 -0
- data/app/components/ariadne/form/form_control/component.html.erb +19 -0
- data/app/components/ariadne/form/form_control/component.rb +27 -0
- data/app/components/ariadne/form/form_reference/component.html.erb +1 -0
- data/app/components/ariadne/form/form_reference/component.rb +18 -0
- data/app/components/ariadne/form/group/component.html.erb +5 -0
- data/app/components/ariadne/form/group/component.rb +27 -0
- data/app/components/ariadne/form/hidden_field/component.html.erb +1 -0
- data/app/components/ariadne/form/hidden_field/component.rb +15 -0
- data/app/components/ariadne/form/separator/component.html.erb +1 -0
- data/app/components/ariadne/form/separator/component.rb +8 -0
- data/app/components/ariadne/form/spacing_wrapper/component.html.erb +3 -0
- data/app/components/ariadne/form/spacing_wrapper/component.rb +8 -0
- data/app/components/ariadne/form/text_field/component.html.erb +25 -0
- data/app/components/ariadne/form/text_field/component.rb +132 -0
- data/app/components/ariadne/form/validation_message/component.html.erb +5 -0
- data/app/components/ariadne/form/validation_message/component.rb +14 -0
- data/app/components/ariadne/layout/narrow/component.html.erb +10 -0
- data/app/components/ariadne/layout/narrow/component.rb +24 -0
- data/app/components/ariadne/layout/nav_bar/component.css +0 -0
- data/app/components/ariadne/layout/nav_bar/component.html.erb +123 -0
- data/app/components/ariadne/layout/nav_bar/component.rb +77 -0
- data/app/components/ariadne/ui/button/component.html.erb +5 -0
- data/app/components/ariadne/ui/button/component.rb +184 -0
- data/app/components/ariadne/ui/clipboard_copy/component.html.erb +8 -0
- data/app/components/ariadne/ui/clipboard_copy/component.rb +102 -0
- data/app/components/ariadne/ui/clipboard_copy/component.ts +54 -0
- data/app/components/ariadne/ui/combobox/component.html.erb +32 -0
- data/app/components/ariadne/ui/combobox/component.rb +83 -0
- data/app/components/ariadne/ui/combobox/component.ts +119 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.html.erb +9 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.rb +53 -0
- data/app/components/ariadne/ui/combobox/option/component.html.erb +11 -0
- data/app/components/ariadne/ui/combobox/option/component.rb +45 -0
- data/app/components/ariadne/ui/heroicon/component.html.erb +3 -0
- data/app/components/ariadne/ui/heroicon/component.rb +141 -0
- data/app/components/ariadne/ui/image/component.rb +69 -0
- data/app/components/ariadne/ui/link/component.html.erb +3 -0
- data/app/components/ariadne/ui/link/component.rb +56 -0
- data/app/components/ariadne/ui/typography/component.html.erb +3 -0
- data/app/components/ariadne/ui/typography/component.rb +41 -0
- data/app/lib/ariadne/attributes_helper.rb +119 -0
- data/app/lib/ariadne/fetch_or_fallback_helper.rb +1 -1
- data/app/lib/ariadne/form.rb +16 -0
- data/app/lib/ariadne/view_helper.rb +2 -5
- data/app/lib/view_components_contrib/html_attrs.rb +64 -0
- data/app/lib/view_components_contrib/style_variants.rb +14 -0
- data/lib/ariadne/forms/acts_as_component.rb +125 -0
- data/lib/ariadne/forms/base.html.erb +8 -0
- data/lib/ariadne/forms/base.rb +132 -0
- data/lib/ariadne/forms/buffer_rewriter.rb +51 -0
- data/lib/ariadne/forms/builder.rb +88 -0
- data/lib/ariadne/forms/dsl/button_input.rb +33 -0
- data/lib/ariadne/forms/dsl/form_object.rb +26 -0
- data/lib/ariadne/forms/dsl/input.rb +322 -0
- data/lib/ariadne/forms/dsl/input_group.rb +34 -0
- data/lib/ariadne/forms/dsl/input_methods.rb +157 -0
- data/lib/ariadne/forms/dsl/submit_button_input.rb +36 -0
- data/lib/ariadne/forms/dsl/text_field_input.rb +73 -0
- data/lib/ariadne/forms/utils.rb +34 -0
- data/lib/ariadne/generate.rb +11 -0
- data/lib/ariadne/view_components/engine.rb +24 -7
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/ariadne/view_components.rb +1 -1
- data/lib/ariadne/yard/backend.rb +24 -0
- data/lib/ariadne/yard/component_manifest.rb +148 -0
- data/lib/ariadne/yard/component_ref.rb +49 -0
- data/lib/ariadne/yard/docs_helper.rb +98 -0
- data/lib/ariadne/yard/info_arch_docs_helper.rb +31 -0
- data/lib/ariadne/yard/lookbook_docs_helper.rb +32 -0
- data/lib/ariadne/yard/lookbook_pages_backend.rb +235 -0
- data/lib/ariadne/yard/registry.rb +136 -0
- data/lib/ariadne/yard/renders_many_handler.rb +23 -0
- data/lib/ariadne/yard/renders_one_handler.rb +23 -0
- data/lib/ariadne/yard.rb +19 -0
- data/static/arguments.yml +141 -48
- data/static/audited_at.json +0 -9
- data/static/classes.yml +210 -209
- data/static/constants.json +2 -209
- data/static/statuses.json +0 -9
- metadata +125 -210
- data/app/assets/builds/ariadne_view_components.css +0 -2202
- data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne.d.ts +0 -2
- data/app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/assets/stylesheets/dropdown.css +0 -46
- data/app/assets/stylesheets/prosemirror.css +0 -323
- data/app/assets/stylesheets/tooltip-component.css +0 -37
- data/app/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/components/ariadne/accumulator_controller/accumulator_controller.js +0 -39
- data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +0 -48
- data/app/components/ariadne/action_card_component.html.erb +0 -13
- data/app/components/ariadne/action_card_component.rb +0 -88
- data/app/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/components/ariadne/ariadne-form.js +0 -85
- data/app/components/ariadne/ariadne.d.ts +0 -2
- data/app/components/ariadne/ariadne.js +0 -24
- data/app/components/ariadne/ariadne.ts +0 -29
- data/app/components/ariadne/avatar_component.rb +0 -81
- data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
- data/app/components/ariadne/avatar_stack_component.rb +0 -75
- data/app/components/ariadne/base_button.rb +0 -70
- data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
- data/app/components/ariadne/blankslate_component.rb +0 -148
- data/app/components/ariadne/body_component.rb +0 -30
- data/app/components/ariadne/bottom_tab_component.html.erb +0 -4
- data/app/components/ariadne/bottom_tab_component.rb +0 -44
- data/app/components/ariadne/bottom_tab_nav_component.html.erb +0 -5
- data/app/components/ariadne/bottom_tab_nav_component.rb +0 -33
- data/app/components/ariadne/breadcrumbs_component.html.erb +0 -13
- data/app/components/ariadne/breadcrumbs_component.rb +0 -31
- data/app/components/ariadne/button_component/button_component.html.erb +0 -4
- data/app/components/ariadne/button_component.rb +0 -165
- data/app/components/ariadne/checkbox_component.html.erb +0 -5
- data/app/components/ariadne/checkbox_component.rb +0 -43
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js +0 -18
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
- data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
- data/app/components/ariadne/clipboard_copy_component.rb +0 -90
- data/app/components/ariadne/close_button_component.html.erb +0 -4
- data/app/components/ariadne/close_button_component.rb +0 -33
- data/app/components/ariadne/combobox_component.html.erb +0 -14
- data/app/components/ariadne/combobox_component.rb +0 -76
- data/app/components/ariadne/component.rb +0 -127
- data/app/components/ariadne/container_component/container_component.html.erb +0 -3
- data/app/components/ariadne/container_component.rb +0 -25
- data/app/components/ariadne/content.rb +0 -12
- data/app/components/ariadne/counter_component.rb +0 -100
- data/app/components/ariadne/details_component/details_component.html.erb +0 -4
- data/app/components/ariadne/details_component.rb +0 -81
- data/app/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
- data/app/components/ariadne/dropdown/menu_component.js +0 -1
- data/app/components/ariadne/dropdown/menu_component.rb +0 -101
- data/app/components/ariadne/dropdown/menu_component.ts +0 -1
- data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
- data/app/components/ariadne/dropdown_component.rb +0 -172
- data/app/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/components/ariadne/events_controller/events_controller.js +0 -6
- data/app/components/ariadne/events_controller/events_controller.ts +0 -7
- data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
- data/app/components/ariadne/flash_component.rb +0 -128
- data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
- data/app/components/ariadne/flex_component.rb +0 -56
- data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
- data/app/components/ariadne/footer_component.rb +0 -23
- data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
- data/app/components/ariadne/grid_component.rb +0 -67
- data/app/components/ariadne/header_component/header_component.html.erb +0 -29
- data/app/components/ariadne/header_component.rb +0 -111
- data/app/components/ariadne/heading_component.rb +0 -49
- data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
- data/app/components/ariadne/heroicon_component.rb +0 -166
- data/app/components/ariadne/image_component.rb +0 -53
- data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
- data/app/components/ariadne/inline_flex_component.rb +0 -72
- data/app/components/ariadne/layout_component.html.erb +0 -21
- data/app/components/ariadne/layout_component.rb +0 -69
- data/app/components/ariadne/link_component.rb +0 -65
- data/app/components/ariadne/list_component/list_component.html.erb +0 -3
- data/app/components/ariadne/list_component.rb +0 -70
- data/app/components/ariadne/modal_component.html.erb +0 -11
- data/app/components/ariadne/modal_component.rb +0 -88
- data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
- data/app/components/ariadne/narrow_container_component.rb +0 -30
- data/app/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/components/ariadne/options_controller/options_controller.js +0 -89
- data/app/components/ariadne/options_controller/options_controller.ts +0 -122
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.js +0 -237
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.ts +0 -278
- data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
- data/app/components/ariadne/panel_bar_component.rb +0 -80
- data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
- data/app/components/ariadne/pill_component.rb +0 -44
- data/app/components/ariadne/popover_component.html.erb +0 -10
- data/app/components/ariadne/popover_component.rb +0 -81
- data/app/components/ariadne/progress_bar_component.html.erb +0 -5
- data/app/components/ariadne/progress_bar_component.rb +0 -63
- data/app/components/ariadne/relative_time_component.html.erb +0 -3
- data/app/components/ariadne/relative_time_component.rb +0 -61
- data/app/components/ariadne/show_more_button_component.html.erb +0 -11
- data/app/components/ariadne/show_more_button_component.rb +0 -47
- data/app/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/components/ariadne/slideover_component/slideover-component.js +0 -11
- data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
- data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
- data/app/components/ariadne/slideover_component.rb +0 -66
- data/app/components/ariadne/spinner_component.html.erb +0 -16
- data/app/components/ariadne/spinner_component.rb +0 -45
- data/app/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/components/ariadne/string_match_controller/string_match_controller.js +0 -51
- data/app/components/ariadne/string_match_controller/string_match_controller.ts +0 -65
- data/app/components/ariadne/subheader_component.html.erb +0 -11
- data/app/components/ariadne/subheader_component.rb +0 -65
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.js +0 -207
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.ts +0 -256
- data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
- data/app/components/ariadne/tab_component.rb +0 -98
- data/app/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/components/ariadne/tab_container_component/tab-container-component.js +0 -23
- data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
- data/app/components/ariadne/tab_container_component.erb +0 -10
- data/app/components/ariadne/tab_container_component.rb +0 -68
- data/app/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/components/ariadne/tab_nav_component/tab-nav-component.js +0 -33
- data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
- data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
- data/app/components/ariadne/tab_nav_component.rb +0 -72
- data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
- data/app/components/ariadne/table_nav_component.rb +0 -338
- data/app/components/ariadne/text.rb +0 -25
- data/app/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.js +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
- data/app/components/ariadne/time_ago_component.rb +0 -56
- data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
- data/app/components/ariadne/timeline_component.rb +0 -34
- data/app/components/ariadne/toggle_component/toggle_component.html.erb +0 -15
- data/app/components/ariadne/toggle_component.rb +0 -95
- data/app/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/components/ariadne/toggleable_controller/toggleable_controller.js +0 -54
- data/app/components/ariadne/toggleable_controller/toggleable_controller.ts +0 -77
- data/app/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/components/ariadne/tooltip_component/tooltip-component.js +0 -43
- data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
- data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
- data/app/components/ariadne/tooltip_component.rb +0 -108
- data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
- data/app/lib/ariadne/audited/dsl.rb +0 -32
- data/app/lib/ariadne/form_builder.rb +0 -80
- data/app/lib/ariadne/status/dsl.rb +0 -41
- data/config/importmap.rb +0 -3
- data/exe/tailwindcss +0 -21
- data/lib/rubocop/cop/ariadne/base_cop.rb +0 -26
- data/tailwind.config.js +0 -70
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
module Forms
|
5
|
+
module Dsl
|
6
|
+
# :nodoc:
|
7
|
+
module InputMethods
|
8
|
+
# Used to render another form object.
|
9
|
+
#
|
10
|
+
# @param args [Array] Positional arguments passed to Rails' [`fields_for` helper](https://api.rubyonrails.org/v7.0.4/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for).
|
11
|
+
# @param kwargs [Hash] The options accepted by the form reference input (see forms docs). Includes keyword arguments passed to Rails' [`fields_for` helper](https://api.rubyonrails.org/v7.0.4/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for).
|
12
|
+
def fields_for(*args, **kwargs, &block)
|
13
|
+
add_input(FormReferenceInput.new(*args, builder: builder, form: form, **kwargs, &block))
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adds a multi input to this form.
|
17
|
+
#
|
18
|
+
# @param options [Hash] The options accepted by the multi input (see forms docs).
|
19
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
20
|
+
def multi(**options, &block)
|
21
|
+
add_input(MultiInput.new(builder: builder, form: form, **options, &block))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Adds a hidden input to this form.
|
25
|
+
#
|
26
|
+
# @param options [Hash] The options accepted by the hidden input (see forms docs).
|
27
|
+
def hidden(**options)
|
28
|
+
add_input(HiddenInput.new(builder: builder, form: form, **options))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Adds a check box to this form.
|
32
|
+
#
|
33
|
+
# @param options [Hash] The options accepted by the check box input (see forms docs).
|
34
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
35
|
+
def check_box(**options, &block)
|
36
|
+
add_input(CheckBoxInput.new(builder: builder, form: form, **options, &block))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Adds a radio button group to this form.
|
40
|
+
#
|
41
|
+
# @param options [Hash] The options accepted by the radio button group input (see forms docs).
|
42
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
43
|
+
def radio_button_group(**options, &block)
|
44
|
+
add_input(RadioButtonGroupInput.new(builder: builder, form: form, **options, &block))
|
45
|
+
end
|
46
|
+
|
47
|
+
# Adds a check box group to this form.
|
48
|
+
#
|
49
|
+
# @param options [Hash] The options accepted by the check box group input (see forms docs).
|
50
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
51
|
+
def check_box_group(**options, &block)
|
52
|
+
add_input(CheckBoxGroupInput.new(builder: builder, form: form, **options, &block))
|
53
|
+
end
|
54
|
+
|
55
|
+
# Adds a horizontal separator to the form.
|
56
|
+
def separator
|
57
|
+
add_input(Separator.new)
|
58
|
+
end
|
59
|
+
|
60
|
+
# START text input methods
|
61
|
+
|
62
|
+
# Adds a text field to this form.
|
63
|
+
#
|
64
|
+
# @param options [Hash] The options accepted by the text field input (see forms docs).
|
65
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
66
|
+
def text_field(**options, &block)
|
67
|
+
options = decorate_options(**options)
|
68
|
+
add_input(TextFieldInput.new(builder: builder, form: form, **options, &block))
|
69
|
+
end
|
70
|
+
|
71
|
+
# Adds an autocomplete text field to this form.
|
72
|
+
#
|
73
|
+
# @param options [Hash] The options accepted by the autocomplete input (see forms docs).
|
74
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
75
|
+
def auto_complete(**options, &block)
|
76
|
+
options = decorate_options(**options)
|
77
|
+
add_input(AutoCompleteInput.new(builder: builder, form: form, **options, &block))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Adds a text area to this form.
|
81
|
+
#
|
82
|
+
# @param options [Hash] The options accepted by the text area input (see forms docs).
|
83
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
84
|
+
def text_area(**options, &block)
|
85
|
+
options = decorate_options(**options)
|
86
|
+
add_input(TextAreaInput.new(builder: builder, form: form, **options, &block))
|
87
|
+
end
|
88
|
+
|
89
|
+
# END text input methods
|
90
|
+
|
91
|
+
# START select input methods
|
92
|
+
|
93
|
+
# Adds a select list to this form.
|
94
|
+
#
|
95
|
+
# @param options [Hash] The options accepted by the select list input (see forms docs).
|
96
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
97
|
+
def select_list(**options, &block)
|
98
|
+
options = decorate_options(**options)
|
99
|
+
add_input(SelectInput.new(builder: builder, form: form, **options, &block))
|
100
|
+
end
|
101
|
+
|
102
|
+
# Adds an <%= link_to_component(Ariadne::Alpha::ActionMenu) %> to this form.
|
103
|
+
#
|
104
|
+
# @param options [Hash] The options accepted by the <%= link_to_component(Ariadne::Alpha::ActionMenu) %> component.
|
105
|
+
# @param block [Proc] The block passed to `#render` when the <%= link_to_component(Ariadne::Alpha::ActionMenu) %> is rendered. This block is passed an instance of <%= link_to_component(Ariadne::Alpha::ActionMenu) %>, which can be used to add items, dividers, etc.
|
106
|
+
def action_menu(**options, &block)
|
107
|
+
options = decorate_options(**options)
|
108
|
+
add_input(ActionMenuInput.new(builder: builder, form: form, **options, &block))
|
109
|
+
end
|
110
|
+
|
111
|
+
# END select input methods
|
112
|
+
|
113
|
+
# START button input methods
|
114
|
+
|
115
|
+
# Adds a submit button to this form.
|
116
|
+
#
|
117
|
+
# @param options [Hash] The options accepted by the submit button input (see forms docs).
|
118
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
119
|
+
def submit(**options, &block)
|
120
|
+
options = decorate_options(**options)
|
121
|
+
add_input(SubmitButtonInput.new(builder: builder, form: form, **options, &block))
|
122
|
+
end
|
123
|
+
|
124
|
+
# Adds a (non-submit) button to this form.
|
125
|
+
#
|
126
|
+
# @param options [Hash] The options accepted by the button input (see forms docs).
|
127
|
+
# @param block [Proc] A block that will be yielded a reference to the input object so it can be customized.
|
128
|
+
def button(**options, &block)
|
129
|
+
options = decorate_options(**options)
|
130
|
+
add_input(ButtonInput.new(builder: builder, form: form, **options, &block))
|
131
|
+
end
|
132
|
+
|
133
|
+
# END button input methods
|
134
|
+
|
135
|
+
# @private
|
136
|
+
def inputs
|
137
|
+
@inputs ||= []
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
# @private
|
143
|
+
def add_input(input)
|
144
|
+
inputs << input
|
145
|
+
end
|
146
|
+
|
147
|
+
# @private
|
148
|
+
#
|
149
|
+
# Called before the corresponding Input class is instantiated. The return value of this method is passed
|
150
|
+
# to the Input class's constructor.
|
151
|
+
def decorate_options(**options)
|
152
|
+
options
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
module Forms
|
5
|
+
module Dsl
|
6
|
+
# :nodoc:
|
7
|
+
class SubmitButtonInput < Input
|
8
|
+
attr_reader :name, :label, :block
|
9
|
+
|
10
|
+
def initialize(**options, &block)
|
11
|
+
@block = block
|
12
|
+
|
13
|
+
super(**options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_component
|
17
|
+
html_attrs = @input_attributes || {}
|
18
|
+
@block.call(Ariadne::UI::Button::Component.new(type: :submit, **@options, html_attrs: html_attrs))
|
19
|
+
end
|
20
|
+
|
21
|
+
def before_render
|
22
|
+
content # ensures that block is called
|
23
|
+
end
|
24
|
+
|
25
|
+
# :nocov:
|
26
|
+
def type
|
27
|
+
:submit_button
|
28
|
+
end
|
29
|
+
|
30
|
+
def supports_validation?
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
module Forms
|
5
|
+
module Dsl
|
6
|
+
# :nodoc:
|
7
|
+
class TextFieldInput < Input
|
8
|
+
attr_reader(
|
9
|
+
:name, :label, :show_clear_button, :leading_visual, :clear_button_id, :visually_hide_label, :inset, :monospace, :field_wrap_classes, :auto_check_src
|
10
|
+
)
|
11
|
+
|
12
|
+
def initialize(name:, label:, **options)
|
13
|
+
@name = name
|
14
|
+
@label = label
|
15
|
+
|
16
|
+
@show_clear_button = options.delete(:show_clear_button)
|
17
|
+
@inset = options.delete(:inset)
|
18
|
+
@monospace = options.delete(:monospace)
|
19
|
+
@auto_check_src = options.delete(:auto_check_src)
|
20
|
+
|
21
|
+
super(**options)
|
22
|
+
|
23
|
+
add_input_data(:target, "ariadne-text-field.inputElement #{@input_attributes.dig(:data, :target) || ""}".rstrip)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_component
|
27
|
+
html_attrs = @input_attributes || {}
|
28
|
+
Ariadne::Form::TextField::Component.new(name: @name, label: @label, **@options, html_attrs: html_attrs)
|
29
|
+
end
|
30
|
+
|
31
|
+
def type
|
32
|
+
:text_field
|
33
|
+
end
|
34
|
+
|
35
|
+
def focusable?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def validation_arguments
|
40
|
+
if auto_check_src.present?
|
41
|
+
super.merge(
|
42
|
+
data: {
|
43
|
+
target: "primer-text-field.validationElement",
|
44
|
+
},
|
45
|
+
)
|
46
|
+
else
|
47
|
+
super
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def validation_success_icon_target
|
52
|
+
"primer-text-field.validationSuccessIcon"
|
53
|
+
end
|
54
|
+
|
55
|
+
def validation_error_icon_target
|
56
|
+
"primer-text-field.validationErrorIcon"
|
57
|
+
end
|
58
|
+
|
59
|
+
def validation_message_arguments
|
60
|
+
if auto_check_src.present?
|
61
|
+
super.merge(
|
62
|
+
data: {
|
63
|
+
target: "primer-text-field.validationMessageElement",
|
64
|
+
},
|
65
|
+
)
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
# :nodoc:
|
5
|
+
module Forms
|
6
|
+
# :nodoc:
|
7
|
+
module Utils
|
8
|
+
# Unfortunately this bug (https://github.com/ruby/ruby/pull/5646) prevents us from using
|
9
|
+
# Ruby's native Module.const_source_location. Instead we have to fudge it by searching
|
10
|
+
# for the file in the configured autoload paths. Doing so relies on Rails' autoloading
|
11
|
+
# conventions, so it should work ok. Zeitwerk also has this information but lacks a
|
12
|
+
# public API to map constants to source files.
|
13
|
+
def const_source_location(class_name)
|
14
|
+
return unless class_name
|
15
|
+
|
16
|
+
# NOTE: underscore respects namespacing, i.e. will convert Foo::Bar to foo/bar.
|
17
|
+
class_path = "#{class_name.underscore}.rb"
|
18
|
+
|
19
|
+
ActiveSupport::Dependencies.autoload_paths.each do |autoload_path|
|
20
|
+
absolute_path = File.join(autoload_path, class_path)
|
21
|
+
return absolute_path if File.exist?(absolute_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def classify(options)
|
28
|
+
options
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Utils.extend(Utils)
|
33
|
+
end
|
34
|
+
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require "rails/engine"
|
4
4
|
|
5
|
-
require "view_component"
|
6
|
-
|
7
5
|
require "tailwind_merge"
|
8
6
|
|
9
7
|
module Ariadne
|
@@ -17,7 +15,7 @@ module Ariadne
|
|
17
15
|
isolate_namespace Ariadne::ViewComponents
|
18
16
|
|
19
17
|
config.autoload_paths = ["#{root}/lib"]
|
20
|
-
config.eager_load_paths = ["#{root}/app/components", "#{root}/app/helpers", "#{root}/app/lib"]
|
18
|
+
config.eager_load_paths = ["#{root}/app/components", "#{root}/app/forms", "#{root}/app/helpers", "#{root}/app/lib"]
|
21
19
|
|
22
20
|
config.ariadne_view_components = ActiveSupport::OrderedOptions.new
|
23
21
|
|
@@ -31,9 +29,28 @@ module Ariadne
|
|
31
29
|
app.config.assets.precompile += ["ariadne_view_components"] if app.config.respond_to?(:assets)
|
32
30
|
end
|
33
31
|
|
34
|
-
initializer "ariadne_view_components.
|
35
|
-
|
36
|
-
|
32
|
+
initializer "ariadne_view_components.eager_load_actions" do
|
33
|
+
ActiveSupport.on_load(:after_initialize) do
|
34
|
+
if Rails.application.config.eager_load
|
35
|
+
Ariadne::Forms::Base.compile!
|
36
|
+
Ariadne::Forms::Base.descendants.each(&:compile!)
|
37
|
+
Ariadne::Forms::BaseComponent.descendants.each(&:compile!)
|
38
|
+
Ariadne::Heroicon::Cache.preload!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
initializer "ariadne.forms.helpers" do
|
44
|
+
ActiveSupport.on_load(:action_controller_base) do
|
45
|
+
begin
|
46
|
+
require "ariadne/form_helper"
|
47
|
+
rescue LoadError # rubocop:disable Lint/SuppressedException
|
48
|
+
end
|
49
|
+
|
50
|
+
helper Ariadne::FormHelper
|
51
|
+
|
52
|
+
# make ariadne_form_with available to view components also
|
53
|
+
ViewComponent::Base.prepend(Ariadne::FormHelper)
|
37
54
|
end
|
38
55
|
end
|
39
56
|
|
@@ -46,7 +63,7 @@ module Ariadne
|
|
46
63
|
end
|
47
64
|
|
48
65
|
config.after_initialize do |_app|
|
49
|
-
Ariadne::ViewComponents.tailwind_merger = TailwindMerge::Merger.new
|
66
|
+
Ariadne::ViewComponents.tailwind_merger = TailwindMerge::Merger.new(config: { prefix: "ariadne-" })
|
50
67
|
end
|
51
68
|
end
|
52
69
|
end
|
@@ -47,7 +47,7 @@ module Ariadne
|
|
47
47
|
require "json"
|
48
48
|
|
49
49
|
File.open(File.join(DEFAULT_STATIC_PATH, FILE_NAMES[stats]), "w") do |f|
|
50
|
-
f.write(JSON.pretty_generate(send("generate_#{stats}")))
|
50
|
+
f.write(JSON.pretty_generate(send(:"generate_#{stats}")))
|
51
51
|
f.write($INPUT_RECORD_SEPARATOR)
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nocov:
|
4
|
+
module Ariadne
|
5
|
+
module Yard
|
6
|
+
# Shared functionality for generating documentation from YARD comments.
|
7
|
+
class Backend
|
8
|
+
include DocsHelper
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def view_context
|
13
|
+
@view_context ||= begin
|
14
|
+
# Rails controller for rendering arbitrary ERB
|
15
|
+
vc = ApplicationController.new.tap { |c| c.request = ActionDispatch::TestRequest.create }.view_context
|
16
|
+
vc.singleton_class.include(DocsHelper)
|
17
|
+
vc.singleton_class.include(Ariadne::ViewHelper)
|
18
|
+
vc
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
# :nocov:
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nocov:
|
4
|
+
module Ariadne
|
5
|
+
module Yard
|
6
|
+
# The set of documented components (and associated metadata).
|
7
|
+
class ComponentManifest
|
8
|
+
COMPONENTS = {
|
9
|
+
Ariadne::Heading::Component => {},
|
10
|
+
# Primer::Beta::IconButton => {},
|
11
|
+
# Primer::Beta::Button => {},
|
12
|
+
# Primer::Alpha::SegmentedControl => {},
|
13
|
+
# Primer::Alpha::Layout => {},
|
14
|
+
# Primer::Alpha::HellipButton => {},
|
15
|
+
# Primer::Alpha::Image => {},
|
16
|
+
# Primer::Alpha::OcticonSymbols => {},
|
17
|
+
# Primer::Alpha::ImageCrop => { js: true },
|
18
|
+
# Primer::IconButton => { js: true },
|
19
|
+
# Primer::Beta::AutoComplete => { js: true },
|
20
|
+
# Primer::Beta::AutoComplete::Item => {},
|
21
|
+
# Primer::Beta::Avatar => {},
|
22
|
+
# Primer::Beta::AvatarStack => {},
|
23
|
+
# Primer::Beta::BaseButton => {},
|
24
|
+
# Primer::Alpha::Banner => { js: true },
|
25
|
+
# Primer::Beta::Blankslate => {},
|
26
|
+
# Primer::BlankslateComponent => {},
|
27
|
+
# Primer::Beta::BorderBox => {},
|
28
|
+
# Primer::Beta::BorderBox::Header => {},
|
29
|
+
# Primer::Box => {},
|
30
|
+
# Primer::Beta::Breadcrumbs => {},
|
31
|
+
# Primer::ButtonComponent => { js: true },
|
32
|
+
# Primer::Beta::ButtonGroup => {},
|
33
|
+
# Primer::Alpha::ButtonMarketing => {},
|
34
|
+
# Primer::Beta::ClipboardCopy => { js: true },
|
35
|
+
# Primer::Beta::CloseButton => {},
|
36
|
+
# Primer::Beta::Counter => {},
|
37
|
+
# Primer::Beta::Details => {},
|
38
|
+
# Primer::Alpha::Dialog => {},
|
39
|
+
# Primer::Alpha::Dropdown => { js: true },
|
40
|
+
# Primer::Beta::Flash => {},
|
41
|
+
# Primer::Beta::Heading => {},
|
42
|
+
# Primer::Alpha::HiddenTextExpander => {},
|
43
|
+
# Primer::Beta::Label => {},
|
44
|
+
# Primer::LayoutComponent => {},
|
45
|
+
# Primer::Beta::Link => { js: true },
|
46
|
+
# Primer::Beta::Markdown => {},
|
47
|
+
# Primer::Alpha::Menu => {},
|
48
|
+
# Primer::Navigation::TabComponent => {},
|
49
|
+
# Primer::Alpha::Navigation::Tab => {},
|
50
|
+
# Primer::Beta::Octicon => {},
|
51
|
+
# Primer::Beta::Popover => {},
|
52
|
+
# Primer::Beta::ProgressBar => {},
|
53
|
+
# Primer::Beta::State => {},
|
54
|
+
# Primer::Beta::Spinner => {},
|
55
|
+
# Primer::Beta::Subhead => {},
|
56
|
+
# Primer::Alpha::TabContainer => { js: true },
|
57
|
+
# Primer::Beta::Text => {},
|
58
|
+
# Primer::Beta::TimelineItem => {},
|
59
|
+
# Primer::Tooltip => {},
|
60
|
+
# Primer::Truncate => {},
|
61
|
+
# Primer::Beta::Truncate => {},
|
62
|
+
# Primer::Alpha::UnderlineNav => {},
|
63
|
+
# Primer::Alpha::UnderlinePanels => { js: true },
|
64
|
+
# Primer::Alpha::TabNav => {},
|
65
|
+
# Primer::Alpha::TabPanels => { js: true },
|
66
|
+
# Primer::Alpha::Tooltip => { js: true },
|
67
|
+
# Primer::Alpha::ToggleSwitch => { js: true },
|
68
|
+
# Primer::Alpha::Overlay => { js: true },
|
69
|
+
# Primer::Alpha::ActionMenu => { js: true },
|
70
|
+
|
71
|
+
# Examples can be seen in the NavList docs
|
72
|
+
# Primer::Alpha::NavList => { js: true },
|
73
|
+
# Primer::Alpha::NavList::Item => { js: true, examples: false },
|
74
|
+
# Primer::Alpha::NavList::Group => { js: true, examples: false },
|
75
|
+
|
76
|
+
# Primer::Beta::NavList => { js: true },
|
77
|
+
# Primer::Beta::NavList::Item => { js: true, examples: false },
|
78
|
+
# Primer::Beta::NavList::Group => { js: true, examples: false },
|
79
|
+
|
80
|
+
# ActionList is a base component that should not be used by itself, and thus
|
81
|
+
# does not have examples of its own
|
82
|
+
# Primer::Alpha::ActionList => { js: true, examples: false },
|
83
|
+
# Primer::Alpha::ActionList::Divider => { examples: false },
|
84
|
+
# Primer::Alpha::ActionList::Heading => { examples: false },
|
85
|
+
# Primer::Alpha::ActionList::Item => { examples: false },
|
86
|
+
|
87
|
+
# Forms
|
88
|
+
# Primer::Alpha::TextField => { form_component: true },
|
89
|
+
# Primer::Alpha::TextArea => { form_component: true, published: false },
|
90
|
+
# Primer::Alpha::Select => { form_component: true, published: false },
|
91
|
+
# Primer::Alpha::MultiInput => { form_component: true, js: true, published: false },
|
92
|
+
# Primer::Alpha::RadioButton => { form_component: true, published: false },
|
93
|
+
# Primer::Alpha::RadioButtonGroup => { form_component: true, published: false },
|
94
|
+
# Primer::Alpha::CheckBox => { form_component: true, published: false },
|
95
|
+
# Primer::Alpha::CheckBoxGroup => { form_component: true, published: false },
|
96
|
+
# Primer::Alpha::SubmitButton => { form_component: true, published: false },
|
97
|
+
# Primer::Alpha::FormButton => { form_component: true, published: false }
|
98
|
+
}.freeze
|
99
|
+
|
100
|
+
include Enumerable
|
101
|
+
|
102
|
+
def initialize(components)
|
103
|
+
@components = components
|
104
|
+
end
|
105
|
+
|
106
|
+
def each
|
107
|
+
return to_enum(__method__) unless block_given?
|
108
|
+
|
109
|
+
@components.each do |klass|
|
110
|
+
yield self.class.ref_for(klass)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def where(**attrs)
|
115
|
+
self.class.where(@components, **attrs)
|
116
|
+
end
|
117
|
+
|
118
|
+
class << self
|
119
|
+
def where(components = COMPONENTS, **desired_attrs)
|
120
|
+
new(
|
121
|
+
components.each_with_object([]) do |(klass, component_attrs), memo|
|
122
|
+
matches = desired_attrs.all? do |name, desired_value|
|
123
|
+
component_attrs.fetch(name, ComponentRef::ATTR_DEFAULTS[name]) == desired_value
|
124
|
+
end
|
125
|
+
|
126
|
+
memo << klass if matches
|
127
|
+
end,
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def all
|
132
|
+
new(COMPONENTS.keys)
|
133
|
+
end
|
134
|
+
|
135
|
+
def ref_for(klass)
|
136
|
+
ref_cache[klass] ||= ComponentRef.new(klass, COMPONENTS.fetch(klass, {}))
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def ref_cache
|
142
|
+
@ref_cache ||= {}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
# :nocov:
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nocov:
|
4
|
+
module Ariadne
|
5
|
+
module Yard
|
6
|
+
# :nodoc:
|
7
|
+
class ComponentRef
|
8
|
+
ATTR_DEFAULTS = {
|
9
|
+
js: false,
|
10
|
+
examples: true,
|
11
|
+
form_component: false,
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
attr_reader :klass, :attrs
|
15
|
+
|
16
|
+
def initialize(klass, attrs)
|
17
|
+
@klass = klass
|
18
|
+
@attrs = attrs
|
19
|
+
end
|
20
|
+
|
21
|
+
def requires_js?
|
22
|
+
@attrs.fetch(:js, ATTR_DEFAULTS[:js])
|
23
|
+
end
|
24
|
+
|
25
|
+
def should_have_examples?
|
26
|
+
@attrs.fetch(:examples, ATTR_DEFAULTS[:examples])
|
27
|
+
end
|
28
|
+
|
29
|
+
def form_component?
|
30
|
+
@attrs.fetch(:form_component, ATTR_DEFAULTS[:form_component])
|
31
|
+
end
|
32
|
+
|
33
|
+
def source_url
|
34
|
+
@source_url ||= begin
|
35
|
+
path = klass.name.split("::").map(&:underscore).join("/")
|
36
|
+
"https://github.com/primer/view_components/tree/main/app/components/#{path}.rb"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def lookbook_url
|
41
|
+
@lookbook_url ||= begin
|
42
|
+
path = klass.name.underscore.gsub("_component", "")
|
43
|
+
"https://ariadne.style/view-components/lookbook/inspect/#{path}/default/"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# :nocov:
|