ariadne_view_components 0.0.38-aarch64-linux → 0.0.40-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) 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. data/static/audited_at.json +0 -1
  6. data/static/constants.json +0 -2
  7. data/static/statuses.json +0 -1
  8. metadata +2 -94
  9. data/app/assets/config/manifest.js +0 -2
  10. data/app/assets/stylesheets/ariadne_view_components.css +0 -7
  11. data/app/assets/stylesheets/dropdown.css +0 -46
  12. data/app/assets/stylesheets/prosemirror.css +0 -323
  13. data/app/assets/stylesheets/tooltip-component.css +0 -37
  14. data/app/components/ariadne/ariadne-form.ts +0 -96
  15. data/app/components/ariadne/ariadne.ts +0 -21
  16. data/app/components/ariadne/avatar_component.rb +0 -81
  17. data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
  18. data/app/components/ariadne/avatar_stack_component.rb +0 -75
  19. data/app/components/ariadne/base_button.rb +0 -70
  20. data/app/components/ariadne/base_component.rb +0 -37
  21. data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
  22. data/app/components/ariadne/blankslate_component.rb +0 -148
  23. data/app/components/ariadne/body_component.rb +0 -30
  24. data/app/components/ariadne/button_component/button_component.html.erb +0 -4
  25. data/app/components/ariadne/button_component.rb +0 -165
  26. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
  27. data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
  28. data/app/components/ariadne/clipboard_copy_component.rb +0 -90
  29. data/app/components/ariadne/comment_component/comment_component.html.erb +0 -37
  30. data/app/components/ariadne/comment_component.rb +0 -71
  31. data/app/components/ariadne/component.rb +0 -127
  32. data/app/components/ariadne/container_component/container_component.html.erb +0 -3
  33. data/app/components/ariadne/container_component.rb +0 -25
  34. data/app/components/ariadne/content.rb +0 -12
  35. data/app/components/ariadne/counter_component.rb +0 -100
  36. data/app/components/ariadne/details_component/details_component.html.erb +0 -4
  37. data/app/components/ariadne/details_component.rb +0 -81
  38. data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
  39. data/app/components/ariadne/dropdown/menu_component.rb +0 -101
  40. data/app/components/ariadne/dropdown/menu_component.ts +0 -1
  41. data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
  42. data/app/components/ariadne/dropdown_component.rb +0 -172
  43. data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
  44. data/app/components/ariadne/flash_component.rb +0 -128
  45. data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
  46. data/app/components/ariadne/flex_component.rb +0 -56
  47. data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
  48. data/app/components/ariadne/footer_component.rb +0 -23
  49. data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
  50. data/app/components/ariadne/grid_component.rb +0 -63
  51. data/app/components/ariadne/header_component/header_component.html.erb +0 -29
  52. data/app/components/ariadne/header_component.rb +0 -111
  53. data/app/components/ariadne/heading_component.rb +0 -49
  54. data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
  55. data/app/components/ariadne/heroicon_component.rb +0 -166
  56. data/app/components/ariadne/image_component.rb +0 -53
  57. data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
  58. data/app/components/ariadne/inline_flex_component.rb +0 -72
  59. data/app/components/ariadne/link_component.rb +0 -65
  60. data/app/components/ariadne/list_component/list_component.html.erb +0 -6
  61. data/app/components/ariadne/list_component.rb +0 -70
  62. data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
  63. data/app/components/ariadne/narrow_container_component.rb +0 -30
  64. data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
  65. data/app/components/ariadne/panel_bar_component.rb +0 -80
  66. data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
  67. data/app/components/ariadne/pill_component.rb +0 -44
  68. data/app/components/ariadne/rich_text_area_component/rich-text-area-component.ts +0 -47
  69. data/app/components/ariadne/rich_text_area_component/rich_text_area_component.html.erb +0 -6
  70. data/app/components/ariadne/rich_text_area_component.rb +0 -35
  71. data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
  72. data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
  73. data/app/components/ariadne/slideover_component.rb +0 -66
  74. data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
  75. data/app/components/ariadne/tab_component.rb +0 -98
  76. data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
  77. data/app/components/ariadne/tab_container_component.erb +0 -10
  78. data/app/components/ariadne/tab_container_component.rb +0 -68
  79. data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
  80. data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
  81. data/app/components/ariadne/tab_nav_component.rb +0 -72
  82. data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
  83. data/app/components/ariadne/table_nav_component.rb +0 -338
  84. data/app/components/ariadne/text.rb +0 -25
  85. data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
  86. data/app/components/ariadne/time_ago_component.rb +0 -56
  87. data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
  88. data/app/components/ariadne/timeline_component.rb +0 -34
  89. data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
  90. data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
  91. data/app/components/ariadne/tooltip_component.rb +0 -108
  92. data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
  93. data/app/lib/ariadne/audited/dsl.rb +0 -32
  94. data/app/lib/ariadne/class_name_helper.rb +0 -22
  95. data/app/lib/ariadne/fetch_or_fallback_helper.rb +0 -110
  96. data/app/lib/ariadne/form_builder.rb +0 -74
  97. data/app/lib/ariadne/icon_helper.rb +0 -51
  98. data/app/lib/ariadne/logger_helper.rb +0 -23
  99. data/app/lib/ariadne/status/dsl.rb +0 -41
  100. data/app/lib/ariadne/view_helper.rb +0 -22
