plutonium 0.15.14 → 0.15.16
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/plutonium.js +9 -9
- data/app/assets/plutonium.js.map +2 -2
- data/app/assets/plutonium.min.js +1 -1
- data/app/assets/plutonium.min.js.map +2 -2
- data/app/views/plutonium/_resource_header.html.erb +1 -1
- data/lib/generators/pu/gem/state_machines/state_machines_generator.rb +20 -0
- data/lib/plutonium/interaction/base.rb +20 -9
- data/lib/plutonium/resource/controllers/interactive_actions.rb +3 -3
- data/lib/plutonium/ui/color_mode_selector.rb +1 -1
- data/lib/plutonium/ui/component/methods.rb +1 -0
- data/lib/plutonium/ui/display/resource.rb +1 -1
- data/lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb +4 -4
- data/lib/plutonium/ui/form/query.rb +5 -3
- data/lib/plutonium/ui/form/resource.rb +2 -2
- data/lib/plutonium/ui/layout/base.rb +1 -1
- data/lib/plutonium/ui/layout/header.rb +3 -3
- data/lib/plutonium/ui/layout/sidebar.rb +0 -2
- data/lib/plutonium/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/src/js/controllers/header_controller.js +9 -9
- metadata +3 -2
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Gem
|
7
|
+
class StateMachinesGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
desc "Set up state_machines"
|
11
|
+
|
12
|
+
def start
|
13
|
+
bundle "state_machines"
|
14
|
+
bundle "state_machines-activerecord"
|
15
|
+
rescue => e
|
16
|
+
exception "#{self.class} failed:", e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -29,19 +29,26 @@ module Plutonium
|
|
29
29
|
|
30
30
|
class Form < Plutonium::UI::Form::Interaction; end
|
31
31
|
|
32
|
+
class << self
|
33
|
+
def call(...)
|
34
|
+
new(...).call
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_form(instance)
|
38
|
+
raise ArgumentError, "instance is required" unless instance
|
39
|
+
|
40
|
+
self::Form.new(instance)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
32
44
|
config_attr :turbo
|
33
45
|
defineable_props :field, :input
|
34
46
|
|
35
|
-
|
36
|
-
#
|
37
|
-
# @param args [Hash] The arguments to initialize the interaction.
|
38
|
-
# @return [Plutonium::Interaction::Outcome] The result of the interaction.
|
39
|
-
def self.call(**args)
|
40
|
-
new(**args).call
|
41
|
-
end
|
47
|
+
attr_reader :view_context
|
42
48
|
|
43
|
-
def
|
44
|
-
|
49
|
+
def initialize(view_context:, **attributes)
|
50
|
+
super(attributes)
|
51
|
+
@view_context = view_context
|
45
52
|
end
|
46
53
|
|
47
54
|
def build_form
|
@@ -101,6 +108,10 @@ module Plutonium
|
|
101
108
|
def failure
|
102
109
|
Plutonium::Interaction::Outcome::Failure.new
|
103
110
|
end
|
111
|
+
|
112
|
+
def current_user
|
113
|
+
view_context.controller.helpers.current_user
|
114
|
+
end
|
104
115
|
end
|
105
116
|
end
|
106
117
|
end
|
@@ -215,13 +215,13 @@ module Plutonium
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def build_interactive_record_action_interaction
|
218
|
-
@interaction = current_interactive_action.interaction.new
|
218
|
+
@interaction = current_interactive_action.interaction.new(view_context:)
|
219
219
|
@interaction.attributes = interaction_params.merge(resource: resource_record)
|
220
220
|
@interaction
|
221
221
|
end
|
222
222
|
|
223
223
|
def build_interactive_resource_action_interaction
|
224
|
-
@interaction = current_interactive_action.interaction.new
|
224
|
+
@interaction = current_interactive_action.interaction.new(view_context:)
|
225
225
|
@interaction.attributes = interaction_params
|
226
226
|
@interaction
|
227
227
|
end
|
@@ -231,7 +231,7 @@ module Plutonium
|
|
231
231
|
def submitted_interaction_params
|
232
232
|
@submitted_interaction_params ||= current_interactive_action
|
233
233
|
.interaction
|
234
|
-
.build_form(
|
234
|
+
.build_form(current_interactive_action.interaction.new(view_context:))
|
235
235
|
.extract_input(params, view_context:)[:interaction]
|
236
236
|
end
|
237
237
|
|
@@ -79,7 +79,7 @@ module Plutonium
|
|
79
79
|
field_options = field_options.except(:as)
|
80
80
|
wrapper_options = display_options.except(:tag, :as)
|
81
81
|
render field(name, **field_options).wrapped(**wrapper_options) do |f|
|
82
|
-
render
|
82
|
+
render instance_exec(f, &tag_block)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -160,14 +160,14 @@ module Plutonium
|
|
160
160
|
def render_multiple_nested_fields(context)
|
161
161
|
nesting_method = :nest_many
|
162
162
|
options = {default: {NEW_RECORD: context.blank_object}}
|
163
|
-
render_template_for_nested_fields(context, options, nesting_method:)
|
163
|
+
render_template_for_nested_fields(context, options.merge(collection: {NEW_RECORD: context.blank_object}), nesting_method:)
|
164
164
|
render_existing_nested_fields(context, options, nesting_method:)
|
165
165
|
end
|
166
166
|
|
167
167
|
def render_single_nested_field(context)
|
168
168
|
nesting_method = :nest_one
|
169
169
|
options = {default: context.blank_object}
|
170
|
-
render_template_for_nested_fields(context, options, nesting_method:)
|
170
|
+
render_template_for_nested_fields(context, options.merge(object: context.blank_object), nesting_method:)
|
171
171
|
render_existing_nested_fields(context, options, nesting_method:)
|
172
172
|
end
|
173
173
|
|
@@ -267,8 +267,8 @@ module Plutonium
|
|
267
267
|
you can either pass in a block:
|
268
268
|
```ruby
|
269
269
|
nested_input :#{name} do |definition|
|
270
|
-
input :city
|
271
|
-
input :country
|
270
|
+
definition.input :city
|
271
|
+
definition.input :country
|
272
272
|
end
|
273
273
|
```
|
274
274
|
|
@@ -9,12 +9,12 @@ module Plutonium
|
|
9
9
|
def initialize(*, query_object:, page_size:, attributes: {}, **options, &)
|
10
10
|
options[:as] = :q
|
11
11
|
options[:method] = :get
|
12
|
-
attributes.deep_merge
|
12
|
+
attributes = mix(attributes.deep_merge(
|
13
13
|
id: :search_form,
|
14
14
|
class!: "space-y-2 mb-4",
|
15
15
|
controller: "form",
|
16
16
|
data: {controller: "form", turbo_frame: nil}
|
17
|
-
)
|
17
|
+
))
|
18
18
|
super(*, attributes:, **options, &)
|
19
19
|
|
20
20
|
@query_object = query_object
|
@@ -97,6 +97,8 @@ module Plutonium
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def render_filter_fields
|
100
|
+
return if query_object.filter_definitions.blank?
|
101
|
+
|
100
102
|
div(class: "flex flex-wrap items-center gap-4") do
|
101
103
|
span(class: "text-sm font-medium text-gray-900 dark:text-white") { "Filters:" }
|
102
104
|
div(class: "flex flex-wrap items-center gap-4 mr-auto") do
|
@@ -162,7 +164,7 @@ module Plutonium
|
|
162
164
|
field_options = field_options.except(:as)
|
163
165
|
nested.field(name, **field_options) do |f|
|
164
166
|
f.placeholder(f.label) unless f.placeholder
|
165
|
-
render
|
167
|
+
render instance_exec(f, &tag_block)
|
166
168
|
end
|
167
169
|
end
|
168
170
|
end
|
@@ -37,7 +37,7 @@ module Plutonium
|
|
37
37
|
|
38
38
|
def render_resource_field(name)
|
39
39
|
when_permitted(name) do
|
40
|
-
if resource_definition.defined_nested_inputs[name]
|
40
|
+
if resource_definition.respond_to?(:defined_nested_inputs) && resource_definition.defined_nested_inputs[name]
|
41
41
|
render_nested_resource_field(name)
|
42
42
|
else
|
43
43
|
render_simple_resource_field(name, resource_definition, self)
|
@@ -75,7 +75,7 @@ module Plutonium
|
|
75
75
|
end
|
76
76
|
|
77
77
|
render form.field(name, **field_options).wrapped(**wrapper_options) do |f|
|
78
|
-
render
|
78
|
+
render instance_exec(f, &tag_block)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -112,7 +112,7 @@ module Plutonium
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def render_favicon_tag
|
115
|
-
favicon_link_tag(Plutonium.configuration.assets.favicon)
|
115
|
+
favicon_link_tag(Plutonium.configuration.assets.favicon) if Plutonium.configuration.assets.favicon
|
116
116
|
end
|
117
117
|
|
118
118
|
def render_assets_tags
|
@@ -84,7 +84,7 @@ module Plutonium
|
|
84
84
|
# Renders the brand section with logo and/or name
|
85
85
|
# @private
|
86
86
|
def render_brand
|
87
|
-
a(href: root_path, class: "flex items-center
|
87
|
+
a(href: root_path, class: "flex items-center space-x-2 md:min-w-60") do
|
88
88
|
render brand_logo_slot if brand_logo_slot?
|
89
89
|
if brand_name_slot?
|
90
90
|
span(class: "self-center text-2xl font-semibold whitespace-nowrap dark:text-white hidden xs:block") do
|
@@ -97,11 +97,11 @@ module Plutonium
|
|
97
97
|
# Renders the toggle icons for the sidebar button
|
98
98
|
# @private
|
99
99
|
def render_toggle_icons
|
100
|
-
span(data_header_target: "
|
100
|
+
span(data_header_target: "openIcon") do
|
101
101
|
render Phlex::TablerIcons::Menu.new(class: "w-6 h-6")
|
102
102
|
end
|
103
103
|
|
104
|
-
span(data_header_target: "
|
104
|
+
span(data_header_target: "closeIcon", class: "hidden", aria_hidden: "true") do
|
105
105
|
render Phlex::TablerIcons::X.new(class: "w-6 h-6")
|
106
106
|
end
|
107
107
|
|
data/lib/plutonium/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@radioactive-labs/plutonium",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.9",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "@radioactive-labs/plutonium",
|
9
|
-
"version": "0.1.
|
9
|
+
"version": "0.1.9",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"@hotwired/stimulus": "^3.2.2",
|
data/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
|
-
static targets = ["
|
4
|
+
static targets = ["openIcon", "closeIcon"]
|
5
5
|
static outlets = ["sidebar"]
|
6
6
|
static values = {
|
7
7
|
placement: { type: String, default: "left" },
|
@@ -57,11 +57,11 @@ export default class extends Controller {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
// Toggle visibility and ARIA attributes of icons
|
60
|
-
this.
|
61
|
-
this.
|
60
|
+
this.openIconTarget.classList.add("hidden")
|
61
|
+
this.openIconTarget.setAttribute("aria-hidden", "true")
|
62
62
|
|
63
|
-
this.
|
64
|
-
this.
|
63
|
+
this.closeIconTarget.classList.remove("hidden")
|
64
|
+
this.closeIconTarget.setAttribute("aria-hidden", "false")
|
65
65
|
|
66
66
|
// Rest of the method stays same...
|
67
67
|
this.sidebarOutlet.element.setAttribute("aria-modal", "true")
|
@@ -88,11 +88,11 @@ export default class extends Controller {
|
|
88
88
|
}
|
89
89
|
|
90
90
|
// Toggle visibility and ARIA attributes of icons
|
91
|
-
this.
|
92
|
-
this.
|
91
|
+
this.openIconTarget.classList.remove("hidden")
|
92
|
+
this.openIconTarget.setAttribute("aria-hidden", "false")
|
93
93
|
|
94
|
-
this.
|
95
|
-
this.
|
94
|
+
this.closeIconTarget.classList.add("hidden")
|
95
|
+
this.closeIconTarget.setAttribute("aria-hidden", "true")
|
96
96
|
|
97
97
|
// Rest of the method stays same...
|
98
98
|
this.sidebarOutlet.element.setAttribute("aria-hidden", "true")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -1128,6 +1128,7 @@ files:
|
|
1128
1128
|
- lib/generators/pu/gem/letter_opener/letter_opener_generator.rb
|
1129
1129
|
- lib/generators/pu/gem/redis/redis_generator.rb
|
1130
1130
|
- lib/generators/pu/gem/standard/standard_generator.rb
|
1131
|
+
- lib/generators/pu/gem/state_machines/state_machines_generator.rb
|
1131
1132
|
- lib/generators/pu/gen/component/component_generator.rb
|
1132
1133
|
- lib/generators/pu/gen/component/templates/component.html.erb.tt
|
1133
1134
|
- lib/generators/pu/gen/component/templates/component.rb.tt
|