plutonium 0.16.0 → 0.16.1
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 +43 -9
- data/app/assets/plutonium.js.map +3 -3
- data/app/assets/plutonium.min.js +14 -14
- data/app/assets/plutonium.min.js.map +4 -4
- data/lib/plutonium/ui/display/theme.rb +1 -0
- data/lib/plutonium/ui/form/base.rb +6 -1
- data/lib/plutonium/ui/form/components/intl_tel_input.rb +24 -0
- data/lib/plutonium/ui/form/theme.rb +6 -1
- data/lib/plutonium/ui/layout/base.rb +11 -0
- data/lib/plutonium/ui/table/display_theme.rb +1 -0
- data/lib/plutonium/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/src/js/controllers/easymde_controller.js +3 -3
- data/src/js/controllers/flatpickr_controller.js +3 -3
- data/src/js/controllers/intl_tel_input_controller.js +39 -0
- data/src/js/controllers/register_controllers.js +2 -0
- data/src/js/controllers/slim_select_controller.js +3 -3
- metadata +3 -1
@@ -18,6 +18,7 @@ module Plutonium
|
|
18
18
|
color: "flex items-center text-md text-gray-900 dark:text-white mb-1 whitespace-pre-line",
|
19
19
|
color_indicator: "w-10 h-10 rounded-full mr-2", # max-h-fit
|
20
20
|
email: "flex items-center text-md text-primary-600 dark:text-primary-500 mb-1 whitespace-pre-line",
|
21
|
+
phone: "flex items-center text-md text-primary-600 dark:text-primary-500 mb-1 whitespace-pre-line",
|
21
22
|
json: "text-sm text-gray-900 dark:text-white mb-1 whitespace-pre font-mono shadow-inner p-4",
|
22
23
|
prefixed_icon: "w-8 h-8 mr-2",
|
23
24
|
markdown: "format dark:format-invert format-primary"
|
@@ -30,8 +30,13 @@ module Plutonium
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def flatpickr_tag(**, &)
|
33
|
-
create_component(
|
33
|
+
create_component(Components::Flatpickr, :flatpickr, **, &)
|
34
34
|
end
|
35
|
+
|
36
|
+
def int_tel_input_tag(**, &)
|
37
|
+
create_component(Components::IntlTelInput, :int_tel_input, **, &)
|
38
|
+
end
|
39
|
+
alias_method :phone_tag, :int_tel_input_tag
|
35
40
|
end
|
36
41
|
|
37
42
|
private
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Plutonium
|
4
|
+
module UI
|
5
|
+
module Form
|
6
|
+
module Components
|
7
|
+
class IntlTelInput < Phlexi::Form::Components::Input
|
8
|
+
def view_template
|
9
|
+
div(data_controller: "intl-tel-input") {
|
10
|
+
super
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def build_input_attributes
|
17
|
+
super
|
18
|
+
attributes[:data_intl_tel_input_target] = tokens(attributes[:data_intl_tel_input_target], :input)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -42,7 +42,12 @@ module Plutonium
|
|
42
42
|
flatpickr: :input,
|
43
43
|
valid_flatpickr: :valid_input,
|
44
44
|
invalid_flatpickr: :invalid_input,
|
45
|
-
neutral_flatpickr: :neutral_input
|
45
|
+
neutral_flatpickr: :neutral_input,
|
46
|
+
# int_tel_input
|
47
|
+
int_tel_input: :input,
|
48
|
+
valid_int_tel_input: :valid_input,
|
49
|
+
invalid_int_tel_input: :invalid_input,
|
50
|
+
neutral_int_tel_input: :neutral_input
|
46
51
|
})
|
47
52
|
end
|
48
53
|
end
|
@@ -132,6 +132,12 @@ module Plutonium
|
|
132
132
|
integrity: "sha384-RkASv+6KfBMW9eknReJIJ6b3UnjKOKC5bOUaNgIY778NFbQ8MtWq9Lr/khUgqtTt",
|
133
133
|
crossorigin: "anonymous"
|
134
134
|
)
|
135
|
+
link(
|
136
|
+
rel: "stylesheet",
|
137
|
+
href: "https://cdn.jsdelivr.net/npm/intl-tel-input@24.8.1/build/css/intlTelInput.min.css",
|
138
|
+
integrity: "sha384-oE0RVGDyNw9goP8V3wYWC9+3GYojVc/LhhKmLT9J5k+L+oGHPa1gRF3FomvOCOFs",
|
139
|
+
crossorigin: "anonymous"
|
140
|
+
)
|
135
141
|
end
|
136
142
|
|
137
143
|
def render_scripts
|
@@ -157,6 +163,11 @@ module Plutonium
|
|
157
163
|
integrity: "sha384-5JqMv4L/Xa0hfvtF06qboNdhvuYXUku9ZrhZh3bSk8VXF0A/RuSLHpLsSV9Zqhl6",
|
158
164
|
crossorigin: "anonymous"
|
159
165
|
)
|
166
|
+
script(
|
167
|
+
src: "https://cdn.jsdelivr.net/npm/intl-tel-input@24.8.1/build/js/intlTelInput.min.js",
|
168
|
+
integrity: "sha384-oCoRbvnGGnM56vTrLX0f7cgRy2aqLchemkQhvfBT7J+b6km6CSuWz/89IpPnTq9j",
|
169
|
+
crossorigin: "anonymous"
|
170
|
+
)
|
160
171
|
end
|
161
172
|
|
162
173
|
def render_body_scripts
|
@@ -12,6 +12,7 @@ module Plutonium
|
|
12
12
|
color: "flex items-center",
|
13
13
|
color_indicator: "w-10 h-10 rounded-full mr-2",
|
14
14
|
email: "flex items-center text-primary-600 dark:text-primary-500 whitespace-nowrap",
|
15
|
+
phone: "flex items-center text-primary-600 dark:text-primary-500 whitespace-nowrap",
|
15
16
|
json: " whitespace-pre font-mono shadow-inner p-4"
|
16
17
|
})
|
17
18
|
end
|
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.16",
|
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.16",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"@hotwired/stimulus": "^3.2.2",
|
data/package.json
CHANGED
@@ -6,13 +6,13 @@ import { marked } from 'marked';
|
|
6
6
|
export default class extends Controller {
|
7
7
|
connect() {
|
8
8
|
console.log(`easymde connected: ${this.element}`)
|
9
|
-
|
9
|
+
this.easyMDE = new EasyMDE(this.#buildOptions())
|
10
10
|
this.element.setAttribute("data-action", "turbo:morph-element->easymde#reconnect")
|
11
11
|
}
|
12
12
|
|
13
13
|
disconnect() {
|
14
|
-
|
15
|
-
|
14
|
+
this.easyMDE.toTextArea()
|
15
|
+
this.easyMDE = null
|
16
16
|
}
|
17
17
|
|
18
18
|
reconnect() {
|
@@ -4,13 +4,13 @@ import { Controller } from "@hotwired/stimulus"
|
|
4
4
|
export default class extends Controller {
|
5
5
|
connect() {
|
6
6
|
console.log(`flatpickr connected: ${this.element}`)
|
7
|
-
|
7
|
+
this.picker = new flatpickr(this.element, this.#buildOptions())
|
8
8
|
this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect")
|
9
9
|
}
|
10
10
|
|
11
11
|
disconnect() {
|
12
|
-
|
13
|
-
|
12
|
+
this.picker.destroy()
|
13
|
+
this.picker = null
|
14
14
|
}
|
15
15
|
|
16
16
|
reconnect() {
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
// Connects to data-controller="intl-tel-input"
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = ["input"]
|
6
|
+
|
7
|
+
connect() {
|
8
|
+
console.log(`intl-tel-input connected: ${this.element}`)
|
9
|
+
}
|
10
|
+
|
11
|
+
disconnect() {
|
12
|
+
this.inputTargetDisconnected()
|
13
|
+
}
|
14
|
+
|
15
|
+
inputTargetConnected() {
|
16
|
+
if (!this.hasInputTarget) return;
|
17
|
+
|
18
|
+
this.iti = window.intlTelInput(this.inputTarget, this.#buildOptions())
|
19
|
+
this.inputTarget.setAttribute("data-action", "turbo:morph-element->intl-tel-input#reconnect")
|
20
|
+
}
|
21
|
+
|
22
|
+
inputTargetDisconnected() {
|
23
|
+
if (this.iti) this.iti.destroy()
|
24
|
+
this.iti = null
|
25
|
+
}
|
26
|
+
|
27
|
+
reconnect() {
|
28
|
+
this.inputTargetDisconnected()
|
29
|
+
this.inputTargetConnected()
|
30
|
+
}
|
31
|
+
|
32
|
+
#buildOptions() {
|
33
|
+
return {
|
34
|
+
strictMode: true,
|
35
|
+
hiddenInput: () => ({ phone: this.inputTarget.attributes.name.value }),
|
36
|
+
loadUtilsOnInit: "https://cdn.jsdelivr.net/npm/intl-tel-input@24.8.1/build/js/utils.js",
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
@@ -24,6 +24,7 @@ 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
26
|
import FlatpickrController from "./flatpickr_controller.js"
|
27
|
+
import IntlTelInputController from "./intl_tel_input_controller.js"
|
27
28
|
|
28
29
|
export default function (application) {
|
29
30
|
// Register controllers here
|
@@ -52,4 +53,5 @@ export default function (application) {
|
|
52
53
|
application.register("easymde", EasyMDEController)
|
53
54
|
application.register("slim-select", SlimSelectController)
|
54
55
|
application.register("flatpickr", FlatpickrController)
|
56
|
+
application.register("intl-tel-input", IntlTelInputController)
|
55
57
|
}
|
@@ -4,15 +4,15 @@ import { Controller } from "@hotwired/stimulus"
|
|
4
4
|
export default class extends Controller {
|
5
5
|
connect() {
|
6
6
|
console.log(`slim-select connected: ${this.element}`)
|
7
|
-
|
7
|
+
this.slimSelect = new SlimSelect({
|
8
8
|
select: this.element
|
9
9
|
})
|
10
10
|
this.element.setAttribute("data-action", "turbo:morph-element->slim-select#reconnect")
|
11
11
|
}
|
12
12
|
|
13
13
|
disconnect() {
|
14
|
-
|
15
|
-
|
14
|
+
this.slimSelect.destroy()
|
15
|
+
this.slimSelect = null
|
16
16
|
}
|
17
17
|
|
18
18
|
reconnect() {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
@@ -1412,6 +1412,7 @@ files:
|
|
1412
1412
|
- lib/plutonium/ui/form/components/easymde.rb
|
1413
1413
|
- lib/plutonium/ui/form/components/flatpickr.rb
|
1414
1414
|
- lib/plutonium/ui/form/components/has_many.rb
|
1415
|
+
- lib/plutonium/ui/form/components/intl_tel_input.rb
|
1415
1416
|
- lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb
|
1416
1417
|
- lib/plutonium/ui/form/interaction.rb
|
1417
1418
|
- lib/plutonium/ui/form/options/inferred_types.rb
|
@@ -1470,6 +1471,7 @@ files:
|
|
1470
1471
|
- src/js/controllers/has_many_panel_controller.js
|
1471
1472
|
- src/js/controllers/header_controller.js
|
1472
1473
|
- src/js/controllers/interactive_action_form_controller.js
|
1474
|
+
- src/js/controllers/intl_tel_input_controller.js
|
1473
1475
|
- src/js/controllers/nav_grid_menu_controller.js
|
1474
1476
|
- src/js/controllers/nav_grid_menu_item_controller.js
|
1475
1477
|
- src/js/controllers/nav_user_controller.js
|