From 7e96ca08adcf741ceb46ce6a771d88e14867c2a8 Mon Sep 17 00:00:00 2001 From: Moeki Kawakami Date: Sat, 19 Oct 2024 20:45:51 +0900 Subject: [PATCH] Fix c method --- lib/clapton/javascripts/dist/c-for-test.js | 18 ++++++++++++++++++ lib/clapton/javascripts/dist/c.js | 18 ++++++++++++++++++ .../javascripts/dist/components-for-test.js | 3 +++ lib/clapton/javascripts/dist/components.js | 3 +++ lib/clapton/javascripts/src/c-base.ts | 15 +++++++++++++++ .../javascripts/src/components/input.ts | 3 +++ 6 files changed, 60 insertions(+) diff --git a/lib/clapton/javascripts/dist/c-for-test.js b/lib/clapton/javascripts/dist/c-for-test.js index a554ca3..0bac19c 100644 --- a/lib/clapton/javascripts/dist/c-for-test.js +++ b/lib/clapton/javascripts/dist/c-for-test.js @@ -244,6 +244,9 @@ var c = (function () { } get renderWrapper() { let value = this.state[this.attribute]; + if (!this.attributes.type) { + this.attributes.type = "text"; + } if (this.attributes.type === "datetime-local" && value) { value = this.datetime_local_value(value); } @@ -383,6 +386,10 @@ var c = (function () { }; const c = (name, ...props) => { switch (name) { + case "bq": + return blockquote(...props); + case "box": + return div(...props); case "blockquote": return blockquote(...props); case "div": @@ -401,6 +408,8 @@ var c = (function () { return em(...props); case "form": return form(...props); + case "h": + return h1(...props); case "h1": return h1(...props); case "h2": @@ -437,6 +446,15 @@ var c = (function () { return input(...props); case "text": return text(...props); + case "radio": + props[3].type = "radio"; + return input(...props); + case "datetime": + props[3].type = "datetime-local"; + return input(...props); + case "check": + props[3].type = "checkbox"; + return input(...props); default: return new Clapton.Element(name, ...props); } diff --git a/lib/clapton/javascripts/dist/c.js b/lib/clapton/javascripts/dist/c.js index 2ed5d2f..23abdc3 100644 --- a/lib/clapton/javascripts/dist/c.js +++ b/lib/clapton/javascripts/dist/c.js @@ -241,6 +241,9 @@ class Input extends Base { } get renderWrapper() { let value = this.state[this.attribute]; + if (!this.attributes.type) { + this.attributes.type = "text"; + } if (this.attributes.type === "datetime-local" && value) { value = this.datetime_local_value(value); } @@ -380,6 +383,10 @@ const text = (...props) => { }; const c = (name, ...props) => { switch (name) { + case "bq": + return blockquote(...props); + case "box": + return div(...props); case "blockquote": return blockquote(...props); case "div": @@ -398,6 +405,8 @@ const c = (name, ...props) => { return em(...props); case "form": return form(...props); + case "h": + return h1(...props); case "h1": return h1(...props); case "h2": @@ -434,6 +443,15 @@ const c = (name, ...props) => { return input(...props); case "text": return text(...props); + case "radio": + props[3].type = "radio"; + return input(...props); + case "datetime": + props[3].type = "datetime-local"; + return input(...props); + case "check": + props[3].type = "checkbox"; + return input(...props); default: return new Clapton.Element(name, ...props); } diff --git a/lib/clapton/javascripts/dist/components-for-test.js b/lib/clapton/javascripts/dist/components-for-test.js index 2a42aaf..7418ab4 100644 --- a/lib/clapton/javascripts/dist/components-for-test.js +++ b/lib/clapton/javascripts/dist/components-for-test.js @@ -244,6 +244,9 @@ var Clapton = (function (exports) { } get renderWrapper() { let value = this.state[this.attribute]; + if (!this.attributes.type) { + this.attributes.type = "text"; + } if (this.attributes.type === "datetime-local" && value) { value = this.datetime_local_value(value); } diff --git a/lib/clapton/javascripts/dist/components.js b/lib/clapton/javascripts/dist/components.js index e803c04..60e2ebf 100644 --- a/lib/clapton/javascripts/dist/components.js +++ b/lib/clapton/javascripts/dist/components.js @@ -241,6 +241,9 @@ class Input extends Base { } get renderWrapper() { let value = this.state[this.attribute]; + if (!this.attributes.type) { + this.attributes.type = "text"; + } if (this.attributes.type === "datetime-local" && value) { value = this.datetime_local_value(value); } diff --git a/lib/clapton/javascripts/src/c-base.ts b/lib/clapton/javascripts/src/c-base.ts index e0ff060..723eb27 100644 --- a/lib/clapton/javascripts/src/c-base.ts +++ b/lib/clapton/javascripts/src/c-base.ts @@ -110,6 +110,10 @@ const text = (...props: any[]) => { const c = (name: string, ...props: any[]) => { switch (name) { + case "bq": + return blockquote(...props) + case "box": + return div(...props) case "blockquote": return blockquote(...props) case "div": @@ -128,6 +132,8 @@ const c = (name: string, ...props: any[]) => { return em(...props) case "form": return form(...props) + case "h": + return h1(...props) case "h1": return h1(...props) case "h2": @@ -164,6 +170,15 @@ const c = (name: string, ...props: any[]) => { return input(...props) case "text": return text(...props) + case "radio": + props[3].type = "radio" + return input(...props) + case "datetime": + props[3].type = "datetime-local" + return input(...props) + case "check": + props[3].type = "checkbox" + return input(...props) default: return new Clapton.Element(name, ...props) } diff --git a/lib/clapton/javascripts/src/components/input.ts b/lib/clapton/javascripts/src/components/input.ts index a3298ea..d0f19a6 100644 --- a/lib/clapton/javascripts/src/components/input.ts +++ b/lib/clapton/javascripts/src/components/input.ts @@ -14,6 +14,9 @@ export class Input extends Base { get renderWrapper(): string { let value = this.state[this.attribute] + if (!this.attributes.type) { + this.attributes.type = "text" + } if (this.attributes.type === "datetime-local" && value) { value = this.datetime_local_value(value) }