clapton 0.0.24 → 0.0.25
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/lib/clapton/javascripts/dist/c-for-test.js +108 -271
- data/lib/clapton/javascripts/dist/c.js +108 -271
- data/lib/clapton/javascripts/dist/components-for-test.js +69 -245
- data/lib/clapton/javascripts/dist/components.js +68 -241
- data/lib/clapton/javascripts/src/c-base.ts +45 -33
- 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} +9 -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 -14
- 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
@@ -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
|
-
}
|