solidus_admin 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +7 -0
  3. data/README.md +1 -1
  4. data/Rakefile +26 -0
  5. data/app/assets/builds/.keep +0 -0
  6. data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
  7. data/app/assets/config/solidus_admin_manifest.js +1 -0
  8. data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
  9. data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
  10. data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
  11. data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +32 -0
  12. data/app/components/solidus_admin/adjustment_reasons/index/component.rb +53 -0
  13. data/app/components/solidus_admin/adjustment_reasons/index/component.yml +4 -0
  14. data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
  15. data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
  16. data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
  17. data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
  18. data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
  19. data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
  20. data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
  21. data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
  22. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
  23. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
  24. data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
  25. data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
  26. data/app/components/solidus_admin/option_types/index/component.html.erb +30 -0
  27. data/app/components/solidus_admin/option_types/index/component.rb +57 -0
  28. data/app/components/solidus_admin/option_types/index/component.yml +4 -0
  29. data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
  30. data/app/components/solidus_admin/orders/cart/component.js +37 -0
  31. data/app/components/solidus_admin/orders/cart/component.rb +7 -0
  32. data/app/components/solidus_admin/orders/cart/component.yml +3 -0
  33. data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
  34. data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
  35. data/app/components/solidus_admin/orders/index/component.html.erb +26 -22
  36. data/app/components/solidus_admin/orders/index/component.rb +80 -16
  37. data/app/components/solidus_admin/orders/index/component.yml +10 -3
  38. data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
  39. data/app/components/solidus_admin/orders/show/address/component.js +9 -0
  40. data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
  41. data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
  42. data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
  43. data/app/components/solidus_admin/orders/show/component.js +7 -0
  44. data/app/components/solidus_admin/orders/show/component.rb +40 -0
  45. data/app/components/solidus_admin/orders/show/component.yml +21 -0
  46. data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
  47. data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
  48. data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
  49. data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
  50. data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
  51. data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
  52. data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
  53. data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
  54. data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
  55. data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
  56. data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
  57. data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
  58. data/app/components/solidus_admin/payment_methods/index/component.html.erb +38 -0
  59. data/app/components/solidus_admin/payment_methods/index/component.rb +93 -0
  60. data/app/components/solidus_admin/payment_methods/index/component.yml +15 -0
  61. data/app/components/solidus_admin/products/index/component.html.erb +26 -22
  62. data/app/components/solidus_admin/products/index/component.rb +36 -36
  63. data/app/components/solidus_admin/products/index/component.yml +9 -6
  64. data/app/components/solidus_admin/products/show/component.html.erb +32 -38
  65. data/app/components/solidus_admin/products/show/component.rb +2 -0
  66. data/app/components/solidus_admin/products/show/component.yml +5 -5
  67. data/app/components/solidus_admin/products/status/component.rb +20 -18
  68. data/app/components/solidus_admin/products/status/component.yml +1 -0
  69. data/app/components/solidus_admin/products/stock/component.rb +38 -0
  70. data/app/components/solidus_admin/products/stock/component.yml +5 -0
  71. data/app/components/solidus_admin/promotion_categories/index/component.html.erb +26 -0
  72. data/app/components/solidus_admin/promotion_categories/index/component.rb +57 -0
  73. data/app/components/solidus_admin/promotion_categories/index/component.yml +4 -0
  74. data/app/components/solidus_admin/promotions/index/component.html.erb +34 -0
  75. data/app/components/solidus_admin/promotions/index/component.rb +97 -0
  76. data/app/components/solidus_admin/promotions/index/component.yml +14 -0
  77. data/app/components/solidus_admin/properties/index/component.html.erb +34 -0
  78. data/app/components/solidus_admin/properties/index/component.rb +65 -0
  79. data/app/components/solidus_admin/properties/index/component.yml +4 -0
  80. data/app/components/solidus_admin/refund_reasons/index/component.html.erb +31 -0
  81. data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
  82. data/app/components/solidus_admin/refund_reasons/index/component.yml +4 -0
  83. data/app/components/solidus_admin/refunds_and_returns/component.html.erb +26 -0
  84. data/app/components/solidus_admin/refunds_and_returns/component.rb +20 -0
  85. data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
  86. data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +22 -0
  87. data/app/components/solidus_admin/reimbursement_types/index/component.rb +45 -0
  88. data/app/components/solidus_admin/reimbursement_types/index/component.yml +4 -0
  89. data/app/components/solidus_admin/return_reasons/index/component.html.erb +31 -0
  90. data/app/components/solidus_admin/return_reasons/index/component.rb +52 -0
  91. data/app/components/solidus_admin/return_reasons/index/component.yml +4 -0
  92. data/app/components/solidus_admin/shipping/component.html.erb +30 -0
  93. data/app/components/solidus_admin/shipping/component.rb +18 -0
  94. data/app/components/solidus_admin/shipping/component.yml +3 -0
  95. data/app/components/solidus_admin/shipping_categories/index/component.html.erb +32 -0
  96. data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
  97. data/app/components/solidus_admin/shipping_categories/index/component.yml +4 -0
  98. data/app/components/solidus_admin/shipping_methods/index/component.html.erb +32 -0
  99. data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
  100. data/app/components/solidus_admin/shipping_methods/index/component.yml +4 -0
  101. data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
  102. data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
  103. data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
  104. data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
  105. data/app/components/solidus_admin/stock_items/index/component.html.erb +26 -0
  106. data/app/components/solidus_admin/stock_items/index/component.rb +180 -0
  107. data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
  108. data/app/components/solidus_admin/stock_locations/index/component.html.erb +32 -0
  109. data/app/components/solidus_admin/stock_locations/index/component.rb +81 -0
  110. data/app/components/solidus_admin/stock_locations/index/component.yml +6 -0
  111. data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +31 -0
  112. data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
  113. data/app/components/solidus_admin/store_credit_reasons/index/component.yml +4 -0
  114. data/app/components/solidus_admin/stores/index/component.html.erb +34 -0
  115. data/app/components/solidus_admin/stores/index/component.rb +59 -0
  116. data/app/components/solidus_admin/stores/index/component.yml +4 -0
  117. data/app/components/solidus_admin/tax_categories/index/component.html.erb +32 -0
  118. data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
  119. data/app/components/solidus_admin/tax_categories/index/component.yml +6 -0
  120. data/app/components/solidus_admin/tax_rates/index/component.html.erb +32 -0
  121. data/app/components/solidus_admin/tax_rates/index/component.rb +84 -0
  122. data/app/components/solidus_admin/tax_rates/index/component.yml +4 -0
  123. data/app/components/solidus_admin/taxes/component.html.erb +24 -0
  124. data/app/components/solidus_admin/taxes/component.rb +25 -0
  125. data/app/components/solidus_admin/taxes/component.yml +3 -0
  126. data/app/components/solidus_admin/taxonomies/index/component.html.erb +28 -0
  127. data/app/components/solidus_admin/taxonomies/index/component.rb +47 -0
  128. data/app/components/solidus_admin/taxonomies/index/component.yml +4 -0
  129. data/app/components/solidus_admin/ui/badge/component.rb +18 -8
  130. data/app/components/solidus_admin/ui/badge/component.yml +3 -0
  131. data/app/components/solidus_admin/ui/button/component.rb +32 -32
  132. data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
  133. data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
  134. data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
  135. data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
  136. data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
  137. data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
  138. data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
  139. data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
  140. data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
  141. data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
  142. data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
  143. data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
  144. data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
  145. data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
  146. data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
  147. data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
  148. data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
  149. data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
  150. data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
  151. data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
  152. data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
  153. data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
  154. data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
  155. data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
  156. data/app/components/solidus_admin/ui/icon/component.rb +4 -0
  157. data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
  158. data/app/components/solidus_admin/ui/modal/component.rb +12 -0
  159. data/app/components/solidus_admin/ui/modal/component.yml +2 -0
  160. data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
  161. data/app/components/solidus_admin/ui/panel/component.rb +17 -0
  162. data/app/components/solidus_admin/ui/panel/component.yml +1 -3
  163. data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
  164. data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
  165. data/app/components/solidus_admin/ui/tab/component.rb +9 -8
  166. data/app/components/solidus_admin/ui/table/component.html.erb +146 -135
  167. data/app/components/solidus_admin/ui/table/component.js +56 -17
  168. data/app/components/solidus_admin/ui/table/component.rb +94 -70
  169. data/app/components/solidus_admin/ui/table/component.yml +0 -1
  170. data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
  171. data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
  172. data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
  173. data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
  174. data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
  175. data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
  176. data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
  177. data/app/components/solidus_admin/ui/toast/component.js +9 -6
  178. data/app/components/solidus_admin/ui/toast/component.rb +2 -2
  179. data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
  180. data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
  181. data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
  182. data/app/components/solidus_admin/users/index/component.html.erb +34 -0
  183. data/app/components/solidus_admin/users/index/component.rb +89 -0
  184. data/app/components/solidus_admin/users/index/component.yml +18 -0
  185. data/app/components/solidus_admin/zones/index/component.html.erb +35 -0
  186. data/app/components/solidus_admin/zones/index/component.rb +55 -0
  187. data/app/components/solidus_admin/zones/index/component.yml +4 -0
  188. data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
  189. data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
  190. data/app/controllers/solidus_admin/base_controller.rb +1 -0
  191. data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
  192. data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
  193. data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
  194. data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
  195. data/app/controllers/solidus_admin/countries_controller.rb +12 -0
  196. data/app/controllers/solidus_admin/customers_controller.rb +29 -0
  197. data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
  198. data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
  199. data/app/controllers/solidus_admin/orders_controller.rb +104 -7
  200. data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
  201. data/app/controllers/solidus_admin/products_controller.rb +26 -17
  202. data/app/controllers/solidus_admin/promotion_categories_controller.rb +38 -0
  203. data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
  204. data/app/controllers/solidus_admin/properties_controller.rb +33 -0
  205. data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
  206. data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
  207. data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
  208. data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
  209. data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
  210. data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
  211. data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
  212. data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
  213. data/app/controllers/solidus_admin/stores_controller.rb +40 -0
  214. data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
  215. data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
  216. data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
  217. data/app/controllers/solidus_admin/users_controller.rb +50 -0
  218. data/app/controllers/solidus_admin/zones_controller.rb +40 -0
  219. data/app/javascript/solidus_admin/controllers/components.js +3 -1
  220. data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
  221. data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
  222. data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
  223. data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
  224. data/app/views/layouts/solidus_admin/application.html.erb +16 -10
  225. data/app/views/layouts/solidus_admin/preview.html.erb +0 -1
  226. data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
  227. data/config/importmap.rb +2 -0
  228. data/config/initializers/view_component.rb +20 -0
  229. data/config/locales/adjustment_reasons.en.yml +6 -0
  230. data/config/locales/customers.en.yml +7 -0
  231. data/config/locales/errors.en.yml +7 -0
  232. data/config/locales/line_items.en.yml +9 -0
  233. data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
  234. data/config/locales/option_types.en.yml +6 -0
  235. data/config/locales/orders.en.yml +9 -0
  236. data/config/locales/payment_methods.en.yml +6 -0
  237. data/config/locales/promotion_categories.en.yml +6 -0
  238. data/config/locales/promotions.en.yml +6 -0
  239. data/config/locales/properties.en.yml +6 -0
  240. data/config/locales/refund_reasons_.en.yml +6 -0
  241. data/config/locales/reimbursement_types.en.yml +4 -0
  242. data/config/locales/return_reasons.en.yml +6 -0
  243. data/config/locales/shipping_categories.en.yml +6 -0
  244. data/config/locales/shipping_methods.en.yml +6 -0
  245. data/config/locales/stock_items.en.yml +4 -0
  246. data/config/locales/stock_locations.en.yml +6 -0
  247. data/config/locales/store_credit_reasons.en.yml +6 -0
  248. data/config/locales/stores.en.yml +6 -0
  249. data/config/locales/tax_categories.en.yml +6 -0
  250. data/config/locales/tax_rates.en.yml +6 -0
  251. data/config/locales/taxonomies.en.yml +6 -0
  252. data/config/locales/users.en.yml +6 -0
  253. data/config/locales/zones.en.yml +6 -0
  254. data/config/routes.rb +50 -3
  255. data/config/tailwind.config.js +119 -0
  256. data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
  257. data/docs/customizing_tailwindcss.md +57 -0
  258. data/docs/customizing_view_components.md +17 -38
  259. data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
  260. data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
  261. data/lib/solidus_admin/admin_resources.rb +23 -0
  262. data/lib/solidus_admin/configuration.rb +93 -67
  263. data/lib/solidus_admin/install_tailwindcss.rb +102 -0
  264. data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
  265. data/lib/solidus_admin/version.rb +1 -1
  266. data/lib/solidus_admin.rb +1 -2
  267. data/lib/tasks/tailwind.rake +10 -0
  268. data/solidus_admin.gemspec +3 -4
  269. metadata +228 -48
  270. data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
  271. data/app/components/solidus_admin/feedback/component.html.erb +0 -11
  272. data/app/components/solidus_admin/feedback/component.rb +0 -4
  273. data/app/components/solidus_admin/feedback/component.yml +0 -5
  274. data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
  275. data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
  276. data/app/components/solidus_admin/sidebar/component.rb +0 -21
  277. data/app/components/solidus_admin/ui/panel/component.js +0 -14
  278. data/config/solidus_admin/tailwind.config.js.erb +0 -95
  279. data/docs/customizing_tailwind.md +0 -78
  280. data/lib/solidus_admin/tailwindcss.rb +0 -58
  281. data/lib/tasks/tailwindcss.rake +0 -55
  282. /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
  283. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
  284. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
  285. /data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.yml +0 -0
