ariadne_view_components 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/ariadne-form-with.d.ts +20 -0
  4. data/app/assets/javascripts/ariadne-form.d.ts +22 -0
  5. data/app/assets/javascripts/ariadne.d.ts +1 -0
  6. data/app/assets/javascripts/ariadne_view_components.js +7 -1
  7. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  8. data/app/assets/javascripts/clipboard-copy-component.d.ts +4 -0
  9. data/app/assets/javascripts/comment-component.d.ts +13 -0
  10. data/app/assets/javascripts/rich-text-area-component.d.ts +4 -0
  11. data/app/assets/javascripts/slideover-component.d.ts +9 -0
  12. data/app/assets/javascripts/time-ago-component.d.ts +1 -0
  13. data/app/assets/javascripts/time_ago_component.d.ts +1 -0
  14. data/app/assets/javascripts/tooltip-component.d.ts +24 -0
  15. data/app/assets/stylesheets/application.ariadne_view_components.css +6 -3
  16. data/app/assets/stylesheets/prosemirror.css +323 -0
  17. data/app/assets/stylesheets/tooltip-component.css +37 -0
  18. data/app/components/ariadne/ariadne-form.ts +96 -0
  19. data/app/components/ariadne/ariadne.ts +11 -1
  20. data/app/components/ariadne/base_button.rb +12 -12
  21. data/app/components/ariadne/base_component.rb +13 -131
  22. data/app/components/ariadne/blankslate_component.html.erb +5 -5
  23. data/app/components/ariadne/blankslate_component.rb +5 -10
  24. data/app/components/ariadne/body_component.rb +30 -0
  25. data/app/components/ariadne/button_component.rb +12 -16
  26. data/app/components/ariadne/clipboard_copy_component.html.erb +5 -4
  27. data/app/components/ariadne/clipboard_copy_component.rb +41 -3
  28. data/app/components/ariadne/comment-component.ts +55 -0
  29. data/app/components/ariadne/comment_component.html.erb +22 -0
  30. data/app/components/ariadne/comment_component.rb +57 -0
  31. data/app/components/ariadne/component.rb +4 -3
  32. data/app/components/ariadne/container_component.rb +1 -1
  33. data/app/components/ariadne/counter_component.rb +4 -4
  34. data/app/components/ariadne/flash_component.html.erb +12 -12
  35. data/app/components/ariadne/flash_component.rb +17 -17
  36. data/app/components/ariadne/flex_component.rb +49 -0
  37. data/app/components/ariadne/footer_component.html.erb +1 -1
  38. data/app/components/ariadne/footer_component.rb +1 -1
  39. data/app/components/ariadne/grid_component.html.erb +13 -4
  40. data/app/components/ariadne/grid_component.rb +22 -11
  41. data/app/components/ariadne/header_component.html.erb +7 -7
  42. data/app/components/ariadne/header_component.rb +8 -8
  43. data/app/components/ariadne/heading_component.rb +3 -3
  44. data/app/components/ariadne/heroicon_component.html.erb +4 -6
  45. data/app/components/ariadne/heroicon_component.rb +21 -10
  46. data/app/components/ariadne/inline_flex_component.rb +14 -12
  47. data/app/components/ariadne/link_component.rb +13 -8
  48. data/app/components/ariadne/list_component.html.erb +5 -7
  49. data/app/components/ariadne/list_component.rb +9 -38
  50. data/app/components/ariadne/main_component.rb +32 -0
  51. data/app/components/ariadne/narrow_container_component.html.erb +3 -0
  52. data/app/components/ariadne/narrow_container_component.rb +30 -0
  53. data/app/components/ariadne/panel_bar_component.html.erb +20 -0
  54. data/app/components/ariadne/panel_bar_component.rb +79 -0
  55. data/app/components/ariadne/pill_component.rb +2 -2
  56. data/app/components/ariadne/rich-text-area-component.ts +32 -0
  57. data/app/components/ariadne/rich_text_area_component.html.erb +6 -0
  58. data/app/components/ariadne/rich_text_area_component.rb +35 -0
  59. data/app/components/ariadne/slideover-component.ts +3 -3
  60. data/app/components/ariadne/slideover_component.html.erb +3 -6
  61. data/app/components/ariadne/slideover_component.rb +19 -15
  62. data/app/components/ariadne/tab_bar_component.html.erb +3 -0
  63. data/app/components/ariadne/tab_bar_component.rb +45 -0
  64. data/app/components/ariadne/tab_component.html.erb +7 -0
  65. data/app/components/ariadne/tab_component.rb +43 -0
  66. data/app/components/ariadne/{time_ago_component.ts → time-ago-component.ts} +0 -0
  67. data/app/components/ariadne/time_ago_component.rb +2 -2
  68. data/app/components/ariadne/timeline_component.html.erb +6 -6
  69. data/app/components/ariadne/tooltip-component.ts +57 -0
  70. data/app/components/ariadne/tooltip_component.html.erb +4 -0
  71. data/app/components/ariadne/tooltip_component.rb +34 -31
  72. data/app/lib/ariadne/action_view_extensions/form_helper.rb +4 -1
  73. data/app/lib/ariadne/fetch_or_fallback_helper.rb +3 -1
  74. data/app/lib/ariadne/form_builder.rb +22 -22
  75. data/app/lib/ariadne/icon_helper.rb +1 -1
  76. data/lib/ariadne/view_components/engine.rb +171 -3
  77. data/lib/ariadne/view_components/version.rb +1 -1
  78. data/lib/ariadne/view_components.rb +31 -30
  79. data/lib/rubocop/config/default.yml +0 -6
  80. data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +1 -0
  81. data/lib/tasks/docs.rake +9 -0
  82. data/static/arguments.yml +186 -15
  83. data/static/audited_at.json +12 -2
  84. data/static/classes.yml +200 -154
  85. data/static/constants.json +168 -146
  86. data/static/statuses.json +12 -2
  87. metadata +65 -13
  88. data/lib/ariadne/classify/utilities.rb +0 -199
  89. data/lib/ariadne/classify/utilities.yml +0 -1817
  90. data/lib/ariadne/classify/validation.rb +0 -18
  91. data/lib/ariadne/classify.rb +0 -218
  92. data/lib/rubocop/cop/ariadne/ariadne_heroicon.rb +0 -252
  93. data/lib/rubocop/cop/ariadne/component_name_migration.rb +0 -35
  94. data/lib/rubocop/cop/ariadne/system_argument_instead_of_class.rb +0 -57
  95. data/lib/tasks/utilities.rake +0 -121
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadne_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.7
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: 2022-07-25 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tailwind_merge
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: actionview
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +70,28 @@ dependencies:
56
70
  requirements:
