clapton 0.0.24 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -113
  3. data/app/channels/clapton/clapton_channel.rb +4 -0
  4. data/lib/clapton/javascripts/dist/c-for-test.js +124 -268
  5. data/lib/clapton/javascripts/dist/c.js +124 -268
  6. data/lib/clapton/javascripts/dist/client.js +6 -31
  7. data/lib/clapton/javascripts/dist/components-for-test.js +73 -245
  8. data/lib/clapton/javascripts/dist/components.js +72 -241
  9. data/lib/clapton/javascripts/src/actions/handle-action.ts +3 -2
  10. data/lib/clapton/javascripts/src/c-base.ts +57 -30
  11. data/lib/clapton/javascripts/src/channel/clapton-channel.js +3 -2
  12. data/lib/clapton/javascripts/src/client.ts +0 -3
  13. data/lib/clapton/javascripts/src/components/{box.ts → base.ts} +6 -8
  14. data/lib/clapton/javascripts/src/components/block-quote.spec.ts +1 -1
  15. data/lib/clapton/javascripts/src/components/block-quote.ts +2 -14
  16. data/lib/clapton/javascripts/src/components/bold.ts +2 -14
  17. data/lib/clapton/javascripts/src/components/button.ts +2 -19
  18. data/lib/clapton/javascripts/src/components/code.ts +2 -14
  19. data/lib/clapton/javascripts/src/components/component.ts +2 -2
  20. data/lib/clapton/javascripts/src/components/{box.spec.ts → div.spec.ts} +8 -8
  21. data/lib/clapton/javascripts/src/components/div.ts +8 -0
  22. data/lib/clapton/javascripts/src/components/element.ts +3 -9
  23. data/lib/clapton/javascripts/src/components/emphasis.ts +2 -14
  24. data/lib/clapton/javascripts/src/components/form.ts +2 -14
  25. data/lib/clapton/javascripts/src/components/heading.ts +4 -10
  26. data/lib/clapton/javascripts/src/components/image.spec.ts +2 -2
  27. data/lib/clapton/javascripts/src/components/image.ts +3 -14
  28. data/lib/clapton/javascripts/src/components/input.spec.ts +16 -0
  29. data/lib/clapton/javascripts/src/components/{datetime-field.ts → input.ts} +13 -11
  30. data/lib/clapton/javascripts/src/components/link.spec.ts +6 -6
  31. data/lib/clapton/javascripts/src/components/link.ts +3 -16
  32. data/lib/clapton/javascripts/src/components/list-item.ts +2 -14
  33. data/lib/clapton/javascripts/src/components/list.ts +2 -14
  34. data/lib/clapton/javascripts/src/components/ordered-list.ts +2 -14
  35. data/lib/clapton/javascripts/src/components/paragraph.ts +2 -14
  36. data/lib/clapton/javascripts/src/components/quote.ts +2 -14
  37. data/lib/clapton/javascripts/src/components/select.ts +3 -5
  38. data/lib/clapton/javascripts/src/components/span.ts +2 -14
  39. data/lib/clapton/javascripts/src/components/text-area.ts +4 -9
  40. data/lib/clapton/javascripts/src/components-for-test.ts +3 -6
  41. data/lib/clapton/javascripts/src/components.ts +3 -6
  42. data/lib/clapton/test_helper/base.rb +4 -4
  43. data/lib/clapton/version.rb +1 -1
  44. metadata +7 -16
  45. data/lib/clapton/javascripts/dist/c +0 -559
  46. data/lib/clapton/javascripts/dist/c-base.js +0 -589
  47. data/lib/clapton/javascripts/src/components/checkbox.spec.ts +0 -16
  48. data/lib/clapton/javascripts/src/components/checkbox.ts +0 -23
  49. data/lib/clapton/javascripts/src/components/datetime-field.spec.ts +0 -16
  50. data/lib/clapton/javascripts/src/components/radio-button.spec.ts +0 -16
  51. data/lib/clapton/javascripts/src/components/radio-button.ts +0 -23
  52. data/lib/clapton/javascripts/src/components/text-field.spec.ts +0 -16
  53. data/lib/clapton/javascripts/src/components/text-field.ts +0 -23
  54. data/lib/clapton/javascripts/src/dom/update-component.ts +0 -11
  55. 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: f15ceb3c247b4a620ea3508dc66511a2d7beb4f2e1bc32a24dd8e69bd0d70332
4
- data.tar.gz: 329b1b8107968efdcce936a4f71deb904e5a609d846ca245d8c90cc7040ba144
3
+ metadata.gz: d7e101f28b9097e8229c855012c0c2649da46060207845c7d6f41c6a1e6c89b3
4
+ data.tar.gz: e1d8c859a3e5e675922a6a79a9783b0129c33fa2f30f56cf2819dac7802e85ea
5
5
  SHA512:
6
- metadata.gz: 24846c65443543d58f3e8f6f6018b5ace3af64166be9b9e2bde2bd0aa5056c7bd2f148ba43b7171a7e43756d0eb485bebaad9fca5ad57a913b038bead70baf8e
7
- data.tar.gz: 60aaeaae14b6277cd5323f5cf1e36201e94f2887e4c1655838ce37a13a58282de3b05c729e2a8212b2e1705f7e4e538f0b2f2b78e57b872f089d9956acc58b57
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
- box = c(:box)
37
+ div = c(:div)
38
38
  @state.tasks.each do |task|
39
- box.add(TaskItemComponent.new(id: task[:id], title: task[:title], due: task[:due], done: task[:done]))
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
- box.add(btn)
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
- box = c(:box)
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
- box.add(btn).add(tf).add(dt)
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
- box = c(:box)
175
- box.add_action(:render, :TaskListState, :add_empty_task, debounce: 500)
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