polaris_view_components 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/icons/polaris/AnalyticsMinor.svg +1 -0
  3. data/app/assets/icons/polaris/AppsMinor.svg +1 -0
  4. data/app/assets/icons/polaris/BlockMinor.svg +1 -0
  5. data/app/assets/icons/polaris/ButtonMinor.svg +1 -0
  6. data/app/assets/icons/polaris/CaretDownMinor.svg +1 -1
  7. data/app/assets/icons/polaris/CaretUpMinor.svg +1 -1
  8. data/app/assets/icons/polaris/CircleTickMinor.svg +1 -0
  9. data/app/assets/icons/polaris/Columns3Minor.svg +1 -0
  10. data/app/assets/icons/polaris/CustomersMinor.svg +1 -1
  11. data/app/assets/icons/polaris/DiscountsMinor.svg +1 -0
  12. data/app/assets/icons/polaris/DropdownMinor.svg +1 -1
  13. data/app/assets/icons/polaris/FinancesMajor.svg +1 -0
  14. data/app/assets/icons/polaris/FinancesMinor.svg +1 -0
  15. data/app/assets/icons/polaris/HomeMinor.svg +1 -0
  16. data/app/assets/icons/polaris/MarketingMinor.svg +1 -0
  17. data/app/assets/icons/polaris/OnlineStoreMinor.svg +1 -0
  18. data/app/assets/icons/polaris/OrdersMinor.svg +1 -0
  19. data/app/assets/icons/polaris/ProductsMinor.svg +1 -0
  20. data/app/assets/icons/polaris/QuestionMarkInverseMajor.svg +1 -0
  21. data/app/assets/icons/polaris/QuestionMarkInverseMinor.svg +1 -0
  22. data/app/assets/icons/polaris/SelectMinor.svg +1 -1
  23. data/app/assets/icons/polaris/TitleMinor.svg +1 -0
  24. data/app/assets/icons/polaris/WandMinor.svg +1 -0
  25. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +32 -15
  26. data/app/assets/javascripts/polaris_view_components/collapsible_controller.js +19 -0
  27. data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +495 -0
  28. data/app/assets/javascripts/polaris_view_components/index.js +4 -0
  29. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +4 -0
  30. data/app/assets/javascripts/polaris_view_components/popover_controller.js +9 -2
  31. data/app/assets/javascripts/polaris_view_components/toast_controller.js +13 -2
  32. data/app/assets/javascripts/polaris_view_components/utils.js +23 -0
  33. data/app/assets/javascripts/polaris_view_components.js +560 -65
  34. data/app/assets/stylesheets/polaris_view_components/custom.css +38 -6
  35. data/app/assets/stylesheets/polaris_view_components.css +2107 -2021
  36. data/app/assets/stylesheets/polaris_view_components.postcss.css +1 -1
  37. data/app/components/polaris/action_list/item_component.rb +1 -1
  38. data/app/components/polaris/action_list/section_component.rb +1 -1
  39. data/app/components/polaris/action_list_component.rb +1 -1
  40. data/app/components/polaris/autocomplete/action_component.rb +1 -1
  41. data/app/components/polaris/autocomplete/option_component.rb +1 -1
  42. data/app/components/polaris/autocomplete/section_component.rb +1 -1
  43. data/app/components/polaris/autocomplete_component.rb +9 -2
  44. data/app/components/polaris/avatar_component.rb +1 -1
  45. data/app/components/polaris/badge_component.rb +1 -1
  46. data/app/components/polaris/banner_component.rb +2 -2
  47. data/app/components/polaris/base_button.rb +1 -1
  48. data/app/components/polaris/base_checkbox.rb +1 -1
  49. data/app/components/polaris/base_component.rb +1 -1
  50. data/app/components/polaris/base_radio_button.rb +1 -1
  51. data/app/components/polaris/button_group_component.rb +3 -3
  52. data/app/components/polaris/callout_card_component.rb +1 -1
  53. data/app/components/polaris/caption_component.rb +1 -1
  54. data/app/components/polaris/card/header_component.rb +1 -1
  55. data/app/components/polaris/card/section_component.rb +2 -2
  56. data/app/components/polaris/card_component.rb +1 -1
  57. data/app/components/polaris/checkbox_component.rb +1 -1
  58. data/app/components/polaris/choice_component.rb +1 -1
  59. data/app/components/polaris/choice_list_component.rb +1 -1
  60. data/app/components/polaris/collapsible_component.rb +37 -0
  61. data/app/components/polaris/component.rb +6 -1
  62. data/app/components/polaris/data_table/cell_component.rb +1 -1
  63. data/app/components/polaris/data_table/column_component.rb +1 -1
  64. data/app/components/polaris/data_table_component.rb +1 -1
  65. data/app/components/polaris/description_list_component.rb +2 -2
  66. data/app/components/polaris/display_text_component.rb +1 -1
  67. data/app/components/polaris/dropzone_component.html.erb +156 -0
  68. data/app/components/polaris/dropzone_component.rb +150 -0
  69. data/app/components/polaris/empty_state_component.rb +1 -1
  70. data/app/components/polaris/exception_list/item_component.rb +1 -1
  71. data/app/components/polaris/exception_list_component.rb +1 -1
  72. data/app/components/polaris/filters_component.rb +3 -3
  73. data/app/components/polaris/footer_help_component.rb +1 -1
  74. data/app/components/polaris/form_layout/group_component.rb +2 -2
  75. data/app/components/polaris/form_layout/item_component.rb +1 -1
  76. data/app/components/polaris/form_layout_component.rb +1 -1
  77. data/app/components/polaris/frame/save_bar_component.rb +1 -1
  78. data/app/components/polaris/frame/top_bar_component.rb +1 -1
  79. data/app/components/polaris/frame_component.rb +1 -1
  80. data/app/components/polaris/heading_component.rb +1 -1
  81. data/app/components/polaris/headless_button.rb +1 -1
  82. data/app/components/polaris/icon_component.rb +1 -1
  83. data/app/components/polaris/index_table/cell_component.rb +1 -1
  84. data/app/components/polaris/index_table/column_component.rb +1 -1
  85. data/app/components/polaris/index_table_component.rb +1 -1
  86. data/app/components/polaris/inline_error_component.rb +1 -1
  87. data/app/components/polaris/keyboard_key_component.rb +20 -0
  88. data/app/components/polaris/label_component.rb +1 -1
  89. data/app/components/polaris/labelled_component.rb +1 -1
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +1 -1
  92. data/app/components/polaris/layout_component.rb +1 -1
  93. data/app/components/polaris/link_component.rb +1 -1
  94. data/app/components/polaris/list_component.rb +2 -2
  95. data/app/components/polaris/modal/section_component.rb +1 -1
  96. data/app/components/polaris/modal_component.rb +1 -1
  97. data/app/components/polaris/navigation/item_component.rb +2 -2
  98. data/app/components/polaris/navigation/section_component.rb +2 -2
  99. data/app/components/polaris/navigation_component.rb +1 -1
  100. data/app/components/polaris/option_list/checkbox_component.rb +1 -1
  101. data/app/components/polaris/option_list/option_component.rb +1 -1
  102. data/app/components/polaris/option_list/radio_button_component.rb +1 -1
  103. data/app/components/polaris/option_list/section_component.rb +1 -1
  104. data/app/components/polaris/option_list_component.rb +1 -1
  105. data/app/components/polaris/page_actions_component.rb +1 -1
  106. data/app/components/polaris/page_component.rb +1 -1
  107. data/app/components/polaris/pagination_component.rb +1 -1
  108. data/app/components/polaris/popover/pane_component.rb +1 -1
  109. data/app/components/polaris/popover/section_component.rb +1 -1
  110. data/app/components/polaris/popover_component.rb +10 -4
  111. data/app/components/polaris/progress_bar_component.rb +1 -1
  112. data/app/components/polaris/radio_button_component.rb +1 -1
  113. data/app/components/polaris/resource_item_component.rb +4 -2
  114. data/app/components/polaris/resource_list_component.rb +1 -1
  115. data/app/components/polaris/scrollable_component.rb +1 -1
  116. data/app/components/polaris/select_component.rb +1 -1
  117. data/app/components/polaris/setting_toggle_component.rb +1 -1
  118. data/app/components/polaris/shopify_navigation_component.rb +2 -2
  119. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  120. data/app/components/polaris/skeleton_display_text_component.rb +32 -0
  121. data/app/components/polaris/skeleton_thumbnail_component.rb +31 -0
  122. data/app/components/polaris/spacer_component.rb +1 -1
  123. data/app/components/polaris/spinner_component.rb +1 -1
  124. data/app/components/polaris/stack/item_component.rb +15 -0
  125. data/app/components/polaris/stack_component.rb +2 -18
  126. data/app/components/polaris/subheading_component.rb +1 -1
  127. data/app/components/polaris/tabs/tab_component.rb +1 -1
  128. data/app/components/polaris/tabs_component.rb +1 -1
  129. data/app/components/polaris/tag_component.rb +3 -2
  130. data/app/components/polaris/text_container_component.rb +1 -1
  131. data/app/components/polaris/text_field_component.rb +2 -2
  132. data/app/components/polaris/text_style_component.rb +1 -1
  133. data/app/components/polaris/thumbnail_component.rb +1 -1
  134. data/app/components/polaris/toast_component.rb +1 -1
  135. data/app/components/polaris/top_bar/user_menu_component.rb +1 -1
  136. data/app/components/polaris/visually_hidden_component.rb +1 -1
  137. data/app/helpers/polaris/form_builder.rb +14 -5
  138. data/app/helpers/polaris/view_helper.rb +6 -1
  139. data/config/locales/en.yml +6 -0
  140. data/lib/polaris/view_components/engine.rb +5 -1
  141. data/lib/polaris/view_components/version.rb +1 -1
  142. metadata +31 -21
  143. data/app/components/polaris/application_component.rb +0 -35
  144. data/app/components/polaris/dropzone/component.html.erb +0 -72
  145. data/app/components/polaris/dropzone/component.rb +0 -128
  146. data/app/components/polaris/dropzone/controller.js +0 -226
  147. data/app/components/polaris/dropzone/utils.js +0 -57
  148. data/app/components/polaris/new_component.rb +0 -10
  149. data/app/helpers/polaris/conditional_helper.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9e5671bf20a8c0aec20920be9fcea01ba39b902057eec479f30b9d621bdbf50
