ariadne_view_components 0.0.85 → 0.0.86

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/app/assets/stylesheets/ariadne_view_components.css +1 -1
  4. data/app/assets/stylesheets/ariadne_view_components.css.br +0 -0
  5. data/app/assets/stylesheets/ariadne_view_components.css.gz +0 -0
  6. data/app/components/ariadne/base_component.rb +15 -5
  7. data/app/components/ariadne/form/base_component.rb +1 -1
  8. data/app/components/ariadne/form/checkbox/component.html.erb +1 -1
  9. data/app/components/ariadne/form/checkbox/component.rb +15 -3
  10. data/app/components/ariadne/form/radio_button/component.html.erb +1 -3
  11. data/app/components/ariadne/form/select/component.html.erb +4 -2
  12. data/app/components/ariadne/form/select/component.rb +50 -2
  13. data/app/components/ariadne/form/toggle_group/component.html.erb +7 -0
  14. data/app/components/ariadne/form/toggle_group/component.rb +35 -0
  15. data/app/components/ariadne/form/toggle_group/option/component.html.erb +8 -0
  16. data/app/components/ariadne/form/toggle_group/option/component.rb +46 -0
  17. data/app/components/ariadne/layout/label_block/component.html.erb +12 -0
  18. data/app/components/ariadne/layout/label_block/component.rb +39 -0
  19. data/app/components/ariadne/layout/nav_bar/component.rb +4 -4
  20. data/app/components/ariadne/layout/section_block/component.html.erb +4 -0
  21. data/app/components/ariadne/layout/section_block/component.rb +12 -0
  22. data/app/components/ariadne/layout/section_block/header/component.html.erb +4 -0
  23. data/app/components/ariadne/layout/section_block/header/component.rb +14 -0
  24. data/app/components/ariadne/ui/avatar/component.html.erb +7 -0
  25. data/app/components/ariadne/ui/avatar/component.rb +54 -0
  26. data/app/components/ariadne/ui/badge/component.rb +8 -0
  27. data/app/components/ariadne/ui/card/body/component.html.erb +3 -0
  28. data/app/components/ariadne/ui/card/body/component.rb +25 -0
  29. data/app/components/ariadne/ui/card/component.html.erb +2 -6
  30. data/app/components/ariadne/ui/card/component.rb +1 -0
  31. data/app/components/ariadne/ui/combobox/component.rb +2 -0
  32. data/app/components/ariadne/ui/list/component.html.erb +2 -2
  33. data/app/components/ariadne/ui/list/component.rb +4 -3
  34. data/app/components/ariadne/ui/pagination/component.html.erb +29 -0
  35. data/app/components/ariadne/ui/pagination/component.rb +30 -0
  36. data/app/components/ariadne/ui/stats_panel/component.html.erb +7 -0
  37. data/app/components/ariadne/ui/stats_panel/component.rb +12 -0
  38. data/app/components/ariadne/ui/stats_panel/item/component.html.erb +4 -0
  39. data/app/components/ariadne/ui/stats_panel/item/component.rb +27 -0
  40. data/app/components/ariadne/ui/time_ago/component.html.erb +1 -0
  41. data/app/components/ariadne/ui/time_ago/component.rb +155 -0
  42. data/app/components/ariadne/ui/time_ago/en.yml +12 -0
  43. data/app/lib/ariadne/fetch_or_fallback_helper.rb +23 -0
  44. data/lib/ariadne/view_components/engine.rb +4 -0
  45. data/lib/ariadne/view_components/version.rb +1 -1
  46. metadata +25 -2
@@ -26,6 +26,29 @@ module Ariadne
26
26
 
27
27
  INTEGER_TYPES = Set.new(["Integer"]).freeze
28
28
 
29
+ def fetch_or_fallback(allowed_values, given_value, fallback = nil, deprecated_values: nil)
30
+ if allowed_values.include?(given_value)
31
+ given_value
32
+ elsif deprecated_values&.include?(given_value)
33
+ ::Ariadne::ViewComponents.deprecation.warn("#{given_value} is deprecated and will be removed in a future version.") unless Rails.env.production? || silence_deprecations?
34
+
35
+ given_value
36
+ else
37
+ if fallback_raises && ENV["RAILS_ENV"] != "production"
38
+ raise InvalidValueError, <<~MSG
39
+ fetch_or_fallback was called with an invalid value.
40
+
41
+ Expected one of: #{allowed_values.inspect}
42
+ Got: #{given_value.inspect}
43
+
44
+ This will not raise in production, but will instead fallback to: #{fallback.inspect}
45
+ MSG
46
+ end
47
+
48
+ fallback
49
+ end
50
+ end
51
+
29
52
  def fetch_or_raise(allowed_values, given_value, against: nil)
30
53
  if !allowed_values.is_a?(Array) && !allowed_values.is_a?(Set)
31
54
  raise ArgumentError, "allowed_values must be an array or a set; it was #{allowed_values.class}"
@@ -61,6 +61,10 @@ module Ariadne
61
61
  end
62
62
  end
63
63
 
64
+ initializer "i18n.load_path" do
65
+ config.i18n.load_path.concat(Dir[Engine.root.join.join("app", "components", "**", "*.yml")])
66
+ end
67
+
64
68
  config.after_initialize do |_app|
65
69
  Ariadne::ViewComponents.tailwind_merger = TailwindMerge::Merger.new(config: { prefix: "ariadne-" })
