polaris_view_components 0.3.1 → 0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/{javascript → assets/javascripts}/polaris_view_components/index.js +0 -0
  4. data/app/{javascript → assets/javascripts}/polaris_view_components/resource_item_controller.js +0 -0
  5. data/app/assets/javascripts/polaris_view_components/select_controller.js +14 -0
  6. data/app/{javascript → assets/javascripts}/polaris_view_components/text_field_controller.js +0 -0
  7. data/app/assets/javascripts/polaris_view_components.js +6 -4
  8. data/app/assets/stylesheets/polaris_view_components/custom.css +43 -0
  9. data/app/assets/stylesheets/{shopify_navigation.css → polaris_view_components/shopify_navigation.css} +0 -4
  10. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  11. data/app/assets/stylesheets/polaris_view_components.css +2214 -3
  12. data/app/assets/stylesheets/polaris_view_components.postcss.css +4 -0
  13. data/app/components/polaris/card/header_component.rb +0 -2
  14. data/app/components/polaris/card/section_component.rb +5 -1
  15. data/app/components/polaris/card_component.rb +0 -2
  16. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  17. data/app/components/polaris/data_table/cell_component.rb +49 -0
  18. data/app/components/polaris/data_table/column_component.rb +19 -0
  19. data/app/components/polaris/data_table_component.html.erb +77 -0
  20. data/app/components/polaris/data_table_component.rb +42 -0
  21. data/app/components/polaris/dropzone/component.rb +0 -2
  22. data/app/components/polaris/empty_state_component.html.erb +16 -11
  23. data/app/components/polaris/empty_state_component.rb +1 -0
  24. data/app/components/polaris/filters_component.html.erb +13 -0
  25. data/app/components/polaris/filters_component.rb +38 -0
  26. data/app/components/polaris/index_table/cell_component.rb +22 -0
  27. data/app/components/polaris/index_table/column_component.rb +13 -0
  28. data/app/components/polaris/index_table_component.html.erb +28 -0
  29. data/app/components/polaris/index_table_component.rb +25 -0
  30. data/app/components/polaris/inline_error_component.html.erb +2 -2
  31. data/app/components/polaris/inline_error_component.rb +7 -1
  32. data/app/components/polaris/layout/section.rb +2 -0
  33. data/app/components/polaris/link_component.rb +3 -1
  34. data/app/components/polaris/page_actions_component.rb +15 -1
  35. data/app/components/polaris/resource_list_component.html.erb +10 -0
  36. data/app/components/polaris/resource_list_component.rb +2 -8
  37. data/app/components/polaris/select_component.rb +7 -2
  38. data/app/components/polaris/spacer_component.rb +50 -0
  39. data/app/components/polaris/stack_component.rb +1 -1
  40. data/app/components/polaris/tag_component.rb +2 -2
  41. data/app/components/polaris/text_style_component.rb +9 -0
  42. data/app/helpers/polaris/form_builder.rb +27 -2
  43. data/app/helpers/polaris/view_helper.rb +15 -3
  44. data/lib/polaris/view_components/engine.rb +0 -1
  45. data/lib/polaris/view_components/version.rb +1 -1
  46. metadata +23 -11
  47. data/app/assets/stylesheets/polaris@6.6.0.css +0 -4104
  48. data/app/components/polaris/choice_list/component.html.erb +0 -34
  49. data/app/components/polaris/choice_list/component.rb +0 -65
  50. data/app/helpers/polaris/action_helper.rb +0 -14
  51. data/app/javascript/polaris_view_components/select_controller.js +0 -12
@@ -0,0 +1,4 @@
1
+ @import "@shopify/polaris/dist/styles.css";
2
+ @import "./polaris_view_components/shopify_navigation.css";
3
+ @import "./polaris_view_components/spacer_component.css";
4
+ @import "./polaris_view_components/custom.css";
@@ -1,6 +1,4 @@
1
1
  class Polaris::Card::HeaderComponent < Polaris::NewComponent
2
- include Polaris::ActionHelper
3
-
4
2
  def initialize(
5
3
  title: "",
6
4
  actions: [],
@@ -7,6 +7,8 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
7
7
  flush: false,
8
8
  full_width: false,
9
9
  unstyled: false,
10
+ border_top: false,
11
+ border_bottom: false,
10
12
  actions: [],
11
13
  **system_arguments
12
14
  )