4
- data.tar.gz: 21bb979fd293cd8379e0e012e9ef2ee9ae06cf62bfdd226fc1ae90ff3b65e9c3
3
+ metadata.gz: c25ff3636898168d8b63d341155e80003d847ee4e3888150382c59275d9df5d0
4
+ data.tar.gz: b865d3b96a3e46b09a76d16699935314403a5efe407ef5f1dd759457f057c4f0
5
5
  SHA512:
6
- metadata.gz: 638f5ef1f9c7be3d41b1f1b9016f3a8f14f13c3fbc65c5df6ab8f02b7e903f7456a01514f1d5297c3ecbc022bf66d4283a014a602a9a49662b9d99a368d1a88a
7
- data.tar.gz: f482994119dd2a2334bf633eae54cb8998d39d38821efc9d16bd88af92869f7f9e18f418cc1f71e2fdf7bbb0d6558cd449c24ae61f93dd660950104b192f4427
6
+ metadata.gz: 459107009e35c2eef5ccfca95eb3708b90e9ea5f45eecb23e9e68b17566a16ba95341e646339515129e20ee5b18bfcb3cf3a3195afc18b5a6ce79946398226de
7
+ data.tar.gz: 3992aad996e4a9f2c38f2d915bd11af2106e6ee54cb5421a9a463f18820c0877eadf9e4b7823a02cf1c6e2995ef09f1019730a3986b4136eb50615e67a1c0b41
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 11a1 1 0 1 1 2 0v5a1 1 0 1 1-2 0v-5zm4-5a1 1 0 1 1 2 0v10a1 1 0 1 1-2 0V6zm4-2a1 1 0 1 1 2 0v12a1 1 0 1 1-2 0V4zM3 8a1 1 0 0 1 2 0v8a1 1 0 1 1-2 0V8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 17a2 2 0 0 1-2-2v-4h6v6H5zm6 0v-6h6v4a2 2 0 0 1-2 2h-4zM3 5v4h6V3H5a2 2 0 0 0-2 2zm8 1a1 1 0 0 1 1-1h1V4a1 1 0 1 1 2 0v1h1a1 1 0 1 1 0 2h-1v1a1 1 0 1 1-2 0V7h-1a1 1 0 0 1-1-1z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.6A1.6 1.6 0 0 1 3.6 2H7a1 1 0 0 1 0 2H4v3a1 1 0 0 1-2 0V3.6zM16.4 2A1.6 1.6 0 0 1 18 3.6V7a1 1 0 1 1-2 0V4h-3a1 1 0 1 1 0-2h3.4zm0 16H13a1 1 0 1 1 0-2h3v-3a1 1 0 1 1 2 0v3.4a1.6 1.6 0 0 1-1.6 1.6zM3.6 18A1.6 1.6 0 0 1 2 16.4V13a1 1 0 1 1 2 0v3h3a1 1 0 1 1 0 2H3.6z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 5.5A1.5 1.5 0 0 1 3.5 4h13A1.5 1.5 0 0 1 18 5.5v4.95l-4.014-2.59c-1.71-1.104-3.953.19-3.853 2.224L10.278 13H3.5A1.5 1.5 0 0 1 2 11.5v-6z"/><path d="M12.131 9.999a.5.5 0 0 1 .77-.445l4.869 3.142a.5.5 0 0 1-.021.853l-1.425.823 1.229 2.128a1 1 0 1 1-1.732 1l-1.23-2.128-1.424.822a.5.5 0 0 1-.75-.408L12.131 10z"/></svg>
@@ -1 +1 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5 8 5 5 5-5H5z"/></svg>
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M13.098 8H6.902c-.751 0-1.172.754-.708 1.268L9.292 12.7c.36.399 1.055.399 1.416 0l3.098-3.433C14.27 8.754 13.849 8 13.098 8z"/></svg>
@@ -1 +1 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m15 12-5-5-5 5h10z"/></svg>
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.902 12h6.196c.751 0 1.172-.754.708-1.268L10.708 7.3c-.36-.399-1.055-.399-1.416 0l-3.098 3.433C5.73 11.246 6.151 12 6.902 12z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M2 10a8 8 0 1 0 16 0 8 8 0 0 0-16 0zm12.16-1.44a.8.8 0 0 0-1.12-1.12L9.2 11.28 7.36 9.44a.8.8 0 0 0-1.12 1.12l2.4 2.4c.32.32.8.32 1.12 0l4.4-4.4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M16 2a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h12zm-2.667 2H16v12h-2.667V4zM8.667 4h2.666v12H8.667V4zm-2 0H4v12h2.667V4z"/></svg>
@@ -1 +1 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.11 2.24a3.44 3.44 0 0 0-3.44 3.43 3.44 3.44 0 0 0 6.88 0 3.44 3.44 0 0 0-3.44-3.43zm0 15.46c2.8 0 5.27-1.36 6.84-3.43-1.57-2.08-4.04-3.44-6.84-3.44s-5.26 1.36-6.83 3.44a8.55 8.55 0 0 0 6.83 3.43z"/></svg>
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-3.5 8a2.5 2.5 0 0 1-1.768-4.268C5.322 12.155 7.2 11 10 11s4.678 1.155 5.268 1.732A2.5 2.5 0 0 1 13.5 17h-7z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 3.072a2 2 0 0 0-.99 1.939 2 2 0 0 0-1.826 3.163 2 2 0 0 0 0 3.652A2 2 0 0 0 5.01 14.99a2 2 0 0 0 3.164 1.828 2 2 0 0 0 3.652 0 2 2 0 0 0 3.164-1.827 2 2 0 0 0 1.826-3.164 2 2 0 0 0 0-3.652A2 2 0 0 0 14.99 5.01a2 2 0 0 0-3.163-1.826 2 2 0 0 0-3.654 0A2 2 0 0 0 6 3.072zm6.832 4.483a1 1 0 1 0-1.664-1.11l-4 6a1 1 0 0 0 1.664 1.11l4-6zM7 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>
@@ -1 +1 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5 8 5 5 5-5H5z"/></svg>
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M13.098 8H6.902c-.751 0-1.172.754-.708 1.268L9.292 12.7c.36.399 1.055.399 1.416 0l3.098-3.433C14.27 8.754 13.849 8 13.098 8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5 3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H5zm7 6.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/><path fill-rule="evenodd" d="M16 15v1a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h1v7a1 1 0 0 0 1 1h13z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 3a3 3 0 0 0-3 3v9a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2H6a1 1 0 0 1 0-2h9a1 1 0 1 0 0-2H6zm8 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.555 3.168a1 1 0 0 0-1.11 0L3.891 6.87A2 2 0 0 0 3 8.535V15a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4h4v4a1 1 0 0 0 1 1h2a2 2 0 0 0 2-2V8.535a2 2 0 0 0-.89-1.664l-5.555-3.703z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9 4a5 5 0 0 0-.163 9.997l.662 1.986a7 7 0 1 1 6.484-6.484l-1.986-.662A5 5 0 0 0 9 4z"/><path d="M9 8a1 1 0 0 0 0 2v2a3 3 0 1 1 3-3h-2a1 1 0 0 0-1-1z"/><path d="M11.316 10.051a1 1 0 0 0-1.265 1.265l2 6a1 1 0 0 0 1.898 0l.842-2.525 2.525-.842a1 1 0 0 0 0-1.898l-6-2z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2a1 1 0 1 1 0 2H6a1 1 0 1 0 0 2h8a1 1 0 1 0 0-2h-1a1 1 0 1 1 0-2h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5zm1.986 3.836a1 1 0 0 0-1.972.329C5.237 8.504 6.579 11 10 11c3.42 0 4.763-2.496 4.986-3.835a1 1 0 1 0-1.972-.33C12.904 7.497 12.179 9 10 9 7.82 9 7.097 7.496 6.986 6.836z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.735 5.507A3 3 0 0 1 6.695 3h6.61a3 3 0 0 1 2.96 2.507L17 10v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5l.735-4.493zM6.695 5a1 1 0 0 0-.987.836L5 10v1h1.394a3 3 0 0 1 1.665.504l.832.555a2 2 0 0 0 2.218 0l.832-.555A3 3 0 0 1 13.607 11H15v-1l-.708-4.164A1 1 0 0 0 13.306 5H6.694z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.408 3H16a1 1 0 0 1 1 1v5.592a2 2 0 0 1-.57 1.399l-5.162 5.277a2.5 2.5 0 0 1-3.536 0l-4-4a2.5 2.5 0 0 1 0-3.536l.008-.008L9.01 3.57A2 2 0 0 1 10.407 3zM13.5 8a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm-7.071.929A10 10 0 1 1 17.07 17.07 10 10 0 0 1 2.93 2.93z"/><path d="M11.126 13.002H8.99V11.86c.01-1.966.492-2.254 1.374-2.782.093-.056.19-.114.293-.178.73-.459 1.292-1.038 1.292-1.883 0-.948-.743-1.564-1.666-1.564-.852 0-1.657.398-1.712 1.533H6.305c.06-2.294 1.877-3.487 3.99-3.487 2.306 0 3.894 1.447 3.894 3.488 0 1.382-.695 2.288-1.806 2.952l-.237.144c-.79.475-1.009.607-1.02 1.777v1.142zm.17 2.012a1.344 1.344 0 0 1-1.327 1.328 1.32 1.32 0 0 1-1.227-1.834 1.318 1.318 0 0 1 1.227-.81c.712 0 1.322.592 1.328 1.316h-.001z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11 12H9v-.148c0-.876.306-1.499 1-1.852.385-.195 1-.568 1-1a1.001 1.001 0 0 0-2 0H7c0-1.654 1.346-3 3-3s3 1 3 3-2 2.165-2 3zm-2 3h2v-2H9v2z"/><path d="M10 4a6 6 0 1 0 0 12 6 6 0 0 0 0-12zm-8 6a8 8 0 1 1 16 0 8 8 0 0 1-16 0z"/></svg>
@@ -1 +1 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10 16-4-4h8l-4 4zm0-12 4 4H6l4-4z"/></svg>
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7.676 9h4.648c.563 0 .879-.603.53-1.014L10.531 5.24a.708.708 0 0 0-1.062 0L7.145 7.986C6.798 8.397 7.113 9 7.676 9zm4.648 2H7.676c-.563 0-.878.603-.53 1.014l2.323 2.746c.27.32.792.32 1.062 0l2.323-2.746c.349-.411.033-1.014-.53-1.014z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 2a1 1 0 0 0-1 1v3a1 1 0 0 0 2 0 2 2 0 0 1 2-2h2v10.999A1 1 0 0 1 7 16h-.001A1 1 0 0 0 7 18h6a1 1 0 1 0 0-2 1 1 0 0 1-1-1V4h2a2 2 0 0 1 2 2 1 1 0 1 0 2 0V3a1 1 0 0 0-1-1H3z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.44 15.56a1.5 1.5 0 0 1 0-2.12l6.792-6.793 3.121 3.12-6.792 6.794a1.5 1.5 0 0 1-2.122 0l-1-1zm11.328-7.206L16.56 6.56a1.5 1.5 0 0 0 0-2.122l-1-1a1.5 1.5 0 0 0-2.122 0l-1.793 1.793 3.122 3.122zM13 12c1 0 2-1 2-2 0 1 1 2 2 2-1 0-2 1-2 2 0-1-1-2-2-2zM6 5c1 0 2-1 2-2 0 1 1 2 2 2-1 0-2 1-2 2 0-1-1-2-2-2z"/></svg>
@@ -1,9 +1,10 @@
1
1
  import { Controller } from '@hotwired/stimulus'