66
70
  end
@@ -3,6 +3,6 @@
3
3
  # :nocov:
4
4
  module Ariadne
5
5
  module ViewComponents
6
- VERSION = "0.0.85"
6
+ VERSION = "0.0.86"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadne_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.85
4
+ version: 0.0.86
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tailwind_merge
@@ -157,17 +157,27 @@ files:
157
157
  - app/components/ariadne/form/separator/component.rb
158
158
  - app/components/ariadne/form/text_field/component.html.erb
159
159
  - app/components/ariadne/form/text_field/component.rb
160
+ - app/components/ariadne/form/toggle_group/component.html.erb
161
+ - app/components/ariadne/form/toggle_group/component.rb
162
+ - app/components/ariadne/form/toggle_group/option/component.html.erb
163
+ - app/components/ariadne/form/toggle_group/option/component.rb
160
164
  - app/components/ariadne/form/validation_message/component.html.erb
161
165
  - app/components/ariadne/form/validation_message/component.rb
162
166
  - app/components/ariadne/layout/grid/component.html.erb
163
167
  - app/components/ariadne/layout/grid/component.rb
164
168
  - app/components/ariadne/layout/grid/item/component.html.erb
165
169
  - app/components/ariadne/layout/grid/item/component.rb
170
+ - app/components/ariadne/layout/label_block/component.html.erb
171
+ - app/components/ariadne/layout/label_block/component.rb
166
172
  - app/components/ariadne/layout/narrow/component.html.erb
167
173
  - app/components/ariadne/layout/narrow/component.rb
168
174
  - app/components/ariadne/layout/nav_bar/component.css
169
175
  - app/components/ariadne/layout/nav_bar/component.html.erb
170
176
  - app/components/ariadne/layout/nav_bar/component.rb
177
+ - app/components/ariadne/layout/section_block/component.html.erb
178
+ - app/components/ariadne/layout/section_block/component.rb
179
+ - app/components/ariadne/layout/section_block/header/component.html.erb
180
+ - app/components/ariadne/layout/section_block/header/component.rb
171
181
  - app/components/ariadne/layout/two_panel/component.html.erb
172
182
  - app/components/ariadne/layout/two_panel/component.rb
173
183
  - app/components/ariadne/layout/wide/component.html.erb
@@ -181,12 +191,16 @@ files:
181
191
  - app/components/ariadne/ui/accordion/component.ts
182
192
  - app/components/ariadne/ui/accordion/item/component.html.erb
183
193
  - app/components/ariadne/ui/accordion/item/component.rb
194
+ - app/components/ariadne/ui/avatar/component.html.erb
195
+ - app/components/ariadne/ui/avatar/component.rb
184
196
  - app/components/ariadne/ui/badge/component.html.erb
185
197
  - app/components/ariadne/ui/badge/component.rb
186
198
  - app/components/ariadne/ui/blankslate/component.html.erb
187
199
  - app/components/ariadne/ui/blankslate/component.rb
188
200
  - app/components/ariadne/ui/button/component.html.erb
189
201
  - app/components/ariadne/ui/button/component.rb
202
+ - app/components/ariadne/ui/card/body/component.html.erb
203
+ - app/components/ariadne/ui/card/body/component.rb
190
204
  - app/components/ariadne/ui/card/component.html.erb
191
205
  - app/components/ariadne/ui/card/component.rb
192
206
  - app/components/ariadne/ui/card/footer/component.html.erb
@@ -220,11 +234,17 @@ files:
220
234
  - app/components/ariadne/ui/overlay/component.html.erb
221
235
  - app/components/ariadne/ui/overlay/component.rb
222
236
  - app/components/ariadne/ui/overlay/component.ts
237
+ - app/components/ariadne/ui/pagination/component.html.erb
238
+ - app/components/ariadne/ui/pagination/component.rb
223
239
  - app/components/ariadne/ui/popover/component.html.erb
224
240
  - app/components/ariadne/ui/popover/component.rb
225
241
  - app/components/ariadne/ui/popover/component.ts
226
242
  - app/components/ariadne/ui/skeleton/component.html.erb
227
243
  - app/components/ariadne/ui/skeleton/component.rb
244
+ - app/components/ariadne/ui/stats_panel/component.html.erb
245
+ - app/components/ariadne/ui/stats_panel/component.rb
246
+ - app/components/ariadne/ui/stats_panel/item/component.html.erb
247
+ - app/components/ariadne/ui/stats_panel/item/component.rb
228
248
  - app/components/ariadne/ui/table/cell/component.html.erb
229
249
  - app/components/ariadne/ui/table/cell/component.rb
230
250
  - app/components/ariadne/ui/table/component.html.erb
@@ -235,6 +255,9 @@ files:
235
255
  - app/components/ariadne/ui/table/header/component.rb
236
256
  - app/components/ariadne/ui/table/row/component.html.erb
237
257
  - app/components/ariadne/ui/table/row/component.rb
258
+ - app/components/ariadne/ui/time_ago/component.html.erb
259
+ - app/components/ariadne/ui/time_ago/component.rb
260
+ - app/components/ariadne/ui/time_ago/en.yml
238
261
  - app/components/ariadne/ui/toggle/component.html.erb
239
262
  - app/components/ariadne/ui/toggle/component.rb
240
263
  - app/components/ariadne/ui/toggle/component.ts