phlexi-field 0.0.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 8.0.0"
6
+ gem "sqlite3", "~> 2.1"
7
+ gem "phlex-rails", "~> 2.2"
8
+
9
+ platforms :ruby, :x86_64_linux, :arm64_darwin do
10
+
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,309 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ phlexi-field (0.1.0)
5
+ activesupport (>= 7.1)
6
+ fiber-local
7
+ phlex (~> 2.0)
8
+ zeitwerk
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (8.0.2)
14
+ actionpack (= 8.0.2)
15
+ activesupport (= 8.0.2)
16
+ nio4r (~> 2.0)
17
+ websocket-driver (>= 0.6.1)
18
+ zeitwerk (~> 2.6)
19
+ actionmailbox (8.0.2)
20
+ actionpack (= 8.0.2)
21
+ activejob (= 8.0.2)
22
+ activerecord (= 8.0.2)
23
+ activestorage (= 8.0.2)
24
+ activesupport (= 8.0.2)
25
+ mail (>= 2.8.0)
26
+ actionmailer (8.0.2)
27
+ actionpack (= 8.0.2)
28
+ actionview (= 8.0.2)
29
+ activejob (= 8.0.2)
30
+ activesupport (= 8.0.2)
31
+ mail (>= 2.8.0)
32
+ rails-dom-testing (~> 2.2)
33
+ actionpack (8.0.2)
34
+ actionview (= 8.0.2)
35
+ activesupport (= 8.0.2)
36
+ nokogiri (>= 1.8.5)
37
+ rack (>= 2.2.4)
38
+ rack-session (>= 1.0.1)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.2)
41
+ rails-html-sanitizer (~> 1.6)
42
+ useragent (~> 0.16)
43
+ actiontext (8.0.2)
44
+ actionpack (= 8.0.2)
45
+ activerecord (= 8.0.2)
46
+ activestorage (= 8.0.2)
47
+ activesupport (= 8.0.2)
48
+ globalid (>= 0.6.0)
49
+ nokogiri (>= 1.8.5)
50
+ actionview (8.0.2)
51
+ activesupport (= 8.0.2)
52
+ builder (~> 3.1)
53
+ erubi (~> 1.11)
54
+ rails-dom-testing (~> 2.2)
55
+ rails-html-sanitizer (~> 1.6)
56
+ activejob (8.0.2)
57
+ activesupport (= 8.0.2)
58
+ globalid (>= 0.3.6)
59
+ activemodel (8.0.2)
60
+ activesupport (= 8.0.2)
61
+ activerecord (8.0.2)
62
+ activemodel (= 8.0.2)
63
+ activesupport (= 8.0.2)
64
+ timeout (>= 0.4.0)
65
+ activestorage (8.0.2)
66
+ actionpack (= 8.0.2)
67
+ activejob (= 8.0.2)
68
+ activerecord (= 8.0.2)
69
+ activesupport (= 8.0.2)
70
+ marcel (~> 1.0)
71
+ activesupport (8.0.2)
72
+ base64
73
+ benchmark (>= 0.3)
74
+ bigdecimal
75
+ concurrent-ruby (~> 1.0, >= 1.3.1)
76
+ connection_pool (>= 2.2.5)
77
+ drb
78
+ i18n (>= 1.6, < 2)
79
+ logger (>= 1.4.2)
80
+ minitest (>= 5.1)
81
+ securerandom (>= 0.3)
82
+ tzinfo (~> 2.0, >= 2.0.5)
83
+ uri (>= 0.13.1)
84
+ ansi (1.5.0)
85
+ appraisal (2.5.0)
86
+ bundler
87
+ rake
88
+ thor (>= 0.14.0)
89
+ ast (2.4.3)
90
+ base64 (0.2.0)
91
+ benchmark (0.4.0)
92
+ bigdecimal (3.1.9)
93
+ builder (3.3.0)
94
+ bundle-audit (0.1.0)
95
+ bundler-audit
96
+ bundler-audit (0.9.2)
97
+ bundler (>= 1.2.0, < 3)
98
+ thor (~> 1.0)
99
+ combustion (1.5.0)
100
+ activesupport (>= 3.0.0)
101
+ railties (>= 3.0.0)
102
+ thor (>= 0.14.6)
103
+ concurrent-ruby (1.3.5)
104
+ connection_pool (2.5.3)
105
+ crass (1.0.6)
106
+ date (3.4.1)
107
+ drb (2.2.1)
108
+ erubi (1.13.1)
109
+ fiber-local (1.1.0)
110
+ fiber-storage
111
+ fiber-storage (1.0.1)
112
+ globalid (1.2.1)
113
+ activesupport (>= 6.1)
114
+ i18n (1.14.7)
115
+ concurrent-ruby (~> 1.0)
116
+ io-console (0.8.0)
117
+ irb (1.15.2)
118
+ pp (>= 0.6.0)
119
+ rdoc (>= 4.0.0)
120
+ reline (>= 0.4.2)
121
+ json (2.11.3)
122
+ language_server-protocol (3.17.0.4)
123
+ lint_roller (1.1.0)
124
+ logger (1.7.0)
125
+ loofah (2.24.0)
126
+ crass (~> 1.0.2)
127
+ nokogiri (>= 1.12.0)
128
+ mail (2.8.1)
129
+ mini_mime (>= 0.1.1)
130
+ net-imap
131
+ net-pop
132
+ net-smtp
133
+ marcel (1.0.4)
134
+ mini_mime (1.1.5)
135
+ minitest (5.25.5)
136
+ minitest-reporters (1.7.1)
137
+ ansi
138
+ builder
139
+ minitest (>= 5.0)
140
+ ruby-progressbar
141
+ net-imap (0.5.8)
142
+ date
143
+ net-protocol
144
+ net-pop (0.1.2)
145
+ net-protocol
146
+ net-protocol (0.2.2)
147
+ timeout
148
+ net-smtp (0.5.1)
149
+ net-protocol
150
+ nio4r (2.7.4)
151
+ nokogiri (1.18.8-aarch64-linux-gnu)
152
+ racc (~> 1.4)
153
+ nokogiri (1.18.8-aarch64-linux-musl)
154
+ racc (~> 1.4)
155
+ nokogiri (1.18.8-arm-linux-gnu)
156
+ racc (~> 1.4)
157
+ nokogiri (1.18.8-arm-linux-musl)
158
+ racc (~> 1.4)
159
+ nokogiri (1.18.8-arm64-darwin)
160
+ racc (~> 1.4)
161
+ nokogiri (1.18.8-x86_64-darwin)
162
+ racc (~> 1.4)
163
+ nokogiri (1.18.8-x86_64-linux-gnu)
164
+ racc (~> 1.4)
165
+ nokogiri (1.18.8-x86_64-linux-musl)
166
+ racc (~> 1.4)
167
+ parallel (1.27.0)
168
+ parser (3.3.8.0)
169
+ ast (~> 2.4.1)
170
+ racc
171
+ phlex (2.2.1)
172
+ zeitwerk (~> 2.7)
173
+ phlex-rails (2.2.0)
174
+ phlex (~> 2.2.1)
175
+ railties (>= 7.1, < 9)
176
+ pp (0.6.2)
177
+ prettyprint
178
+ prettyprint (0.2.0)
179
+ prism (1.4.0)
180
+ psych (5.2.5)
181
+ date
182
+ stringio
183
+ racc (1.8.1)
184
+ rack (3.1.14)
185
+ rack-session (2.1.1)
186
+ base64 (>= 0.1.0)
187
+ rack (>= 3.0.0)
188
+ rack-test (2.2.0)
189
+ rack (>= 1.3)
190
+ rackup (2.2.1)
191
+ rack (>= 3)
192
+ rails (8.0.2)
193
+ actioncable (= 8.0.2)
194
+ actionmailbox (= 8.0.2)
195
+ actionmailer (= 8.0.2)
196
+ actionpack (= 8.0.2)
197
+ actiontext (= 8.0.2)
198
+ actionview (= 8.0.2)
199
+ activejob (= 8.0.2)
200
+ activemodel (= 8.0.2)
201
+ activerecord (= 8.0.2)
202
+ activestorage (= 8.0.2)
203
+ activesupport (= 8.0.2)
204
+ bundler (>= 1.15.0)
205
+ railties (= 8.0.2)
206
+ rails-dom-testing (2.2.0)
207
+ activesupport (>= 5.0.0)
208
+ minitest
209
+ nokogiri (>= 1.6)
210
+ rails-html-sanitizer (1.6.2)
211
+ loofah (~> 2.21)
212
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
213
+ railties (8.0.2)
214
+ actionpack (= 8.0.2)
215
+ activesupport (= 8.0.2)
216
+ irb (~> 1.13)
217
+ rackup (>= 1.0.0)
218
+ rake (>= 12.2)
219
+ thor (~> 1.0, >= 1.2.2)
220
+ zeitwerk (~> 2.6)
221
+ rainbow (3.1.1)
222
+ rake (13.2.1)
223
+ rdoc (6.13.1)
224
+ psych (>= 4.0.0)
225
+ regexp_parser (2.10.0)
226
+ reline (0.6.1)
227
+ io-console (~> 0.5)
228
+ rubocop (1.75.5)
229
+ json (~> 2.3)
230
+ language_server-protocol (~> 3.17.0.2)
231
+ lint_roller (~> 1.1.0)
232
+ parallel (~> 1.10)
233
+ parser (>= 3.3.0.2)
234
+ rainbow (>= 2.2.2, < 4.0)
235
+ regexp_parser (>= 2.9.3, < 3.0)
236
+ rubocop-ast (>= 1.44.0, < 2.0)
237
+ ruby-progressbar (~> 1.7)
238
+ unicode-display_width (>= 2.4.0, < 4.0)
239
+ rubocop-ast (1.44.1)
240
+ parser (>= 3.3.7.2)
241
+ prism (~> 1.4)
242
+ rubocop-performance (1.25.0)
243
+ lint_roller (~> 1.1)
244
+ rubocop (>= 1.75.0, < 2.0)
245
+ rubocop-ast (>= 1.38.0, < 2.0)
246
+ ruby-progressbar (1.13.0)
247
+ securerandom (0.4.1)
248
+ sqlite3 (2.6.0-aarch64-linux-gnu)
249
+ sqlite3 (2.6.0-aarch64-linux-musl)
250
+ sqlite3 (2.6.0-arm-linux-gnu)
251
+ sqlite3 (2.6.0-arm-linux-musl)
252
+ sqlite3 (2.6.0-arm64-darwin)
253
+ sqlite3 (2.6.0-x86_64-darwin)
254
+ sqlite3 (2.6.0-x86_64-linux-gnu)
255
+ sqlite3 (2.6.0-x86_64-linux-musl)
256
+ standard (1.49.0)
257
+ language_server-protocol (~> 3.17.0.2)
258
+ lint_roller (~> 1.0)
259
+ rubocop (~> 1.75.2)
260
+ standard-custom (~> 1.0.0)
261
+ standard-performance (~> 1.8)
262
+ standard-custom (1.0.2)
263
+ lint_roller (~> 1.0)
264
+ rubocop (~> 1.50)
265
+ standard-performance (1.8.0)
266
+ lint_roller (~> 1.1)
267
+ rubocop-performance (~> 1.25.0)
268
+ stringio (3.1.7)
269
+ thor (1.3.2)
270
+ timeout (0.4.3)
271
+ tzinfo (2.0.6)
272
+ concurrent-ruby (~> 1.0)
273
+ unicode-display_width (3.1.4)
274
+ unicode-emoji (~> 4.0, >= 4.0.4)
275
+ unicode-emoji (4.0.4)
276
+ uri (1.0.3)
277
+ useragent (0.16.11)
278
+ websocket-driver (0.7.7)
279
+ base64
280
+ websocket-extensions (>= 0.1.0)
281
+ websocket-extensions (0.1.5)
282
+ zeitwerk (2.7.2)
283
+
284
+ PLATFORMS
285
+ aarch64-linux-gnu
286
+ aarch64-linux-musl
287
+ arm-linux-gnu
288
+ arm-linux-musl
289
+ arm64-darwin
290
+ x86_64-darwin
291
+ x86_64-linux-gnu
292
+ x86_64-linux-musl
293
+
294
+ DEPENDENCIES
295
+ appraisal
296
+ bundle-audit
297
+ combustion
298
+ minitest
299
+ minitest-reporters
300
+ nokogiri
301
+ phlex-rails (~> 2.2)
302
+ phlexi-field!
303
+ rails (~> 8.0.0)
304
+ rake
305
+ sqlite3 (~> 2.1)
306
+ standard
307
+
308
+ BUNDLED WITH
309
+ 2.6.2
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Phlexi
4
+ module Field
5
+ module Common
6
+ module Tokens
7
+ def classes(*tokens, **conditional_tokens)
8
+ tokens = self.tokens(*tokens, **conditional_tokens)
9
+
10
+ if tokens.empty?
11
+ {}
12
+ else
13
+ {class: tokens}
14
+ end
15
+ end
16
+
17
+ def tokens(*tokens, **conditional_tokens)
18
+ conditional_tokens.each do |condition, token|
19
+ truthy = case condition
20
+ when Symbol then send(condition)
21
+ when Proc then condition.call
22
+ else raise ArgumentError, "The class condition must be a Symbol or a Proc."
23
+ end
24
+
25
+ if truthy
26
+ case token
27
+ when Hash then __append_token__(tokens, token[:then])
28
+ else __append_token__(tokens, token)
29
+ end
30
+ else
31
+ case token
32
+ when Hash then __append_token__(tokens, token[:else])
33
+ end
34
+ end
35
+ end
36
+
37
+ tokens = tokens.select(&:itself).join(" ")
38
+ tokens.strip!
39
+ tokens.gsub!(/\s+/, " ")
40
+ tokens
41
+ end
42
+
43
+ private
44
+
45
+ def __append_token__(tokens, token)
46
+ case token
47
+ when nil then nil
48
+ when String then tokens << token
49
+ when Symbol then tokens << token.name
50
+ when Array then tokens.concat(token)
51
+ else raise ArgumentError,
52
+ "Conditional classes must be Symbols, Strings, or Arrays of Symbols or Strings."
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -4,6 +4,8 @@ module Phlexi
4
4
  module Field
