clapton 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba556f54f55566ad5502aff210ab368c040d332a62313411377314b99a507ab0
4
- data.tar.gz: f8a71c1947ea6eb6544f637f53641ce87fc904543efadac7e30c244b6d1e8c85
3
+ metadata.gz: f5a917233f15421e530f894af3f7fa67b46b79c78d8568cd158566610f6c2db5
4
+ data.tar.gz: 2935aea66e3fc3e7442606c0fcf55ffcea56b61bb36864c4fc77101680cc29ea
5
5
  SHA512:
6
- metadata.gz: a8b32c159a66aa00df226c792f99e3d8a2ca96706a6189f3f442fec764eefe9f4a90e66f7f4c050a6a3c84212f46469e5f232c219b10999ebe543affb659a3f2
7
- data.tar.gz: eb01a40f84c3e8437be75b05d716f9702c0ed15666041015d06f74449f317f144558bd4c798ac94710008e63bf4c7a062556c14dcfbb9b3ee693217e905c86e0
6
+ metadata.gz: 458297f32dca2583bfb675fb74bba00b781bef37d825b9a76e9116cea3c3bf0f98b18d1d6867d62b67d47638335c2f99d0ef3885358281f5fad63245e53e6d2f
7
+ data.tar.gz: 586febac7acaf53ed42c0dadaa696c5e136bee87de707214343cf36104f2b56625f3aef3cfa4dfd71bd34c8108243813b26f8ea8f8fa7d7aea7ac2b686e9c25a
data/README.md CHANGED
@@ -349,6 +349,15 @@ module ApplicationCable
349
349
  end