57
71
  - - "~>"
58
72
  - !ruby/object:Gem::Version
59
- version: '0.4'
73
+ version: '0.6'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.6'
81
+ - !ruby/object:Gem::Dependency
82
+ name: simple_form
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '5.1'
60
88
  type: :runtime
61
89
  prerelease: false
62
90
  version_requirements: !ruby/object:Gem::Requirement
63
91
  requirements:
64
92
  - - "~>"
65
93
  - !ruby/object:Gem::Version
66
- version: '0.4'
94
+ version: '5.1'
67
95
  - !ruby/object:Gem::Dependency
68
96
  name: view_component
69
97
  requirement: !ruby/object:Gem::Requirement
@@ -94,19 +122,36 @@ files:
94
122
  - LICENSE.txt
95
123
  - README.md
96
124
  - app/assets/config/manifest.js
125
+ - app/assets/javascripts/ariadne-form-with.d.ts
126
+ - app/assets/javascripts/ariadne-form.d.ts
127
+ - app/assets/javascripts/ariadne.d.ts
97
128
  - app/assets/javascripts/ariadne_view_components.js
98
129
  - app/assets/javascripts/ariadne_view_components.js.map
130
+ - app/assets/javascripts/clipboard-copy-component.d.ts
131
+ - app/assets/javascripts/comment-component.d.ts
132
+ - app/assets/javascripts/rich-text-area-component.d.ts
133
+ - app/assets/javascripts/slideover-component.d.ts
134
+ - app/assets/javascripts/time-ago-component.d.ts
135
+ - app/assets/javascripts/time_ago_component.d.ts
136
+ - app/assets/javascripts/tooltip-component.d.ts
99
137
  - app/assets/stylesheets/application.ariadne_view_components.css