@@ -14,10 +16,12 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
14
16
  @system_arguments[:tag] = :div
15
17
  @system_arguments[:classes] = class_names(
16
18
  @system_arguments[:classes],
19
+ "Polaris-Card__Section": !unstyled,
17
20
  "Polaris-Card__Section--flush": flush,
18
21
  "Polaris-Card__Section--subdued": subdued,
19
22
  "Polaris-Card__Section--fullWidth": full_width,
20
- "Polaris-Card__Section": !unstyled,
23
+ "Polaris-Card__Section--borderTop": border_top,
24
+ "Polaris-Card__Section--borderBottom": border_bottom,
21
25
  )
22
26
 
23
27
  @title = title
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Polaris
4
4
  class CardComponent < Polaris::NewComponent
5
- include Polaris::ActionHelper
6
-
7
5
  FOOTER_ACTION_ALIGNMENT_DEFAULT = :right
8
6
  FOOTER_ACTION_ALIGNMENT_MAPPINGS = {
9
7
  FOOTER_ACTION_ALIGNMENT_DEFAULT => "",
@@ -0,0 +1,18 @@
1
+ <% if @sort_url %>
2
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
3
+ <%= link_to @sort_url, class: "Polaris-DataTable__Heading" do %>
4
+ <span class="Polaris-DataTable__Icon">
5
+ <% if @sorted == :asc %>
6
+ <%= polaris_icon(name: "CaretUpMinor") %>
7
+ <% else %>
8
+ <%= polaris_icon(name: "CaretDownMinor") %>
9
+ <% end %>
10
+ </span>
11
+ <%= content %>
12
+ <% end %>
13
+ <% end %>
14
+ <% else %>
15
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
16
+ <%= content %>
17
+ <% end %>
18
+ <% end %>
@@ -0,0 +1,49 @@
1
+ class Polaris::DataTable::CellComponent < Polaris::NewComponent
2
+ ALIGNMENT_DEFAULT = :top
3
+ ALIGNMENT_MAPPINGS = {
4
+ top: "Polaris-DataTable__Cell--verticalAlignTop",
5
+ bottom: "Polaris-DataTable__Cell--verticalAlignBottom",
6
+ middle: "Polaris-DataTable__Cell--verticalAlignMiddle",
7
+ baseline: "Polaris-DataTable__Cell--verticalAlignBaseline",
8
+ }
9
+ ALIGNMENT_OPTIONS = ALIGNMENT_MAPPINGS.keys
10
+
11
+ def initialize(
12
+ vertical_alignment:,
13
+ first: false,
14
+ numeric: false,
15
+ header: false,
16
+ total: false,
17
+ total_footer: false,
18
+ sorted: false,
19
+ sort_url: nil,
20
+ **system_arguments
21
+ )
22
+ @vertical_alignment = vertical_alignment
23
+ @numeric = numeric
24
+ @first = first
25
+ @header = header
26
+ @total = total
27
+ @total_footer = total_footer
28
+ @sorted = sorted
29
+ @sort_url = sort_url
30
+ @system_arguments = system_arguments
31
+ end
32
+
33
+ def system_arguments
34
+ { tag: "td" }.deep_merge(@system_arguments).tap do |args|
35
+ args[:classes] = class_names(
36
+ args[:classes],
37
+ "Polaris-DataTable__Cell",
38
+ ALIGNMENT_MAPPINGS[@vertical_alignment],
39
+ "Polaris-DataTable__Cell--firstColumn": @first,
40
+ "Polaris-DataTable__Cell--numeric": @numeric,
41
+ "Polaris-DataTable__Cell--header": @header,
42
+ "Polaris-DataTable__Cell--total": @total,
43
+ "Polaris-DataTable__Cell--sortable": @sort_url.present?,
44
+ "Polaris-DataTable__Cell--sorted": @sorted,
45
+ "Polaris-DataTable--cellTotalFooter": @total_footer,
46
+ )
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ class Polaris::DataTable::ColumnComponent < Polaris::NewComponent
2
+ SORT_DEFAULT = false
3
+ SORT_OPTIONS = [false, :asc, :desc]
4
+
5
+ attr_reader :title, :numeric, :total, :sorted, :sort_url
6
+
7
+ def initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block)
8
+ @title = title
9
+ @numeric = numeric
10
+ @total = total
11
+ @sorted = fetch_or_fallback(SORT_OPTIONS, sorted, SORT_DEFAULT)
12
+ @sort_url = sort_url
13
+ @block = block
14
+ end
15
+
16
+ def call(row)
17
+ @block.call(row)
18
+ end
19
+ end
@@ -0,0 +1,77 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-DataTable__ScrollContainer">
3
+ <table class="Polaris-DataTable__Table">
4
+ <thead>
5
+ <tr>
6
+ <% columns.each_with_index do |column, index| %>
7
+ <%= render_cell(
8
+ first: index.zero?,
9
+ numeric: column.numeric,
10
+ tag: "th",
11
+ scope: "col",
12
+ header: true,
13
+ sort_url: column.sort_url,
14
+ sorted: column.sorted,
15
+ ) do %>
16
+ <%= column.title %>
17
+ <% end %>
18
+ <% end %>
19
+ </tr>
20
+ <% if @totals_in_header %>
21
+ <tr>
22
+ <% columns.each_with_index do |column, index| %>
23
+ <%= render_cell(
24
+ first: index.zero?,
25
+ numeric: column.numeric,
26
+ tag: (index.zero? ? "th" : "td"),
27
+ scope: ("row" if index.zero?),
28
+ total: true,
29
+ ) do %>
30
+ <%= column.total %>
31
+ <% end %>
32
+ <% end %>
33
+ </tr>
34
+ <% end %>
35
+ </thead>
36
+ <tbody>
37
+ <% @data.each do |row| %>
38
+ <tr class="Polaris-DataTable__TableRow <%= "Polaris-DataTable--hoverable" if @hoverable %>">
39
+ <% columns.each_with_index do |column, index| %>
40
+ <%= render_cell(
41
+ first: index.zero?,
42
+ numeric: column.numeric,
43
+ tag: (index.zero? ? "th" : "td"),
44
+ scope: ("row" if index.zero?),
45
+ ) do %>
46
+ <%= column.call(row) %>
47
+ <% end %>
48
+ <% end %>
49
+ </tr>
50
+ <% end %>
51
+ </tbody>
52
+ <% if @totals_in_footer %>
53
+ <tfoot>
54
+ <tr>
55
+ <% columns.each_with_index do |column, index| %>
56
+ <%= render_cell(
57
+ first: index.zero?,
58
+ numeric: column.numeric,
59
+ tag: (index.zero? ? "th" : "td"),
60
+ scope: ("row" if index.zero?),
61
+ total: true,
62
+ total_footer: true,
63
+ ) do %>
64
+ <%= column.total %>
65
+ <% end %>
66
+ <% end %>
67
+ </tr>
68
+ </tfoot>
69
+ <% end %>
70
+ </table>
71
+ </div>
72
+ <% if footer.present? %>
73
+ <div class="Polaris-DataTable__Footer">
74
+ <%= footer %>
75
+ </div>
76
+ <% end %>
77
+ <% end %>
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class DataTableComponent < Polaris::NewComponent
5
+ ALIGNMENT_DEFAULT = :top
6
+ ALIGNMENT_OPTIONS = [:top, :bottom, :middle, :baseline]
7
+
8
+ renders_many :columns, -> (title, **system_arguments, &block) do
9
+ DataTable::ColumnComponent.new(title, **system_arguments, &block)
10
+ end
11
+ renders_one :footer
12
+
13
+ def initialize(
14
+ data,
15
+ hoverable: true,
16
+ vertical_alignment: ALIGNMENT_DEFAULT,
17
+ totals_in_header: false,
18
+ totals_in_footer: false,
19
+ **system_arguments
20
+ )
21
+ @data = data
22
+ @hoverable = hoverable
23
+ @vertical_alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, vertical_alignment, ALIGNMENT_DEFAULT)
24
+ @totals_in_header = totals_in_header
25
+ @totals_in_footer = totals_in_footer
26
+ @system_arguments = system_arguments
27
+ end
28
+
29
+ def system_arguments
30
+ { tag: "div" }.deep_merge(@system_arguments).tap do |args|
31
+ args[:classes] = class_names(
32
+ args[:classes],
33
+ "Polaris-DataTable",
34
+ )
35
+ end
36
+ end
37
+
38
+ def render_cell(**arguments, &block)
39
+ render(DataTable::CellComponent.new(vertical_alignment: @vertical_alignment, **arguments), &block)
40
+ end
41
+ end
42
+ end
@@ -3,8 +3,6 @@
3
3
  module Polaris
