clapton 0.0.24 → 0.0.26
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 -113
- data/app/channels/clapton/clapton_channel.rb +4 -0
- data/lib/clapton/javascripts/dist/c-for-test.js +124 -268
- data/lib/clapton/javascripts/dist/c.js +124 -268
- data/lib/clapton/javascripts/dist/client.js +6 -31
- data/lib/clapton/javascripts/dist/components-for-test.js +73 -245
- data/lib/clapton/javascripts/dist/components.js +72 -241
- data/lib/clapton/javascripts/src/actions/handle-action.ts +3 -2
- data/lib/clapton/javascripts/src/c-base.ts +57 -30
- data/lib/clapton/javascripts/src/channel/clapton-channel.js +3 -2
- data/lib/clapton/javascripts/src/client.ts +0 -3
- data/lib/clapton/javascripts/src/components/{box.ts → base.ts} +6 -8
- data/lib/clapton/javascripts/src/components/block-quote.spec.ts +1 -1
- data/lib/clapton/javascripts/src/components/block-quote.ts +2 -14
- data/lib/clapton/javascripts/src/components/bold.ts +2 -14
- data/lib/clapton/javascripts/src/components/button.ts +2 -19
- data/lib/clapton/javascripts/src/components/code.ts +2 -14
- data/lib/clapton/javascripts/src/components/component.ts +2 -2
- data/lib/clapton/javascripts/src/components/{box.spec.ts → div.spec.ts} +8 -8
- data/lib/clapton/javascripts/src/components/div.ts +8 -0
- data/lib/clapton/javascripts/src/components/element.ts +3 -9
- data/lib/clapton/javascripts/src/components/emphasis.ts +2 -14
- data/lib/clapton/javascripts/src/components/form.ts +2 -14
- data/lib/clapton/javascripts/src/components/heading.ts +4 -10
- data/lib/clapton/javascripts/src/components/image.spec.ts +2 -2
- data/lib/clapton/javascripts/src/components/image.ts +3 -14
- data/lib/clapton/javascripts/src/components/input.spec.ts +16 -0
- data/lib/clapton/javascripts/src/components/{datetime-field.ts → input.ts} +13 -11
- data/lib/clapton/javascripts/src/components/link.spec.ts +6 -6
- data/lib/clapton/javascripts/src/components/link.ts +3 -16
- data/lib/clapton/javascripts/src/components/list-item.ts +2 -14
- data/lib/clapton/javascripts/src/components/list.ts +2 -14
- data/lib/clapton/javascripts/src/components/ordered-list.ts +2 -14
- data/lib/clapton/javascripts/src/components/paragraph.ts +2 -14
- data/lib/clapton/javascripts/src/components/quote.ts +2 -14
- data/lib/clapton/javascripts/src/components/select.ts +3 -5
- data/lib/clapton/javascripts/src/components/span.ts +2 -14
- data/lib/clapton/javascripts/src/components/text-area.ts +4 -9
- data/lib/clapton/javascripts/src/components-for-test.ts +3 -6
- data/lib/clapton/javascripts/src/components.ts +3 -6
- data/lib/clapton/test_helper/base.rb +4 -4
- data/lib/clapton/version.rb +1 -1
- metadata +7 -16
- data/lib/clapton/javascripts/dist/c +0 -559
- data/lib/clapton/javascripts/dist/c-base.js +0 -589
- data/lib/clapton/javascripts/src/components/checkbox.spec.ts +0 -16
- data/lib/clapton/javascripts/src/components/checkbox.ts +0 -23
- data/lib/clapton/javascripts/src/components/datetime-field.spec.ts +0 -16
- data/lib/clapton/javascripts/src/components/radio-button.spec.ts +0 -16
- data/lib/clapton/javascripts/src/components/radio-button.ts +0 -23
- data/lib/clapton/javascripts/src/components/text-field.spec.ts +0 -16
- data/lib/clapton/javascripts/src/components/text-field.ts +0 -23
- data/lib/clapton/javascripts/src/dom/update-component.ts +0 -11
- data/lib/clapton/javascripts/src/inputs/initialize-inputs.ts +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7e101f28b9097e8229c855012c0c2649da46060207845c7d6f41c6a1e6c89b3
|
4
|
+
data.tar.gz: e1d8c859a3e5e675922a6a79a9783b0129c33fa2f30f56cf2819dac7802e85ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f0a863288caa1f2ff959a14ae745c6043aaece8642ece8428ac91695a036f1601088bc81dc562c9bc3bf140101e8b210f47990b77ba26dbf2b07597225ec1c9
|
7
|
+
data.tar.gz: 75d7c625ce602ff727709bfe217e79e19f6c17a11ddceecbb4d8c5765ea353206a4763f4e182ffcb7081842d9485d13b21127d39536ae3270967d5362467cd0f
|
data/README.md
CHANGED
@@ -34,14 +34,14 @@ To use a Clapton component in your view:
|
|
34
34
|
# app/components/task_list_component.rb
|
35
35
|
class TaskListComponent < Clapton::Component
|
36
36
|
def render
|
37
|
-
|
37
|
+
div = c(:div)
|
38
38
|
@state.tasks.each do |task|
|
39
|
-
|
39
|
+
div.add(TaskItemComponent.new(id: task[:id], title: task[:title], due: task[:due], done: task[:done]))
|
40
40
|
end
|
41
41
|
btn = c(:button)
|
42
42
|
btn.add(c(:text, "Add Task"))
|
43
43
|
btn.add_action(:click, :TaskListState, :add_task)
|
44
|
-
|
44
|
+
div.add(btn)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,7 +51,7 @@ end
|
|
51
51
|
# app/components/task_item_component.rb
|
52
52
|
class TaskItemComponent < Clapton::Component
|
53
53
|
def render
|
54
|
-
|
54
|
+
div = c(:div)
|
55
55
|
btn = c(:button)
|
56
56
|
btn.add(c(:text, @state.done ? "✅" : "🟩"))
|
57
57
|
btn.add_action(:click, :TaskListState, :toggle_done)
|
@@ -62,7 +62,7 @@ class TaskItemComponent < Clapton::Component
|
|
62
62
|
dt = c(:datetime, @state, :due)
|
63
63
|
dt.add_action(:input, :TaskListState, :update_due)
|
64
64
|
|
65
|
-
|
65
|
+
div.add(btn).add(tf).add(dt)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -171,8 +171,8 @@ The `render` event is a special event that is triggered when the component is re
|
|
171
171
|
class TaskListComponent < Clapton::Component
|
172
172
|
def render
|
173
173
|
# ...
|
174
|
-
|
175
|
-
|
174
|
+
div = c(:div)
|
175
|
+
div.add_action(:render, :TaskListState, :add_empty_task, debounce: 500)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
```
|
@@ -201,112 +201,6 @@ class VideoPlayerComponent < Clapton::Component
|
|
201
201
|
end
|
202
202
|
```
|
203
203
|
|
204
|
-
### Preset Components Classes
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
block_quote = Clapton::BlockQuote.new
|
208
|
-
block_quote.add(Clapton::Text.new("Hello"))
|
209
|
-
|
210
|
-
box = Clapton::Box.new
|
211
|
-
box.add(Clapton::Text.new("Hello"))
|
212
|
-
|
213
|
-
button = Clapton::Button.new
|
214
|
-
button.add(Clapton::Text.new("Click me"))
|
215
|
-
button.add_action(:click, :TaskListState, :add_task)
|
216
|
-
|
217
|
-
checkbox = Clapton::Checkbox.new(:ExampleState, :example_attribute, { id: "example-checkbox" })
|
218
|
-
checkbox.add_action(:change, :ExampleState, :update_example_attribute)
|
219
|
-
|
220
|
-
code = Clapton::Code.new
|
221
|
-
code.add(Clapton::Text.new("Hello"))
|
222
|
-
|
223
|
-
datetime_field = Clapton::DateTimeField.new(:ExampleState, :example_attribute, { id: "example-datetime-field" })
|
224
|
-
|
225
|
-
element = Clapton::Element.new("div", { id: "example-element" })
|
226
|
-
element.add(Clapton::Text.new("Hello"))
|
227
|
-
|
228
|
-
embed = Clapton::Embed.new("<blockquote>This is a test</blockquote>")
|
229
|
-
|
230
|
-
emphasis = Clapton::Emphasis.new
|
231
|
-
emphasis.add(Clapton::Text.new("Hello"))
|
232
|
-
|
233
|
-
form = Clapton::Form.new
|
234
|
-
form.add(Clapton::Text.new("Hello"))
|
235
|
-
|
236
|
-
heading = Clapton::Heading.new(1)
|
237
|
-
heading.add(Clapton::Text.new("Hello"))
|
238
|
-
|
239
|
-
image = Clapton::Image.new("https://example.com/image.png", "Example Image")
|
240
|
-
|
241
|
-
link = Clapton::Link.new("https://example.com")
|
242
|
-
link.add(Clapton::Text.new("Example Link"))
|
243
|
-
|
244
|
-
list = Clapton::List.new
|
245
|
-
(1..3).each do
|
246
|
-
item = Clapton::ListItem.new
|
247
|
-
item.add(Clapton::Text.new("Item #{i}"))
|
248
|
-
list.add(item)
|
249
|
-
end
|
250
|
-
|
251
|
-
ordered_list = Clapton::OrderedList.new
|
252
|
-
(1..3).each do
|
253
|
-
item = Clapton::ListItem.new
|
254
|
-
item.add(Clapton::Text.new("Item #{i}"))
|
255
|
-
ordered_list.add(item)
|
256
|
-
end
|
257
|
-
|
258
|
-
paragraph = Clapton::Paragraph.new
|
259
|
-
paragraph.add(Clapton::Text.new("Hello"))
|
260
|
-
|
261
|
-
quote = Clapton::Quote.new
|
262
|
-
quote.add(Clapton::Text.new("Hello"))
|
263
|
-
|
264
|
-
radio_button = Clapton::RadioButton.new(:ExampleState, :example_attribute, { id: "example-radio-button" })
|
265
|
-
radio_button.add_action(:change, :ExampleState, :update_example_attribute)
|
266
|
-
|
267
|
-
select = Clapton::Select.new([{ value: "1", text: "One" }, { value: "2", text: "Two" }], :ExampleState, :example_attribute, { id: "example-select" })
|
268
|
-
select.add_action(:change, :ExampleState, :update_example_attribute)
|
269
|
-
|
270
|
-
span = Clapton::Span.new
|
271
|
-
span.add(Clapton::Text.new("Hello"))
|
272
|
-
|
273
|
-
text_area = Clapton::TextArea.new(:ExampleState, :example_attribute, { id: "example-text-area" })
|
274
|
-
|
275
|
-
text_field = Clapton::TextField.new(:ExampleState, :example_attribute, { id: "example-text-field" })
|
276
|
-
|
277
|
-
text = Clapton::Text.new("Hello")`
|
278
|
-
```
|
279
|
-
|
280
|
-
### Preset Component Methods
|
281
|
-
|
282
|
-
```javascript
|
283
|
-
c(:bq, ...props)
|
284
|
-
c(:box, ...props)
|
285
|
-
c(:b, ...props)
|
286
|
-
c(:button, ...props)
|
287
|
-
c(:check, ...props)
|
288
|
-
c(:code, ...props)
|
289
|
-
c(:datetime, ...props)
|
290
|
-
c(:el, ...props)
|
291
|
-
c(:embed, ...props)
|
292
|
-
c(:em, ...props)
|
293
|
-
c(:form, ...props)
|
294
|
-
c(:h, ...props)
|
295
|
-
c(:img, ...props)
|
296
|
-
c(:a, ...props)
|
297
|
-
c(:li, ...props)
|
298
|
-
c(:ul, ...props)
|
299
|
-
c(:ol, ...props)
|
300
|
-
c(:p, ...props)
|
301
|
-
c(:q, ...props)
|
302
|
-
c(:radio, ...props)
|
303
|
-
c(:select, ...props)
|
304
|
-
c(:span, ...props)
|
305
|
-
c(:textarea, ...props)
|
306
|
-
c(:input, ...props)
|
307
|
-
c(:text, ...props)
|
308
|
-
```
|
309
|
-
|
310
204
|
### Streaming
|
311
205
|
|
312
206
|
Clapton supports streaming.
|
@@ -19,6 +19,7 @@ module Clapton
|
|
19
19
|
id: data["data"]["component"]["id"],
|
20
20
|
},
|
21
21
|
state: state.to_h,
|
22
|
+
focus: data["data"]["focus"]
|
22
23
|
}
|
23
24
|
})
|
24
25
|
end
|
@@ -32,6 +33,7 @@ module Clapton
|
|
32
33
|
id: data["data"]["component"]["id"],
|
33
34
|
},
|
34
35
|
state: state.to_h,
|
36
|
+
focus: data["data"]["focus"]
|
35
37
|
}
|
36
38
|
})
|
37
39
|
return
|
@@ -47,6 +49,7 @@ module Clapton
|
|
47
49
|
id: data["data"]["component"]["id"],
|
48
50
|
},
|
49
51
|
state: state.to_h,
|
52
|
+
focus: data["data"]["focus"]
|
50
53
|
}
|
51
54
|
})
|
52
55
|
else
|
@@ -59,6 +62,7 @@ module Clapton
|
|
59
62
|
id: data["data"]["component"]["id"],
|
60
63
|
},
|
61
64
|
state: state.to_h,
|
65
|
+
focus: data["data"]["focus"]
|
62
66
|
}
|
63
67
|
})
|
64
68
|
end
|