5
5
  module Components
6
6
  class Base < COMPONENT_BASE
7
+ include Phlexi::Field::Common::Tokens
8
+
7
9
  attr_reader :field, :attributes
8
10
 
9
11
  def initialize(field, **attributes)
@@ -25,11 +25,6 @@ module Phlexi
25
25
  end
26
26
 
27
27
  def infer_field_type
28
- if object.class.respond_to?(:rich_text_association_names) &&
29
- object.class.rich_text_association_names.include?(:"rich_text_#{key}")
30
- return :rich_text
31
- end
32
-
33
28
  # Check attachments first since they are implemented as associations
34
29
  return :attachment if attachment_reflection
35
30
 
@@ -103,7 +98,6 @@ module Phlexi
103
98
  /^email/ => :email,
104
99
  /^search/ => :search,
105
100
  /phone|tel(ephone)?/ => :phone,
106
- /^datetime/ => :datetime,
107
101
  /^time/ => :time,
108
102
  /^date/ => :date,
109
103
  /^number|_count$|_amount$/ => :number,
@@ -23,6 +23,8 @@ module Phlexi
23
23
  private
24
24
 
25
25
  def each(&)
26
+ # Only iterate if we have namespaces
27
+ return [] unless @collection
26
28
  namespaces.each(&)