4
4
  module Dropzone
5
5
  class Component < Polaris::Component
6
- include Polaris::ActionHelper
7
-
8
6
  ALLOWED_TYPES = %w[file image]
9
7
 
10
8
  validates :type, inclusion: { in: ALLOWED_TYPES, message: "%{value} is not a valid type" }
@@ -16,20 +16,22 @@
16
16
  <% end %>
17
17
  </div>
18
18
  <% end %>
19
- <div class="Polaris-EmptyState__Actions">
20
- <%= polaris_stack(spacing: :tight, distribution: :center, alignment: :center) do |stack| %>
21
- <% if primary_action.present? %>
22
- <% stack.item do %>
23
- <%= primary_action %>
19
+ <% if primary_action.present? || secondary_action.present? %>
20
+ <div class="Polaris-EmptyState__Actions">
21
+ <%= polaris_stack(spacing: :tight, distribution: :center, alignment: :center) do |stack| %>
22
+ <% if primary_action.present? %>
23
+ <% stack.item do %>
24
+ <%= primary_action %>
25
+ <% end %>
24
26
  <% end %>
25
- <% end %>
26
- <% if secondary_action.present? %>
27
- <% stack.item do %>
28
- <%= secondary_action %>
27
+ <% if secondary_action.present? %>
28
+ <% stack.item do %>
29
+ <%= secondary_action %>
30
+ <% end %>
29
31
  <% end %>
