clapton 0.0.17 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -7
  3. data/lib/clapton/javascripts/dist/client.js +14 -4
  4. data/lib/clapton/javascripts/dist/components-for-test.js +54 -45
  5. data/lib/clapton/javascripts/dist/components.js +54 -45
  6. data/lib/clapton/javascripts/src/channel/clapton-channel.js +1 -1
  7. data/lib/clapton/javascripts/src/client.ts +11 -2
  8. data/lib/clapton/javascripts/src/components/block-quote.spec.ts +6 -6
  9. data/lib/clapton/javascripts/src/components/block-quote.ts +2 -2
  10. data/lib/clapton/javascripts/src/components/bold.spec.ts +3 -3
  11. data/lib/clapton/javascripts/src/components/bold.ts +2 -2
  12. data/lib/clapton/javascripts/src/components/box.spec.ts +6 -6
  13. data/lib/clapton/javascripts/src/components/box.ts +2 -2
  14. data/lib/clapton/javascripts/src/components/button.spec.ts +5 -5
  15. data/lib/clapton/javascripts/src/components/button.ts +2 -2
  16. data/lib/clapton/javascripts/src/components/checkbox.spec.ts +3 -3
  17. data/lib/clapton/javascripts/src/components/checkbox.ts +1 -1
  18. data/lib/clapton/javascripts/src/components/code.spec.ts +6 -6
  19. data/lib/clapton/javascripts/src/components/code.ts +2 -2
  20. data/lib/clapton/javascripts/src/components/component.ts +12 -4
  21. data/lib/clapton/javascripts/src/components/datetime-field.spec.ts +3 -3
  22. data/lib/clapton/javascripts/src/components/datetime-field.ts +1 -1
  23. data/lib/clapton/javascripts/src/components/element.spec.ts +6 -6
  24. data/lib/clapton/javascripts/src/components/element.ts +2 -2
  25. data/lib/clapton/javascripts/src/components/embed.spec.ts +1 -1
  26. data/lib/clapton/javascripts/src/components/embed.ts +1 -1
  27. data/lib/clapton/javascripts/src/components/emphasis.spec.ts +6 -6
  28. data/lib/clapton/javascripts/src/components/emphasis.ts +2 -2
  29. data/lib/clapton/javascripts/src/components/form.spec.ts +6 -6
  30. data/lib/clapton/javascripts/src/components/form.ts +2 -2
  31. data/lib/clapton/javascripts/src/components/heading.spec.ts +6 -6
  32. data/lib/clapton/javascripts/src/components/heading.ts +2 -2
  33. data/lib/clapton/javascripts/src/components/image.spec.ts +2 -2
  34. data/lib/clapton/javascripts/src/components/image.ts +1 -1
  35. data/lib/clapton/javascripts/src/components/link.spec.ts +6 -6
  36. data/lib/clapton/javascripts/src/components/link.ts +2 -2
  37. data/lib/clapton/javascripts/src/components/list-item.spec.ts +6 -6
  38. data/lib/clapton/javascripts/src/components/list-item.ts +2 -2
  39. data/lib/clapton/javascripts/src/components/list.spec.ts +6 -6
  40. data/lib/clapton/javascripts/src/components/list.ts +2 -2
  41. data/lib/clapton/javascripts/src/components/ordered-list.spec.ts +6 -6
  42. data/lib/clapton/javascripts/src/components/ordered-list.ts +2 -2
  43. data/lib/clapton/javascripts/src/components/paragraph.spec.ts +6 -6
  44. data/lib/clapton/javascripts/src/components/paragraph.ts +2 -2
  45. data/lib/clapton/javascripts/src/components/presets.ts +1 -1
  46. data/lib/clapton/javascripts/src/components/quote.spec.ts +6 -6
  47. data/lib/clapton/javascripts/src/components/quote.ts +2 -2
  48. data/lib/clapton/javascripts/src/components/radio-button.spec.ts +3 -3
  49. data/lib/clapton/javascripts/src/components/radio-button.ts +1 -1
  50. data/lib/clapton/javascripts/src/components/select.spec.ts +6 -6
  51. data/lib/clapton/javascripts/src/components/select.ts +2 -2
  52. data/lib/clapton/javascripts/src/components/span.spec.ts +6 -6
  53. data/lib/clapton/javascripts/src/components/span.ts +2 -2
  54. data/lib/clapton/javascripts/src/components/text-area.spec.ts +3 -3
  55. data/lib/clapton/javascripts/src/components/text-area.ts +1 -1
  56. data/lib/clapton/javascripts/src/components/text-field.spec.ts +3 -3
  57. data/lib/clapton/javascripts/src/components/text-field.ts +1 -1
  58. data/lib/clapton/javascripts/src/components/text.spec.ts +2 -2
  59. data/lib/clapton/javascripts/src/components/text.ts +1 -1
  60. data/lib/clapton/javascripts/src/dom/update-component.ts +1 -1
  61. data/lib/clapton/test_helper/base.rb +1 -1
  62. data/lib/clapton/version.rb +1 -1
  63. data/lib/rails/generators/clapton_generator.rb +2 -0
  64. metadata +1 -1
@@ -3,14 +3,14 @@ import { TextArea } from "./text-area"
3
3
 