27
29
  end
28
30
 
@@ -39,6 +41,8 @@ module Phlexi
39
41
  @collection.map.with_index do |object, key|
40
42
  build_namespace(key, object: object)
41
43
  end
44
+ else
45
+ [] # Return empty array for nil or invalid collections
42
46
  end
43
47
  end
44
48
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlexi
4
4
  module Field
5
- VERSION = "0.0.11"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlexi-field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-30 00:00:00.000000000 Z
11
+ date: 2025-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '7.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '7.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zeitwerk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: phlex-testing-capybara
168
+ name: nokogiri
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -178,7 +178,9 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- description: Base fields for the Phlexi libraries
181
+ description: A field component framework for Ruby applications that provides a unified
182
+ field abstraction across forms, displays, and tables. Built on Phlex with a namespace-based
183
+ architecture for handling complex object relationships.
182
184
  email:
183
185
  - sfroelich01@gmail.com
184
186
  executables: []
@@ -187,6 +189,7 @@ extra_rdoc_files: []
187
189
  files:
188
190
  - ".rspec"
189
191
  - ".ruby-version"
192
+ - ".standard.yml"
190
193
  - Appraisals
191
194
  - CHANGELOG.md
192
195
  - LICENSE.txt
@@ -196,11 +199,14 @@ files:
196
199
  - config.ru