@@ -0,0 +1,116 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import { useClickOutside, useDebounce } from "stimulus-use"
3
+
4
+ export default class extends Controller {
5
+ static targets = ["result", "results", "searchField"]
6
+ static values = {
7
+ results: String,
8
+ loadingText: String,
9
+ initialText: String,
10
+ emptyText: String,
11
+ }
12
+ static debounces = ["search"]
13
+
14
+ get query() {
15
+ return this.searchFieldTarget.value
16
+ }
17
+
18
+ get selectedResult() {
19
+ // Keep the index within boundaries
20
+ if (this.selectedIndex < 0) this.selectedIndex = 0
21
+ if (this.selectedIndex >= this.resultTargets.length) this.selectedIndex = this.resultTargets.length - 1
22
+
23
+ return this.resultTargets[this.selectedIndex]
24
+ }
25
+
26
+ connect() {
27
+ useClickOutside(this)
28
+ useDebounce(this)
29
+
30
+ this.selectedIndex = 0
31
+
32
+ if (this.query) {
33
+ this.showResults()
34
+ this.search()
35
+ }
36
+ }
37
+
38
+ selectResult(event) {
39
+ event.preventDefault()
40
+ this.dispatch("submit", { detail: { resultTarget: this.selectedResult } })
41
+ }
42
+
43
+ clickedResult(event) {
44
+ this.selectedIndex = this.resultTargets.indexOf(event.currentTarget)
45
+ this.render()
46
+ this.selectResult(event)
47
+ }
48
+
49
+ selectPrev(event) {
50
+ event.preventDefault()
51
+ this.selectedIndex -= 1
52
+ this.render()
53
+ }
54
+
55
+ selectNext(event) {
56
+ event.preventDefault()
57
+ this.selectedIndex += 1
58
+ this.render()
59
+ }
60
+
61
+ clickOutside() {
62
+ this.openResults = false
63
+ this.render()
64
+ }
65
+
66
+ async search() {
67
+ const query = this.query
68
+
69
+ if (query) {
70
+ this.resultsValue = this.loadingTextValue
71
+ this.render()
72
+ this.dispatch("search", { detail: { query, controller: this } })
73
+ } else {
74
+ this.resultsValue = this.initialTextValue
75
+ this.render()
76
+ }
77
+ }
78
+
79
+ resultsValueChanged() {
80
+ this.selectedIndex = 0
81
+ this.render()
82
+ }
83
+
84
+ showResults() {
85
+ this.openResults = true
86
+ this.render()
87
+ }
88
+
89
+ render() {
90
+ let resultsHtml = this.resultsValue
91
+
92
+ if (this.renderedHtml !== resultsHtml) {
93
+ this.renderedHtml = resultsHtml
94
+ this.resultsTarget.innerHTML = resultsHtml
95
+ }
96
+
97
+ if (this.openResults && resultsHtml && this.query) {
98
+ if (!this.resultsTarget.parentNode.open) this.selectedIndex = 0
99
+
100
+ for (const result of this.resultTargets) {
101
+ if (result === this.selectedResult) {
102
+ if (!result.hasAttribute("aria-selected") && result.scrollIntoViewIfNeeded) {
103
+ // This is a non-standard method, but it's supported by all major browsers
104
+ result.scrollIntoViewIfNeeded()
105
+ }
106
+ result.setAttribute("aria-selected", true)
107
+ } else {
108
+ result.removeAttribute("aria-selected")
109
+ }
110
+ }
111
+ this.resultsTarget.parentNode.open = true
112
+ } else {
113
+ this.resultsTarget.parentNode.open = false
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::Search::Component < SolidusAdmin::BaseComponent
4
+ def initialize(id: nil, **attributes)
5
+ @id = id
6
+ @attributes = attributes
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ loading: "Loading..."
3
+ initial: "Type to search"
4
+ empty: "No results"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::Search::Result::Component < SolidusAdmin::BaseComponent
4
+ def call
5
+ tag.div(
6
+ content,
7
+ class: "rounded p-2 hover:bg-gray-25 aria-selected:bg-gray-25 cursor-pointer",
8
+ "data-#{component('ui/forms/search').stimulus_id}-target": "result",
9
+ "data-action": "click->#{component('ui/forms/search').stimulus_id}#clickedResult",
10
+ )
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ <label
2
+ data-controller="<%= stimulus_id %>"
3
+ class="items-center gap-1 p-0 inline-flex w-full justify-start relative"
4
+ >
5
+ <%= render component("ui/icon").new(
6
+ name: "search-line",
7
+ class: "w-[1.4em] h-[1.4em] fill-gray-500 absolute ml-3",
8
+ ) %>
9
+ <%= render component("ui/forms/input").new(**@attributes) %>
10
+ <button
11
+ class="absolute right-0 mr-3 peer-placeholder-shown:hidden"
12
+ data-action="<%= stimulus_id %>#clear"
13
+ aria-label="<%= t('.clear') %>"
14
+ >
15
+ <%= render component("ui/icon").new(
16
+ name: "close-circle-fill",
17
+ class: "w-[1.4em] h-[1.4em] fill-gray-500"
18
+ ) %>
19
+ </button>
20
+ </label>
@@ -1,7 +1,9 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
- greet() {
5
- console.log(`Hello World! ${new Date()}`)
4
+ static targets = ["input"]
5
+
6
+ clear() {
7
+ this.inputTarget.value = ""
6
8
  }
7
9
  }
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::SearchField::Component < SolidusAdmin::BaseComponent
4
+ def initialize(**attributes)
5
+ @attributes = attributes
6
+ @attributes[:type] ||= :search
7
+ @attributes[:class] = "search-cancel:appearance-none peer !px-10 #{@attributes[:class]}"
8
+ @attributes[:"data-#{stimulus_id}-target"] = "input"
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ clear: Clear
@@ -2,46 +2,42 @@
2
2
 
3
3
  class SolidusAdmin::UI::Forms::Switch::Component < SolidusAdmin::BaseComponent
4
4
  SIZES = {
5
- s: '
6
- w-8 h-5
7
-
8
- after:w-4 after:h-4
9
- after:top-0.5 after:left-0.5
10
-
11
- active:after:w-4
12
- after:checked:left-[1.875rem]
13
- ',
14
- m: '
15
- w-10 h-6
16
-
17
- after:w-5 after:h-5
18
- after:top-0.5 after:left-0.5
19
-
20
- active:after:w-5
21
- after:checked:left-[2.375rem]
22
- ',
5
+ s: 'w-8 h-5 after:w-4 after:h-4 after:checked:translate-x-3',
6
+ m: 'w-10 h-6 after:w-5 after:h-5 after:checked:translate-x-4',
23
7
  }.freeze
24
8
 
25
- def initialize(size: :m, **attributes)
9
+ def initialize(size: :m, include_hidden: false, **attributes)
26
10
  @size = size
27
11
  @attributes = attributes
12
+ @include_hidden = include_hidden
13
+ @attributes[:class] = "
14
+ #{SIZES.fetch(@size)}
15
+ rounded-full after:rounded-full
16
+ appearance-none inline-block relative p-0.5 cursor-pointer
17
+
18
+ outline-none
19
+ focus:ring focus:ring-gray-300 focus:ring-0.5 focus:ring-offset-1
20
+ active:ring active:ring-gray-300 active:ring-0.5 active:ring-offset-1
21
+
22
+ disabled:cursor-not-allowed
23
+ after:top-0 after:left-0
24
+ after:content-[''] after:block
25
+ after:transition-all after:duration-300 after:ease-in-out
26
+
27
+ bg-gray-200 after:bg-white
28
+ hover:bg-gray-300
29
+ checked:bg-gray-500 checked:hover:bg-gray-70
30
+ disabled:opacity-40
31
+ #{attributes[:class]}
32
+ "
28
33
  end
29
34
 
30
35
  def call
31
- tag.input(
36
+ input = tag.input(
32
37
  type: 'checkbox',
33
- class: "
34
- #{SIZES.fetch(@size)}
35
- appearance-none outline-0 cursor-pointer bg-gray-200 inline-block rounded-full relative
36
-
37
- after:content-[''] after:absolute after:bg-white
38
- after:duration-300 after:rounded-full after:checked:-translate-x-full
39
-
40
- hover:bg-gray-300
41
- disabled:opacity-40 disabled:cursor-not-allowed
42
- checked:bg-gray-500 checked:hover:bg-gray-700
43
- ",
44
38
  **@attributes,
45
39
  )
40
+
41
+ @include_hidden ? hidden_field_tag(@attributes.fetch(:name), false) + input : input
46
42
  end
47
43
  end
@@ -0,0 +1,20 @@
1
+ <label class="flex flex-wrap items-center gap-2 w-full border border-gray-100 rounded px-4 py-2">
2
+ <div class="flex gap-1 items-center grow py-2">
3
+ <span class="text-gray-700 font-semibold text-base"><%= @label %></span>
4
+
5
+ <%= render component("ui/toggletip").new(text: @tip) if @tip.present? %>
6
+ </div>
7
+
8
+ <%= render component("ui/forms/switch").new(**@attributes) %>
9
+
10
+ <% if @hint.present? || @error.present? %>
11
+ <div
12
+ class="
13
+ w-full font-normal text-sm [:disabled~&]:text-gray-300 text-gray-500 flex gap-1 flex-col pt-2 pb-4
14
+ "
15
+ >
16
+ <%= tag.span @hint if @hint.present? %>
17
+ <%= tag.span safe_join(@error, tag.br), class: "text-red-400" if @error.present? %>
18
+ </div>
19
+ <% end %>
20
+ </label>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::SwitchField::Component < SolidusAdmin::BaseComponent
4
+ def initialize(label:, error:, hint: nil, tip: nil, **attributes)
5
+ @label = label
6
+ @error = error
7
+ @hint = hint
8
+ @tip = tip
9
+ @attributes = attributes
10
+ end
11
+ end
@@ -16,6 +16,10 @@ class SolidusAdmin::UI::Icon::Component < SolidusAdmin::BaseComponent
16
16
 
17
17
  # Hide the icon from screen readers by default.
18
18
  @attrs['aria-hidden'] = true unless @attrs.key?('aria-hidden')
19
+
20
+ # Default icons without style to 16x16, mostly useful in test snapshots.
21
+ @attrs['width'] = '16'
22
+ @attrs['height'] = '16'
19
23
  end
20
24
 
21
25
  def call
@@ -0,0 +1,37 @@
1
+ <dialog
2
+ data-controller="<%= stimulus_id %>"
3
+ <%= tag.attributes(
4
+ "aria-label": @title,
5
+ class: "relative z-10",
6
+ **@attributes
7
+ ) %>
8
+ >
9
+ <a href="<%= @close_path %>" aria-hidden="true" class="cursor-default fixed inset-0 bg-full-black/50 overflow-y-auto"></a>
10
+ <div class="fixed inset-0 z-10 pointer-events-none flex min-h-full justify-center p-4 text-center items-center">
11
+ <div class="min-w-[40rem] max-h-screen pointer-events-auto cursor-auto relative transform overflow-auto rounded-lg bg-white text-left shadow-xl max-w-lg divide-y divide-gray-100">
12
+
13
+ <header class="flex items-center justify-between p-4 sticky top-0 bg-inherit">
14
+ <h3 class="text-xl font-semibold text-gray-900">
15
+ <%= @title %>
16
+ </h3>
17
+ <%= render component('ui/button').new(
18
+ tag: :a,
19
+ href: @close_path,
20
+ icon: 'close-line',
21
+ scheme: :ghost,
22
+ title: t('.close'),
23
+ ) %>
24
+ </header>
25
+
26
+ <div class="p-4 overflow-auto">
27
+ <%= content %>
28
+ </div>
29
+
30
+ <% if actions? %>
31
+ <footer class="p-4 flex gap-2 justify-end sticky bottom-0 bg-inherit">
32
+ <%= actions %>
33
+ </footer>
34
+ <% end %>
35
+ </div>
36
+ </div>
37
+ </dialog>
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Modal::Component < SolidusAdmin::BaseComponent
4
+ renders_one :actions
5
+
6
+ def initialize(title:, close_path: nil, open: true, **attributes)
7
+ @title = title
8
+ @close_path = close_path
9
+ @attributes = attributes
10
+ @attributes[:open] = open
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ close: Close
@@ -8,29 +8,43 @@
8
8
  flex-col
9
9
  justify-start
10
10
  items-start
11
- gap-6
12
11
  inline-flex
13
12
  w-full
14
- py-6
13
+ relative
15
14
  "
16
15
  data-controller="<%= stimulus_id %>"
17
16
  >
17
+ <% if menus? %>
18
+ <%= render component('ui/dropdown').new(
19
+ size: :s,
20
+ class: "absolute top-0 right-0 m-6",
21
+ ).with_content(safe_join(menus)) %>
22
+ <% end %>
23
+
18
24
  <% if @title %>
19
- <h2 class="mt-0 px-6 w-full">
20
- <span class="body-title"><%= @title %></span>
21
- <%= render component('ui/toggletip').new(text: @title_hint, position: :left) if @title_hint %>
22
- </h2>
25
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
26
+ <h2>
27
+ <span class="font-semibold text-xl"><%= @title %></span>
28
+ <%= render component("ui/toggletip").new(text: @title_hint) if @title_hint %>
29
+ </h2>
30
+ </section>
31
+ <% end %>
32
+
33
+ <% sections.each do |section| %>
34
+ <%= section %>
23
35
  <% end %>
24
36
 
25
- <% if content&.present? %>
26
- <div class="px-6 w-full flex flex-col gap-6">
37
+ <% if content.present? %>
38
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
27
39
  <%= content %>
28
- </div>
40
+ </section>
29
41
  <% end %>
30
42
 
31
43
  <% if action? %>
32
- <div class="flex gap-2 items-center border-t border-gray-100 px-6 pt-6 w-full">
33
- <%= action %>
34
- </div>
44
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
45
+ <div class="flex justify-between items-center">
46
+ <%= action %>
47
+ </div>
48
+ </section>
35
49
  <% end %>
36
50
  </div>
@@ -10,6 +10,23 @@ class SolidusAdmin::UI::Panel::Component < SolidusAdmin::BaseComponent
10
10
  )
11
11
  }
12
12
 
13
+ renders_many :sections, ->(wide: false, high: false, **args, &block) do
14
+ tag.section(**args, class: "
15
+ border-gray-100 border-t w-full first-of-type:border-t-0
16
+ #{'px-6' unless wide}
17
+ #{'py-6' unless high}
18
+ #{args[:class]}
19
+ ", &block)
20
+ end
21
+
22
+ renders_many :menus, ->(name, url, **args) do
23
+ if args[:method]
24
+ button_to(name, url, **args)
25
+ else
26
+ link_to(name, url, **args)
27
+ end
28
+ end
29
+
13
30
  # @param title [String] the title of the panel
14
31
  # @param title_hint [String] the title hint of the panel
15
32
  def initialize(title: nil, title_hint: nil)
@@ -1,4 +1,2 @@
1
- # Add your component translations here.
2
- # Use the translation in the example in your template with `t(".hello")`.
3
1
  en:
4
- hello: "Hello world!"
2
+ more: "More"
@@ -0,0 +1,10 @@
1
+ <div class="flex gap-2 grow">
2
+ <%= render component("ui/thumbnail").new(
3
+ src: @thumbnail,
4
+ alt: @title,
5
+ ) if @thumbnail %>
6
+ <div class="flex-col">
7
+ <div class="leading-5 text-black font-semibold text-sm"><%= @title %></div>
8
+ <div class="leading-5 text-gray-500 font-normal text-sm"><%= @subtitle %></div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::ResourceItem::Component < SolidusAdmin::BaseComponent
4
+ def initialize(title:, subtitle:, thumbnail: nil)
5
+ @thumbnail = thumbnail
6
+ @title = title
7
+ @subtitle = subtitle
8
+ end
9
+ end
@@ -2,12 +2,13 @@
2
2
 
3
3
  class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
4
4
  SIZES = {
5
- s: %w[h-7 px-1.5 body-small-bold],
6
- m: %w[h-9 px-3 body-small-bold],
7
- l: %w[h-12 px-4 body-text-bold],
5
+ s: %w[h-7 px-1.5 font-semibold text-sm],
6
+ m: %w[h-9 px-3 font-semibold text-sm],
7
+ l: %w[h-12 px-4 font-semibold text-base],
8
8
  }
9
9
 
10
- def initialize(text:, size: :m, current: false, disabled: false, **attributes)
10
+ def initialize(text:, tag: :a, size: :m, current: false, disabled: false, **attributes)
11
+ @tag = tag
11
12
  @text = text
12
13
  @size = size
13
14
  @attributes = attributes
@@ -22,11 +23,11 @@ class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
22
23
  hover:bg-gray-75 hover:text-gray-700
23
24
  focus:bg-gray-25 focus:text-gray-700
24
25
 
25
- active:bg-gray-50 active:text-black
26
+ active:bg-gray-75 active:text-black
26
27
  aria-current:bg-gray-50 aria-current:text-black
27
28
 
28
- disabled:bg-gray-100 disabled:text-gray-400
29
- aria-disabled:bg-gray-100 aria-disabled:text-gray-400
29
+ disabled:bg-gray-75 disabled:text-gray-400
30
+ aria-disabled:bg-gray-75 aria-disabled:text-gray-400
30
31
  ],
31
32
  SIZES.fetch(@size.to_sym),
32
33
  @attributes.delete(:class),
@@ -35,7 +36,7 @@ class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
35
36
 
36
37
  def call
37
38
  content_tag(
38
- :a,
39
+ @tag,
39
40
  @text,
40
41
  **@attributes
41
42
  )