350
350
  ```
351
351
 
352
+ ### Using with importmap-rails
353
+
354
+ Use `clapton_javascript_tag` instead of `javascript_importmap_tags`.
355
+
356
+ ```diff
357
+ - <%= javascript_importmap_tags %>
358
+ + <%= clapton_javascript_tag %>
359
+ ```
360
+
352
361
  ### Events
353
362
 
354
363
  #### clapton:render
@@ -1,11 +1,10 @@
1
1
  module Clapton
2
2
  module ClaptonHelper
3
3
 
4
- def clapton_javascript_tag
4
+ def clapton_javascript_tag(entry_point = "application", importmap: nil)
5
5
  all_components = Dir.glob(Rails.root.join("app", "components", "**", "*.rb"))
6
- tags = <<~HTML
7
- <script type="importmap">
8
- {
6
+ clapton_json = JSON.parse <<~JSON
7
+ {
9
8
  "imports": {
10
9
  "client": "/clapton/client.js",
11
10
  "components": "/clapton/components.js",
@@ -15,10 +14,25 @@ module Clapton
15
14
  end.join(",\n") }
16
15
  }
17
16
  }
18
- </script>
19
- <script type="module" src="/clapton/client.js"></script>
20
- HTML
21
- tags.html_safe
17
+ JSON
18
+ if defined?(javascript_importmap_tags)
19
+ importmap ||= Rails.application.importmap
20
+ json = { imports: JSON.parse(importmap.to_json(resolver: self))["imports"].merge(clapton_json["imports"]) }
21
+ safe_join [
22
+ javascript_inline_importmap_tag(json.to_json),
23
+ javascript_importmap_module_preload_tags(importmap, entry_point:),
24
+ javascript_import_module_tag(entry_point),
25
+ tag.script(type: "module", src: "/clapton/client.js"),
26
+ ], "\n"
27
+ else
28
+ html = <<~HTML
29
+ <script type="importmap">
30
+ #{clapton_json.to_json}
31
+ </script>
32
+ <script type="module" src="/clapton/client.js"></script>
33
+ HTML
34
+ html.html_safe
35
+ end
22
36
  end
23
37
 
24
38
  def clapton_tag
@@ -1448,6 +1448,13 @@ document.addEventListener("DOMContentLoaded", async () => {
1448
1448
  const event = new Event('clapton:render');
1449
1449
  document.dispatchEvent(event);
1450
1450
  });
1451
+ document.addEventListener("turbo:render", async () => {
1452
+ await initializeComponents();
1453
+ initializeActions();
1454
+ initializeInputs();
1455
+ const event = new Event('clapton:render');
1456
+ document.dispatchEvent(event);
1457
+ });
1451
1458
  window.addEventListener('beforeunload', () => {
1452
1459
  sessionStorage.setItem('scrollPosition', window.scrollY.toString());
1453
1460
  });
@@ -0,0 +1,160 @@
1
+ import { Clapton } from "components"
2
+
3
+ const bq = (...props: any[]) => {
4
+ return new Clapton.BlockQuote(...props)
5
+ }
6
+
7
+ const box = (...props: any[]) => {
8
+ return new Clapton.Box(...props)
9
+ }
10
+
11
+ const b = (...props: any[]) => {
12
+ return new Clapton.Bold(...props)
13
+ }
14
+
15
+ const button = (...props: any[]) => {
16
+ return new Clapton.Button(...props)
17
+ }
18
+
19
+ const check = (...props: any[]) => {
20
+ return new Clapton.Checkbox(props[0], props[1], props[2])
21
+ }
22
+
23
+ const code = (...props: any[]) => {
24
+ return new Clapton.Code(...props)
25
+ }
26
+
27
+ const datetime = (...props: any[]) => {
28
+ return new Clapton.DateTimeField(props[0], props[1], props[2])
29
+ }
30
+
31
+ const el = (...props: any[]) => {
32
+ return new Clapton.Element(props[0], props[1])
33
+ }
34
+
35
+ const embed = (...props: any[]) => {
36
+ return new Clapton.Embed(props[0])
37
+ }
38
+
39
+ const em = (...props: any[]) => {
40
+ return new Clapton.Emphasis(...props)
41
+ }
42
+
43
+ const form = (...props: any[]) => {
44
+ return new Clapton.Form(...props)
45
+ }
46
+
47
+ const h = (...props: any[]) => {
48
+ return new Clapton.Heading(props[0], props[1])
49
+ }
50
+
51
+ const img = (...props: any[]) => {
52
+ return new Clapton.Image(props[0], props[1], props[2])
53
+ }
54
+
55
+ const a = (...props: any[]) => {
56
+ return new Clapton.Link(props[0], props[1])
57
+ }
58
+
59
+ const li = (...props: any[]) => {
60
+ return new Clapton.ListItem(...props)
61
+ }
62
+
63
+ const ul = (...props: any[]) => {
64
+ return new Clapton.List(...props)
65
+ }
66
+
67
+ const ol = (...props: any[]) => {
68
+ return new Clapton.OrderedList(...props)
69
+ }
70
+
71
+ const p = (...props: any[]) => {
72
+ return new Clapton.Paragraph(...props)
73
+ }
74
+
75
+ const q = (...props: any[]) => {
76
+ return new Clapton.Quote(...props)
77
+ }
78
+
79
+ const radio = (...props: any[]) => {
80
+ return new Clapton.RadioButton(props[0], props[1], props[2])
81
+ }
82
+
83
+ const select = (...props: any[]) => {
84
+ return new Clapton.Select(props[0], props[1], props[2])
85
+ }
86
+
87
+ const span = (...props: any[]) => {
88
+ return new Clapton.Span(...props)
89
+ }
90
+
91
+ const textarea = (...props: any[]) => {
92
+ return new Clapton.TextArea(props[0], props[1], props[2])
93
+ }
94
+
95
+ const input = (...props: any[]) => {
96
+ return new Clapton.TextField(props[0], props[1], props[2])
97
+ }
98
+
99
+ const text = (...props: any[]) => {
100
+ return new Clapton.Text(props[0])
101
+ }
102
+
103
+ const c = (name: string, ...props: any[]) => {
104
+ switch (name) {
105
+ case "bq":
106
+ return bq(...props)
107
+ case "box":
108
+ return box(...props)
109
+ case "b":
110
+ return b(...props)
111
+ case "button":
112
+ return button(...props)
113
+ case "check":
114
+ return check(...props)
115
+ case "code":
116
+ return code(...props)
117
+ case "datetime":
118
+ return datetime(...props)
119
+ case "el":
120
+ return el(...props)
121
+ case "embed":
122
+ return embed(...props)
123
+ case "em":
124
+ return em(...props)
125
+ case "form":
126
+ return form(...props)
127
+ case "h":
128
+ return h(...props)
129
+ case "img":
130
+ return img(...props)
131
+ case "a":
132
+ return a(...props)
133
+ case "li":
134
+ return li(...props)
135
+ case "ul":
136
+ return ul(...props)
137
+ case "ol":
138
+ return ol(...props)
139
+ case "p":
140
+ return p(...props)
141
+ case "q":
142
+ return q(...props)
143
+ case "radio":
144
+ return radio(...props)
145
+ case "select":
146
+ return select(...props)
147
+ case "span":
148
+ return span(...props)
149
+ case "textarea":
150
+ return textarea(...props)
151
+ case "input":
152
+ return input(...props)
153
+ case "text":
154
+ return text(...props)
155
+ default:
156
+ return new Clapton.Component(...props)
157
+ }
158
+ }
159
+
160
+ export { c }
@@ -1,160 +1,3 @@
1
- import { Clapton } from "components"
2
-
3
- const bq = (...props: any[]) => {
4
- return new Clapton.BlockQuote(...props)
5
- }
6
-
7
- const box = (...props: any[]) => {
8
- return new Clapton.Box(...props)
9
- }
10
-
11
- const b = (...props: any[]) => {
12
- return new Clapton.Bold(...props)
13
- }
14
-
15
- const button = (...props: any[]) => {
16
- return new Clapton.Button(...props)
17
- }
18
-
19
- const check = (...props: any[]) => {
20
- return new Clapton.Checkbox(props[0], props[1], props[2])
21
- }
22
-
23
- const code = (...props: any[]) => {
24
- return new Clapton.Code(...props)
25
- }
26
-
27
- const datetime = (...props: any[]) => {
28
- return new Clapton.DateTimeField(props[0], props[1], props[2])
29
- }
30
-
31
- const el = (...props: any[]) => {
32
- return new Clapton.Element(props[0], props[1])
33
- }
34
-
35
- const embed = (...props: any[]) => {
36
- return new Clapton.Embed(props[0])
37
- }
38
-
39
- const em = (...props: any[]) => {
40
- return new Clapton.Emphasis(...props)
41
- }
42
-
43
- const form = (...props: any[]) => {
44
- return new Clapton.Form(...props)
45
- }
46
-
47
- const h = (...props: any[]) => {
48
- return new Clapton.Heading(props[0], props[1])
49
- }
50
-
51
- const img = (...props: any[]) => {
52
- return new Clapton.Image(props[0], props[1], props[2])
53
- }
54
-
55
- const a = (...props: any[]) => {
56
- return new Clapton.Link(props[0], props[1])
57
- }
58
-
59
- const li = (...props: any[]) => {
60
- return new Clapton.ListItem(...props)
61
- }
62
-
63
- const ul = (...props: any[]) => {
64
- return new Clapton.List(...props)
65
- }
66
-
67
- const ol = (...props: any[]) => {
68
- return new Clapton.OrderedList(...props)
69
- }
70
-
71
- const p = (...props: any[]) => {
72
- return new Clapton.Paragraph(...props)
73
- }
74
-
75
- const q = (...props: any[]) => {
76
- return new Clapton.Quote(...props)
77
- }
78
-
79
- const radio = (...props: any[]) => {
80
- return new Clapton.RadioButton(props[0], props[1], props[2])
81
- }
82
-
83
- const select = (...props: any[]) => {
84
- return new Clapton.Select(props[0], props[1], props[2])
85
- }
86
-
87
- const span = (...props: any[]) => {
88
- return new Clapton.Span(...props)
89
- }
90
-
91
- const textarea = (...props: any[]) => {
92
- return new Clapton.TextArea(props[0], props[1], props[2])
93
- }
94
-
95
- const input = (...props: any[]) => {
96
- return new Clapton.TextField(props[0], props[1], props[2])
97
- }
98
-
99
- const text = (...props: any[]) => {
100
- return new Clapton.Text(props[0])
101
- }
102
-
103
- const c = (name: string, ...props: any[]) => {
104
- switch (name) {
105
- case "bq":
106
- return bq(...props)
107
- case "box":
108
- return box(...props)
109
- case "b":
110
- return b(...props)
111
- case "button":
112
- return button(...props)
113
- case "check":
114
- return check(...props)
115
- case "code":
116
- return code(...props)
117
- case "datetime":
118
- return datetime(...props)
119
- case "el":
120
- return el(...props)
121
- case "embed":
122
- return embed(...props)
123
- case "em":
124
- return em(...props)
125
- case "form":
126
- return form(...props)
127
- case "h":
128
- return h(...props)
129
- case "img":
130
- return img(...props)
131
- case "a":
132
- return a(...props)
133
- case "li":
134
- return li(...props)
135
- case "ul":
136
- return ul(...props)
137
- case "ol":
138
- return ol(...props)
139
- case "p":
140
- return p(...props)
141
- case "q":
142
- return q(...props)
143
- case "radio":
144
- return radio(...props)
145
- case "select":
146
- return select(...props)
147
- case "span":
148
- return span(...props)
149
- case "textarea":
150
- return textarea(...props)
151
- case "input":
152
- return input(...props)
153
- case "text":
154
- return text(...props)
155
- default:
156
- return new Clapton.Component(...props)
157
- }
158
- }
1
+ import { c } from "./c-base"
159
2
 
160
3
  export default c
@@ -1,160 +1,3 @@
1
- import { Clapton } from "components"
2
-
3
- const bq = (...props: any[]) => {
4
- return new Clapton.BlockQuote(...props)
5
- }
6
-
7
- const box = (...props: any[]) => {
8
- return new Clapton.Box(...props)
9
- }
10
-
11
- const b = (...props: any[]) => {
12
- return new Clapton.Bold(...props)
13
- }
14
-
15
- const button = (...props: any[]) => {
16
- return new Clapton.Button(...props)
17
- }
18
-
19
- const check = (...props: any[]) => {
20
- return new Clapton.Checkbox(props[0], props[1], props[2])
21
- }
22
-
23
- const code = (...props: any[]) => {
24
- return new Clapton.Code(...props)
25
- }
26
-
27
- const datetime = (...props: any[]) => {
28
- return new Clapton.DateTimeField(props[0], props[1], props[2])
29
- }
30
-
31
- const el = (...props: any[]) => {
32
- return new Clapton.Element(props[0], props[1])
33
- }
34
-
35
- const embed = (...props: any[]) => {
36
- return new Clapton.Embed(props[0])
37
- }
38
-
39
- const em = (...props: any[]) => {
40
- return new Clapton.Emphasis(...props)
41
- }
42
-
43
- const form = (...props: any[]) => {
44
- return new Clapton.Form(...props)
45
- }
46
-
47
- const h = (...props: any[]) => {
48
- return new Clapton.Heading(props[0], props[1])
49
- }
50
-
51
- const img = (...props: any[]) => {
52
- return new Clapton.Image(props[0], props[1], props[2])
53
- }
54
-
55
- const a = (...props: any[]) => {
56
- return new Clapton.Link(props[0], props[1])
57
- }
58
-
59
- const li = (...props: any[]) => {
60
- return new Clapton.ListItem(...props)
61
- }
62
-
63
- const ul = (...props: any[]) => {
64
- return new Clapton.List(...props)
65
- }
66
-
67
- const ol = (...props: any[]) => {
68
- return new Clapton.OrderedList(...props)
69
- }
70
-
71
- const p = (...props: any[]) => {
72
- return new Clapton.Paragraph(...props)
73
- }
74
-
75
- const q = (...props: any[]) => {
76
- return new Clapton.Quote(...props)
77
- }
78
-
79
- const radio = (...props: any[]) => {
80
- return new Clapton.RadioButton(props[0], props[1], props[2])
81
- }
82
-
83
- const select = (...props: any[]) => {
84
- return new Clapton.Select(props[0], props[1], props[2])
85
- }
86
-
87
- const span = (...props: any[]) => {
88
- return new Clapton.Span(...props)
89
- }
90
-
91
- const textarea = (...props: any[]) => {
92
- return new Clapton.TextArea(props[0], props[1], props[2])
93
- }
94
-
95
- const input = (...props: any[]) => {
96
- return new Clapton.TextField(props[0], props[1], props[2])
97
- }
98
-
99
- const text = (...props: any[]) => {
100
- return new Clapton.Text(props[0])
101
- }
102
-
103
- const c = (name: string, ...props: any[]) => {
104
- switch (name) {
105
- case "bq":
106
- return bq(...props)
107
- case "box":
108
- return box(...props)
109
- case "b":
110
- return b(...props)
111
- case "button":
112
- return button(...props)
113
- case "check":
114
- return check(...props)
115
- case "code":
116
- return code(...props)
117
- case "datetime":
118
- return datetime(...props)
119
- case "el":
120
- return el(...props)
121
- case "embed":
122
- return embed(...props)
123
- case "em":
124
- return em(...props)
125
- case "form":
126
- return form(...props)
127
- case "h":
128
- return h(...props)
129
- case "img":
130
- return img(...props)
131
- case "a":
132
- return a(...props)
133
- case "li":
134
- return li(...props)
135
- case "ul":
136
- return ul(...props)
137
- case "ol":
138
- return ol(...props)
139
- case "p":
140
- return p(...props)
141
- case "q":
142
- return q(...props)
143
- case "radio":
144
- return radio(...props)
145
- case "select":
146
- return select(...props)
147
- case "span":
148
- return span(...props)
149
- case "textarea":
150
- return textarea(...props)
151
- case "input":
152
- return input(...props)
153
- case "text":
154
- return text(...props)
155
- default:
156
- return new Clapton.Component(...props)
157
- }
158
- }
1
+ import { c } from "./c-base"
159
2
 
160
3
  export { c }
@@ -46,6 +46,14 @@ document.addEventListener("DOMContentLoaded", async () => {
46
46
  document.dispatchEvent(event);
47
47
  });
48
48
 
49
+ document.addEventListener("turbo:render", async () => {
50
+ await initializeComponents();
51
+ initializeActions();
52
+ initializeInputs();
53
+ const event = new Event('clapton:render');
54
+ document.dispatchEvent(event);
55
+ });
56
+
49
57
  window.addEventListener('beforeunload', () => {
50
58
  sessionStorage.setItem('scrollPosition', window.scrollY.toString());
51
59
  });
@@ -1,3 +1,3 @@
1
1
  module Clapton
2
- VERSION = '0.0.22'
2
+ VERSION = '0.0.23'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clapton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
11
+ date: 2024-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -6706,6 +6706,7 @@ files:
6706
6706
  - lib/clapton/javascripts/src/actions/handle-action.spec.ts
6707
6707
  - lib/clapton/javascripts/src/actions/handle-action.ts
6708
6708
  - lib/clapton/javascripts/src/actions/initialize-actions.ts
6709
+ - lib/clapton/javascripts/src/c-base.ts
6709
6710
  - lib/clapton/javascripts/src/c-for-test.ts
6710
6711
  - lib/clapton/javascripts/src/c.ts
6711
6712
  - lib/clapton/javascripts/src/channel/clapton-channel.js