138
+ - app/assets/stylesheets/prosemirror.css
139
+ - app/assets/stylesheets/tooltip-component.css
140
+ - app/components/ariadne/ariadne-form.ts
100
141
  - app/components/ariadne/ariadne.ts
101
142
  - app/components/ariadne/base_button.rb
102
143
  - app/components/ariadne/base_component.rb
103
144
  - app/components/ariadne/blankslate_component.html.erb
104
145
  - app/components/ariadne/blankslate_component.rb
146
+ - app/components/ariadne/body_component.rb
105
147
  - app/components/ariadne/button_component.html.erb
106
148
  - app/components/ariadne/button_component.rb
107
149
  - app/components/ariadne/clipboard-copy-component.ts
108
150
  - app/components/ariadne/clipboard_copy_component.html.erb
109
151
  - app/components/ariadne/clipboard_copy_component.rb
152
+ - app/components/ariadne/comment-component.ts
153
+ - app/components/ariadne/comment_component.html.erb
154
+ - app/components/ariadne/comment_component.rb
110
155
  - app/components/ariadne/component.rb
111
156
  - app/components/ariadne/container_component.html.erb
112
157
  - app/components/ariadne/container_component.rb
@@ -114,6 +159,7 @@ files:
114
159
  - app/components/ariadne/counter_component.rb
115
160
  - app/components/ariadne/flash_component.html.erb
116
161
  - app/components/ariadne/flash_component.rb
162
+ - app/components/ariadne/flex_component.rb
117
163
  - app/components/ariadne/footer_component.html.erb
118
164
  - app/components/ariadne/footer_component.rb
119
165
  - app/components/ariadne/grid_component.html.erb
@@ -129,16 +175,30 @@ files:
129
175
  - app/components/ariadne/link_component.rb
130
176
  - app/components/ariadne/list_component.html.erb
131
177
  - app/components/ariadne/list_component.rb
178
+ - app/components/ariadne/main_component.rb
179
+ - app/components/ariadne/narrow_container_component.html.erb
180
+ - app/components/ariadne/narrow_container_component.rb
181
+ - app/components/ariadne/panel_bar_component.html.erb
182
+ - app/components/ariadne/panel_bar_component.rb
132
183
  - app/components/ariadne/pill_component.html.erb
133
184
  - app/components/ariadne/pill_component.rb
185
+ - app/components/ariadne/rich-text-area-component.ts
186
+ - app/components/ariadne/rich_text_area_component.html.erb
187
+ - app/components/ariadne/rich_text_area_component.rb
134
188
  - app/components/ariadne/slideover-component.ts
135
189
  - app/components/ariadne/slideover_component.html.erb
136
190
  - app/components/ariadne/slideover_component.rb
191
+ - app/components/ariadne/tab_bar_component.html.erb
192
+ - app/components/ariadne/tab_bar_component.rb
193
+ - app/components/ariadne/tab_component.html.erb
194
+ - app/components/ariadne/tab_component.rb
137
195
  - app/components/ariadne/text.rb
196
+ - app/components/ariadne/time-ago-component.ts
138
197
  - app/components/ariadne/time_ago_component.rb
139
- - app/components/ariadne/time_ago_component.ts
140
198
  - app/components/ariadne/timeline_component.html.erb
141
199
  - app/components/ariadne/timeline_component.rb
200
+ - app/components/ariadne/tooltip-component.ts
201
+ - app/components/ariadne/tooltip_component.html.erb
142
202
  - app/components/ariadne/tooltip_component.rb
143
203
  - app/lib/ariadne/action_view_extensions/form_helper.rb
144
204
  - app/lib/ariadne/audited/dsl.rb
@@ -154,10 +214,6 @@ files:
154
214
  - app/lib/ariadne/test_selector_helper.rb
155
215
  - app/lib/ariadne/underline_nav_helper.rb
156
216
  - app/lib/ariadne/view_helper.rb
