clapton 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -113
  3. data/lib/clapton/javascripts/dist/c-for-test.js +108 -271
  4. data/lib/clapton/javascripts/dist/c.js +108 -271
  5. data/lib/clapton/javascripts/dist/components-for-test.js +69 -245
  6. data/lib/clapton/javascripts/dist/components.js +68 -241
  7. data/lib/clapton/javascripts/src/c-base.ts +45 -33
  8. data/lib/clapton/javascripts/src/components/{box.ts → base.ts} +6 -8
  9. data/lib/clapton/javascripts/src/components/block-quote.spec.ts +1 -1
  10. data/lib/clapton/javascripts/src/components/block-quote.ts +2 -14
  11. data/lib/clapton/javascripts/src/components/bold.ts +2 -14
  12. data/lib/clapton/javascripts/src/components/button.ts +2 -19
  13. data/lib/clapton/javascripts/src/components/code.ts +2 -14
  14. data/lib/clapton/javascripts/src/components/component.ts +2 -2
  15. data/lib/clapton/javascripts/src/components/{box.spec.ts → div.spec.ts} +8 -8
  16. data/lib/clapton/javascripts/src/components/div.ts +8 -0
  17. data/lib/clapton/javascripts/src/components/element.ts +3 -9
  18. data/lib/clapton/javascripts/src/components/emphasis.ts +2 -14
  19. data/lib/clapton/javascripts/src/components/form.ts +2 -14
  20. data/lib/clapton/javascripts/src/components/heading.ts +4 -10
  21. data/lib/clapton/javascripts/src/components/image.spec.ts +2 -2
  22. data/lib/clapton/javascripts/src/components/image.ts +3 -14
  23. data/lib/clapton/javascripts/src/components/input.spec.ts +16 -0
  24. data/lib/clapton/javascripts/src/components/{datetime-field.ts → input.ts} +9 -11
  25. data/lib/clapton/javascripts/src/components/link.spec.ts +6 -6
  26. data/lib/clapton/javascripts/src/components/link.ts +3 -16
  27. data/lib/clapton/javascripts/src/components/list-item.ts +2 -14
  28. data/lib/clapton/javascripts/src/components/list.ts +2 -14
  29. data/lib/clapton/javascripts/src/components/ordered-list.ts +2 -14
  30. data/lib/clapton/javascripts/src/components/paragraph.ts +2 -14
  31. data/lib/clapton/javascripts/src/components/quote.ts +2 -14
  32. data/lib/clapton/javascripts/src/components/select.ts +3 -5
  33. data/lib/clapton/javascripts/src/components/span.ts +2 -14
  34. data/lib/clapton/javascripts/src/components/text-area.ts +4 -9
  35. data/lib/clapton/javascripts/src/components-for-test.ts +3 -6
  36. data/lib/clapton/javascripts/src/components.ts +3 -6
  37. data/lib/clapton/test_helper/base.rb +4 -4
  38. data/lib/clapton/version.rb +1 -1
  39. metadata +7 -14
  40. data/lib/clapton/javascripts/dist/c +0 -559
  41. data/lib/clapton/javascripts/dist/c-base.js +0 -589
  42. data/lib/clapton/javascripts/src/components/checkbox.spec.ts +0 -16
  43. data/lib/clapton/javascripts/src/components/checkbox.ts +0 -23
  44. data/lib/clapton/javascripts/src/components/datetime-field.spec.ts +0 -16
  45. data/lib/clapton/javascripts/src/components/radio-button.spec.ts +0 -16
  46. data/lib/clapton/javascripts/src/components/radio-button.ts +0 -23
  47. data/lib/clapton/javascripts/src/components/text-field.spec.ts +0 -16
  48. 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
- }