clapton 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -40,155 +40,63 @@ const escapeHtml = (unsafe) => {
40
40
  .replace(/'/g, "'");
41
41
  };
42
42
 
43
- class BlockQuote {
43
+ class Base {
44
44
  constructor(attributes = {}) {
45
45
  this.children = [];
46
46
  this.attributes = attributes;
47
47
  }
48
- get renderWrapper() {
49
- return `<blockquote ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</blockquote>`;
50
- }
51
48
  add(child) {
52
49
  this.children.push(child);
53
50
  return this;
54
51
  }
55
- }
56
-
57
- class Box {
58
- constructor(attributes = {}) {
59
- this.children = [];
60
- this.attributes = attributes;
61
- }
62
- add(child) {
63
- this.children.push(child);
64
- return this;
65
- }
66
- get renderWrapper() {
67
- return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</div>`;
68
- }
69
52
  add_action(eventType, stateName, fnName, options = {}) {
70
53
  this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${eventType}->${stateName}#${fnName}@${options.debounce || 0}`;
71
54
  return this;
72
55
  }
56
+ get renderWrapper() {
57
+ return "";
58
+ }
73
59
  }
74
60
 
75
- class Button {
76
- constructor(attributes = {}) {
77
- this.attributes = attributes;
78
- this.children = [];
79
- }
80
- add(child) {
81
- this.children.push(child);
82
- return this;
83
- }
61
+ class BlockQuote extends Base {
84
62
  get renderWrapper() {
85
- return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</button>`;
86
- }
87
- add_action(event, klass, fn, options = {}) {
88
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
89
- return this;
63
+ return `<blockquote ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</blockquote>`;
90
64
  }
91
65
  }
92
66
 
93
- class Bold {
94
- constructor(attributes = {}) {
95
- this.children = [];
96
- this.attributes = attributes;
97
- }
67
+ class Div extends Base {
98
68
  get renderWrapper() {
99
- return `<strong ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</strong>`;
100
- }
101
- add(child) {
102
- this.children.push(child);
103
- return this;
69
+ return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</div>`;
104
70
  }
105
71
  }
106
72
 
107
- class Checkbox {
108
- constructor(state, attribute, attributes = {}) {
109
- this.state = state;
110
- this.attributes = attributes;
111
- this.attribute = attribute;
112
- this.attributes["data-attribute"] = attribute;
113
- }
73
+ class Button extends Base {
114
74
  get renderWrapper() {
115
- return `<input type='checkbox' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
116
- }
117
- add_action(event, klass, fn, options = {}) {
118
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
119
- return this;
75
+ return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</button>`;
120
76
  }
121
77
  }
122
78
 
123
- class Code {
124
- constructor(attributes = {}) {
125
- this.children = [];
126
- this.attributes = attributes;
127
- }
79
+ class Bold extends Base {
128
80
  get renderWrapper() {
129
- return `<code ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</code>`;
130
- }
131
- add(child) {
132
- this.children.push(child);
133
- return this;
81
+ return `<strong ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</strong>`;
134
82
  }
135
83
  }
136
84
 
137
- class DateTimeField {
138
- constructor(state, attribute, attributes = {}) {
139
- this.attributes = {};
140
- this.state = state;
141
- this.attribute = attribute;
142
- this.attributes = attributes;
143
- this.attributes["data-attribute"] = attribute;
144
- }
85
+ class Code extends Base {
145
86
  get renderWrapper() {
146
- const value = this.state[this.attribute] ? this.datetime_local_value(this.state[this.attribute]) : "";
147
- return `<input type='datetime-local' ${htmlAttributes(this.attributes)} value='${value}'/>`;
148
- }
149
- add_action(event, klass, fn, options = {}) {
150
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
151
- return this;
152
- }
153
- datetime_local_value(value) {
154
- if (!value) {
155
- return "";
156
- }
157
- const date = new Date(value);
158
- date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
159
- let month = date.getMonth() + 1;
160
- let day = date.getDate();
161
- let hours = date.getHours();
162
- let minutes = date.getMinutes();
163
- if (month < 10) {
164
- month = `0${month}`;
165
- }
166
- if (day < 10) {
167
- day = `0${day}`;
168
- }
169
- if (hours < 10) {
170
- hours = `0${hours}`;
171
- }
172
- if (minutes < 10) {
173
- minutes = `0${minutes}`;
174
- }
175
- return `${date.getFullYear()}-${month}-${day}T${hours}:${minutes}`;
87
+ return `<code ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</code>`;
176
88
  }
177
89
  }
178
90
 
179
- class Element {
91
+ class Element extends Base {
180
92
  constructor(type, attributes = {}) {
93
+ super(attributes);
181
94
  this.children = [];
182
95
  this.type = type;
183
- this.attributes = attributes;
184
96
  }
185
97
  get renderWrapper() {
186
98
  return `<${this.type} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</${this.type}>`;
187
99
  }
188
- add(child) {
189
- this.children.push(child);
190
- return this;
191
- }
192
100
  }
193
101
 
194
102
  class Embed {
@@ -200,187 +108,86 @@ class Embed {
200
108
  }
201
109
  }
202
110
 
203
- class Emphasis {
204
- constructor(attributes = {}) {
205
- this.children = [];
206
- this.attributes = attributes;
207
- }
111
+ class Emphasis extends Base {
208
112
  get renderWrapper() {
209
113
  return `<em ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</em>`;
210
114
  }
211
- add(child) {
212
- this.children.push(child);
213
- return this;
214
- }
215
115
  }
216
116
 
217
- class Form {
218
- constructor(attributes = {}) {
219
- this.children = [];
220
- this.attributes = attributes;
221
- }
117
+ class Form extends Base {
222
118
  get renderWrapper() {
223
119
  return `<form ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</form>`;
224
120
  }
225
- add(child) {
226
- this.children.push(child);
227
- return this;
228
- }
229
121
  }
230
122
 
231
- class Heading {
123
+ class Heading extends Base {
232
124
  constructor(level, attributes = {}) {
233
- this.children = [];
125
+ super(attributes);
234
126
  this.level = level;
235
- this.attributes = attributes;
236
127
  }
237
128
  get renderWrapper() {
238
129
  return `<h${this.level} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</h${this.level}>`;
239
130
  }
240
- add(child) {
241
- this.children.push(child);
242
- return this;
243
- }
244
131
  }
245
132
 
246
- class Image {
247
- constructor(src, alt, attributes = {}) {
248
- this.children = [];
249
- this.attributes = attributes;
250
- this.src = src;
251
- this.alt = alt;
252
- }
133
+ class Image extends Base {
253
134
  get renderWrapper() {
254
- return `<img src='${this.src}' alt='${this.alt}' ${htmlAttributes(this.attributes)}/>`;
135
+ return `<img ${htmlAttributes(this.attributes)}/>`;
255
136
  }
256
137
  }
257
138
 
258
- class Link {
259
- constructor(href, attributes = {}) {
260
- this.children = [];
261
- this.attributes = attributes;
262
- this.href = href;
263
- }
139
+ class Link extends Base {
264
140
  get renderWrapper() {
265
- return `<a href='${this.href}' ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</a>`;
266
- }
267
- add(child) {
268
- this.children.push(child);
269
- return this;
141
+ return `<a ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</a>`;
270
142
  }
271
143
  }
272
144
 
273
- class ListItem {
274
- constructor(attributes = {}) {
275
- this.children = [];
276
- this.attributes = attributes;
277
- }
278
- add(child) {
279
- this.children.push(child);
280
- return this;
281
- }
145
+ class ListItem extends Base {
282
146
  get renderWrapper() {
283
147
  return `<li ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</li>`;
284
148
  }
285
149
  }
286
150
 
287
- class List {
288
- constructor(attributes = {}) {
289
- this.children = [];
290
- this.attributes = attributes;
291
- }
292
- add(child) {
293
- this.children.push(child);
294
- return this;
295
- }
151
+ class List extends Base {
296
152
  get renderWrapper() {
297
153
  return `<ul ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</ul>`;
298
154
  }
299
155
  }
300
156
 
301
- class OrderedList {
302
- constructor(attributes = {}) {
303
- this.children = [];
304
- this.attributes = attributes;
305
- }
306
- add(child) {
307
- this.children.push(child);
308
- return this;
309
- }
157
+ class OrderedList extends Base {
310
158
  get renderWrapper() {
311
159
  return `<ol ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</ol>`;
312
160
  }
313
161
  }
314
162
 
315
- class Paragraph {
316
- constructor(attributes = {}) {
317
- this.children = [];
318
- this.attributes = attributes;
319
- }
163
+ class Paragraph extends Base {
320
164
  get renderWrapper() {
321
165
  return `<p ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</p>`;
322
166
  }
323
- add(child) {
324
- this.children.push(child);
325
- return this;
326
- }
327
167
  }
328
168
 
329
- class Quote {
330
- constructor(attributes = {}) {
331
- this.children = [];
332
- this.attributes = attributes;
333
- }
169
+ class Quote extends Base {
334
170
  get renderWrapper() {
335
171
  return `<q ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</q>`;
336
172
  }
337
- add(child) {
338
- this.children.push(child);
339
- return this;
340
- }
341
- }
342
-
343
- class RadioButton {
344
- constructor(state, attribute, attributes = {}) {
345
- this.state = state;
346
- this.attributes = attributes;
347
- this.attribute = attribute;
348
- this.attributes["data-attribute"] = attribute;
349
- }
350
- get renderWrapper() {
351
- return `<input type='radio' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
352
- }
353
- add_action(event, klass, fn, options = {}) {
354
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
355
- return this;
356
- }
357
173
  }
358
174
 
359
- class Select {
175
+ class Select extends Base {
360
176
  constructor(options = [], state, attribute, attributes = {}) {
361
- this.children = [];
177
+ super(attributes);
362
178
  this.options = options;
363
179
  this.state = state;
364
180
  this.attribute = attribute;
365
- this.attributes = attributes;
366
181
  }
367
182
  get renderWrapper() {
368
183
  return `<select ${htmlAttributes(this.attributes)}>${this.options.map(option => `<option value='${option.value}'${option.value === this.state[this.attribute] ? " selected" : ""}>${option.text}</option>`).join("")}${this.children.map(child => child.renderWrapper).join("")}</select>`;
369
184
  }
370
185
  }
371
186
 
372
- class Span {
373
- constructor(attributes = {}) {
374
- this.children = [];
375
- this.attributes = attributes;
376
- }
187
+ class Span extends Base {
377
188
  get renderWrapper() {
378
189
  return `<span ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</span>`;
379
190
  }
380
- add(child) {
381
- this.children.push(child);
382
- return this;
383
- }
384
191
  }
385
192
 
386
193
  class Component {
@@ -390,7 +197,7 @@ class Component {
390
197
  this._errors = errors;
391
198
  }
392
199
  get render() {
393
- return new Box({});
200
+ return new Div({});
394
201
  }
395
202
  get renderWrapper() {
396
203
  const root = this.render;
@@ -425,19 +232,43 @@ class Component {
425
232
  }
426
233
  Component._effects = [];
427
234
 
428
- class TextField {
235
+ class Input extends Base {
429
236
  constructor(state, attribute, attributes = {}) {
430
- this.state = state;
431
- this.attributes = attributes;
237
+ super(attributes);
432
238
  this.attribute = attribute;
239
+ this.state = state;
433
240
  this.attributes["data-attribute"] = attribute;
434
241
  }
435
242
  get renderWrapper() {
436
- return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
243
+ let value = this.state[this.attribute];
244
+ if (this.attributes.type === "datetime-local" && value) {
245
+ value = this.datetime_local_value(value);
246
+ }
247
+ return `<input ${htmlAttributes(this.attributes)} value='${value || ""}'/>`;
437
248
  }
438
- add_action(event, klass, fn, options = {}) {
439
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
440
- return this;
249
+ datetime_local_value(value) {
250
+ if (!value) {
251
+ return "";
252
+ }
253
+ const date = new Date(value);
254
+ date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
255
+ let month = date.getMonth() + 1;
256
+ let day = date.getDate();
257
+ let hours = date.getHours();
258
+ let minutes = date.getMinutes();
259
+ if (month < 10) {
260
+ month = `0${month}`;
261
+ }
262
+ if (day < 10) {
263
+ day = `0${day}`;
264
+ }
265
+ if (hours < 10) {
266
+ hours = `0${hours}`;
267
+ }
268
+ if (minutes < 10) {
269
+ minutes = `0${minutes}`;
270
+ }
271
+ return `${date.getFullYear()}-${month}-${day}T${hours}:${minutes}`;
441
272
  }
442
273
  }
443
274
 
@@ -450,24 +281,20 @@ class Text {
450
281
  }
451
282
  }
452
283
 
453
- class TextArea {
284
+ class TextArea extends Base {
454
285
  constructor(state, attribute, attributes = {}) {
455
- this.state = state;
456
- this.attributes = attributes;
286
+ super(attributes);
457
287
  this.attribute = attribute;
288
+ this.state = state;
458
289
  this.attributes["data-attribute"] = attribute;
459
290
  }
460
291
  get renderWrapper() {
461
292
  return `<textarea ${htmlAttributes(this.attributes)}>${this.state[this.attribute] || ""}</textarea>`;
462
293
  }
463
- add_action(event, klass, fn, options = {}) {
464
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
465
- return this;
466
- }
467
294
  }
468
295
 
469
296
  const Clapton = {
470
- Box, Component, Text, TextField, Button, DateTimeField, BlockQuote, Checkbox, Code, Element, Emphasis, Form, Heading, Image, Link, List, ListItem, OrderedList, Paragraph, Quote, RadioButton, Select, Span, Embed, Bold, TextArea
297
+ Div, Component, Text, Input, Button, BlockQuote, Code, Element, Emphasis, Form, Heading, Image, Link, List, ListItem, OrderedList, Paragraph, Quote, Select, Span, Embed, Bold, TextArea
471
298
  };
472
299
 
473
300
  export { Clapton };
@@ -1,11 +1,11 @@
1
1
  import { Clapton } from "components"
2
2
 
3
- const bq = (...props: any[]) => {
3
+ const blockquote = (...props: any[]) => {
4
4
  return new Clapton.BlockQuote(...props)
5
5
  }
6
6
 
7
- const box = (...props: any[]) => {
8
- return new Clapton.Box(...props)
7
+ const div = (...props: any[]) => {
8
+ return new Clapton.Div(...props)
9
9
  }
10
10
 
11
11
  const b = (...props: any[]) => {
@@ -16,18 +16,10 @@ const button = (...props: any[]) => {
16
16
  return new Clapton.Button(...props)
17
17
  }
18
18
 
19
- const check = (...props: any[]) => {
20
- return new Clapton.Checkbox(props[0], props[1], props[2])
21
- }
22
-
23
19
  const code = (...props: any[]) => {
24
20
  return new Clapton.Code(...props)
25
21
  }
26
22
 
27
- const datetime = (...props: any[]) => {
28
- return new Clapton.DateTimeField(props[0], props[1], props[2])
29
- }
30
-
31
23
  const el = (...props: any[]) => {
32
24
  return new Clapton.Element(props[0], props[1])
33
25
  }
@@ -44,16 +36,36 @@ const form = (...props: any[]) => {
44
36
  return new Clapton.Form(...props)
45
37
  }
46
38
 
47
- const h = (...props: any[]) => {
48
- return new Clapton.Heading(props[0], props[1])
39
+ const h1 = (...props: any[]) => {
40
+ return new Clapton.Heading(1, props[1])
41
+ }
42
+
43
+ const h2 = (...props: any[]) => {
44
+ return new Clapton.Heading(2, props[1])
45
+ }
46
+
47
+ const h3 = (...props: any[]) => {
48
+ return new Clapton.Heading(3, props[1])
49
+ }
50
+
51
+ const h4 = (...props: any[]) => {
52
+ return new Clapton.Heading(4, props[1])
53
+ }
54
+
55
+ const h5 = (...props: any[]) => {
56
+ return new Clapton.Heading(5, props[1])
57
+ }
58
+
59
+ const h6 = (...props: any[]) => {
60
+ return new Clapton.Heading(6, props[1])
49
61
  }
50
62
 
51
63
  const img = (...props: any[]) => {
52
- return new Clapton.Image(props[0], props[1], props[2])
64
+ return new Clapton.Image(props[0])
53
65
  }
54
66
 
55
67
  const a = (...props: any[]) => {
56
- return new Clapton.Link(props[0], props[1])
68
+ return new Clapton.Link(props[0])
57
69
  }
58
70
 
59
71
  const li = (...props: any[]) => {
@@ -76,10 +88,6 @@ const q = (...props: any[]) => {
76
88
  return new Clapton.Quote(...props)
77
89
  }
78
90
 
79
- const radio = (...props: any[]) => {
80
- return new Clapton.RadioButton(props[0], props[1], props[2])
81
- }
82
-
83
91
  const select = (...props: any[]) => {
84
92
  return new Clapton.Select(props[0], props[1], props[2])
85
93
  }
@@ -93,7 +101,7 @@ const textarea = (...props: any[]) => {
93
101
  }
94
102
 
95
103
  const input = (...props: any[]) => {
96
- return new Clapton.TextField(props[0], props[1], props[2])
104
+ return new Clapton.Input(props[0], props[1], props[2])
97
105
  }
98
106
 
99
107
  const text = (...props: any[]) => {
@@ -102,20 +110,16 @@ const text = (...props: any[]) => {
102
110
 
103
111
  const c = (name: string, ...props: any[]) => {
104
112
  switch (name) {
105
- case "bq":
106
- return bq(...props)
107
- case "box":
108
- return box(...props)
113
+ case "blockquote":
114
+ return blockquote(...props)
115
+ case "div":
116
+ return div(...props)
109
117
  case "b":
110
118
  return b(...props)
111
119
  case "button":
112
120
  return button(...props)
113
- case "check":
114
- return check(...props)
115
121
  case "code":
116
122
  return code(...props)
117
- case "datetime":
118
- return datetime(...props)
119
123
  case "el":
120
124
  return el(...props)
121
125
  case "embed":
@@ -124,8 +128,18 @@ const c = (name: string, ...props: any[]) => {
124
128
  return em(...props)
125
129
  case "form":
126
130
  return form(...props)
127
- case "h":
128
- return h(...props)
131
+ case "h1":
132
+ return h1(...props)
133
+ case "h2":
134
+ return h2(...props)
135
+ case "h3":
136
+ return h3(...props)
137
+ case "h4":
138
+ return h4(...props)
139
+ case "h5":
140
+ return h5(...props)
141
+ case "h6":
142
+ return h6(...props)
129
143
  case "img":
130
144
  return img(...props)
131
145
  case "a":
@@ -140,8 +154,6 @@ const c = (name: string, ...props: any[]) => {
140
154
  return p(...props)
141
155
  case "q":
142
156
  return q(...props)
143
- case "radio":
144
- return radio(...props)
145
157
  case "select":
146
158
  return select(...props)
147
159
  case "span":
@@ -153,7 +165,7 @@ const c = (name: string, ...props: any[]) => {
153
165
  case "text":
154
166
  return text(...props)
155
167
  default:
156
- return new Clapton.Component(...props)
168
+ return new Clapton.Element(name, ...props)
157
169
  }
158
170
  }
159
171
 
@@ -1,6 +1,4 @@
1
- import { htmlAttributes } from "../html/html-attributes";
2
-
3
- export class Box {
1
+ export class Base {
4
2
  attributes: Record<string, any>;
5
3
  children: any[];
6
4
 
@@ -9,17 +7,17 @@ export class Box {
9
7
  this.attributes = attributes;
10
8
  }
11
9
 
12
- add(child: any): this {
10
+ add(child: any): Base {
13
11
  this.children.push(child);
14
12
  return this;
15
13
  }
16
14
 
17
- get renderWrapper(): string {
18
- return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</div>`;
19
- }
20
-
21
15
  add_action(eventType: string, stateName: string, fnName: string, options: Record<string, any> = {}): this {
22
16
  this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${eventType}->${stateName}#${fnName}@${options.debounce || 0}`;
23
17
  return this;
24
18
  }
19
+
20
+ get renderWrapper() {
21
+ return "";
22
+ }
25
23
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest"
2
- import { BlockQuote } from "./block-quote"
2
+ import { BlockQuote} from "./block-quote"
3
3
  import { Text } from "./text"
4
4
 
5
5
  describe("BlockQuote", () => {
@@ -1,20 +1,8 @@
1
1
  import { htmlAttributes } from "../html/html-attributes";
2
+ import { Base } from "./base";
2
3
 
3
- export class BlockQuote {
4
- attributes: Record<string, any>;
5
- children: any[];
6
-
7
- constructor(attributes: Record<string, any> = {}) {
8
- this.children = [];
9
- this.attributes = attributes;
10
- }
11
-
4
+ export class BlockQuote extends Base {
12
5
  get renderWrapper(): string {
13
6
  return `<blockquote ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</blockquote>`;
14
7
  }
15
-
16
- add(child: any): BlockQuote {
17
- this.children.push(child);
18
- return this;
19
- }
20
8
  }