plutonium 0.15.21 → 0.15.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/plutonium.js +23 -0
- data/app/assets/plutonium.js.map +3 -3
- data/app/assets/plutonium.min.js +5 -5
- data/app/assets/plutonium.min.js.map +4 -4
- data/lib/plutonium/ui/display/base.rb +2 -2
- data/lib/plutonium/ui/display/component/{association.rb → association_field.rb} +1 -1
- data/lib/plutonium/ui/display/component/{markdown.rb → markdown_field.rb} +11 -1
- data/lib/plutonium/ui/form/base.rb +5 -1
- data/lib/plutonium/ui/form/components/{easymde.rb → easymde_input.rb} +12 -2
- data/lib/plutonium/ui/form/components/flatpickr_input.rb +18 -0
- data/lib/plutonium/ui/form/options/inferred_types.rb +4 -0
- data/lib/plutonium/ui/form/theme.rb +6 -1
- data/lib/plutonium/ui/layout/base.rb +11 -0
- data/lib/plutonium/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/src/js/controllers/flatpickr_controller.js +28 -0
- data/src/js/controllers/register_controllers.js +2 -0
- metadata +7 -5
@@ -8,11 +8,11 @@ module Plutonium
|
|
8
8
|
|
9
9
|
class Builder < Builder
|
10
10
|
def association_tag(**, &)
|
11
|
-
create_component(Plutonium::UI::Display::Component::
|
11
|
+
create_component(Plutonium::UI::Display::Component::AssociationField, :association, **, &)
|
12
12
|
end
|
13
13
|
|
14
14
|
def markdown_tag(**, &)
|
15
|
-
create_component(Plutonium::UI::Display::Component::
|
15
|
+
create_component(Plutonium::UI::Display::Component::MarkdownField, :markdown, **, &)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -4,7 +4,7 @@ module Plutonium
|
|
4
4
|
module UI
|
5
5
|
module Display
|
6
6
|
module Component
|
7
|
-
class
|
7
|
+
class AssociationField < Phlexi::Display::Components::Association
|
8
8
|
include Plutonium::UI::Component::Methods
|
9
9
|
|
10
10
|
def render_value(value)
|
@@ -6,7 +6,7 @@ module Plutonium
|
|
6
6
|
module UI
|
7
7
|
module Display
|
8
8
|
module Component
|
9
|
-
class
|
9
|
+
class MarkdownField < Phlexi::Display::Components::Base
|
10
10
|
include Phlexi::Display::Components::Concerns::DisplaysValue
|
11
11
|
|
12
12
|
RENDERER = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
|
@@ -16,6 +16,16 @@ module Plutonium
|
|
16
16
|
unsafe_raw RENDERER.render(value)
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def normalize_value(value)
|
23
|
+
if value.respond_to?(:to_plain_text)
|
24
|
+
value.to_plain_text
|
25
|
+
else
|
26
|
+
value.to_s
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
@@ -10,7 +10,7 @@ module Plutonium
|
|
10
10
|
include Plutonium::UI::Form::Options::InferredTypes
|
11
11
|
|
12
12
|
def easymde_tag(**, &)
|
13
|
-
create_component(Plutonium::UI::Form::Components::
|
13
|
+
create_component(Plutonium::UI::Form::Components::EasymdeInput, :easymde, **, &)
|
14
14
|
end
|
15
15
|
alias_method :markdown_tag, :easymde_tag
|
16
16
|
|
@@ -19,6 +19,10 @@ module Plutonium
|
|
19
19
|
basic_select_tag(**, data_controller: "slim-select", class!: "", &)
|
20
20
|
end
|
21
21
|
alias_method :select_tag, :slim_select_tag
|
22
|
+
|
23
|
+
def flatpickr_tag(**, &)
|
24
|
+
create_component(Plutonium::UI::Form::Components::FlatpickrInput, :flatpickr, **, &)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
@@ -4,11 +4,21 @@ module Plutonium
|
|
4
4
|
module UI
|
5
5
|
module Form
|
6
6
|
module Components
|
7
|
-
class
|
7
|
+
class EasymdeInput < Phlexi::Form::Components::Base
|
8
8
|
include Phlexi::Form::Components::Concerns::HandlesInput
|
9
9
|
|
10
10
|
def view_template
|
11
|
-
textarea(**attributes, data_controller: "easymde") { field.
|
11
|
+
textarea(**attributes, data_controller: "easymde") { normalize_value(field.value) }
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def normalize_value(value)
|
17
|
+
if value.respond_to?(:to_plain_text)
|
18
|
+
value.to_plain_text
|
19
|
+
else
|
20
|
+
value.to_s
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Plutonium
|
4
|
+
module UI
|
5
|
+
module Form
|
6
|
+
module Components
|
7
|
+
class FlatpickrInput < Phlexi::Form::Components::Input
|
8
|
+
private
|
9
|
+
|
10
|
+
def build_input_attributes
|
11
|
+
super
|
12
|
+
attributes[:data_controller] = tokens(attributes[:data_controller], :flatpickr)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,10 +8,14 @@ module Plutonium
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def infer_field_component
|
11
|
+
return :markdown if inferred_field_type == :rich_text
|
12
|
+
|
11
13
|
component = super
|
12
14
|
case component
|
13
15
|
when :select
|
14
16
|
:slim_select
|
17
|
+
when :date, :time, :datetime
|
18
|
+
:flatpickr
|
15
19
|
else
|
16
20
|
component
|
17
21
|
end
|
@@ -37,7 +37,12 @@ module Plutonium
|
|
37
37
|
# error themes
|
38
38
|
error: "mt-2 text-sm text-red-600 dark:text-red-500",
|
39
39
|
# button themes
|
40
|
-
button: "px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
40
|
+
button: "px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500",
|
41
|
+
# flatpickr
|
42
|
+
flatpickr: :input,
|
43
|
+
valid_flatpickr: :valid_input,
|
44
|
+
invalid_flatpickr: :invalid_input,
|
45
|
+
neutral_flatpickr: :neutral_input
|
41
46
|
})
|
42
47
|
end
|
43
48
|
end
|
@@ -126,6 +126,12 @@ module Plutonium
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def render_external_styles
|
129
|
+
link(
|
130
|
+
rel: "stylesheet",
|
131
|
+
href: "https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.css",
|
132
|
+
integrity: "sha384-RkASv+6KfBMW9eknReJIJ6b3UnjKOKC5bOUaNgIY778NFbQ8MtWq9Lr/khUgqtTt",
|
133
|
+
crossorigin: "anonymous"
|
134
|
+
)
|
129
135
|
end
|
130
136
|
|
131
137
|
def render_scripts
|
@@ -146,6 +152,11 @@ module Plutonium
|
|
146
152
|
integrity: "sha384-WKsmo+vSs0gqrT+es6wFEojVFn4P0kNaHpHTIkn84iHY8T4rF2V2McZeSbLPLlHy",
|
147
153
|
crossorigin: "anonymous"
|
148
154
|
)
|
155
|
+
script(
|
156
|
+
src: "https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.js",
|
157
|
+
integrity: "sha384-5JqMv4L/Xa0hfvtF06qboNdhvuYXUku9ZrhZh3bSk8VXF0A/RuSLHpLsSV9Zqhl6",
|
158
|
+
crossorigin: "anonymous"
|
159
|
+
)
|
149
160
|
end
|
150
161
|
|
151
162
|
def render_body_scripts
|
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.12",
|
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.12",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"@hotwired/stimulus": "^3.2.2",
|
data/package.json
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
// Connects to data-controller="flatpickr"
|
4
|
+
export default class extends Controller {
|
5
|
+
connect() {
|
6
|
+
console.log(`flatpickr connected: ${this.element}`)
|
7
|
+
self.picker = new flatpickr(this.element, this.#buildOptions())
|
8
|
+
}
|
9
|
+
|
10
|
+
disconnect() {
|
11
|
+
self.picker.destroy()
|
12
|
+
self.picker = null
|
13
|
+
}
|
14
|
+
|
15
|
+
#buildOptions() {
|
16
|
+
let options = { altInput: true }
|
17
|
+
if (this.element.attributes.type.value == "datetime-local") {
|
18
|
+
options.enableTime = true
|
19
|
+
}
|
20
|
+
else if (this.element.attributes.type.value == "time") {
|
21
|
+
options.enableTime = true
|
22
|
+
options.noCalendar = true
|
23
|
+
// options.time_24hr = true
|
24
|
+
// options.altFormat = "H:i"
|
25
|
+
}
|
26
|
+
return options
|
27
|
+
}
|
28
|
+
}
|
@@ -23,6 +23,7 @@ import FrameNavigatorController from "./frame_navigator_controller.js"
|
|
23
23
|
import ColorModeController from "./color_mode_controller.js"
|
24
24
|
import EasyMDEController from "./easymde_controller.js"
|
25
25
|
import SlimSelectController from "./slim_select_controller.js"
|
26
|
+
import FlatpickrController from "./flatpickr_controller.js"
|
26
27
|
|
27
28
|
export default function (application) {
|
28
29
|
// Register controllers here
|
@@ -50,4 +51,5 @@ export default function (application) {
|
|
50
51
|
application.register("color-mode", ColorModeController)
|
51
52
|
application.register("easymde", EasyMDEController)
|
52
53
|
application.register("slim-select", SlimSelectController)
|
54
|
+
application.register("flatpickr", FlatpickrController)
|
53
55
|
}
|
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.23
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -1400,15 +1400,16 @@ files:
|
|
1400
1400
|
- lib/plutonium/ui/component/kit.rb
|
1401
1401
|
- lib/plutonium/ui/component/methods.rb
|
1402
1402
|
- lib/plutonium/ui/display/base.rb
|
1403
|
-
- lib/plutonium/ui/display/component/
|
1404
|
-
- lib/plutonium/ui/display/component/
|
1403
|
+
- lib/plutonium/ui/display/component/association_field.rb
|
1404
|
+
- lib/plutonium/ui/display/component/markdown_field.rb
|
1405
1405
|
- lib/plutonium/ui/display/resource.rb
|
1406
1406
|
- lib/plutonium/ui/display/theme.rb
|
1407
1407
|
- lib/plutonium/ui/dyna_frame/content.rb
|
1408
1408
|
- lib/plutonium/ui/dyna_frame/host.rb
|
1409
1409
|
- lib/plutonium/ui/empty_card.rb
|
1410
1410
|
- lib/plutonium/ui/form/base.rb
|
1411
|
-
- lib/plutonium/ui/form/components/
|
1411
|
+
- lib/plutonium/ui/form/components/easymde_input.rb
|
1412
|
+
- lib/plutonium/ui/form/components/flatpickr_input.rb
|
1412
1413
|
- lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb
|
1413
1414
|
- lib/plutonium/ui/form/interaction.rb
|
1414
1415
|
- lib/plutonium/ui/form/options/inferred_types.rb
|
@@ -1461,6 +1462,7 @@ files:
|
|
1461
1462
|
- src/css/slim_select.css
|
1462
1463
|
- src/js/controllers/color_mode_controller.js
|
1463
1464
|
- src/js/controllers/easymde_controller.js
|
1465
|
+
- src/js/controllers/flatpickr_controller.js
|
1464
1466
|
- src/js/controllers/form_controller.js
|
1465
1467
|
- src/js/controllers/frame_navigator_controller.js
|
1466
1468
|
- src/js/controllers/has_many_panel_controller.js
|