157
- - lib/ariadne/classify.rb
158
- - lib/ariadne/classify/utilities.rb
159
- - lib/ariadne/classify/utilities.yml
160
- - lib/ariadne/classify/validation.rb
161
217
  - lib/ariadne/view_components.rb
162
218
  - lib/ariadne/view_components/constants.rb
163
219
  - lib/ariadne/view_components/engine.rb
@@ -166,11 +222,8 @@ files:
166
222
  - lib/ariadne/view_components/version.rb
167
223
  - lib/rubocop/config/default.yml
168
224
  - lib/rubocop/cop/ariadne.rb
169
- - lib/rubocop/cop/ariadne/ariadne_heroicon.rb
170
225
  - lib/rubocop/cop/ariadne/base_cop.rb
171
- - lib/rubocop/cop/ariadne/component_name_migration.rb
172
226
  - lib/rubocop/cop/ariadne/no_tag_memoize.rb
173
- - lib/rubocop/cop/ariadne/system_argument_instead_of_class.rb
174
227
  - lib/tasks/ariadne_view_components.rake
175
228
  - lib/tasks/coverage.rake
176
229
  - lib/tasks/custom_utilities.yml
@@ -178,7 +231,6 @@ files:
178
231
  - lib/tasks/helpers/ast_processor.rb
179
232
  - lib/tasks/helpers/ast_traverser.rb
180
233
  - lib/tasks/static.rake
181
- - lib/tasks/utilities.rake
182
234
  - lib/yard/docs_helper.rb
183
235
  - lib/yard/renders_many_handler.rb
184
236
  - lib/yard/renders_one_handler.rb