4
4
  describe("TextArea", () => {
5
5
  it("returns empty string if no params", () => {
6
- expect(new TextArea({}, "foo").render).toBe("<textarea data-attribute='foo'></textarea>")
6
+ expect(new TextArea({}, "foo").renderWrapper).toBe("<textarea data-attribute='foo'></textarea>")
7
7
  })
8
8
 
9
9
  it("returns attributes and data attributes", () => {
10
- expect(new TextArea({ foo: "bar" }, "foo", { id: "1", "data-foo": "bar" }).render).toBe(`<textarea id='1' data-foo='bar' data-attribute='foo'>bar</textarea>`)
10
+ expect(new TextArea({ foo: "bar" }, "foo", { id: "1", "data-foo": "bar" }).renderWrapper).toBe(`<textarea id='1' data-foo='bar' data-attribute='foo'>bar</textarea>`)
11
11
  })
12
12
 
13
13
  it("returns attributes and data attributes with custom data attributes", () => {
14
- expect(new TextArea({ foo: "bar" }, "foo", { id: "1", data: { foo: { baz: "qux", quux: "corge" } } }).render).toBe(`<textarea id='1' data-attribute='foo' data-foo-baz='qux' data-foo-quux='corge'>bar</textarea>`)
14
+ expect(new TextArea({ foo: "bar" }, "foo", { id: "1", data: { foo: { baz: "qux", quux: "corge" } } }).renderWrapper).toBe(`<textarea id='1' data-attribute='foo' data-foo-baz='qux' data-foo-quux='corge'>bar</textarea>`)
15
15
  })
16
16
  })
@@ -12,7 +12,7 @@ export class TextArea {
12
12
  this.attributes["data-attribute"] = attribute;
13
13
  }
14
14
 
15
- get render(): string {
15
+ get renderWrapper(): string {
16
16
  return `<textarea ${htmlAttributes(this.attributes)}>${this.state[this.attribute] || ""}</textarea>`;
17
17
  }
18
18
 
@@ -3,14 +3,14 @@ import { TextField } from "./text-field"
3
3
 
4
4
  describe("TextField", () => {
5
5
  it("returns empty string if no params", () => {
6
- expect(new TextField({}, "foo").render).toBe("<input type='text' data-attribute='foo' value=''/>")
6
+ expect(new TextField({}, "foo").renderWrapper).toBe("<input type='text' data-attribute='foo' value=''/>")
7
7
  })
8
8
 
9
9
  it("returns attributes and data attributes", () => {
10
- expect(new TextField({ foo: "bar" }, "foo", { id: "1", "data-foo": "bar" }).render).toBe(`<input type='text' id='1' data-foo='bar' data-attribute='foo' value='bar'/>`)
10
+ expect(new TextField({ foo: "bar" }, "foo", { id: "1", "data-foo": "bar" }).renderWrapper).toBe(`<input type='text' id='1' data-foo='bar' data-attribute='foo' value='bar'/>`)
11
11
  })
12
12
 
13
13
  it("returns attributes and data attributes with custom data attributes", () => {
14
- expect(new TextField({ foo: "bar" }, "foo", { id: "1", data: { foo: { baz: "qux", quux: "corge" } } }).render).toBe(`<input type='text' id='1' data-attribute='foo' data-foo-baz='qux' data-foo-quux='corge' value='bar'/>`)
14
+ expect(new TextField({ foo: "bar" }, "foo", { id: "1", data: { foo: { baz: "qux", quux: "corge" } } }).renderWrapper).toBe(`<input type='text' id='1' data-attribute='foo' data-foo-baz='qux' data-foo-quux='corge' value='bar'/>`)
15
15
  })
16
16
  })
@@ -12,7 +12,7 @@ export class TextField {
12
12
  this.attributes["data-attribute"] = attribute;
13
13
  }
14
14
 
15
- get render(): string {
15
+ get renderWrapper(): string {
16
16
  return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
17
17
  }
18
18
 
@@ -3,10 +3,10 @@ import { Text } from "./text"
3
3
 
4
4
  describe("Text", () => {
5
5
  it("returns empty string if no params", () => {
6
- expect(new Text("").render).toBe("")
6
+ expect(new Text("").renderWrapper).toBe("")
7
7
  })
8
8
 
9
9
  it("returns value", () => {
10
- expect(new Text("bar").render).toBe("bar")
10
+ expect(new Text("bar").renderWrapper).toBe("bar")
11
11
  })
12
12
  })
@@ -5,7 +5,7 @@ export class Text {
5
5
  this.value = value;
6
6
  }
7
7
 
8
- get render(): string {
8
+ get renderWrapper(): string {
9
9
  return this.value;
10
10
  }
11
11
  }
@@ -6,5 +6,5 @@ export const updateComponent = async (component: HTMLElement, state: any, proper
6
6
  const module = await import(`${componentName}`);
7
7
  const ComponentClass = module[componentName] as any;
8
8
  const instance = new ComponentClass(state, component.dataset.id);
9
- morphdom(component, instance.render);
9
+ morphdom(component, instance.renderWrapper);
10
10
  };
@@ -18,7 +18,7 @@ module Clapton
18
18
  Box, Text, TextField, Button, DateTimeField, BlockQuote, Checkbox, Code, Element, Emphasis, Form, Heading, Image, Link, List, ListItem, OrderedList, Paragraph, Quote, RadioButton, Select, Span, Embed, Bold, TextArea
19
19
  };")
20
20
  context = ExecJS.compile(js)
21
- html = context.eval("new #{component.name.camelize}(#{params.to_json}).render")
21
+ html = context.eval("new #{component.name.camelize}(#{params.to_json}).renderWrapper")
22
22
  @page = Capybara.string(html)
23
23
  end
24
24
 
@@ -1,4 +1,4 @@
1
1
  module Clapton
2
- VERSION = '0.0.17'
2
+ VERSION = '0.0.19'
3
3
  end
4
4
 
@@ -7,6 +7,8 @@ module Rails
7
7
  create_file "app/components/#{file_name}_component.rb" do
8
8
  <<~RUBY
9
9
  class #{class_name}Component < Clapton::Component
10
+ def render
11
+ end
10
12
  end
11
13
  RUBY
12
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clapton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami