ariadne_view_components 0.0.39-x86_64-linux → 0.0.41-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/ariadne/view_components/upstream.rb +0 -1
  4. data/lib/ariadne/view_components/version.rb +1 -1
  5. metadata +2 -90
  6. data/app/assets/config/manifest.js +0 -2
  7. data/app/components/ariadne/ariadne-form.ts +0 -96
  8. data/app/components/ariadne/ariadne.ts +0 -21
  9. data/app/components/ariadne/avatar_component.rb +0 -81
  10. data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
  11. data/app/components/ariadne/avatar_stack_component.rb +0 -75
  12. data/app/components/ariadne/base_button.rb +0 -70
  13. data/app/components/ariadne/base_component.rb +0 -37
  14. data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
  15. data/app/components/ariadne/blankslate_component.rb +0 -148
  16. data/app/components/ariadne/body_component.rb +0 -30
  17. data/app/components/ariadne/button_component/button_component.html.erb +0 -4
  18. data/app/components/ariadne/button_component.rb +0 -165
  19. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
  20. data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
  21. data/app/components/ariadne/clipboard_copy_component.rb +0 -90
  22. data/app/components/ariadne/comment_component/comment_component.html.erb +0 -37
  23. data/app/components/ariadne/comment_component.rb +0 -71
  24. data/app/components/ariadne/component.rb +0 -127
  25. data/app/components/ariadne/container_component/container_component.html.erb +0 -3
  26. data/app/components/ariadne/container_component.rb +0 -25
  27. data/app/components/ariadne/content.rb +0 -12
  28. data/app/components/ariadne/counter_component.rb +0 -100
  29. data/app/components/ariadne/details_component/details_component.html.erb +0 -4
  30. data/app/components/ariadne/details_component.rb +0 -81
  31. data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
  32. data/app/components/ariadne/dropdown/menu_component.rb +0 -101
  33. data/app/components/ariadne/dropdown/menu_component.ts +0 -1
  34. data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
  35. data/app/components/ariadne/dropdown_component.rb +0 -172
  36. data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
  37. data/app/components/ariadne/flash_component.rb +0 -128
  38. data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
  39. data/app/components/ariadne/flex_component.rb +0 -56
  40. data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
  41. data/app/components/ariadne/footer_component.rb +0 -23
  42. data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
  43. data/app/components/ariadne/grid_component.rb +0 -67
  44. data/app/components/ariadne/header_component/header_component.html.erb +0 -29
  45. data/app/components/ariadne/header_component.rb +0 -111
  46. data/app/components/ariadne/heading_component.rb +0 -49
  47. data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
  48. data/app/components/ariadne/heroicon_component.rb +0 -166
  49. data/app/components/ariadne/image_component.rb +0 -53
  50. data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
  51. data/app/components/ariadne/inline_flex_component.rb +0 -72
  52. data/app/components/ariadne/link_component.rb +0 -65
  53. data/app/components/ariadne/list_component/list_component.html.erb +0 -6
  54. data/app/components/ariadne/list_component.rb +0 -70
  55. data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
  56. data/app/components/ariadne/narrow_container_component.rb +0 -30
  57. data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
  58. data/app/components/ariadne/panel_bar_component.rb +0 -80
  59. data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
  60. data/app/components/ariadne/pill_component.rb +0 -44
  61. data/app/components/ariadne/rich_text_area_component/rich-text-area-component.ts +0 -47
  62. data/app/components/ariadne/rich_text_area_component/rich_text_area_component.html.erb +0 -6
  63. data/app/components/ariadne/rich_text_area_component.rb +0 -35
  64. data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
  65. data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
  66. data/app/components/ariadne/slideover_component.rb +0 -66
  67. data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
  68. data/app/components/ariadne/tab_component.rb +0 -98
  69. data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
  70. data/app/components/ariadne/tab_container_component.erb +0 -10
  71. data/app/components/ariadne/tab_container_component.rb +0 -68
  72. data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
  73. data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
  74. data/app/components/ariadne/tab_nav_component.rb +0 -72
  75. data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
  76. data/app/components/ariadne/table_nav_component.rb +0 -338
  77. data/app/components/ariadne/text.rb +0 -25
  78. data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
  79. data/app/components/ariadne/time_ago_component.rb +0 -56
  80. data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
  81. data/app/components/ariadne/timeline_component.rb +0 -34
  82. data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
  83. data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
  84. data/app/components/ariadne/tooltip_component.rb +0 -108
  85. data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
  86. data/app/lib/ariadne/audited/dsl.rb +0 -32
  87. data/app/lib/ariadne/class_name_helper.rb +0 -22
  88. data/app/lib/ariadne/fetch_or_fallback_helper.rb +0 -110
  89. data/app/lib/ariadne/form_builder.rb +0 -74
  90. data/app/lib/ariadne/icon_helper.rb +0 -51
  91. data/app/lib/ariadne/logger_helper.rb +0 -23
  92. data/app/lib/ariadne/status/dsl.rb +0 -41
  93. data/app/lib/ariadne/view_helper.rb +0 -22
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Ariadne
6
- # :nodoc:
7
- module Audited
8
- # DSL to register when a component has passed an accessibility audit.
9
- #
10
- # Example:
11
- #
12
- # class MyComponent < ViewComponent::Base
13
- # include Ariadne::Audited::Dsl
14
- # audited_at 'YYYY-MM-DD'
15
- # end
16
- module Dsl
17
- extend ActiveSupport::Concern
18
-
19
- included do
20
- class_attribute :audit_date, instance_writer: false
21
- end
22
-
23
- class_methods do
24
- def audited_at(date = nil)
25
- return audit_date if date.nil?
26
-
27
- self.audit_date = date
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Helps build a list of conditional class names
4
- module Ariadne
5
- # :nodoc:
6
- module ClassNameHelper
7
- def merge_class_names(*args)
8
- [].tap do |classes|
9
- args.each do |class_name|
10
- next if class_name.blank?
11
-
12
- case class_name
13
- when String
14
- classes << class_name
15
- else
16
- raise ArgumentError, "Expected String class name, got #{class_name.class}"
17
- end
18
- end
19
- end.join(" ")
20
- end
21
- end
22
- end
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Ariadne::FetchOrFallbackHelper
4
- # A little helper to enable graceful fallbacks
5
- #
6
- # Use this helper to quietly ensure a value is
7
- # one that you expect:
8
- #
9
- # allowed_values - allowed options for *value*
10
- # given_value - input being coerced
11
- # fallback - returned if *given_value* is not included in *allowed_values*
12
- #
13
- # fetch_or_raise([1,2,3], 5) => 2
14
- # fetch_or_raise([1,2,3], 1) => 1
15
- # fetch_or_raise([1,2,3], nil) => 2
16
- module Ariadne
17
- # :nodoc:
18
- module FetchOrFallbackHelper
19
- include LoggerHelper
20
-
21
- mattr_accessor :fallback_raises, default: true
22
-
23
- InvalidValueError = Class.new(StandardError)
24
-
25
- TRUE_OR_FALSE = Set.new([true, false]).freeze
26
-
27
- INTEGER_TYPES = Set.new(["Integer"]).freeze
28
-
29
- def fetch_or_raise(allowed_values, given_value, against: nil)
30
- if !allowed_values.is_a?(Array) && !allowed_values.is_a?(Set)
31
- raise ArgumentError, "allowed_values must be an array or a set; it was #{allowed_values.class}"
32
- end
33
-
34
- check_against_given_value = against || given_value
35
- if allowed_values.include?(check_against_given_value)
36
- given_value
37
- else
38
- raise InvalidValueError, <<~MSG
39
- fetch_or_raise was called with an invalid value.
40
-
41
- Expected one of: #{allowed_values.inspect}
42
- Got: #{given_value.inspect}
43
- MSG
44
- end
45
- end
46
-
47
- # TODO: use these two more
48
- def fetch_or_raise_boolean(given_value)
49
- fetch_or_raise(TRUE_OR_FALSE, given_value)
50
- end
51
-
52
- def fetch_or_raise_integer(given_value)
53
- fetch_or_raise(INTEGER_TYPES, given_value, against: given_value.class.name)
54
- end
55
-
56
- # TODO: test this
57
- def check_incoming_tag(preferred_tag, given_tag)
58
- return preferred_tag if given_tag.blank? || preferred_tag == given_tag
59
-
60
- unless silence_warnings?
61
- message = <<~MSG
62
- Ariadne: note that `#{preferred_tag}` is the preferred tag here;
63
- you passed `#{given_tag}` (which will still be used)
64
- MSG
65
-
66
- logger.warn(message)
67
- end
68
-
69
- given_tag
70
- end
71
-
72
- # TODO: test this
73
- def check_incoming_attribute(preferred_attribute, given_attribute)
74
- return preferred_attribute if given_attribute.blank? || preferred_attribute != given_attribute
75
-
76
- unless silence_warnings?
77
- message = <<~MSG
78
- Ariadne: note that `#{preferred_attribute}` is the preferred attribute here;
79
- you passed `#{given_attribute}` (which will still be used)
80
- MSG
81
-
82
- logger.warn(message)
83
- end
84
-
85
- given_attribute
86
- end
87
-
88
- # TODO: test this
89
- def check_incoming_value(preferred_value, given_pair)
90
- return preferred_value if given_pair.blank? || !given_pair.is_a?(Hash)
91
-
92
- given_key = given_pair.keys.first
93
- given_value = given_pair.values.first
94
-
95
- return preferred_value if given_value.blank?
96
-
97
- unless silence_warnings?
98
-
99
- message = <<~MSG
100
- Ariadne: note that `#{preferred_value}` is the preferred value for `#{given_key}` here;
101
- you passed `#{given_value}` (which will still be used)
102
- MSG
103
-
104
- logger.warn(message)
105
- end
106
-
107
- given_value
108
- end
109
- end
110
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # :nodoc:
5
- # Many of the form methods simply call out to the corresponding ActionView::Helpers::FormBuilder methods,
6
- # documented at https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html, with
7
- # default Tailwind classes applied.
8
- class FormBuilder < ActionView::Helpers::FormBuilder
9
- include ClassNameHelper
10
-
11
- DEFAULT_SECTION_CLASSES = "ariadne-space-y-6 ariadne-px-4"
12
- def section(classes: "", attributes: {}, &block)
13
- actual_classes = merge_class_names(DEFAULT_SECTION_CLASSES, classes)
14
- options = { class: actual_classes, **attributes }
15
- @template.content_tag(:div, **options, &block)
16
- end
17
-
18
- DEFAULT_SECTION_HEADING_CLASSES = "ariadne-text-lg ariadne-leading-6 ariadne-py-4 ariadne-font-medium ariadne-text-gray-900"
19
- def heading(tag: :h3, classes: "", attributes: {}, &block)
20
- actual_classes = merge_class_names(DEFAULT_SECTION_HEADING_CLASSES, classes)
21
- options = { class: actual_classes, **attributes }
22
- @template.content_tag(tag, **options, &block)
23
- end
24
-
25
- DEFAULT_SECTION_SUBHEADING_CLASSES = "ariadne-mt-1 ariadne-max-w-2xl ariadne-text-sm ariadne-text-gray-500"
26
- def subheading(classes: "", attributes: {}, &block)
27
- actual_classes = merge_class_names(DEFAULT_SECTION_SUBHEADING_CLASSES, classes)
28
- options = { class: actual_classes, **attributes }
29
- @template.content_tag(:p, **options, &block)
30
- end
31
-
32
- DEFAULT_LABEL_CLASSES = "ariadne-block ariadne-text-sm ariadne-font-medium ariadne-text-gray-700 ariadne-pl-2"
33
- def label(method, text = nil, options = {}, &block)
34
- options[:class] = merge_class_names(DEFAULT_LABEL_CLASSES, options.delete(:classes))
35
- super(method, text, options, &block)
36
- end
37
-
38
- DEFAULT_TEXT_CLASSES = "ariadne-shadow-sm focus:ariadne-ring-slate-500 focus:ariadne-border-slate-500 ariadne-block ariadne-w-full sm:ariadne-text-sm ariadne-border-gray-300 ariadne-rounded-md"
39
- def text_field(method, options = {})
40
- options[:class] = merge_class_names(DEFAULT_TEXT_CLASSES, options.delete(:classes))
41
- super(method, **options)
42
- end
43
-
44
- DEFAULT_CHECKBOX_CLASSES = "focus:ariadne-ring-slate-500 ariadne-h-4 ariadne-w-4 ariadne-text-slate-600 ariadne-border-slate-300 ariadne-rounded"
45
- def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
46
- options[:class] = merge_class_names(DEFAULT_CHECKBOX_CLASSES, options.delete(:classes))
47
- super(method, options, checked_value, unchecked_value)
48
- end
49
-
50
- DEFAULT_RADIO_CLASSES = "focus:ariadne-ring-slate-500 ariadne-h-4 ariadne-w-4 ariadne-text-slate-600 ariadne-border-gray-300 ariadne-rounded"
51
- def radio_button(method, tag_value, options = {})
52
- options[:class] = merge_class_names(DEFAULT_RADIO_CLASSES, options.delete(:classes))
53
- super(method, tag_value, **options)
54
- end
55
-
56
- DEFAULT_TEXTAREA_CLASSES = "ariadne-shadow-sm focus:ariadne-ring-slate-500 focus:ariadne-border-slate-500 ariadne-block ariadne-w-full sm:ariadne-text-sm ariadne-border ariadne-border-gray-300 ariadne-rounded-md"
57
- def text_area(method, options = {})
58
- options[:class] = merge_class_names(DEFAULT_TEXTAREA_CLASSES, options.delete(:classes))
59
- super(method, **options)
60
- end
61
-
62
- DEFAULT_EMAIL_CLASSES = "ariadne-shadow-sm focus:ariadne-ring-slate-500 focus:ariadne-border-slate-500 ariadne-block ariadne-w-full sm:ariadne-text-sm ariadne-border-gray-300 ariadne-rounded-md"
63
- def email_field(method, options = {})
64
- options[:class] = merge_class_names(DEFAULT_EMAIL_CLASSES, options.delete(:classes))
65
- super(method, **options)
66
- end
67
-
68
- DEFAULT_PASSWORD_CLASSES = "ariadne-appearance-none ariadne-block ariadne-w-full ariadne-px-3 ariadne-py-2 ariadne-border ariadne-border-gray-300 ariadne-rounded-md ariadne-shadow-sm ariadne-placeholder-gray-400 focus:ariadne-outline-none focus:ariadne-ring-slate-500 focus:ariadne-border-slate-500 sm:ariadne-text-sm"
69
- def password_field(method, options = {})
70
- options[:class] = merge_class_names(DEFAULT_PASSWORD_CLASSES, options.delete(:classes))
71
- super(method, **options)
72
- end
73
- end
74
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Ariadne::IconHelper
4
- # A helper that insists on certain values when
5
- # checking herocions and their varients.
6
- #
7
- # Use this helper to loudly ensure a value is
8
- # one that you expect.
9
- module Ariadne
10
- # :nodoc:
11
- module IconHelper
12
- include FetchOrFallbackHelper
13
-
14
- def check_icon_presence!(icon, variant)
15
- return true unless has_partial_icon?(icon, variant)
16
-
17
- icon_presence!(icon, variant)
18
- variant_presence!(icon, variant)
19
- ensure_valid_variant(variant)
20
-
21
- true
22
- end
23
-
24
- def ensure_valid_variant(variant)
25
- check_variant = if variant.blank? || !variant.respond_to?(:to_s)
26
- ""
27
- else
28
- variant.to_s
29
- end
30
-
31
- fetch_or_raise(HeroiconsHelper::Icon::VALID_VARIANTS, check_variant)
32
- end
33
- module_function :ensure_valid_variant
34
-
35
- def has_partial_icon?(icon, variant)
36
- icon.present? || variant.present?
37
- end
38
-
39
- def icon_presence!(icon, variant)
40
- raise(ArgumentError, "You must provide an `icon` when providing a `variant`.") if icon.blank? && variant.present?
41
-
42
- true
43
- end
44
-
45
- def variant_presence!(icon, variant)
46
- raise(ArgumentError, "You must provide a `variant` when providing an `icon`.") if icon.present? && variant.blank?
47
-
48
- true
49
- end
50
- end
51
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # :nodoc:
5
- module LoggerHelper
6
- def logger
7
- return Rails.logger if defined?(Rails) && Rails.logger
8
-
9
- require "logger"
10
- Logger.new($stderr)
11
- end
12
-
13
- # TODO: test
14
- def silence_deprecations?
15
- Rails.application.config.ariadne_view_components.silence_deprecations
16
- end
17
-
18
- # TODO: test
19
- def silence_warnings?
20
- Rails.application.config.ariadne_view_components.silence_warnings
21
- end
22
- end
23
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Ariadne
6
- # :nodoc:
7
- module Status
8
- # DSL to allow components to register their status.
9
- #
10
- # Example:
11
- #
12
- # class MyComponent < ViewComponent::Base
13
- # include Ariadne::Status::Dsl
14
- # status :experimental
15
- # end
16
- module Dsl
17
- extend ActiveSupport::Concern
18
-
19
- STATUSES = {
20
- experimental: :experimental,
21
- stable: :stable,
22
- }.freeze
23
-
24
- class UnknownStatusError < StandardError; end
25
-
26
- included do
27
- class_attribute :component_status, instance_writer: false, default: STATUSES[:stable]
28
- end
29
-
30
- class_methods do
31
- def status(status = nil)
32
- return component_status if status.nil?
33
-
34
- raise UnknownStatusError, "status #{status} does not exist" if STATUSES[status].nil?
35
-
36
- self.component_status = STATUSES[status]
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
- module Ariadne
5
- # Module to allow shorthand calls for Ariadne components
6
- module ViewHelper
7
- class ViewHelperNotFound < StandardError; end
8
-
9
- HELPERS = {
10
- heroicon: "Ariadne::HeroiconComponent",
11
- heading: "Ariadne::HeadingComponent",
12
- time_ago: "Ariadne::TimeAgoComponent",
13
- image: "Ariadne::ImageComponent",
14
- }.freeze
15
-
16
- HELPERS.each do |name, component|
17
- define_method "ariadne_#{name}" do |*args, **kwargs, &block|
18
- render component.constantize.new(*args, **kwargs), &block
19
- end
20
- end
21
- end
22
- end