@@ -1,199 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "yaml"
4
-
5
- # :nodoc:
6
- module Ariadne
7
- class Classify
8
- # Handler for AriadneCSS utility classes loaded from utilities.rake
9
- class Utilities
10
- # Load the utilities.yml file.
11
- # Disabling because we want to load symbols, strings, and integers from the .yml file
12
- UTILITIES = YAML.load(
13
- File.read(
14
- File.join(File.dirname(__FILE__), "./utilities.yml")
15
- )
16
- ).freeze
17
- BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
18
-
19
- # Replacements for some classnames that end up being a different argument key
20
- REPLACEMENT_KEYS = {
21
- "^anim" => "animation",
22
- "^v-align" => "vertical_align",
23
- "^d" => "display",
24
- "^wb" => "word_break",
25
- "^v" => "visibility",
26
- "^width" => "w",
27
- "^height" => "h",
28
- "^color-bg" => "bg",
29
- "^color-border" => "border_color",
30
- "^color-fg" => "color",
31
- }.freeze
32
-
33
- SUPPORTED_KEY_CACHE = Hash.new { |h, k| h[k] = !UTILITIES[k].nil? }
34
- BREAKPOINT_INDEX_CACHE = Hash.new { |h, k| h[k] = BREAKPOINTS.index(k) }
35
-
36
- class << self
37
- attr_accessor :validate_class_names
38
- alias_method :validate_class_names?, :validate_class_names
39
-
40
- def classname(key, val, breakpoint = "")
41
- # For cases when `argument: false` is passed in, treat like we would nil
42
- return nil unless val
43
-
44
- if (valid = validate(key, val, breakpoint))
45
- valid
46
- else
47
- # Get selector
48
- UTILITIES[key][val][BREAKPOINT_INDEX_CACHE[breakpoint]]
49
- end
50
- end
51
-
52
- # Does the Utility class support the given key
53
- #
54
- # returns Boolean
55
- def supported_key?(key)
56
- SUPPORTED_KEY_CACHE[key]
57
- end
58
-
59
- # Does the Utility class support the given key and value
60
- #
61
- # returns Boolean
62
- def supported_value?(key, val)
63
- supported_key?(key) && !UTILITIES[key][val].nil?
64
- end
65
-
66
- # Does the given selector exist in the utilities file
67
- #
68
- # returns Boolean
69
- def supported_selector?(selector)
70
- # This method is too slow to run in production
71
- return false unless validate_class_names?
72
-
73
- find_selector(selector).present?
74
- end
75
-
76
- # Is the key and value responsive
77
- #
78
- # returns Boolean
79
- def responsive?(key, val)
80
- supported_value?(key, val) && UTILITIES[key][val].count > 1
81
- end
82
-
83
- # Get the options for the given key
84
- #
85
- # returns Array or nil if key not supported
86
- def mappings(key)
87
- return unless supported_key?(key)
88
-
89
- UTILITIES[key].keys
90
- end
91
-
92
- # Extract hash from classes ie. "mr-1 mb-2 foo" => { mr: 1, mb: 2, classes: "foo" }
93
- def classes_to_hash(classes)
94
- # This method is too slow to run in production
95
- return { classes: classes } unless validate_class_names?
96
-
97
- obj = {}
98
- classes = classes.split
99
- # Loop through all classes supplied and reject ones we find a match for
100
- # So when we're at the end of the loop we have classes left with any non-system classes.
101
- classes.reject! do |classname|
102
- key, value, index = find_selector(classname)
103
- next false if key.nil?
104
-
105
- # Create array if nil
106
- obj[key] = Array.new(5, nil) if obj[key].nil?
107
- # Place the arguments in the responsive array based on index mr: [nil, 2]
108
- obj[key][index] = value
109
- next true
110
- end
111
-
112
- # Transform responsive arrays into arrays without trailing nil, so `mr: [1, nil, nil, nil, nil]` becomes `mr: 1`
113
- obj.transform_values! do |value|
114
- value = value.reverse.drop_while(&:nil?).reverse
115
- if value.count == 1
116
- value.first
117
- else
118
- value
119
- end
120
- end
121
-
122
- # Add back the non-system classes
123
- obj[:classes] = classes.join(" ") if classes.any?
124
- obj
125
- end
126
-
127
- def classes_to_args(classes)
128
- hash_to_args(classes_to_hash(classes))
129
- end
130
-
131
- def hash_to_args(hash)
132
- hash.map do |key, value|
133
- val = case value
134
- when Symbol
135
- ":#{value}"
136
- when String
137
- value.to_json
138
- else
139
- value
140
- end
141
-
142
- "#{key}: #{val}"
143
- end.join(", ")
144
- end
145
-
146
- def validate(key, val, breakpoint)
147
- unless supported_key?(key)
148
- raise ArgumentError, "#{key} is not a valid Ariadne utility key" if validate_class_names?
149
-
150
- return ""
151
- end
152
-
153
- unless breakpoint.empty? || responsive?(key, val)
154
- raise ArgumentError, "#{key} does not support responsive values" if validate_class_names?
155
-
156
- return ""
157
- end
158
-
159
- unless supported_value?(key, val)
160
- raise ArgumentError, "#{val} is not a valid value for :#{key}. Use one of #{mappings(key)}" if validate_class_names?
161
-
162
- return nil if [true, false].include?(val)
163
-
164
- return "#{key.to_s.dasherize}-#{val.to_s.dasherize}"
165
- end
166
-
167
- nil
168
- end
169
-
170
- private def find_selector(selector)
171
- key = infer_selector_key(selector)
172
- value_hash = UTILITIES[key]
173
-
174
- return nil if value_hash.blank?
175
-
176
- # Each value hash will also contain an array of classnames for breakpoints
177
- # Key argument `0`, classes `[ "mr-0", "mr-sm-0", "mr-md-0", "mr-lg-0", "mr-xl-0" ]`
178
- value_hash.each do |key_argument, classnames|
179
- # Skip each value hash until we get one with the selector
180
- next unless classnames.include?(selector)
181
-
182
- # Return [:mr, 0, 1]
183
- # has index of classname, so we can match it up with responsive array `mr: [nil, 0]`
184
- return [key, key_argument, classnames.index(selector)]
185
- end
186
-
187
- nil
188
- end
189
-
190
- private def infer_selector_key(selector)
191
- REPLACEMENT_KEYS.each do |k, v|
192
- return v.to_sym if selector.match?(Regexp.new(k))
193
- end
194
- selector.split("-").first.to_sym
195
- end
196
- end
197
- end
198
- end
199
- end