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.
- checksums.yaml +4 -4
- data/.eslintrc.json +7 -0
- data/README.md +1 -1
- data/Rakefile +26 -0
- data/app/assets/builds/.keep +0 -0
- data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
- data/app/assets/config/solidus_admin_manifest.js +1 -0
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
- data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
- data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +32 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
- data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
- data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
- data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
- data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
- data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
- data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
- data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
- data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
- data/app/components/solidus_admin/option_types/index/component.html.erb +30 -0
- data/app/components/solidus_admin/option_types/index/component.rb +57 -0
- data/app/components/solidus_admin/option_types/index/component.yml +4 -0
- data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
- data/app/components/solidus_admin/orders/cart/component.js +37 -0
- data/app/components/solidus_admin/orders/cart/component.rb +7 -0
- data/app/components/solidus_admin/orders/cart/component.yml +3 -0
- data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
- data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/index/component.html.erb +26 -22
- data/app/components/solidus_admin/orders/index/component.rb +80 -16
- data/app/components/solidus_admin/orders/index/component.yml +10 -3
- data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
- data/app/components/solidus_admin/orders/show/address/component.js +9 -0
- data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
- data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
- data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
- data/app/components/solidus_admin/orders/show/component.js +7 -0
- data/app/components/solidus_admin/orders/show/component.rb +40 -0
- data/app/components/solidus_admin/orders/show/component.yml +21 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
- data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
- data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
- data/app/components/solidus_admin/payment_methods/index/component.html.erb +38 -0
- data/app/components/solidus_admin/payment_methods/index/component.rb +93 -0
- data/app/components/solidus_admin/payment_methods/index/component.yml +15 -0
- data/app/components/solidus_admin/products/index/component.html.erb +26 -22
- data/app/components/solidus_admin/products/index/component.rb +36 -36
- data/app/components/solidus_admin/products/index/component.yml +9 -6
- data/app/components/solidus_admin/products/show/component.html.erb +32 -38
- data/app/components/solidus_admin/products/show/component.rb +2 -0
- data/app/components/solidus_admin/products/show/component.yml +5 -5
- data/app/components/solidus_admin/products/status/component.rb +20 -18
- data/app/components/solidus_admin/products/status/component.yml +1 -0
- data/app/components/solidus_admin/products/stock/component.rb +38 -0
- data/app/components/solidus_admin/products/stock/component.yml +5 -0
- data/app/components/solidus_admin/promotion_categories/index/component.html.erb +26 -0
- data/app/components/solidus_admin/promotion_categories/index/component.rb +57 -0
- data/app/components/solidus_admin/promotion_categories/index/component.yml +4 -0
- data/app/components/solidus_admin/promotions/index/component.html.erb +34 -0
- data/app/components/solidus_admin/promotions/index/component.rb +97 -0
- data/app/components/solidus_admin/promotions/index/component.yml +14 -0
- data/app/components/solidus_admin/properties/index/component.html.erb +34 -0
- data/app/components/solidus_admin/properties/index/component.rb +65 -0
- data/app/components/solidus_admin/properties/index/component.yml +4 -0
- data/app/components/solidus_admin/refund_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/refund_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/refunds_and_returns/component.html.erb +26 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +20 -0
- data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +22 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +45 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.yml +4 -0
- data/app/components/solidus_admin/return_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/return_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/shipping/component.html.erb +30 -0
- data/app/components/solidus_admin/shipping/component.rb +18 -0
- data/app/components/solidus_admin/shipping/component.yml +3 -0
- data/app/components/solidus_admin/shipping_categories/index/component.html.erb +32 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
- data/app/components/solidus_admin/shipping_categories/index/component.yml +4 -0
- data/app/components/solidus_admin/shipping_methods/index/component.html.erb +32 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
- data/app/components/solidus_admin/shipping_methods/index/component.yml +4 -0
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
- data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
- data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
- data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
- data/app/components/solidus_admin/stock_items/index/component.html.erb +26 -0
- data/app/components/solidus_admin/stock_items/index/component.rb +180 -0
- data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
- data/app/components/solidus_admin/stock_locations/index/component.html.erb +32 -0
- data/app/components/solidus_admin/stock_locations/index/component.rb +81 -0
- data/app/components/solidus_admin/stock_locations/index/component.yml +6 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/stores/index/component.html.erb +34 -0
- data/app/components/solidus_admin/stores/index/component.rb +59 -0
- data/app/components/solidus_admin/stores/index/component.yml +4 -0
- data/app/components/solidus_admin/tax_categories/index/component.html.erb +32 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_categories/index/component.yml +6 -0
- data/app/components/solidus_admin/tax_rates/index/component.html.erb +32 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +84 -0
- data/app/components/solidus_admin/tax_rates/index/component.yml +4 -0
- data/app/components/solidus_admin/taxes/component.html.erb +24 -0
- data/app/components/solidus_admin/taxes/component.rb +25 -0
- data/app/components/solidus_admin/taxes/component.yml +3 -0
- data/app/components/solidus_admin/taxonomies/index/component.html.erb +28 -0
- data/app/components/solidus_admin/taxonomies/index/component.rb +47 -0
- data/app/components/solidus_admin/taxonomies/index/component.yml +4 -0
- data/app/components/solidus_admin/ui/badge/component.rb +18 -8
- data/app/components/solidus_admin/ui/badge/component.yml +3 -0
- data/app/components/solidus_admin/ui/button/component.rb +32 -32
- data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
- data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
- data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
- data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
- data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
- data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
- data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
- data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
- data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
- data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
- data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
- data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
- data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
- data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
- data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
- data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
- data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
- data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
- data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
- data/app/components/solidus_admin/ui/icon/component.rb +4 -0
- data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
- data/app/components/solidus_admin/ui/modal/component.rb +12 -0
- data/app/components/solidus_admin/ui/modal/component.yml +2 -0
- data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
- data/app/components/solidus_admin/ui/panel/component.rb +17 -0
- data/app/components/solidus_admin/ui/panel/component.yml +1 -3
- data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
- data/app/components/solidus_admin/ui/tab/component.rb +9 -8
- data/app/components/solidus_admin/ui/table/component.html.erb +146 -135
- data/app/components/solidus_admin/ui/table/component.js +56 -17
- data/app/components/solidus_admin/ui/table/component.rb +94 -70
- data/app/components/solidus_admin/ui/table/component.yml +0 -1
- data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
- data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
- data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
- data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
- data/app/components/solidus_admin/ui/toast/component.js +9 -6
- data/app/components/solidus_admin/ui/toast/component.rb +2 -2
- data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
- data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
- data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
- data/app/components/solidus_admin/users/index/component.html.erb +34 -0
- data/app/components/solidus_admin/users/index/component.rb +89 -0
- data/app/components/solidus_admin/users/index/component.yml +18 -0
- data/app/components/solidus_admin/zones/index/component.html.erb +35 -0
- data/app/components/solidus_admin/zones/index/component.rb +55 -0
- data/app/components/solidus_admin/zones/index/component.yml +4 -0
- data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/base_controller.rb +1 -0
- data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
- data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
- data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
- data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
- data/app/controllers/solidus_admin/countries_controller.rb +12 -0
- data/app/controllers/solidus_admin/customers_controller.rb +29 -0
- data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
- data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
- data/app/controllers/solidus_admin/orders_controller.rb +104 -7
- data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
- data/app/controllers/solidus_admin/products_controller.rb +26 -17
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +38 -0
- data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
- data/app/controllers/solidus_admin/properties_controller.rb +33 -0
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
- data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
- data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
- data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/stores_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
- data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
- data/app/controllers/solidus_admin/users_controller.rb +50 -0
- data/app/controllers/solidus_admin/zones_controller.rb +40 -0
- data/app/javascript/solidus_admin/controllers/components.js +3 -1
- data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
- data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
- data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
- data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
- data/app/views/layouts/solidus_admin/application.html.erb +16 -10
- data/app/views/layouts/solidus_admin/preview.html.erb +0 -1
- data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
- data/config/importmap.rb +2 -0
- data/config/initializers/view_component.rb +20 -0
- data/config/locales/adjustment_reasons.en.yml +6 -0
- data/config/locales/customers.en.yml +7 -0
- data/config/locales/errors.en.yml +7 -0
- data/config/locales/line_items.en.yml +9 -0
- data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
- data/config/locales/option_types.en.yml +6 -0
- data/config/locales/orders.en.yml +9 -0
- data/config/locales/payment_methods.en.yml +6 -0
- data/config/locales/promotion_categories.en.yml +6 -0
- data/config/locales/promotions.en.yml +6 -0
- data/config/locales/properties.en.yml +6 -0
- data/config/locales/refund_reasons_.en.yml +6 -0
- data/config/locales/reimbursement_types.en.yml +4 -0
- data/config/locales/return_reasons.en.yml +6 -0
- data/config/locales/shipping_categories.en.yml +6 -0
- data/config/locales/shipping_methods.en.yml +6 -0
- data/config/locales/stock_items.en.yml +4 -0
- data/config/locales/stock_locations.en.yml +6 -0
- data/config/locales/store_credit_reasons.en.yml +6 -0
- data/config/locales/stores.en.yml +6 -0
- data/config/locales/tax_categories.en.yml +6 -0
- data/config/locales/tax_rates.en.yml +6 -0
- data/config/locales/taxonomies.en.yml +6 -0
- data/config/locales/users.en.yml +6 -0
- data/config/locales/zones.en.yml +6 -0
- data/config/routes.rb +50 -3
- data/config/tailwind.config.js +119 -0
- data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
- data/docs/customizing_tailwindcss.md +57 -0
- data/docs/customizing_view_components.md +17 -38
- data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
- data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
- data/lib/solidus_admin/admin_resources.rb +23 -0
- data/lib/solidus_admin/configuration.rb +93 -67
- data/lib/solidus_admin/install_tailwindcss.rb +102 -0
- data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
- data/lib/solidus_admin/version.rb +1 -1
- data/lib/solidus_admin.rb +1 -2
- data/lib/tasks/tailwind.rake +10 -0
- data/solidus_admin.gemspec +3 -4
- metadata +228 -48
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
- data/app/components/solidus_admin/feedback/component.html.erb +0 -11
- data/app/components/solidus_admin/feedback/component.rb +0 -4
- data/app/components/solidus_admin/feedback/component.yml +0 -5
- data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
- data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
- data/app/components/solidus_admin/sidebar/component.rb +0 -21
- data/app/components/solidus_admin/ui/panel/component.js +0 -14
- data/config/solidus_admin/tailwind.config.js.erb +0 -95
- data/docs/customizing_tailwind.md +0 -78
- data/lib/solidus_admin/tailwindcss.rb +0 -58
- data/lib/tasks/tailwindcss.rake +0 -55
- /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
- /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,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>
|
@@ -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
|
@@ -2,46 +2,42 @@
|
|
2
2
|
|
3
3
|
class SolidusAdmin::UI::Forms::Switch::Component < SolidusAdmin::BaseComponent
|
4
4
|
SIZES = {
|
5
|
-
s: '
|
6
|
-
|
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
|
@@ -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
|
-
|
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
|
-
<
|
20
|
-
<
|
21
|
-
|
22
|
-
|
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
|
26
|
-
<
|
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
|
-
</
|
40
|
+
</section>
|
29
41
|
<% end %>
|
30
42
|
|
31
43
|
<% if action? %>
|
32
|
-
<
|
33
|
-
|
34
|
-
|
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)
|
@@ -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>
|
@@ -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
|
6
|
-
m: %w[h-9 px-3
|
7
|
-
l: %w[h-12 px-4
|
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-
|
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-
|
29
|
-
aria-disabled:bg-gray-
|
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
|
-
|
39
|
+
@tag,
|
39
40
|
@text,
|
40
41
|
**@attributes
|
41
42
|
)
|