2
2
  import { get } from '@rails/request.js'
3
+ import { debounce } from './utils'
3
4
 
4
5
  export default class extends Controller {
5
6
  static targets = ['popover', 'input', 'results', 'option', 'emptyState']
6
- static values = { url: String }
7
+ static values = { url: String, selected: Array }
7
8
 
8
9
  connect() {
9
10
  this.inputTarget.addEventListener("input", this.onInputChange)
@@ -16,13 +17,10 @@ export default class extends Controller {
16
17
  // Actions
17
18
 
18
19
  toggle() {
19
- if (this.visibleOptions.length > 0) {
20
- this.hideEmptyState()
21
- this.popoverController.show()
22
- } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
23
- this.showEmptyState()
20
+ if (this.isRemote && this.visibleOptions.length == 0 && this.value.length == 0) {
21
+ this.fetchResults()
24
22
  } else {
25
- this.popoverController.forceHide()
23
+ this.handleResults()
26
24
  }
27
25
  }
28
26
 
@@ -44,6 +42,13 @@ export default class extends Controller {
44
42
  }
45
43
  }, 200)
46
44
 
45
+ reset() {
46
+ this.inputTarget.value = ''
47
+ this.optionTargets.forEach(option => {
48
+ option.classList.add('Polaris--hidden')
49
+ })
50
+ this.handleResults()
51
+ }
47
52
 
48
53
  // Private
49
54
 
@@ -65,6 +70,18 @@ export default class extends Controller {
65
70
  })
