plutonium 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/Rakefile +10 -0
- data/app/assets/build/plutonium.js +5122 -0
- data/app/assets/javascripts/controllers/index.js +34 -0
- data/app/assets/javascripts/controllers/resource_dismiss_controller.js +37 -0
- data/app/assets/javascripts/controllers/resource_drop_down_controller.js +29 -0
- data/app/assets/javascripts/plutonium-app.js +7 -0
- data/app/assets/javascripts/plutonium.js +1 -0
- data/app/assets/{js → javascripts}/turbo/index.js +1 -1
- data/app/views/application/_flash.html.erb +1 -1
- data/app/views/application/_flash_alerts.html.erb +51 -7
- data/app/views/application/_flash_toasts.html.erb +53 -23
- data/app/views/application/_resource_header.html.erb +563 -561
- data/app/views/components/form/form_builder.rb +2 -2
- data/app/views/components/form/form_component.html.erb +5 -6
- data/app/views/components/interactive_action_form/interactive_action_form_component.html.erb +1 -1
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +66 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.rb +23 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_controller.js +64 -0
- data/app/views/components/sidebar/sidebar_component.html.erb +61 -63
- data/app/views/components/table_search_input/table_search_input_component.html.erb +1 -1
- data/app/views/layouts/resource.html copy.erb +0 -2
- data/app/views/layouts/resource.html.erb +1 -3
- data/app/views/layouts/rodauth.html.erb +0 -1
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/css.manifest +3 -0
- data/esbuild.config.js +44 -0
- data/exe/pug +6 -0
- data/lib/generators/pu/gen/component/component_generator.rb +14 -5
- data/lib/generators/pu/gen/pug/pug_generator.rb +1 -1
- data/lib/generators/pu/lib/plutonium_generators/cli.rb +42 -0
- data/lib/generators/pu/lib/plutonium_generators/concerns/actions.rb +86 -72
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +1 -5
- data/lib/generators/pu/lib/plutonium_generators.rb +8 -0
- data/lib/generators/pu/rodauth/install_generator.rb +1 -2
- data/lib/plutonium/core/actions/collection.rb +1 -1
- data/lib/plutonium/core/controllers/authorizable.rb +4 -4
- data/lib/plutonium/core/fields/inputs/base.rb +1 -1
- data/lib/plutonium/core/fields/inputs/nested_input.rb +57 -0
- data/lib/plutonium/core/fields/inputs/noop_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/phone_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/simple_form_association_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/simple_form_input.rb +1 -1
- data/lib/plutonium/pkg/base.rb +0 -4
- data/lib/plutonium/railtie.rb +10 -2
- data/lib/plutonium/resource/policy.rb +6 -0
- data/lib/plutonium/resource/presenter.rb +35 -0
- data/lib/plutonium/resource/record.rb +40 -7
- data/lib/plutonium/version.rb +1 -1
- data/lib/plutonium.rb +17 -14
- data/package.json +4 -3
- data/postcss.config.js +1 -1
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js +6 -0
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js.map +7 -0
- data/public/plutonium-assets/plutonium.50232e35b5495f5ad90d.css +3415 -0
- data/tailwind.config.js +11 -12
- data/templates/base.rb +8 -0
- metadata +28 -21
- data/app/assets/js/controllers/application.js +0 -6
- data/app/assets/js/controllers/dropdown_controller.js +0 -12
- data/app/assets/js/controllers/index.js +0 -21
- data/app/assets/js/plutonium.js +0 -2
- data/build.js +0 -12
- data/lib/generators/pu/gem/pagy/pagy_generator.rb +0 -25
- data/lib/generators/pu/gem/pagy/templates/config/initializers/pagy.rb +0 -4
- data/lib/generators/pu/gem/rabl/rabl_generator.rb +0 -25
- data/lib/generators/pu/gem/rabl/templates/.keep +0 -0
- data/lib/generators/pu/gem/rabl/templates/config/initializers/rabl.rb +0 -60
- data/lib/generators/pu/gem/simple_form/simple_form_generator.rb +0 -25
- data/lib/generators/pu/gem/simple_form/templates/.keep +0 -0
- /data/{lib/generators/pu/gem/pagy/templates → app/assets/build}/.keep +0 -0
- /data/app/assets/{js → javascripts}/turbo/turbo_actions.js +0 -0
- /data/app/assets/{js → javascripts}/turbo/turbo_debug.js +0 -0
- /data/app/assets/{js → javascripts}/turbo/turbo_frame_monkey_patch.js +0 -0
- /data/app/assets/{css → stylesheets}/plutonium.css +0 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
// Import controllers here
|
2
|
+
import NestedResourceFormFieldsController from "../../../views/components/nested_resource_form_fields/nested_resource_form_fields_controller.js"
|
3
|
+
import TabBarController from "../../../views/components/tab_bar/tab_bar_controller.js"
|
4
|
+
import ToolbarController from "../../../views/components/toolbar/toolbar_controller.js"
|
5
|
+
import TableSearchInputController from "../../../views/components/table_search_input/table_search_input_controller.js"
|
6
|
+
import TableToolbarController from "../../../views/components/table_toolbar/table_toolbar_controller.js"
|
7
|
+
import TableController from "../../../views/components/table/table_controller.js"
|
8
|
+
import FormController from "../../../views/components/form/form_controller.js"
|
9
|
+
import ResourceDropDownController from "./resource_drop_down_controller.js"
|
10
|
+
import ResourceDismissController from "./resource_dismiss_controller.js"
|
11
|
+
|
12
|
+
export function registerControllers(application) {
|
13
|
+
// Register controllers here
|
14
|
+
application.register("nested-resource-form-fields", NestedResourceFormFieldsController)
|
15
|
+
application.register("tab-bar", TabBarController)
|
16
|
+
application.register("toolbar", ToolbarController)
|
17
|
+
application.register("table-search-input", TableSearchInputController)
|
18
|
+
application.register("table-toolbar", TableToolbarController)
|
19
|
+
application.register("table", TableController)
|
20
|
+
application.register("form", FormController)
|
21
|
+
application.register("resource-drop-down", ResourceDropDownController)
|
22
|
+
application.register("resource-dismiss", ResourceDismissController)
|
23
|
+
}
|
24
|
+
|
25
|
+
// Export controllers here
|
26
|
+
export { NestedResourceFormFieldsController };
|
27
|
+
export { TabBarController };
|
28
|
+
export { ToolbarController };
|
29
|
+
export { TableSearchInputController };
|
30
|
+
export { TableToolbarController };
|
31
|
+
export { TableController };
|
32
|
+
export { FormController };
|
33
|
+
export { ResourceDropDownController };
|
34
|
+
export { ResourceDismissController };
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { Dismiss } from 'flowbite';
|
3
|
+
|
4
|
+
|
5
|
+
// Connects to data-controller="resource-dismiss"
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["trigger", "target"]
|
8
|
+
|
9
|
+
static values = {
|
10
|
+
after: Number,
|
11
|
+
}
|
12
|
+
|
13
|
+
connect() {
|
14
|
+
// https://flowbite.com/docs/components/alerts/#javascript-behaviour
|
15
|
+
this.dismiss = new Dismiss(this.targetTarget, this.triggerTarget);
|
16
|
+
|
17
|
+
console.log(this.hasAfterValue)
|
18
|
+
console.log(this.afterValue)
|
19
|
+
if (this.hasAfterValue && this.afterValue > 0) {
|
20
|
+
this.autoDismissTimeout = setTimeout(() => {
|
21
|
+
this.hide()
|
22
|
+
this.autoDismissTimeout = null
|
23
|
+
}, this.afterValue);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
disconnect() {
|
28
|
+
if (this.autoDismissTimeout) clearTimeout(this.autoDismissTimeout)
|
29
|
+
|
30
|
+
this.dismiss = null
|
31
|
+
this.autoDismissTimeout = null
|
32
|
+
}
|
33
|
+
|
34
|
+
hide() {
|
35
|
+
this.dismiss.hide()
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { Dropdown } from 'flowbite';
|
3
|
+
|
4
|
+
|
5
|
+
// Connects to data-controller="resource-drop-down"
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["trigger", "menu"]
|
8
|
+
|
9
|
+
connect() {
|
10
|
+
// https://flowbite.com/docs/components/dropdowns/#javascript-behaviour
|
11
|
+
this.dropdown = new Dropdown(this.menuTarget, this.triggerTarget);
|
12
|
+
}
|
13
|
+
|
14
|
+
disconnect() {
|
15
|
+
this.dropdown = null
|
16
|
+
}
|
17
|
+
|
18
|
+
toggle() {
|
19
|
+
this.dropdown.toggle()
|
20
|
+
}
|
21
|
+
|
22
|
+
show() {
|
23
|
+
this.dropdown.show()
|
24
|
+
}
|
25
|
+
|
26
|
+
hide() {
|
27
|
+
this.dropdown.show()
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./controllers"
|
@@ -1 +1 @@
|
|
1
|
-
<%= render "
|
1
|
+
<%= render "flash_alerts" %>
|
@@ -1,9 +1,53 @@
|
|
1
1
|
<% flash.each do |type, msg| %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
<%
|
3
|
+
color = case type.to_sym
|
4
|
+
when :success
|
5
|
+
# bg-green-50 text-green-800 text-green-500 text-green-400 ring-green-400
|
6
|
+
"green"
|
7
|
+
when :warning
|
8
|
+
# bg-yellow-50 text-yellow-800 text-yellow-500 text-yellow-400 ring-yellow-400
|
9
|
+
"yellow"
|
10
|
+
when :alert, :danger, :error
|
11
|
+
# bg-red-50 text-red-800 text-red-500 text-red-400 ring-red-400
|
12
|
+
"red"
|
13
|
+
else
|
14
|
+
# bg-blue-50 text-blue-800 text-blue-500 text-blue-400 ring-blue-400
|
15
|
+
"blue"
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
|
19
|
+
<div data-controller="resource-dismiss"
|
20
|
+
data-resource-dismiss-target="target"
|
21
|
+
data-resource-dismiss-after-value="6000"
|
22
|
+
class="flex items-center p-4 mb-4 text-<%= color %>-800 rounded-lg bg-<%= color %>-50 dark:bg-gray-800 dark:text-<%= color %>-400"
|
23
|
+
role="alert">
|
24
|
+
<% case type.to_sym %>
|
25
|
+
<% when :success %>
|
26
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
27
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
28
|
+
</svg>
|
29
|
+
<% when :warning %>
|
30
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
31
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
32
|
+
</svg>
|
33
|
+
<% when :alert, :danger, :error %>
|
34
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
35
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
36
|
+
</svg>
|
37
|
+
<% else %>
|
38
|
+
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
39
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
40
|
+
</svg>
|
9
41
|
<% end %>
|
42
|
+
<div class="ms-3 text-sm font-normal"><%= msg %></div>
|
43
|
+
<button type="button"
|
44
|
+
class="ms-auto -mx-1.5 -my-1.5 bg-<%= color %>-50 text-<%= color %>-500 rounded-lg focus:ring-2 focus:ring-<%= color %>-400 p-1.5 hover:bg-<%= color %>-200 inline-flex items-center justify-center h-8 w-8 dark:bg-gray-800 dark:text-<%= color %>-400 dark:hover:bg-gray-700"
|
45
|
+
data-resource-dismiss-target="trigger"
|
46
|
+
aria-label="Close">
|
47
|
+
<span class="sr-only">Close</span>
|
48
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
49
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
50
|
+
</svg>
|
51
|
+
</button>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
@@ -1,26 +1,56 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
<% flash.each do |type, msg| %>
|
2
|
+
<%
|
3
|
+
color = case type.to_sym
|
4
|
+
when :success
|
5
|
+
# text-green-500 bg-green-100 bg-green-800 text-green-200 bg-green-50 text-green-400 ring-green-400
|
6
|
+
"green"
|
7
|
+
when :warning
|
8
|
+
# text-yellow-500 bg-yellow-100 bg-yellow-800 text-yellow-200 bg-yellow-50 text-yellow-400 ring-yellow-400
|
9
|
+
"yellow"
|
10
|
+
when :alert, :danger, :error
|
11
|
+
# text-red-500 bg-red-100 bg-red-800 text-red-200 bg-red-50 text-red-400 ring-red-400
|
12
|
+
"red"
|
13
|
+
else
|
14
|
+
# text-blue-500 bg-blue-100 bg-blue-800 text-blue-200 bg-blue-50 text-blue-400 ring-blue-400
|
15
|
+
"blue"
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
|
19
|
+
<div data-controller="resource-dismiss"
|
20
|
+
data-resource-dismiss-target="target"
|
21
|
+
data-resource-dismiss-after-value="6000"
|
22
|
+
class="fixed z-50 top-16 right-5 flex items-center w-full max-w-md p-4 text-gray-500 bg-<%= color %>-50 rounded-lg shadow dark:text-<%= color %>-400 dark:bg-gray-800"
|
23
|
+
role="alert">
|
24
|
+
|
25
|
+
<div class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-<%= color %>-500 bg-<%= color %>-100 rounded-lg dark:bg-<%= color %>-800 dark:text-<%= color %>-200">
|
26
|
+
<% case type.to_sym %>
|
27
|
+
<% when :success %>
|
28
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
29
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
30
|
+
</svg>
|
31
|
+
<% when :warning %>
|
32
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
33
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
34
|
+
</svg>
|
35
|
+
<% when :alert, :danger, :error %>
|
36
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
37
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
38
|
+
</svg>
|
39
|
+
<% else %>
|
40
|
+
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
41
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
42
|
+
</svg>
|
24
43
|
<% end %>
|
25
44
|
</div>
|
45
|
+
<div class="ms-3 text-sm font-normal"><%= msg %></div>
|
46
|
+
<button type="button"
|
47
|
+
class="ms-auto -mx-1.5 -my-1.5 bg-<%= color %>-50 text-<%= color %>-400 rounded-lg focus:ring-2 focus:ring-<%= color %>-400 p-1.5 hover:bg-<%= color %>-200 inline-flex items-center justify-center h-8 w-8 dark:text-<%= color %>-400 dark:bg-gray-800 dark:hover:bg-gray-700"
|
48
|
+
data-resource-dismiss-target="trigger"
|
49
|
+
aria-label="Close">
|
50
|
+
<span class="sr-only">Close</span>
|
51
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
52
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
53
|
+
</svg>
|
54
|
+
</button>
|
26
55
|
</div>
|
56
|
+
<% end %>
|