polaris_view_components 2.4.0 → 2.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afe73c510dcccbc175a32899246cbc0086d7beb9f951badfd6a2f4696ae06932
4
- data.tar.gz: ade6fa42a44a20ff391d441fd432ab5d078f565aecf6bae9bd05af2fdc4bb1f7
3
+ metadata.gz: 84f1b013b1c1b56632fecca163692825151171015df3b9edca221b21c12e87d2
4
+ data.tar.gz: 6ca879737c1a5e7730dc6299feb6101ec53cfe35bc929a632a8b1950157cd7f3
5
5
  SHA512:
6
- metadata.gz: c2eeffc04f4f14c24791f8411d38cefb70bb5d55b12e3ea58aa0ede26e1cf503648ebd3945f8a531c0e00cedbcad180036be7a2a6ac689e39d8ca317a241cfc2
7
- data.tar.gz: e8c79131fde3961768bece82c91b084d9dc67df9d809665146545e0fdae2fefb0de040e45770d2451eab1029eeef09224bb9ed433e1f1ee7bab40e2cf0427797
6
+ metadata.gz: 0ad985b0add0dd115eefb5e94a64d5c53c8e5966bdfee188eec8e93da1c23ee327cc0bd0d35f62b11b178c6588bbc76cfeefb06de06d7eef1ac3faf0ff4cb50f
7
+ data.tar.gz: 25f136409d1e0c9aec94f43fc403a040f7f357cf1c53f5d9a1fe5ea567d6543cd9e0168b4d7b913e92c7842e5ee9efcf3fcafe5e064b79f4e9d17e6d429e2b97
@@ -31,14 +31,14 @@ export default class extends Controller {
31
31
  detail: { value: input.value, label, selected: input.checked }
32
32
  })
33
33
 
34
- this.element.dispatchEvent(changeEvent)
35
-
36
34
  if (!this.multipleValue) {
37
35
  this.popoverController.forceHide()
38
36
  this.inputTarget.value = label
39
37
  if (this.hasHiddenInputTarget)
40
38
  this.hiddenInputTarget.value = input.value
41
39
  }
40
+
41
+ this.element.dispatchEvent(changeEvent)
42
42
  }
43
43
 
44
44
  onInputChange = debounce(() => {
@@ -203,12 +203,12 @@ class Autocomplete extends Controller {
203
203
  selected: input.checked
204
204
  }
205
205
  });
206
- this.element.dispatchEvent(changeEvent);
207
206
  if (!this.multipleValue) {
208
207
  this.popoverController.forceHide();
209
208
  this.inputTarget.value = label;
210
209
  if (this.hasHiddenInputTarget) this.hiddenInputTarget.value = input.value;
211
210
  }
211
+ this.element.dispatchEvent(changeEvent);
212
212
  }
213
213
  onInputChange=debounce((() => {
214
214
  if (this.isRemote) {
@@ -50,18 +50,14 @@ module Polaris
50
50
  end
51
51
 
52
52
  def polaris_text_field(method, **options, &block)
53
- options[:error] ||= error_for(method)
54
- if options[:error_hidden] && options[:error]
55
- options[:error] = !!options[:error]
56
- end
53
+ apply_error_options(options, method)
54
+
57
55
  render Polaris::TextFieldComponent.new(form: self, attribute: method, **options), &block
58
56
  end
59
57
 
60
58
  def polaris_select(method, **options, &block)
61
- options[:error] ||= error_for(method)
62
- if options[:error_hidden] && options[:error]
63
- options[:error] = !!options[:error]
64
- end
59
+ apply_error_options(options, method)
60
+
65
61
  value = object&.public_send(method)
66
62
  if value.present?
67
63
  options[:selected] = value
@@ -70,34 +66,25 @@ module Polaris
70
66
  end
71
67
 
72
68
  def polaris_check_box(method, **options, &block)
73
- options[:error] ||= error_for(method)
74
- if options[:error_hidden] && options[:error]
75
- options[:error] = !!options[:error]
76
- end
69
+ apply_error_options(options, method)
70
+
77
71
  render Polaris::CheckboxComponent.new(form: self, attribute: method, **options, &block)
78
72
  end
79
73
 
80
74
  def polaris_radio_button(method, **options, &block)
81
- options[:error] ||= error_for(method)
82
- if options[:error_hidden] && options[:error]
83
- options[:error] = !!options[:error]
84
- end
75
+ apply_error_options(options, method)
76
+
85
77
  render Polaris::RadioButtonComponent.new(form: self, attribute: method, **options, &block)
86
78
  end
87
79
 
88
80
  def polaris_dropzone(method, **options, &block)
89
- options[:error] ||= error_for(method)
90
- if options[:error_hidden] && options[:error]
91
- options[:error] = !!options[:error]
92
- end
81
+ apply_error_options(options, method)
82
+
93
83
  render Polaris::DropzoneComponent.new(form: self, attribute: method, **options, &block)
94
84
  end
95
85
 
96
86
  def polaris_collection_check_boxes(method, collection, value_method, text_method, **options, &block)
97
- options[:error] ||= error_for(method)
98
- if options[:error_hidden] && options[:error]
99
- options[:error] = !!options[:error]
100
- end
87
+ apply_error_options(options, method)
101
88
 
102
89
  value = object&.public_send(method)
103
90
  if value.present?
@@ -124,11 +111,19 @@ module Polaris
124
111
  end
125
112
 
126
113
  def polaris_autocomplete(method, **options, &block)
127
- options[:error] ||= error_for(method)
114
+ apply_error_options(options, method)
115
+
116
+ render Polaris::AutocompleteComponent.new(form: self, attribute: method, name: method, **options), &block
117
+ end
118
+
119
+ private
120
+
121
+ def apply_error_options(options, method)
122
+ options[:error] ||= error_for(method) unless options.has_key?(:error)
123
+
128
124
  if options[:error_hidden] && options[:error]
129
125
  options[:error] = !!options[:error]
130
126
  end
131
- render Polaris::AutocompleteComponent.new(form: self, attribute: method, name: method, **options), &block
132
127
  end
133
128
  end
134
129
  end
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
2
  module ViewComponents
3
- VERSION = "2.4.0"
3
+ VERSION = "2.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polaris_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gamble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-05-15 00:00:00.000000000 Z
12
+ date: 2025-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails