polaris_view_components 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41ae2dca9a546a5e3b919785de08f06c4a69312610d5b8b8e8f802a50ed5e824
4
- data.tar.gz: 52348bb3a4c799acc1e8a8cdb6c80e6d10e4e37d0493f3eeef06a5e977fabb42
3
+ metadata.gz: e9f0dda0dd8c18919a32d2db1f85d8f141e6c034d4b01a14a1f3962ccd1b44d5
4
+ data.tar.gz: b852067c8aaf0a6b8227979b8b8e11d8ceaf16835ee750d426a33c9a07753641
5
5
  SHA512:
6
- metadata.gz: 48361c39b6d1ba7c4c0081130ccc4813e736382507f4ae4835da1c92d0ef73fd2e05731d5f3d3eabbcb9240f4e62b5b3ac1a4445ad57f4eec7c0bc8001b6ac25
7
- data.tar.gz: 3efca47b17182223025d1f7ce1d38b34f8aa94ac34fa0cbe8a1a99096cc90b0fbf8dc51845bfea248cd5fe6d5530839bcff4a14a2ef716f5f368962a328c7a09
6
+ metadata.gz: 34ad4b65aaeab109d00e2220c6df2276c53d6b549858aaf177bf80d042522334f5633e53c678df3d7f8b891656e906318180259dd705c5664d91584383c2f470
7
+ data.tar.gz: 2e5eddc9bf78ad83546587ff76e59f1c3419ab19b9c7a2679e1a8234e6f4e9355d25e172a07d6ddbd5adea8374898897837590a73cbc4a54eecc958a93009630
@@ -94,9 +94,9 @@ export default class extends Controller {
94
94
  this.stopEvent(e)
95
95
  if (this.disabled) return
96
96
 
97
+ const fileList = getDataTransferFiles(e)
97
98
  this.clearFiles()
98
99
 
99
- const fileList = getDataTransferFiles(e)
100
100
  const { files, acceptedFiles, rejectedFiles } = this.getValidatedFiles(fileList)
101
101
  this.dragTargets = []
102
102
 
@@ -451,8 +451,8 @@ class Dropzone extends Controller {
451
451
  onChange(e) {
452
452
  this.stopEvent(e);
453
453
  if (this.disabled) return;
454
- this.clearFiles();
455
454
  const fileList = getDataTransferFiles(e);
455
+ this.clearFiles();
456
456
  const {files: files, acceptedFiles: acceptedFiles, rejectedFiles: rejectedFiles} = this.getValidatedFiles(fileList);
457
457
  this.dragTargets = [];
458
458
  this.files = files;
@@ -2,7 +2,9 @@
2
2
  <%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
3
3
  <% popover.with_activator do %>
4
4
  <%= text_field %>
5
- <% if @name.present? %>
5
+ <% if @form.present? && @attribute.present? %>
6
+ <%= @form.hidden_field @attribute, data: {polaris_autocomplete_target: "hiddenInput"} %>
7
+ <% else %>
6
8
  <%= hidden_field_tag @name, nil, data: {polaris_autocomplete_target: "hiddenInput"} %>
7
9
  <% end %>
8
10
  <% end %>
@@ -11,7 +11,7 @@ module Polaris
11
11
  system_arguments[:input_options][:data] ||= {}
12
12
  system_arguments[:input_options][:data][:polaris_autocomplete_target] = "input"
13
13
 
14
- TextFieldComponent.new(**system_arguments)
14
+ TextFieldComponent.new(form: @form, attribute: @attribute, name: @name, **system_arguments)
15
15
  end
16
16
  renders_many :sections, ->(**system_arguments) do
17
17
  Autocomplete::SectionComponent.new(multiple: @multiple, **system_arguments)
@@ -22,16 +22,20 @@ module Polaris
22
22
  renders_one :empty_state
23
23
 
24
24
  def initialize(
25
+ form: nil,
26
+ attribute: nil,
27
+ name: nil,
25
28
  multiple: false,
26
29
  url: nil,
27
- name: nil,
28
30
  selected: [],
29
31
  popover_arguments: {},
30
32
  **system_arguments
31
33
  )
34
+ @form = form
35
+ @attribute = attribute
36
+ @name = name
32
37
  @multiple = multiple
33
38
  @url = url
34
- @name = name
35
39
  @selected = selected
36
40
  @popover_arguments = popover_arguments
37
41
  @system_arguments = system_arguments
@@ -38,6 +38,7 @@ module Polaris
38
38
  **system_arguments
39
39
  )
40
40
  @title = title
41
+ @title_hidden = title_hidden
41
42
  @error = error
42
43
  @form = form
43
44
  @attribute = attribute
@@ -117,5 +117,13 @@ module Polaris
117
117
  end
118
118
  end
119
119
  end
120
+
121
+ def polaris_autocomplete(method, **options, &block)
122
+ options[:error] ||= error_for(method)
123
+ if options[:error_hidden] && options[:error]
124
+ options[:error] = !!options[:error]
125
+ end
126
+ render Polaris::AutocompleteComponent.new(form: self, attribute: method, name: method, **options), &block
127
+ end
120
128
  end
121
129
  end
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
2
  module ViewComponents
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.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.0.1
4
+ version: 2.1.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: 2024-04-08 00:00:00.000000000 Z
12
+ date: 2024-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -934,7 +934,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
934
934
  - !ruby/object:Gem::Version
935
935
  version: '0'
936
936
  requirements: []
937
- rubygems_version: 3.5.6
937
+ rubygems_version: 3.5.8
938
938
  signing_key:
939
939
  specification_version: 4
940
940
  summary: ViewComponents for Polaris Design System