30
32
  <% end %>
31
- <% end %>
32
- </div>
33
+ </div>
34
+ <% end %>
33
35
  <% if footer.present? %>
34
36
  <div class="Polaris-EmptyState__FooterContent">
35
37
  <div class="Polaris-TextContainer">
@@ -44,4 +46,7 @@
44
46
  <img src="<%= @image %>" role="presentation" alt="" class="Polaris-EmptyState__Image">
45
47
  </div>
46
48
  </div>
49
+ <% if unsectioned_content.present? %>
50
+ <%= unsectioned_content %>
51
+ <% end %>
47
52
  <% end %>
@@ -14,6 +14,7 @@ module Polaris
14
14
  end
15
15
  renders_one :secondary_action, Polaris::ButtonComponent
16
16
  renders_one :footer
17
+ renders_one :unsectioned_content
17
18
 
18
19
  def initialize(
19
20
  image:,
@@ -0,0 +1,13 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-Filters-ConnectedFilterControl__Wrapper">
3
+ <div class="Polaris-Filters-ConnectedFilterControl Polaris-Filters-ConnectedFilterControl--right">
4
+ <% if query.present? %>
5
+ <div class="Polaris-Filters-ConnectedFilterControl__CenterContainer">
6
+ <div class="Polaris-Filters-ConnectedFilterControl__Item">
7
+ <%= query %>
8
+ </div>
9
+ </div>
10
+ <% end %>
11
+ </div>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Polaris
4
+ class FiltersComponent < Polaris::NewComponent
5
+ renders_one :query, "QueryComponent"
6
+
7
+ def initialize(**system_arguments)
8
+ @system_arguments = system_arguments
9
+ end
10
+
11
+ def system_arguments
12
+ @system_arguments.tap do |opts|
13
+ opts[:tag] = "div"
14
+ opts[:classes] = class_names(
15
+ @system_arguments[:classes],
16
+ "Polaris-Filters",
17
+ )
18
+ end
19
+ end
20
+
21
+ class QueryComponent < Polaris::NewComponent
22
+ def initialize(clear_button: true, **system_arguments)
23
+ @system_arguments = system_arguments.merge(
24
+ label_hidden: true,
25
+ clear_button: clear_button,
26
+ )
27
+ end
28
+
29
+ def call
30
+ polaris_text_field(**@system_arguments) do |text_field|
31
+ text_field.prefix do
32
+ polaris_icon(name: "SearchMinor")
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ class Polaris::IndexTable::CellComponent < Polaris::NewComponent
2
+ def initialize(flush: false, **system_arguments)
3
+ @flush = flush
4
+ @system_arguments = system_arguments
5
+ end
6
+
7
+ def system_arguments
8
+ { tag: "td" }.deep_merge(@system_arguments).tap do |args|
9
+ args[:classes] = class_names(
10
+ args[:classes],
11
+ "Polaris-IndexTable__TableCell",
12
+ "Polaris-IndexTable__TableCell--flush": @flush,
13
+ )
14
+ end
15
+ end
16
+
17
+ def call
18
+ render(Polaris::BaseComponent.new(**system_arguments)) do
19
+ content
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ class Polaris::IndexTable::ColumnComponent < Polaris::NewComponent
2
+ attr_reader :title, :flush
3
+
4
+ def initialize(title, flush: false, **system_arguments, &block)
5
+ @title = title
6
+ @flush = flush
7
+ @block = block
8
+ end
9
+
10
+ def call(row)
11
+ @block.call(row)
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <div class="Polaris-IndexTable-ScrollContainer">
3
+ <table class="Polaris-IndexTable__Table">
4
+ <thead>
5
+ <tr>
6
+ <% columns.each_with_index do |column, index| %>
7
+ <th class="Polaris-IndexTable__TableHeading">
8
+ <%= column.title %>
9
+ </th>
10
+ <% end %>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% @data.each do |row| %>
15
+ <tr class="Polaris-IndexTable__TableRow Polaris-IndexTable__TableRow--unclickable">
16
+ <% columns.each_with_index do |column, index| %>
17
+ <%= render_cell(
18
+ flush: column.flush,
19
+ ) do %>
20
+ <%= column.call(row) %>
21
+ <% end %>
22
+ <% end %>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,25 @@
1
+ module Polaris
2
+ class IndexTableComponent < Polaris::NewComponent
3
+ renders_many :columns, -> (title, **system_arguments, &block) do
4
+ IndexTable::ColumnComponent.new(title, **system_arguments, &block)
5
+ end
6
+
7
+ def initialize(data, **system_arguments)
8
+ @data = data
9
+ @system_arguments = system_arguments
10
+ end
11
+
12
+ def system_arguments
13
+ { tag: "div" }.deep_merge(@system_arguments).tap do |args|
14
+ args[:classes] = class_names(
15
+ args[:classes],
16
+ "Polaris-IndexTable",
17
+ )
18
+ end
19
+ end
20
+
21
+ def render_cell(**arguments, &block)
22
+ render(IndexTable::CellComponent.new(**arguments), &block)
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
- <div class="Polaris-InlineError">
1
+ <%= render(Polaris::BaseComponent.new(**@system_arguments)) do %>
2
2
  <div class="Polaris-InlineError__Icon">
3
3
  <%= polaris_icon(name: "AlertMinor") %>
4
4
  </div>
5
5
  <%= content %>
6
- </div>
6
+ <% end %>
@@ -2,7 +2,13 @@
2
2
 
3
3
  module Polaris
4
4
  class InlineErrorComponent < Polaris::NewComponent
5
- def initialize
5
+ def initialize(**system_arguments)
6
+ @system_arguments = system_arguments
7
+ @system_arguments[:tag] = "div"
8
+ @system_arguments[:classes] = class_names(
9
+ @system_arguments[:classes],
10
+ "Polaris-InlineError",
11
+ )
6
12
  end
7
13
 
8
14
  def renders?
@@ -11,6 +11,7 @@ module Polaris
11
11
  full_width: false,
12
12
  one_half: false,
13
13
  one_third: false,
14
+ one_fourth: false,
14
15
  **system_arguments
15
16
  )
