clapton 0.0.23 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -105
  3. data/lib/clapton/javascripts/dist/c-for-test.js +129 -271
  4. data/lib/clapton/javascripts/dist/c.js +129 -271
  5. data/lib/clapton/javascripts/dist/client.js +3 -0
  6. data/lib/clapton/javascripts/dist/components-for-test.js +90 -245
  7. data/lib/clapton/javascripts/dist/components.js +89 -241
  8. data/lib/clapton/javascripts/src/c-base.ts +45 -33
  9. data/lib/clapton/javascripts/src/channel/clapton-channel.js +1 -0
  10. data/lib/clapton/javascripts/src/client.ts +1 -0
  11. data/lib/clapton/javascripts/src/components/{box.ts → base.ts} +6 -8
  12. data/lib/clapton/javascripts/src/components/block-quote.spec.ts +1 -1
  13. data/lib/clapton/javascripts/src/components/block-quote.ts +2 -14
  14. data/lib/clapton/javascripts/src/components/bold.ts +2 -14
  15. data/lib/clapton/javascripts/src/components/button.ts +2 -19
  16. data/lib/clapton/javascripts/src/components/code.ts +2 -14
  17. data/lib/clapton/javascripts/src/components/component.ts +28 -2
  18. data/lib/clapton/javascripts/src/components/{box.spec.ts → div.spec.ts} +8 -8
  19. data/lib/clapton/javascripts/src/components/div.ts +8 -0
  20. data/lib/clapton/javascripts/src/components/element.ts +3 -9
  21. data/lib/clapton/javascripts/src/components/emphasis.ts +2 -14
  22. data/lib/clapton/javascripts/src/components/form.ts +2 -14
  23. data/lib/clapton/javascripts/src/components/heading.ts +4 -10
  24. data/lib/clapton/javascripts/src/components/image.spec.ts +2 -2
  25. data/lib/clapton/javascripts/src/components/image.ts +3 -14
  26. data/lib/clapton/javascripts/src/components/input.spec.ts +16 -0
  27. data/lib/clapton/javascripts/src/components/{datetime-field.ts → input.ts} +9 -11
  28. data/lib/clapton/javascripts/src/components/link.spec.ts +6 -6
  29. data/lib/clapton/javascripts/src/components/link.ts +3 -16
  30. data/lib/clapton/javascripts/src/components/list-item.ts +2 -14
  31. data/lib/clapton/javascripts/src/components/list.ts +2 -14
  32. data/lib/clapton/javascripts/src/components/ordered-list.ts +2 -14
  33. data/lib/clapton/javascripts/src/components/paragraph.ts +2 -14
  34. data/lib/clapton/javascripts/src/components/quote.ts +2 -14
  35. data/lib/clapton/javascripts/src/components/select.ts +3 -5
  36. data/lib/clapton/javascripts/src/components/span.ts +2 -14
  37. data/lib/clapton/javascripts/src/components/text-area.ts +4 -9
  38. data/lib/clapton/javascripts/src/components-for-test.ts +3 -6
  39. data/lib/clapton/javascripts/src/components.ts +3 -6
  40. data/lib/clapton/javascripts/src/dom/update-component.ts +1 -0
  41. data/lib/clapton/test_helper/base.rb +4 -4
  42. data/lib/clapton/version.rb +1 -1
  43. metadata +7 -14
  44. data/lib/clapton/javascripts/dist/c +0 -559
  45. data/lib/clapton/javascripts/dist/c-base.js +0 -589
  46. data/lib/clapton/javascripts/src/components/checkbox.spec.ts +0 -16
  47. data/lib/clapton/javascripts/src/components/checkbox.ts +0 -23
  48. data/lib/clapton/javascripts/src/components/datetime-field.spec.ts +0 -16
  49. data/lib/clapton/javascripts/src/components/radio-button.spec.ts +0 -16
  50. data/lib/clapton/javascripts/src/components/radio-button.ts +0 -23
  51. data/lib/clapton/javascripts/src/components/text-field.spec.ts +0 -16
  52. data/lib/clapton/javascripts/src/components/text-field.ts +0 -23
@@ -1,16 +0,0 @@
1
- import { describe, it, expect } from "vitest"
2
- import { TextField } from "./text-field"
3
-
4
- describe("TextField", () => {
5
- it("returns empty string if no params", () => {
6
- expect(new TextField({}, "foo").renderWrapper).toBe("<input type='text' data-attribute='foo' value=''/>")
7
- })
8
-
9
- it("returns attributes and data attributes", () => {
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
- })
12
-
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" } } }).renderWrapper).toBe(`<input type='text' id='1' data-attribute='foo' data-foo-baz='qux' data-foo-quux='corge' value='bar'/>`)
15
- })
16
- })
@@ -1,23 +0,0 @@
1
- import { htmlAttributes } from "../html/html-attributes";
2
-
3
- export class TextField {
4
- state: any;
5
- attribute: string;
6
- attributes: Record<string, any>;
7
-
8
- constructor(state: any, attribute: string, attributes: Record<string, any> = {}) {
9
- this.state = state;
10
- this.attributes = attributes;
11
- this.attribute = attribute;
12
- this.attributes["data-attribute"] = attribute;
13
- }
14
-
15
- get renderWrapper(): string {
16
- return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
17
- }
18
-
19
- add_action(event: string, klass: string, fn: string, options: { debounce?: number } = {}): TextField {
20
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
21
- return this;
22
- }
23
- }