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
@@ -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
173
  }
342
174
 
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
- }
358
-
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;
@@ -402,21 +209,66 @@ class Component {
402
209
  }
403
210
  return root.renderWrapper;
404
211
  }
212
+ static effect(dependencies, callback) {
213
+ this._effects.push({ dependencies, callback });
214
+ }
215
+ get effects() {
216
+ return this.constructor._effects;
217
+ }
218
+ runEffects() {
219
+ this.effects.forEach((effect) => {
220
+ if (effect.dependencies.some((dependency) => this._state[dependency] !== undefined)) {
221
+ effect.callback(this._state);
222
+ }
223
+ });
224
+ }
225
+ runEffectOnFirstRender() {
226
+ this.effects.forEach((effect) => {
227
+ if (effect.dependencies.length === 0) {
228
+ effect.callback(this._state);
229
+ }
230
+ });
231
+ }
405
232
  }
233
+ Component._effects = [];
406
234
 
407
- class TextField {
235
+ class Input extends Base {
408
236
  constructor(state, attribute, attributes = {}) {
409
- this.state = state;
410
- this.attributes = attributes;
237
+ super(attributes);
411
238
  this.attribute = attribute;
239
+ this.state = state;
412
240
  this.attributes["data-attribute"] = attribute;
413
241
  }
414
242
  get renderWrapper() {
415
- 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 || ""}'/>`;
416
248
  }
417
- add_action(event, klass, fn, options = {}) {
418
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
419
- 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}`;
420
272
  }
421
273
  }
422
274
 
@@ -429,31 +281,27 @@ class Text {
429
281
  }
430
282
  }
431
283
 
432
- class TextArea {
284
+ class TextArea extends Base {
433
285
  constructor(state, attribute, attributes = {}) {
434
- this.state = state;
435
- this.attributes = attributes;
286
+ super(attributes);
436
287
  this.attribute = attribute;
288
+ this.state = state;
437
289
  this.attributes["data-attribute"] = attribute;
438
290
  }
439
291
  get renderWrapper() {
440
292
  return `<textarea ${htmlAttributes(this.attributes)}>${this.state[this.attribute] || ""}</textarea>`;
441
293
  }
442
- add_action(event, klass, fn, options = {}) {
443
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
444
- return this;
445
- }
446
294
  }
447
295
 
448
296
  const Clapton = {
449
- 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
450
298
  };
451
299
 
452
- const bq = (...props) => {
300
+ const blockquote = (...props) => {
453
301
  return new Clapton.BlockQuote(...props);
454
302
  };
455
- const box = (...props) => {
456
- return new Clapton.Box(...props);
303
+ const div = (...props) => {
304
+ return new Clapton.Div(...props);
457
305
  };
458
306
  const b = (...props) => {
459
307
  return new Clapton.Bold(...props);
@@ -461,15 +309,9 @@ const b = (...props) => {
461
309
  const button = (...props) => {
462
310
  return new Clapton.Button(...props);
463
311
  };
464
- const check = (...props) => {
465
- return new Clapton.Checkbox(props[0], props[1], props[2]);
466
- };
467
312
  const code = (...props) => {
468
313
  return new Clapton.Code(...props);
469
314
  };
470
- const datetime = (...props) => {
471
- return new Clapton.DateTimeField(props[0], props[1], props[2]);
472
- };
473
315
  const el = (...props) => {
474
316
  return new Clapton.Element(props[0], props[1]);
475
317
  };
@@ -482,14 +324,29 @@ const em = (...props) => {
482
324
  const form = (...props) => {
483
325
  return new Clapton.Form(...props);
484
326
  };
485
- const h = (...props) => {
486
- return new Clapton.Heading(props[0], props[1]);
327
+ const h1 = (...props) => {
328
+ return new Clapton.Heading(1, props[1]);
329
+ };
330
+ const h2 = (...props) => {
331
+ return new Clapton.Heading(2, props[1]);
332
+ };
333
+ const h3 = (...props) => {
334
+ return new Clapton.Heading(3, props[1]);
335
+ };
336
+ const h4 = (...props) => {
337
+ return new Clapton.Heading(4, props[1]);
338
+ };
339
+ const h5 = (...props) => {
340
+ return new Clapton.Heading(5, props[1]);
341
+ };
342
+ const h6 = (...props) => {
343
+ return new Clapton.Heading(6, props[1]);
487
344
  };
488
345
  const img = (...props) => {
489
- return new Clapton.Image(props[0], props[1], props[2]);
346
+ return new Clapton.Image(props[0]);
490
347
  };
491
348
  const a = (...props) => {
492
- return new Clapton.Link(props[0], props[1]);
349
+ return new Clapton.Link(props[0]);
493
350
  };
494
351
  const li = (...props) => {
495
352
  return new Clapton.ListItem(...props);
@@ -506,9 +363,6 @@ const p = (...props) => {
506
363
  const q = (...props) => {
507
364
  return new Clapton.Quote(...props);
508
365
  };
509
- const radio = (...props) => {
510
- return new Clapton.RadioButton(props[0], props[1], props[2]);
511
- };
512
366
  const select = (...props) => {
513
367
  return new Clapton.Select(props[0], props[1], props[2]);
514
368
  };
@@ -519,27 +373,23 @@ const textarea = (...props) => {
519
373
  return new Clapton.TextArea(props[0], props[1], props[2]);
520
374
  };
521
375
  const input = (...props) => {
522
- return new Clapton.TextField(props[0], props[1], props[2]);
376
+ return new Clapton.Input(props[0], props[1], props[2]);
523
377
  };
524
378
  const text = (...props) => {
525
379
  return new Clapton.Text(props[0]);
526
380
  };
527
381
  const c = (name, ...props) => {
528
382
  switch (name) {
529
- case "bq":
530
- return bq(...props);
531
- case "box":
532
- return box(...props);
383
+ case "blockquote":
384
+ return blockquote(...props);
385
+ case "div":
386
+ return div(...props);
533
387
  case "b":
534
388
  return b(...props);
535
389
  case "button":
536
390
  return button(...props);
537
- case "check":
538
- return check(...props);
539
391
  case "code":
540
392
  return code(...props);
541
- case "datetime":
542
- return datetime(...props);
543
393
  case "el":
544
394
  return el(...props);
545
395
  case "embed":
@@ -548,8 +398,18 @@ const c = (name, ...props) => {
548
398
  return em(...props);
549
399
  case "form":
550
400
  return form(...props);
551
- case "h":
552
- return h(...props);
401
+ case "h1":
402
+ return h1(...props);
403
+ case "h2":
404
+ return h2(...props);
405
+ case "h3":
406
+ return h3(...props);
407
+ case "h4":
408
+ return h4(...props);
409
+ case "h5":
410
+ return h5(...props);
411
+ case "h6":
412
+ return h6(...props);
553
413
  case "img":
554
414
  return img(...props);
555
415
  case "a":
@@ -564,8 +424,6 @@ const c = (name, ...props) => {
564
424
  return p(...props);
565
425
  case "q":
566
426
  return q(...props);
567
- case "radio":
568
- return radio(...props);
569
427
  case "select":
570
428
  return select(...props);
571
429
  case "span":
@@ -577,7 +435,7 @@ const c = (name, ...props) => {
577
435
  case "text":
578
436
  return text(...props);
579
437
  default:
580
- return new Clapton.Component(...props);
438
+ return new Clapton.Element(name, ...props);
581
439
  }
582
440
  };
583
441
 
@@ -1292,6 +1292,7 @@ const updateComponent = async (component, state, property, target) => {
1292
1292
  const ComponentClass = module[componentName];
1293
1293
  const instance = new ComponentClass(state, component.dataset.id);
1294
1294
  morphdom(component, instance.renderWrapper);
1295
+ instance.runEffects();
1295
1296
  };
1296
1297
 
1297
1298
  const initializeInputs = () => {
@@ -1333,6 +1334,7 @@ const claptonChannel = consumer.subscriptions.create("Clapton::ClaptonChannel",
1333
1334
 
1334
1335
  initializeInputs();
1335
1336
  initializeActions();
1337
+ instance.runEffects();
1336
1338
  }
1337
1339
  });
1338
1340
 
@@ -1440,6 +1442,7 @@ const createAndAppendComponent = async (component, element) => {
1440
1442
  element.outerHTML = firstChild.outerHTML;
1441
1443
  }
1442
1444
  }
1445
+ instance.runEffects();
1443
1446
  };
1444
1447
  document.addEventListener("DOMContentLoaded", async () => {
1445
1448
  await initializeComponents();