16
17
  @position = position
@@ -24,6 +25,7 @@ module Polaris
24
25
  "Polaris-Layout__Section--fullWidth" => full_width,
25
26
  "Polaris-Layout__Section--oneHalf" => one_half,
26
27
  "Polaris-Layout__Section--oneThird" => one_third,
28
+ "Polaris-Layout__Section--oneFourth" => one_fourth,
27
29
  )
28
30
  end
29
31
 
@@ -6,6 +6,7 @@ module Polaris
6
6
  url:,
7
7
  external: false,
8
8
  monochrome: false,
9
+ no_underline: false,
9
10
  **system_arguments
10
11
  )
11
12
  @url = url
@@ -23,13 +24,14 @@ module Polaris
23
24
  @system_arguments[:classes],
24
25
  "Polaris-Link",
25
26
  "Polaris-Link--monochrome" => monochrome,
27
+ "Polaris-Link--removeUnderline" => no_underline,
26
28
  )
27
29
  end
28
30
 
29
31
  def call
30
32
  render(Polaris::BaseComponent.new(**@system_arguments)) do
31
33
  safe_join [
32
- content.strip,
34
+ content.strip.html_safe,
33
35
  (external_icon if @external),
34
36
  ].compact
35
37
  end
@@ -2,12 +2,24 @@
2
2
 
