rails-active-ui 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/datatables.css +15 -0
- data/app/assets/stylesheets.css +5 -1
- data/app/blocks/resource_list_block.rb +153 -0
- data/app/components/back_button_component.rb +34 -0
- data/app/components/button_component.rb +4 -2
- data/app/components/button_to_component.rb +3 -4
- data/app/components/column_component.rb +1 -1
- data/app/components/container_component.rb +1 -1
- data/app/components/dropdown_component.rb +8 -2
- data/app/components/grid_component.rb +5 -1
- data/app/components/link_to_component.rb +23 -0
- data/app/components/menu_item_component.rb +5 -1
- data/app/components/message_component.rb +3 -1
- data/app/components/modal_component.rb +23 -3
- data/app/components/paragraph_component.rb +13 -0
- data/app/components/row_component.rb +1 -1
- data/app/components/table_row_component.rb +3 -5
- data/app/components/template_component.rb +13 -0
- data/app/helpers/component_helper.rb +122 -76
- data/app/helpers/fui_helper.rb +37 -0
- data/app/javascript/datatables.js +10 -0
- data/app/javascript/ui/controllers/fui_datatable_controller.js +35 -0
- data/app/javascript/ui/controllers/fui_dropdown_controller.js +8 -1
- data/app/javascript/ui/controllers/fui_item_list_controller.js +40 -0
- data/app/javascript/ui/controllers/navigation_controller.js +23 -0
- data/app/javascript/ui/index.js +11 -0
- data/app/lib/component.rb +1 -1
- data/config/importmap.rb +3 -0
- data/config/initializers/ruby_template_handler.rb +4 -1
- data/lib/ui/engine.rb +7 -2
- data/lib/ui/version.rb +1 -1
- metadata +13 -7
- data/app/components/link_component.rb +0 -23
|
@@ -18,6 +18,7 @@ export default class extends Controller {
|
|
|
18
18
|
static values = {
|
|
19
19
|
clearable: { type: Boolean, default: false },
|
|
20
20
|
placeholder: { type: String, default: "" },
|
|
21
|
+
action: { type: String, default: "" },
|
|
21
22
|
forceSelection: { type: Boolean, default: false },
|
|
22
23
|
fullTextSearch: { type: Boolean, default: false },
|
|
23
24
|
duration: { type: Number, default: 200 },
|
|
@@ -45,7 +46,7 @@ export default class extends Controller {
|
|
|
45
46
|
// -- Private --
|
|
46
47
|
|
|
47
48
|
_options() {
|
|
48
|
-
|
|
49
|
+
const options = {
|
|
49
50
|
clearable: this.clearableValue,
|
|
50
51
|
placeholder: this.placeholderValue || false,
|
|
51
52
|
forceSelection: this.forceSelectionValue,
|
|
@@ -64,5 +65,11 @@ export default class extends Controller {
|
|
|
64
65
|
this.dispatch("remove", { detail: { value: removedValue, text: removedText } })
|
|
65
66
|
},
|
|
66
67
|
}
|
|
68
|
+
|
|
69
|
+
if (this.actionValue) {
|
|
70
|
+
options.action = this.actionValue
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return options
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Generic list-item selection controller.
|
|
4
|
+
//
|
|
5
|
+
// Mark clickable items with:
|
|
6
|
+
// - data-fui-item-list-target="item"
|
|
7
|
+
// - data-item-id="123"
|
|
8
|
+
//
|
|
9
|
+
// Wire click on link/card with:
|
|
10
|
+
// - data-action="click->fui-item-list#select"
|
|
11
|
+
export default class extends Controller {
|
|
12
|
+
static targets = ["item"]
|
|
13
|
+
static values = { selectedId: { type: Number, default: 0 } }
|
|
14
|
+
|
|
15
|
+
connect() {
|
|
16
|
+
this.#applySelected()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
select(event) {
|
|
20
|
+
const card =
|
|
21
|
+
event.target.closest("[data-item-id]") ||
|
|
22
|
+
event.currentTarget?.closest?.("[data-item-id]") ||
|
|
23
|
+
event.currentTarget?.querySelector?.("[data-item-id]")
|
|
24
|
+
|
|
25
|
+
if (card) {
|
|
26
|
+
this.selectedIdValue = parseInt(card.dataset.itemId, 10) || 0
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
selectedIdValueChanged() {
|
|
31
|
+
this.#applySelected()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#applySelected() {
|
|
35
|
+
this.itemTargets.forEach((item) => {
|
|
36
|
+
const id = parseInt(item.dataset.itemId, 10) || 0
|
|
37
|
+
item.classList.toggle("active", id === this.selectedIdValue)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Navigation back controller.
|
|
4
|
+
//
|
|
5
|
+
// If there is Turbo history to restore, prevent normal navigation and go back.
|
|
6
|
+
// Otherwise fallback to link href.
|
|
7
|
+
export default class extends Controller {
|
|
8
|
+
back(event) {
|
|
9
|
+
if (this.#shouldRestore) {
|
|
10
|
+
event.preventDefault()
|
|
11
|
+
window.history.back()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get #shouldRestore() {
|
|
16
|
+
return !this.#isFirstHistoryEntry
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get #isFirstHistoryEntry() {
|
|
20
|
+
const state = window.history.state
|
|
21
|
+
return !state || !state.turbo || state.turbo.restorationIndex === 0
|
|
22
|
+
}
|
|
23
|
+
}
|
data/app/javascript/ui/index.js
CHANGED
|
@@ -50,6 +50,11 @@ import FuiApiController from "ui/controllers/fui_api_controller"
|
|
|
50
50
|
import FuiStateController from "ui/controllers/fui_state_controller"
|
|
51
51
|
import FuiVisibilityController from "ui/controllers/fui_visibility_controller"
|
|
52
52
|
import FuiEmojiPickerController from "ui/controllers/fui_emoji_picker_controller"
|
|
53
|
+
import NavigationController from "ui/controllers/navigation_controller"
|
|
54
|
+
|
|
55
|
+
// DataTables
|
|
56
|
+
import FuiDatatableController from "ui/controllers/fui_datatable_controller"
|
|
57
|
+
import FuiItemListController from "ui/controllers/fui_item_list_controller"
|
|
53
58
|
|
|
54
59
|
const controllers = {
|
|
55
60
|
"fui-site": FuiSiteController,
|
|
@@ -78,6 +83,9 @@ const controllers = {
|
|
|
78
83
|
"fui-state": FuiStateController,
|
|
79
84
|
"fui-visibility": FuiVisibilityController,
|
|
80
85
|
"fui-emoji-picker": FuiEmojiPickerController,
|
|
86
|
+
"fui-datatable": FuiDatatableController,
|
|
87
|
+
"fui-item-list": FuiItemListController,
|
|
88
|
+
"navigation": NavigationController,
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
export function registerFuiControllers(application) {
|
|
@@ -114,4 +122,7 @@ export {
|
|
|
114
122
|
FuiStateController,
|
|
115
123
|
FuiVisibilityController,
|
|
116
124
|
FuiEmojiPickerController,
|
|
125
|
+
FuiDatatableController,
|
|
126
|
+
FuiItemListController,
|
|
127
|
+
NavigationController,
|
|
117
128
|
}
|
data/app/lib/component.rb
CHANGED
|
@@ -14,7 +14,7 @@ class Component
|
|
|
14
14
|
include ActiveModel::Attributes
|
|
15
15
|
|
|
16
16
|
# HTML pass-through keys that bypass ActiveModel attributes
|
|
17
|
-
HTML_OPTIONS = %i[id class data style role tabindex title aria].to_set.freeze
|
|
17
|
+
HTML_OPTIONS = %i[id class data style role tabindex title aria target rel].to_set.freeze
|
|
18
18
|
|
|
19
19
|
class_attribute :slot_names, default: []
|
|
20
20
|
|
data/config/importmap.rb
CHANGED
|
@@ -26,5 +26,8 @@ pin "ui/controllers/fui_toast_controller", to: "ui/controllers/fui_toast_control
|
|
|
26
26
|
pin "ui/controllers/fui_transition_controller", to: "ui/controllers/fui_transition_controller.js"
|
|
27
27
|
pin "ui/controllers/fui_visibility_controller", to: "ui/controllers/fui_visibility_controller.js"
|
|
28
28
|
pin "ui/controllers/fui_emoji_picker_controller", to: "ui/controllers/fui_emoji_picker_controller.js"
|
|
29
|
+
pin "ui/controllers/fui_datatable_controller", to: "ui/controllers/fui_datatable_controller.js"
|
|
30
|
+
pin "ui/controllers/fui_item_list_controller", to: "ui/controllers/fui_item_list_controller.js"
|
|
31
|
+
pin "ui/controllers/navigation_controller", to: "ui/controllers/navigation_controller.js"
|
|
29
32
|
|
|
30
33
|
pin "emoji-picker-element", to: "https://cdn.jsdelivr.net/npm/emoji-picker-element@^1/index.js"
|
data/lib/ui/engine.rb
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
module Ui
|
|
4
4
|
class Engine < ::Rails::Engine
|
|
5
5
|
initializer "ui.autoload_paths" do |app|
|
|
6
|
-
app.config.autoload_paths += [
|
|
6
|
+
app.config.autoload_paths += [
|
|
7
|
+
root.join("app", "lib").to_s,
|
|
8
|
+
root.join("app", "blocks").to_s
|
|
9
|
+
]
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
initializer "ui.assets" do |app|
|
|
@@ -17,8 +20,10 @@ module Ui
|
|
|
17
20
|
end
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
initializer "ui.helpers" do
|
|
23
|
+
initializer "ui.helpers", after: :load_config_initializers do
|
|
21
24
|
ActiveSupport.on_load(:action_view) do
|
|
25
|
+
require_dependency "component_helper"
|
|
26
|
+
require_dependency "fui_helper"
|
|
22
27
|
include ComponentHelper
|
|
23
28
|
include FuiHelper
|
|
24
29
|
end
|
data/lib/ui/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-active-ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- nathan
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -39,10 +38,13 @@ extensions: []
|
|
|
39
38
|
extra_rdoc_files: []
|
|
40
39
|
files:
|
|
41
40
|
- Rakefile
|
|
41
|
+
- app/assets/datatables.css
|
|
42
42
|
- app/assets/stylesheets.css
|
|
43
|
+
- app/blocks/resource_list_block.rb
|
|
43
44
|
- app/components/accordion_component.rb
|
|
44
45
|
- app/components/ad_component.rb
|
|
45
46
|
- app/components/api_component.rb
|
|
47
|
+
- app/components/back_button_component.rb
|
|
46
48
|
- app/components/breadcrumb_component.rb
|
|
47
49
|
- app/components/button_component.rb
|
|
48
50
|
- app/components/button_to_component.rb
|
|
@@ -75,7 +77,7 @@ files:
|
|
|
75
77
|
- app/components/item_component.rb
|
|
76
78
|
- app/components/item_group_component.rb
|
|
77
79
|
- app/components/label_component.rb
|
|
78
|
-
- app/components/
|
|
80
|
+
- app/components/link_to_component.rb
|
|
79
81
|
- app/components/list_component.rb
|
|
80
82
|
- app/components/loader_component.rb
|
|
81
83
|
- app/components/menu_component.rb
|
|
@@ -84,6 +86,7 @@ files:
|
|
|
84
86
|
- app/components/modal_component.rb
|
|
85
87
|
- app/components/nag_component.rb
|
|
86
88
|
- app/components/overlay_component.rb
|
|
89
|
+
- app/components/paragraph_component.rb
|
|
87
90
|
- app/components/placeholder_component.rb
|
|
88
91
|
- app/components/popup_component.rb
|
|
89
92
|
- app/components/progress_component.rb
|
|
@@ -112,6 +115,7 @@ files:
|
|
|
112
115
|
- app/components/table_cell_component.rb
|
|
113
116
|
- app/components/table_component.rb
|
|
114
117
|
- app/components/table_row_component.rb
|
|
118
|
+
- app/components/template_component.rb
|
|
115
119
|
- app/components/text_component.rb
|
|
116
120
|
- app/components/toast_component.rb
|
|
117
121
|
- app/components/transition_component.rb
|
|
@@ -128,6 +132,7 @@ files:
|
|
|
128
132
|
- app/javascript/calendar.min.js
|
|
129
133
|
- app/javascript/checkbox.js
|
|
130
134
|
- app/javascript/checkbox.min.js
|
|
135
|
+
- app/javascript/datatables.js
|
|
131
136
|
- app/javascript/dimmer.js
|
|
132
137
|
- app/javascript/dimmer.min.js
|
|
133
138
|
- app/javascript/dropdown.js
|
|
@@ -174,12 +179,14 @@ files:
|
|
|
174
179
|
- app/javascript/ui/controllers/fui_api_controller.js
|
|
175
180
|
- app/javascript/ui/controllers/fui_calendar_controller.js
|
|
176
181
|
- app/javascript/ui/controllers/fui_checkbox_controller.js
|
|
182
|
+
- app/javascript/ui/controllers/fui_datatable_controller.js
|
|
177
183
|
- app/javascript/ui/controllers/fui_dimmer_controller.js
|
|
178
184
|
- app/javascript/ui/controllers/fui_dropdown_controller.js
|
|
179
185
|
- app/javascript/ui/controllers/fui_embed_controller.js
|
|
180
186
|
- app/javascript/ui/controllers/fui_emoji_picker_controller.js
|
|
181
187
|
- app/javascript/ui/controllers/fui_flyout_controller.js
|
|
182
188
|
- app/javascript/ui/controllers/fui_form_controller.js
|
|
189
|
+
- app/javascript/ui/controllers/fui_item_list_controller.js
|
|
183
190
|
- app/javascript/ui/controllers/fui_modal_controller.js
|
|
184
191
|
- app/javascript/ui/controllers/fui_nag_controller.js
|
|
185
192
|
- app/javascript/ui/controllers/fui_popup_controller.js
|
|
@@ -196,6 +203,7 @@ files:
|
|
|
196
203
|
- app/javascript/ui/controllers/fui_toast_controller.js
|
|
197
204
|
- app/javascript/ui/controllers/fui_transition_controller.js
|
|
198
205
|
- app/javascript/ui/controllers/fui_visibility_controller.js
|
|
206
|
+
- app/javascript/ui/controllers/navigation_controller.js
|
|
199
207
|
- app/javascript/ui/index.js
|
|
200
208
|
- app/javascript/visibility.js
|
|
201
209
|
- app/javascript/visibility.min.js
|
|
@@ -216,7 +224,6 @@ metadata:
|
|
|
216
224
|
homepage_uri: https://github.com/n-at-han-k/rails-active-ui
|
|
217
225
|
source_code_uri: https://github.com/n-at-han-k/rails-active-ui/tree/main
|
|
218
226
|
changelog_uri: https://github.com/n-at-han-k/rails-active-ui/blob/main/CHANGELOG.md
|
|
219
|
-
post_install_message:
|
|
220
227
|
rdoc_options: []
|
|
221
228
|
require_paths:
|
|
222
229
|
- lib
|
|
@@ -231,8 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
231
238
|
- !ruby/object:Gem::Version
|
|
232
239
|
version: '0'
|
|
233
240
|
requirements: []
|
|
234
|
-
rubygems_version: 3.
|
|
235
|
-
signing_key:
|
|
241
|
+
rubygems_version: 3.7.2
|
|
236
242
|
specification_version: 4
|
|
237
243
|
summary: ActiveModel::Attributes-based view components
|
|
238
244
|
test_files: []
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Link — anchor element.
|
|
4
|
-
#
|
|
5
|
-
# Usage:
|
|
6
|
-
# Link(href: "/about") { text "About Us" }
|
|
7
|
-
# Link(href: "/help", target: "_blank") { text "Help" }
|
|
8
|
-
|
|
9
|
-
class LinkComponent < Component
|
|
10
|
-
attribute :href, :string, default: "#"
|
|
11
|
-
attribute :target, :string, default: nil
|
|
12
|
-
attribute :rel, :string, default: nil
|
|
13
|
-
attribute :css_class, :string, default: nil
|
|
14
|
-
|
|
15
|
-
def to_s
|
|
16
|
-
opts = { href: href }
|
|
17
|
-
opts[:class] = css_class if css_class
|
|
18
|
-
opts[:target] = target if target
|
|
19
|
-
opts[:rel] = rel if rel
|
|
20
|
-
|
|
21
|
-
tag.a(**merge_html_options(**opts)) { @content }
|
|
22
|
-
end
|
|
23
|
-
end
|