66
71
  }
67
72
 
73
+ handleResults() {
74
+ if (this.visibleOptions.length > 0) {
75
+ this.hideEmptyState()
76
+ this.popoverController.show()
77
+ this.checkSelected()
78
+ } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
79
+ this.showEmptyState()
80
+ } else {
81
+ this.popoverController.forceHide()
82
+ }
83
+ }
84
+
68
85
  filterOptions() {
69
86
  if (this.value === '') {
70
87
  this.optionTargets.forEach(option => {
@@ -80,7 +97,7 @@ export default class extends Controller {
80
97
  }
81
98
  })
82
99
  }
83
- this.toggle()
100
+ this.handleResults()
84
101
  }
85
102
 
86
103
  async fetchResults() {
@@ -90,7 +107,7 @@ export default class extends Controller {
90
107
  if (response.ok) {
91
108
  const results = await response.html
92
109
  this.resultsTarget.innerHTML = results
93
- this.toggle()
110
+ this.handleResults()
94
111
  }
95
112
  }
96
113
 
@@ -107,13 +124,13 @@ export default class extends Controller {
107
124
  this.resultsTarget.classList.remove('Polaris--hidden')
108
125
  }
109
126
  }
110
- }
111
127
 
112
- const debounce = (fn, delay = 10) => {
113
- let timeoutId = null
128
+ checkSelected() {
129
+ this.visibleOptions.forEach(option => {
130
+ const input = option.querySelector('input')
131
+ if (!input) return
114
132
 
115
- return (...args) => {
116
- clearTimeout(timeoutId)
117
- timeoutId = setTimeout(fn, delay)
133
+ input.checked = this.selectedValue.includes(input.value)
134
+ })
118
135
  }
119
136
  }
@@ -0,0 +1,19 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ toggle() {
5
+ if (this.isClosed) {
6
+ this.element.style.maxHeight = "none"
7
+ this.element.style.overflow = "visible"
8
+ this.element.classList.remove("Polaris-Collapsible--isFullyClosed")
9
+ } else {
10
+ this.element.style.maxHeight = "0px"
11
+ this.element.style.overflow = "hidden"
12
+ this.element.classList.add("Polaris-Collapsible--isFullyClosed")
13
+ }
14
+ }
15
+
16
+ get isClosed() {
17
+ return this.element.classList.contains("Polaris-Collapsible--isFullyClosed")
18
+ }
19
+ }