197
200
  - gemfiles/default.gemfile
198
201
  - gemfiles/default.gemfile.lock
199
- - gemfiles/rails_7.gemfile
200
- - gemfiles/rails_7.gemfile.lock
202
+ - gemfiles/rails_7.1.gemfile
203
+ - gemfiles/rails_7.1.gemfile.lock
204
+ - gemfiles/rails_8.gemfile
205
+ - gemfiles/rails_8.gemfile.lock
201
206
  - lib/phlexi-field.rb
202
207
  - lib/phlexi/field.rb
203
208
  - lib/phlexi/field/builder.rb
209
+ - lib/phlexi/field/common/tokens.rb
204
210
  - lib/phlexi/field/components/base.rb
205
211
  - lib/phlexi/field/options/associations.rb
206
212
  - lib/phlexi/field/options/attachments.rb
@@ -246,5 +252,6 @@ requirements: []
246
252
  rubygems_version: 3.4.10
247
253
  signing_key:
248
254
  specification_version: 4
249
- summary: Base fields for the Phlexi libraries
255
+ summary: A field component framework for Ruby applications that provides a unified
256
+ field abstraction across forms, displays, and tables.
250
257
  test_files: []
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.1.3", ">= 7.1.3.4"
6
- gem "sqlite3", "~> 1.4"
7
-
8
- gemspec path: "../"