3
3
  module Polaris
4
4
  class PageActionsComponent < Polaris::NewComponent
5
+ DISTRIBUTION_DEFAULT = nil
6
+ DISTRIBUTION_OPTIONS = [
7
+ DISTRIBUTION_DEFAULT,
8
+ :equal_spacing,
9
+ :leading,
10
+ :trailing,
11
+ :center,
12
+ :fill,
13
+ :fill_evenly,
14
+ ]
15
+
5
16
  renders_one :primary_action, -> (primary: true, **system_arguments) do
6
17
  Polaris::ButtonComponent.new(primary: primary, **system_arguments)
7
18
  end
8
19
  renders_many :secondary_actions, Polaris::ButtonComponent
9
20
 
10
- def initialize(**system_arguments)
21
+ def initialize(distribution: DISTRIBUTION_DEFAULT, **system_arguments)
22
+ @distribution = fetch_or_fallback(DISTRIBUTION_OPTIONS, distribution, DISTRIBUTION_DEFAULT)
11
23
  @system_arguments = system_arguments
12
24
  @system_arguments[:tag] = "div"
13
25
  @system_arguments[:classes] = class_names(
@@ -18,6 +30,8 @@ module Polaris
18
30
 
19
31
  private
20
32
  def stack_distribution
33
+ return @distribution if @distribution.present?
34
+
21
35
  (primary_action.present? && secondary_actions.any?) ? :equal_spacing : :trailing
22
36
  end
23
37
  end
@@ -0,0 +1,10 @@
1
+ <%= render(Polaris::BaseComponent.new(**@wrapper_arguments)) do %>
2
+ <% if filters.present? %>
3
+ <div class="Polaris-ResourceList__FiltersWrapper">
4
+ <%= filters %>
5
+ </div>
6
+ <% end %>
7
+ <%= render(Polaris::BaseComponent.new(**@system_arguments)) do %>
8
+ <%= content %>
9
+ <% end %>
10
+ <% end %>
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Polaris
4
4
  class ResourceListComponent < Polaris::NewComponent
5
+ renders_one :filters, Polaris::FiltersComponent
6
+
5
7
  def initialize(
6
8
  wrapper_arguments: {},
7
9
  **system_arguments
@@ -20,13 +22,5 @@ module Polaris
20
22
  "Polaris-ResourceList",
21
23
  )
22
24
  end
23
-
24
- def call
25
- render(Polaris::BaseComponent.new(**@wrapper_arguments)) do
26
- render(Polaris::BaseComponent.new(**@system_arguments)) do
27
- content
28
- end
29
- end
30
- end
31
25
  end
32
26
  end
@@ -37,6 +37,7 @@ module Polaris
37
37
  @system_arguments[:tag] = "div"
38
38
  @system_arguments[:data] ||= {}
39
39
  prepend_option(@system_arguments[:data], :controller, "polaris-select")
40
+ prepend_option(@system_arguments[:data], :selected_value, @selected)
40
41
  @system_arguments[:classes] = class_names(
41
42
  @system_arguments[:classes],
42
43
  "Polaris-Select",
@@ -56,12 +57,14 @@ module Polaris
56
57
  error: error,
57
58
  }.merge(wrapper_arguments)
58
59
 
59
- @select_options = {}
60
+ @select_options = select_options
60
61
 
61
62
  @input_options = input_options
63
+ @input_options.deep_merge!(select_options) unless @form
62
64
  @input_options[:class] = class_names(@input_options[:classes], "Polaris-Select__Input")
63
65
  @input_options[:disabled] = disabled
64
66
  @input_options[:data] ||= {}
67
+ prepend_option(@input_options[:data], :polaris_select_target, "select")
65
68
  prepend_option(@input_options[:data], :action, "polaris-select#update")
66
69
  end
67
70
 
@@ -71,7 +74,9 @@ module Polaris
71
74
 
72
75
  def selected_option
73
76
  option = @options.to_a.find { |i| i.last.to_s == @selected.to_s }
74
- option ? option.first : @options.first.first
77
+ return unless option
78
+
79
+ option.first
75
80
  end
76
81
  end
77
82
  end