@@ -1,165 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `Button` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
5
- class ButtonComponent < Ariadne::Component
6
- include IconHelper
7
-
8
- DEFAULT_SCHEME = :default
9
- LINK_SCHEME = :link
10
-
11
- SCHEME_CLASS_MAPPINGS = {
12
- link: Ariadne::LinkComponent::DEFAULT_ACTIONABLE_CLASSES,
13
- none: "",
14
- default: "ariadne-text-slate-800 ariadne-bg-slate-50 hover:ariadne-bg-slate-100 ariadne-border-slate-300 focus:ariadne-ring-offset-slate-50 focus:ariadne-ring-slate-600",
15
- info: "ariadne-text-slate-800 ariadne-bg-slate-50 hover:ariadne-bg-slate-100 ariadne-border-slate-300 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-slate-600",
16
- success: "ariadne-text-green-800 ariadne-bg-green-50 hover:ariadne-bg-green-100 ariadne-border-green-300 focus:ariadne-ring-offset-green-50 focus:ariadne-ring-green-600",
17
- warning: "ariadne-text-yellow-800 ariadne-bg-yellow-50 hover:ariadne-bg-yellow-100 ariadne-border-yellow-300 focus:ariadne-ring-offset-yellow-50 focus:ariadne-ring-yellow-600",
18
- danger: "ariadne-text-red-800 ariadne-bg-red-50 hover:ariadne-bg-red-100 ariadne-border-red-300 focus:ariadne-ring-offset-red-50 focus:ariadne-ring-red-600",
19
- }.freeze
20
- VALID_SCHEMES = SCHEME_CLASS_MAPPINGS.keys.freeze
21
-
22
- # Leading visuals appear to the left of the button text.
23
- #
24
- # Use:
25
- #
26
- # - `icon` for a <%= link_to_component(Ariadne::HeroiconComponent) %>.
27
- #
28
- # @param tag [Symbol, String] The rendered tag name
29
- # @param classes [String] <%= link_to_classes_docs %>
30
- # @param icon [String] Name of <%= link_to_heroicons %> to use.
31
- # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
32
- # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::HeroiconComponent) %>.
33
- renders_one :icon, lambda { |tag: :svg, icon:, variant:, classes: "", attributes: {}|
34
- @icon = icon
35
- @variant = variant
36
- tag = check_incoming_tag(:svg, tag)
37
- Ariadne::HeroiconComponent.new(tag: tag, icon: icon, variant: variant, classes: classes, attributes: attributes)
38
- }
39
-
40
- # Trailing visuals appear to the right of the button text.
41
- #
42
- # Use:
43
- #
44
- # - `counter` for a <%= link_to_component(Ariadne::CounterComponent) %>.
45
- #
46
- # @param tag [Symbol, String] The rendered tag name
47
- # @param classes [String] <%= link_to_classes_docs %>
48
- # @param counter [Number] The starting counter value
49
- # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::CounterComponent) %>.
50
- renders_one :counter, lambda { |tag: :span, count: 0, classes: "", attributes: {}|
51
- tag = check_incoming_tag(:span, tag)
52
- attributes[:ml] = check_incoming_value(2, ml: attributes[:ml])
53
-
54
- Ariadne::CounterComponent.new(tag: tag, count: count, classes: classes, attributes: attributes)
55
- }
56
-
57
- # `Tooltip` that appears on mouse hover or keyboard focus over the button. Use tooltips sparingly and as a last resort.
58
- # **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
59
- # Consult the <%= link_to_component(Ariadne::TooltipComponent) %> documentation for more information.
60
- #
61
- # @param tag [Symbol, String] The rendered tag name
62
- # @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
63
- # @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
64
- # @param classes [String] <%= link_to_classes_docs %>
65
- # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::TooltipComponent) %>.
66
- renders_one :tooltip, lambda { |tag: Ariadne::TooltipComponent::DEFAULT_TAG, text:, direction: Ariadne::TooltipComponent::DEFAULT_PLACEMENT, type: Ariadne::TooltipComponent::TYPE_DEFAULT, classes: "", attributes: {}|
67
- raise ArgumentError, "Buttons with a tooltip must have a unique `id` set on the `Button`." if @id.blank?
68
-
69
- Ariadne::TooltipComponent.new(for_id: @id, tag: tag, text: text, direction: direction, type: type, classes: classes, attributes: attributes)
70
- }
71
-
72
- # @example Schemes
73
- # <%= render(Ariadne::ButtonComponent.new) { "Default" } %>
74
- # <%= render(Ariadne::ButtonComponent.new(scheme: :default)) { "Default" } %>
75
- # <%= render(Ariadne::ButtonComponent.new(scheme: :info)) { "Info" } %>
76
- # <%= render(Ariadne::ButtonComponent.new(scheme: :success)) { "Success" } %>
77
- # <%= render(Ariadne::ButtonComponent.new(scheme: :warning)) { "Warning" } %>
78
- # <%= render(Ariadne::ButtonComponent.new(scheme: :danger)) { "Danger" } %>
79
- #
80
- # @example Sizes
81
- # <%= render(Ariadne::ButtonComponent.new(size: :sm)) { "Small" } %>
82
- # <%= render(Ariadne::ButtonComponent.new(size: :md)) { "Medium" } %>
83
- #
84
- # @example With leading visual
85
- # <%= render(Ariadne::ButtonComponent.new) do |c| %>
86
- # <% c.with_icon(icon: :star, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "ariadne-text-yellow-600") %>
87
- # Button
88
- # <% end %>
89
- #
90
- # @example With trailing visual
91
- # <%= render(Ariadne::ButtonComponent.new) do |c| %>
92
- # <% c.with_counter(count: 15) %>
93
- # Button
94
- # <% end %>
95
- #
96
- # @example With leading and trailing visuals
97
- # <%= render(Ariadne::ButtonComponent.new) do |c| %>
98
- # <% c.with_icon(icon: :star, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
99
- # <% c.with_counter(count: 15) %>
100
- # Button
101
- # <% end %>
102
- #
103
- # @example With tooltip
104
- # @description
105
- # Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Ariadne::TooltipComponent) %> documentation for more information.
106
- # @code
107
- # <%= render(Ariadne::ButtonComponent.new(attributes: { id: "button-with-tooltip" })) do |c| %>
108
- # <% c.with_tooltip(text: "Tooltip text") %>
109
- # Button
110
- # <% end %>
111
- #
112
- # @param tag [Symbol] <%= one_of(Ariadne::BaseButton::TAG_OPTIONS) %>
113
- # @param type [Symbol] <%= one_of(Ariadne::BaseButton::VALID_TYPES) %>
114
- # @param scheme [Symbol] <%= one_of(Ariadne::ButtonComponent::VALID_SCHEMES) %>
115
- # @param size [Symbol] <%= one_of(Ariadne::BaseButton::VALID_SIZES) %>
116
- # @param dropdown [Boolean] Whether or not to render a dropdown caret.
117
- # @param classes [String] <%= link_to_classes_docs %>
118
- # @param attributes [Hash] <%= link_to_attributes_docs %>
119
- def initialize(
120
- tag: Ariadne::BaseButton::DEFAULT_TAG,
121
- type: Ariadne::BaseButton::DEFAULT_TYPE,
122
- scheme: DEFAULT_SCHEME,
123
- size: BaseButton::DEFAULT_SIZE,
124
- dropdown: false,
125
- classes: "",
126
- attributes: {}
127
- )
128
- @tag = tag
129
- @type = type
130
-
131
- @attributes = attributes
132
- @id = @attributes[:id]
133
-
134
- @size = fetch_or_raise(Ariadne::BaseButton::VALID_SIZES, size)
135
- @scheme = fetch_or_raise(VALID_SCHEMES, scheme)
136
- @scheme = LINK_SCHEME if @tag == :a
137
-
138
- @classes = merge_class_names(
139
- SCHEME_CLASS_MAPPINGS[@scheme],
140
- classes,
141
- )
142
-
143
- @dropdown = dropdown
144
- end
145
-
146
- private def dropdown?
147
- @dropdown
148
- end
149
-
150
- private def trimmed_content
151
- return if content.blank?
152
-
153
- trimmed_content = content.strip
154
-
155
- return trimmed_content unless content.html_safe?
156
-
157
- # strip unsets `html_safe`, so we have to set it back again to guarantee that HTML blocks won't break
158
- trimmed_content.html_safe # rubocop:disable Rails/OutputSafety
159
- end
160
-
161
- private def link?
162
- @scheme == LINK_SCHEME
163
- end
164
- end
165
- end
@@ -1,19 +0,0 @@
1
- import {Controller} from '@hotwired/stimulus'
2
-
3
- export default class ClipboardCopyComponent extends Controller {
4
- copy() {
5
- const value = this.element.attributes.getNamedItem('value')
6
-
7
- const forNode = this.element.attributes.getNamedItem('for')
8
-
9
- if (value) {
10
- navigator.clipboard.writeText(value.value)
11
- } else if (forNode) {
12
- const node = document.getElementById(forNode.value)
13
- navigator.clipboard.writeText(node?.textContent || '')
14
- } else {
15
- // just copy inner text
16
- navigator.clipboard.writeText(this.element.textContent || '')
17
- }
18
- }
19
- }
@@ -1,9 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes.merge(controller_data)) do %>
2
- <% if content.present? %>
3
- <%= content.to_s + tooltip.to_s %>
4
- <% else %>
5
- <%= render Ariadne::HeroiconComponent.new(icon: :"document-duplicate", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
6
- <!-- TODO: fix, check should replace on click -->
7
- <%= render Ariadne::HeroiconComponent.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "ariadne-text-green-600", attributes: { style: "display: none;" }) %>
8
- <% end %>
9
- <% end %>
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `ClipboardCopyComponent` to copy element text content or input values to the clipboard.
5
- #
6
- # @accessibility
7
- # Always set an accessible label to help the user interact with the component.
8
- class ClipboardCopyComponent < Ariadne::Component
9
- DEFAULT_TAG = :"clipboard-copy"
10
-
11
- DEFAULT_CLASSES = LinkComponent::DEFAULT_ACTIONABLE_CLASSES
12
-
13
- DATA_CONTROLLER = "clipboard-copy-component"
14
- DATA_ACTION = "click->clipboard-copy-component#copy"
15
-
16
- # `Tooltip` that appears on mouse hover or keyboard focus over the button. Use tooltips sparingly and as a last resort.
17
- # **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
18
- # Consult the <%= link_to_component(Ariadne::TooltipComponent) %> documentation for more information.
19
- #
20
- # @param tag [Symbol, String] The rendered tag name
21
- # @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
22
- # @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
23
- # @param classes [String] <%= link_to_classes_docs %>
24
- # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::TooltipComponent) %>.
25
- renders_one :tooltip, lambda { |tag: Ariadne::TooltipComponent::DEFAULT_TAG, text:, direction: Ariadne::TooltipComponent::DEFAULT_PLACEMENT, type: Ariadne::TooltipComponent::TYPE_DEFAULT, classes: "", attributes: {}|
26
- raise ArgumentError, "CopyClipboardComponents with a tooltip must have a unique `id` set on the `CopyClipboardComponent`." if @id.blank?
27
-
28
- @data_tooltip_direction = { "data-tooltip-component-direction": direction }
29
-
30
- Ariadne::TooltipComponent.new(tag: tag, for_id: @id, text: text, direction: direction, type: type, classes: classes, attributes: attributes)
31
- }
32
-
33
- # @example Default
34
- # <%= render(Ariadne::ClipboardCopyComponent.new(value: "Text to copy", aria_label: "Copy text to the system clipboard" )) %>
35
- #
36
- # @example With text instead of icons
37
- # <%= render(Ariadne::ClipboardCopyComponent.new(value: "Text to copy", aria_label: "Copy text to the system clipboard" )) do %>
38
- # Click to copy!
39
- # <% end %>
40
- #
41
- # @example Copying from an element
42
- # <%= render(Ariadne::ClipboardCopyComponent.new(for_id: "blob-path", aria_label: "Copy text to the system clipboard" )) %>
43
- # <div id="blob-path">src/index.js</div>
44
- #
45
- # @param tag [Symbol, String] The rendered tag name
46
- # @param classes [String] <%= link_to_classes_docs %>
47
- # @param value [String] Text to copy into the users clipboard when they click the component.
48
- # @param for_id [String] If `value` is not provided, the element with this id will be copied.
49
- # @param aria_label [String] Text for accessibility. Can also be passed in as part of `attributes`, but it must be present.
50
- # @param attributes [Hash] <%= link_to_attributes_docs %>
51
- def initialize(tag: DEFAULT_TAG, value: "", for_id: nil, aria_label: "", classes: "", attributes: {})
52
- @attributes = attributes
53
- @value = value
54
-
55
- @attributes[:"aria-label"] = aria_label
56
- @attributes[:for] ||= for_id
57
- @id = @attributes[:id]
58
-
59
- validate!
60
-
61
- @classes = merge_class_names(DEFAULT_CLASSES, classes)
62
- @tag = check_incoming_tag(DEFAULT_TAG, tag)
63
- @attributes[:value] = value if value.present?
64
- end
65
-
66
- private def validate!
67
- validate_aria_label!
68
- raise ArgumentError, "Must provide either `value` or `for`" if @value.blank? && @attributes[:for].blank?
69
- raise ArgumentError, "Must provide only `value` or `for`, not both" if @value.present? && @attributes[:for].present?
70
- end
71
-
72
- DATA_CONTROLLERS_WITH_TOOLTIPS = {
73
- "data-controller": "#{DATA_CONTROLLER} #{Ariadne::TooltipComponent::DATA_CONTROLLER}",
74
- "data-action": "#{DATA_ACTION} #{Ariadne::TooltipComponent::DATA_ACTION}",
75
- "data-tooltip-component-target": "trigger",
76
- }
77
-
78
- DATA_CONTROLLERS =
79
- {
80
- "data-controller": DATA_CONTROLLER.to_s,
81
- "data-action": DATA_ACTION,
82
- }
83
-
84
- def controller_data
85
- return DATA_CONTROLLERS_WITH_TOOLTIPS if tooltip.present?
86
-
87
- DATA_CONTROLLERS
88
- end
89
- end
90
- end
@@ -1,37 +0,0 @@
1
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
2
- <%= render(Ariadne::TabContainerComponent.new(sr_label: @sr_label)) do |tab_container| %>
3
- <%= tab_container.with_tab(id: public_tab.id, selected: public_tab.selected, classes: public_tab.classes, attributes: public_tab.attributes) do |tab| %>
4
- <% tab.with_text { @public_tab_text } %>
5
- <% tab.with_panel(attributes: {:"data-public" => true}) do %>
6
- <%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
7
- <% @hidden_fields.each do |name, value| %>
8
- <%= hidden_field_tag name, value %>
9
- <% end %>
10
- <div class="ariadne-overflow-hidden ariadne-border ariadne-border-slate-300 ariadne-shadow-sm">
11
- <%= hidden_field_tag 'message_is_public', true %>
12
- <%= render(Ariadne::RichTextAreaComponent.new(name: :message_public_bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
13
- <% comment_box.submit { @submit } %>
14
- </div>
15
- <div class="ariadne-py-2 ariadne-flex ariadne-justify-end">
16
- <%= public_submit %>
17
- </div>
18
- <% end %>
19
- <% end %>
20
- <% end %>
21
- <%= tab_container.with_tab(id: internal_tab.id, selected: internal_tab.selected, classes: internal_tab.classes, attributes: internal_tab.attributes) do |tab| %>
22
- <% tab.with_text { @internal_tab_text } %>
23
- <% tab.with_panel do %>
24
- <%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
25
- <div class="ariadne-overflow-hidden ariadne-border ariadne-border-gray-300 ariadne-shadow-sm">
26
- <%= hidden_field_tag 'message_is_public', false %>
27
- <%= render(Ariadne::RichTextAreaComponent.new(name: :message_internal_bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
28
- <% comment_box.submit { @submit } %>
29
- </div>
30
- <div class="ariadne-py-2 ariadne-flex ariadne-justify-end">
31
- <%= internal_submit %>
32
- </div>
33
- <% end %>
34
- <% end %>
35
- <% end %>
36
- <% end %>
37
- <% end %>
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Defines a submittable form for adding comments to a conversation.
5
- #
6
- #
7
- # @accessibility This component requires you to pass in a `sr_label`
8
- # attribute, which will be used to label the tabs for screen readers.
9
- class CommentComponent < Ariadne::Component
10
- DEFAULT_TAG = :div
11
- TAG_OPTIONS = [DEFAULT_TAG].freeze
12
-
13
- DEFAULT_CLASSES = "ariadne-border-gray-300 ariadne-border ariadne-shadow ariadne-py-5 ariadne-px-5 ariadne-rounded-md "
14
-
15
- renders_one :public_tab, lambda { |selected: false, text:, classes: "", attributes: {}|
16
- attributes[:"data-public"] = true
17
- @tab_idx += 1
18
- id = attributes.fetch(:id, "public-tab-#{@tab_idx}")
19
- @public_tab_text = text
20
-
21
- Ariadne::TabComponent.new(selected: selected, classes: classes, id: id, with_panel: true, attributes: attributes)
22
- }
23
-
24
- renders_one :public_submit, lambda { |classes: "", attributes: {}|
25
- Ariadne::ButtonComponent.new(type: Ariadne::BaseButton::TYPE_SUBMIT, scheme: Ariadne::ButtonComponent::DEFAULT_SCHEME, classes: classes, attributes: attributes)
26
- }
27
-
28
- renders_one :internal_tab, lambda { |selected: false, text:, classes: "", attributes: {}|
29
- attributes[:"data-public"] = false
30
- @tab_idx += 1
31
- id = attributes.fetch(:id, "internal-tab-#{@tab_idx}")
32
- @internal_tab_text = text
33
-
34
- Ariadne::TabComponent.new(selected: selected, classes: classes, id: id, with_panel: true, attributes: attributes)
35
- }
36
-
37
- renders_one :internal_submit, lambda { |classes: "", attributes: {}|
38
- Ariadne::ButtonComponent.new(type: Ariadne::BaseButton::TYPE_SUBMIT, scheme: Ariadne::ButtonComponent::DEFAULT_SCHEME, classes: classes, attributes: attributes)
39
- }
40
-
41
- # @example Default
42
- #
43
- # <%= render(Ariadne::CommentComponent.new(url: "/messages", method: :post, sr_label: "Select delivery time")) do |comment| %>
44
- # <% comment.with_public_tab(selected: true, text: "Reply to sender") %>
45
- # <% comment.with_public_submit { "Send" } %>
46
- # <% comment.with_internal_tab(text: "Internal comment") %>
47
- # <% comment.with_internal_submit { "Send" } %>
48
- # <% end %>
49
- #
50
- # @param url [String] The URL to take action against.
51
- # @param method [String] The method to use when submitting the form.
52
- # @param sr_label [String] A label to introduce these tabs for screen readers.
53
- # @param hidden_fields [[String]] An array of arrays of additional (hidden) fields to add to the form.
54
- # @param classes [String] <%= link_to_classes_docs %>
55
- # @param attributes [Hash] <%= link_to_attributes_docs %>
56
- def initialize(url:, method: :post, sr_label:, hidden_fields: [], classes: "", attributes: {})
57
- @tag = DEFAULT_TAG
58
- @classes = merge_class_names(
59
- DEFAULT_CLASSES,
60
- classes,
61
- )
62
- @url = url
63
- @method = method
64
- @sr_label = sr_label
65
-
66
- @tab_idx = -1
67
- @hidden_fields = hidden_fields
68
- @attributes = attributes
69
- end
70
- end
71
- end
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "view_component/version"
4
-
5
- require "heroicons_helper"
6
-
7
- module Ariadne
8
- # @private
9
- class Component < ViewComponent::Base
10
- include ClassNameHelper
11
- include FetchOrFallbackHelper
12
- include ViewHelper
13
- include Status::Dsl
14
- include Audited::Dsl
15
- include LoggerHelper
16
- include Ariadne::ActionViewExtensions::FormHelper
17
-
18
- BASE_WRAPPER_CLASSES = "ariadne-flex ariadne-flex-col ariadne-h-screen ariadne-justify-between"
19
- BASE_MAIN_CLASSES = "ariadne-flex-auto"
20
-
21
- # this is defined here for the Tailwind parser to pick up; it can be useful
22
- # in situations where hiddenness is defined by a kwarg, eg `selected: false`
23
- BASE_HIDDEN_CLASS = "ariadne-hidden"
24
-
25
- INVALID_ARIA_LABEL_TAGS = [:div, :span, :p].freeze
26
-
27
- private def raise_on_invalid_options?
28
- Rails.application.config.ariadne_view_components.raise_on_invalid_options
29
- end
30
-
31
- private def raise_on_invalid_aria?
32
- Rails.application.config.ariadne_view_components.raise_on_invalid_aria
33
- end
34
-
35
- private def deprecated_component_warning(new_class: nil, version: nil)
36
- return if silence_deprecations?
37
-
38
- message = "#{self.class.name} is deprecated"
39
- message += " and will be removed in v#{version}." if version
40
- message += " Use #{new_class.name} instead." if new_class
41
-
42
- ActiveSupport::Deprecation.warn(message)
43
- end
44
-
45
- private def aria(val, attributes)
46
- attributes[:"aria-#{val}"] || attributes.dig(:aria, val.to_sym)
47
- end
48
-
49
- private def validate_aria_label!
50
- aria_label = aria("label", @attributes)
51
- raise ArgumentError, "`aria-label` is required." if aria_label.blank?
52
- end
53
-
54
- private def check_denylist(denylist = [], attributes = {})
55
- if should_raise_error?
56
-
57
- # Convert denylist from:
58
- # { [:p, :pt] => "message" } to:
59
- # { p: "message", pt: "message" }
60
- unpacked_denylist =
61
- denylist.each_with_object({}) do |(keys, value), memo|
62
- keys.each { |key| memo[key] = value }
63
- end
64
-
65
- violations = unpacked_denylist.keys & attributes.keys
66
-
67
- if violations.any?
68
- message = "Found #{violations.count} #{"violation".pluralize(violations)}:"
69
- violations.each do |violation|
70
- message += "\n The #{violation} argument is not allowed here. #{unpacked_denylist[violation]}"
71
- end
72
-
73
- raise(ArgumentError, message)
74
- end
75
- end
76
-
77
- attributes
78
- end
79
-
80
- private def validate_attributes(tag:, denylist_name: :attributes_denylist, attributes: {})
81
- deny_single_argument(:class, "Use `classes` instead.", attributes)
82
-
83
- if (denylist = attributes[denylist_name])
84
- check_denylist(denylist, attributes)
85
-
86
- # Remove :attributes_denylist key and any denied keys from attributes
87
- attributes.except!(denylist_name)
88
- attributes.except!(*denylist.keys.flatten)
89
- end
90
-
91
- deny_aria_label(tag: tag, attributes: attributes)
92
-
93
- attributes
94
- end
95
-
96
- private def deny_single_argument(key, help_text, attributes)
97
- raise ArgumentError, "`#{key}` is an invalid argument. #{help_text}" \
98
- if should_raise_error? && attributes.key?(key)
99
-
100
- attributes.except!(key)
101
- end
102
-
103
- private def deny_aria_label(tag:, attributes:)
104
- return attributes.except!(:skip_aria_label_check) if attributes[:skip_aria_label_check]
105
- return if attributes[:role]
106
- return unless INVALID_ARIA_LABEL_TAGS.include?(tag)
107
-
108
- deny_aria_key(
109
- :label,
110
- "Don't use `aria-label` on `#{tag}` elements. See https://www.tpgi.com/short-note-on-aria-label-aria-labelledby-and-aria-describedby/",
111
- attributes,
112
- )
113
- end
114
-
115
- private def deny_aria_key(key, help_text, attributes)
116
- raise ArgumentError, help_text if should_raise_aria_error? && aria(key, attributes)
117
- end
118
-
119
- private def should_raise_error?
120
- raise_on_invalid_options? && !ENV["ARIADNE_WARNINGS_DISABLED"]
121
- end
122
-
123
- private def should_raise_aria_error?
124
- raise_on_invalid_aria? && !ENV["ARIADNE_WARNINGS_DISABLED"]
125
- end
126
- end
127
- end
@@ -1,3 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |component| %>
2
- <%= content %>
3
- <% end %>
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # The container wraps the majority, if not all, of the content on a page.
5
- class ContainerComponent < Ariadne::Component
6
- DEFAULT_CLASSES = "ariadne-px-4 sm:ariadne-px-6 lg:ariadne-px-8"
7
-
8
- # @example Default
9
- # <%= render(Ariadne::ContainerComponent.new) do |container| %>
10
- # <%= render(Ariadne::ButtonComponent.new) { "Click me!" } %>
11
- # <% end %>
12
- #
13
- # @param classes [String] <%= link_to_classes_docs %>
14
- # @param attributes [Hash] <%= link_to_attributes_docs %>
15
- def initialize(classes: "", attributes: {})
16
- @tag = :div
17
- @classes = merge_class_names(
18
- DEFAULT_CLASSES,
19
- classes,
20
- )
21
-
22
- @attributes = attributes
23
- end
24
- end
25
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- #
5
- # Use `Content` as a helper to render content passed to a slot without adding any tags.
6
- #
7
- class Content < Ariadne::Component
8
- def call
9
- content
10
- end
11
- end
12
- end
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `CounterComponent` to add a count to navigational elements and buttons.
5
- #
6
- # @accessibility
7
- # Always use `CounterComponent` with adjacent text that provides supplementary information regarding what the count is for. For instance, `Counter`
8
- # should be accompanied with text such as `issues` or `pull requests`.
9
- #
10
- class CounterComponent < Ariadne::Component
11
- DEFAULT_CLASSES = "ariadne-inline-flex ariadne-items-center ariadne-p-1 ariadne-border ariadne-border-transparent ariadne-rounded-full ariadne-shadow-sm focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
12
-
13
- # @example Default
14
- # <%= render(Ariadne::CounterComponent.new(count: 25)) %>
15
- #
16
- # @example Schemes
17
- # <%= render(Ariadne::CounterComponent.new(count: 25)) %>
18
- # <%= render(Ariadne::CounterComponent.new(count: 25)) %>
19
- #
20
- # @param tag [Symbol, String] The rendered tag name
21
- # @param classes [String] <%= link_to_classes_docs %>
22
- # @param count [Integer, Float::INFINITY, nil] The number to be displayed (e.x. # of issues, pull requests)
23
- # @param limit [Integer, nil] Maximum value to display. Pass `nil` for no limit. (e.x. if `count` == 6,000 and `limit` == 5000, counter will display "5,000+")
24
- # @param hide_if_zero [Boolean] If true, a `hidden` attribute is added to the counter if `count` is zero.
25
- # @param text [String] Text to display instead of count.
26
- # @param round [Boolean] Whether to apply rounding logic to value.
27
- # @param attributes [Hash] <%= link_to_attributes_docs %>
28
- def initialize(
29
- tag: :span,
30
- count: 0,
31
- limit: 9_000,
32
- hide_if_zero: false,
33
- text: "",
34
- round: false,
35
- classes: "",
36
- attributes: {}
37
- )
38
- @count = count
39
- @limit = limit
40
- @hide_if_zero = hide_if_zero
41
- @text = text
42
- @round = round
43
- @attributes = attributes
44
-
45
- @has_limit = !@limit.nil?
46
-
47
- @tag = check_incoming_tag(:span, tag)
48
-
49
- @attributes[:title] = title
50
-
51
- @classes = merge_class_names(
52
- DEFAULT_CLASSES,
53
- classes,
54
- )
55
- @attributes[:hidden] = true if count == 0 && hide_if_zero
56
- end
57
-
58
- def call
59
- render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { value }
60
- end
61
-
62
- private def title
63
- if @text.present?
64
- @text
65
- elsif @count.nil?
66
- "Not available"
67
- elsif @count == Float::INFINITY
68
- "Infinity"
69
- else
70
- count = @count.to_i
71
- str = number_with_delimiter(@has_limit ? [count, @limit].min : count)
72
- str += "+" if @has_limit && count > @limit
73
- str
74
- end
75
- end
76
-
77
- private def value
78
- if @text.present?
79
- @text
80
- elsif @count.nil?
81
- "" # CSS will hide it
82
- elsif @count == Float::INFINITY
83
- "∞"
84
- else
85
- if @round
86
- count = @has_limit ? [@count.to_i, @limit].min : @count.to_i
87
- precision = count.between?(100_000, 999_999) ? 0 : 1
88
- units = { thousand: "k", million: "m", billion: "b" }
89
- str = number_to_human(count, precision: precision, significant: false, units: units, format: "%n%u")
90
- else
91
- @count = @count.to_i
92
- str = number_with_delimiter(@has_limit ? [@count, @limit].min : @count)
93
- end
94
-
95
- str += "+" if @has_limit && @count.to_i > @limit
96
- str
97
- end
98
- end
99
- end
100
- end
@@ -1,4 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |component| %>
2
- <%= summary %>
3
- <%= body %>
4
- <% end %>