clapton 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/app/helpers/clapton/clapton_helper.rb +16 -1
  4. data/lib/clapton/engine.rb +20 -10
  5. data/lib/clapton/javascripts/dist/client.js +38 -27
  6. data/lib/clapton/javascripts/dist/components-for-test.js +439 -0
  7. data/lib/clapton/javascripts/dist/components.js +356 -382
  8. data/lib/clapton/javascripts/node_modules/diff-dom/LICENSE.txt +165 -0
  9. data/lib/clapton/javascripts/node_modules/diff-dom/README.md +224 -0
  10. data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js +2 -0
  11. data/lib/clapton/javascripts/node_modules/diff-dom/browser/diffDOM.js.map +1 -0
  12. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/TraceLogger.d.ts +28 -0
  13. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/apply.d.ts +4 -0
  14. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/fromVirtual.d.ts +2 -0
  15. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/index.d.ts +2 -0
  16. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/dom/undo.d.ts +3 -0
  17. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/helpers.d.ts +11 -0
  18. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/index.d.ts +10 -0
  19. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/types.d.ts +104 -0
  20. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/apply.d.ts +3 -0
  21. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/diff.d.ts +22 -0
  22. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromDOM.d.ts +2 -0
  23. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/fromString.d.ts +2 -0
  24. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/helpers.d.ts +40 -0
  25. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/diffDOM/virtual/index.d.ts +3 -0
  26. data/lib/clapton/javascripts/node_modules/diff-dom/dist/dts/index.d.ts +2 -0
  27. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.d.ts +136 -0
  28. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js +1996 -0
  29. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.js.map +1 -0
  30. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js +2 -0
  31. data/lib/clapton/javascripts/node_modules/diff-dom/dist/index.min.js.map +1 -0
  32. data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js +1991 -0
  33. data/lib/clapton/javascripts/node_modules/diff-dom/dist/module.js.map +1 -0
  34. data/lib/clapton/javascripts/node_modules/diff-dom/index.html +62 -0
  35. data/lib/clapton/javascripts/node_modules/diff-dom/package.json +54 -0
  36. data/lib/clapton/javascripts/node_modules/diff-dom/rollup.config.mjs +67 -0
  37. data/lib/clapton/javascripts/node_modules/diff-dom/src/TraceLogger.ts +143 -0
  38. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/apply.ts +227 -0
  39. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/fromVirtual.ts +83 -0
  40. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/index.ts +2 -0
  41. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/dom/undo.ts +90 -0
  42. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/helpers.ts +40 -0
  43. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/index.ts +121 -0
  44. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/types.ts +154 -0
  45. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/apply.ts +349 -0
  46. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/diff.ts +855 -0
  47. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromDOM.ts +74 -0
  48. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/fromString.ts +239 -0
  49. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/helpers.ts +461 -0
  50. data/lib/clapton/javascripts/node_modules/diff-dom/src/diffDOM/virtual/index.ts +3 -0
  51. data/lib/clapton/javascripts/node_modules/diff-dom/src/index.ts +2 -0
  52. data/lib/clapton/javascripts/node_modules/diff-dom/tsconfig.json +103 -0
  53. data/lib/clapton/javascripts/rollup.config.mjs +17 -2
  54. data/lib/clapton/javascripts/src/actions/handle-action.ts +6 -6
  55. data/lib/clapton/javascripts/src/actions/initialize-actions.ts +6 -3
  56. data/lib/clapton/javascripts/src/channel/clapton-channel.js +6 -3
  57. data/lib/clapton/javascripts/src/client.ts +15 -15
  58. data/lib/clapton/javascripts/src/components-for-test.ts +29 -0
  59. data/lib/clapton/javascripts/src/components.ts +4 -1
  60. data/lib/clapton/javascripts/src/dom/update-component.ts +4 -4
  61. data/lib/clapton/javascripts/src/inputs/initialize-inputs.ts +2 -2
  62. data/lib/clapton/test_helper/base.rb +1 -1
  63. data/lib/clapton/version.rb +1 -2
  64. metadata +49 -3
  65. data/lib/clapton/javascripts/src/dom/update-component.spec.ts +0 -32
@@ -1,439 +1,413 @@
1
- var Clapton = (function (exports) {
2
- 'use strict';
3
-
4
- const htmlAttributes = (params) => {
5
- const customDataAttributes = params.data || {};
6
- const others = Object.keys(params).filter(key => key !== "data");
7
- const flattenDataAttributes = (data, prefix = "data") => {
8
- return Object.keys(data).reduce((acc, key) => {
9
- const value = data[key];
10
- if (typeof value === "object" && value !== null) {
11
- acc.push(...flattenDataAttributes(value, `${prefix}-${key}`));
1
+ const htmlAttributes = (params) => {
2
+ const customDataAttributes = params.data || {};
3
+ const others = Object.keys(params).filter(key => key !== "data");
4
+ const flattenDataAttributes = (data, prefix = "data") => {
5
+ return Object.keys(data).reduce((acc, key) => {
6
+ const value = data[key];
7
+ if (typeof value === "object" && value !== null) {
8
+ acc.push(...flattenDataAttributes(value, `${prefix}-${key}`));
9
+ }
10
+ else {
11
+ acc.push(`${prefix}-${key}='${escapeHtml(value)}'`);
12
+ }
13
+ return acc;
14
+ }, []);
15
+ };
16
+ return [
17
+ others.map(key => {
18
+ if (key === "disabled") {
19
+ if (params[key] === false) {
20
+ return "";
12
21
  }
13
22
  else {
14
- acc.push(`${prefix}-${key}='${escapeHtml(value)}'`);
15
- }
16
- return acc;
17
- }, []);
18
- };
19
- return [
20
- others.map(key => {
21
- if (key === "disabled") {
22
- if (params[key] === false) {
23
- return "";
24
- }
25
- else {
26
- return `${key}`;
27
- }
23
+ return `${key}`;
28
24
  }
29
- return `${key}='${escapeHtml(params[key])}'`;
30
- }).join(" "),
31
- flattenDataAttributes(customDataAttributes).join(" ")
32
- ].filter(Boolean).join(" ");
33
- };
34
- const escapeHtml = (unsafe) => {
35
- if (typeof unsafe !== "string") {
36
- return "";
37
- }
38
- return unsafe
39
- .replace(/&/g, "&")
40
- .replace(/</g, "&lt;")
41
- .replace(/>/g, "&gt;")
42
- .replace(/"/g, "&quot;")
43
- .replace(/'/g, "&#039;");
44
- };
25
+ }
26
+ return `${key}='${escapeHtml(params[key])}'`;
27
+ }).join(" "),
28
+ flattenDataAttributes(customDataAttributes).join(" ")
29
+ ].filter(Boolean).join(" ");
30
+ };
31
+ const escapeHtml = (unsafe) => {
32
+ if (typeof unsafe !== "string") {
33
+ return "";
34
+ }
35
+ return unsafe
36
+ .replace(/&/g, "&amp;")
37
+ .replace(/</g, "&lt;")
38
+ .replace(/>/g, "&gt;")
39
+ .replace(/"/g, "&quot;")
40
+ .replace(/'/g, "&#039;");
41
+ };
45
42
 
46
- class BlockQuote {
47
- constructor(attributes = {}) {
48
- this.children = [];
49
- this.attributes = attributes;
50
- }
51
- get render() {
52
- return `<blockquote ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</blockquote>`;
53
- }
54
- add(child) {
55
- this.children.push(child);
56
- return this;
57
- }
43
+ class BlockQuote {
44
+ constructor(attributes = {}) {
45
+ this.children = [];
46
+ this.attributes = attributes;
47
+ }
48
+ get render() {
49
+ return `<blockquote ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</blockquote>`;
58
50
  }
51
+ add(child) {
52
+ this.children.push(child);
53
+ return this;
54
+ }
55
+ }
59
56
 
60
- class Box {
61
- constructor(attributes = {}) {
62
- this.children = [];
63
- this.attributes = attributes;
64
- }
65
- add(child) {
66
- this.children.push(child);
67
- return this;
68
- }
69
- get render() {
70
- return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</div>`;
71
- }
72
- add_action(eventType, stateName, fnName, options = {}) {
73
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${eventType}->${stateName}#${fnName}@${options.debounce || 0}`;
74
- return this;
75
- }
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;
76
65
  }
66
+ get render() {
67
+ return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</div>`;
68
+ }
69
+ add_action(eventType, stateName, fnName, options = {}) {
70
+ this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${eventType}->${stateName}#${fnName}@${options.debounce || 0}`;
71
+ return this;
72
+ }
73
+ }
77
74
 
78
- class Button {
79
- constructor(attributes = {}) {
80
- this.attributes = attributes;
81
- this.children = [];
82
- }
83
- add(child) {
84
- this.children.push(child);
85
- return this;
86
- }
87
- get render() {
88
- return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</button>`;
89
- }
90
- add_action(event, klass, fn, options = {}) {
91
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
92
- return this;
93
- }
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
+ }
84
+ get render() {
85
+ return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</button>`;
94
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;
90
+ }
91
+ }
95
92
 
96
- class Checkbox {
97
- constructor(state, attribute, attributes = {}) {
98
- this.state = state;
99
- this.attributes = attributes;
100
- this.attribute = attribute;
101
- this.attributes["data-attribute"] = attribute;
102
- }
103
- get render() {
104
- return `<input type='checkbox' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
105
- }
106
- add_action(event, klass, fn, options = {}) {
107
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
108
- return this;
109
- }
93
+ class Checkbox {
94
+ constructor(state, attribute, attributes = {}) {
95
+ this.state = state;
96
+ this.attributes = attributes;
97
+ this.attribute = attribute;
98
+ this.attributes["data-attribute"] = attribute;
110
99
  }
100
+ get render() {
101
+ return `<input type='checkbox' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
102
+ }
103
+ add_action(event, klass, fn, options = {}) {
104
+ this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
105
+ return this;
106
+ }
107
+ }
111
108
 
112
- class Code {
113
- constructor(attributes = {}) {
114
- this.children = [];
115
- this.attributes = attributes;
116
- }
117
- get render() {
118
- return `<code ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</code>`;
119
- }
120
- add(child) {
121
- this.children.push(child);
122
- return this;
123
- }
109
+ class Code {
110
+ constructor(attributes = {}) {
111
+ this.children = [];
112
+ this.attributes = attributes;
124
113
  }
114
+ get render() {
115
+ return `<code ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</code>`;
116
+ }
117
+ add(child) {
118
+ this.children.push(child);
119
+ return this;
120
+ }
121
+ }
125
122
 
126
- class DateTimeField {
127
- constructor(state, attribute, attributes = {}) {
128
- this.attributes = {};
129
- this.state = state;
130
- this.attribute = attribute;
131
- this.attributes = attributes;
132
- this.attributes["data-attribute"] = attribute;
123
+ class DateTimeField {
124
+ constructor(state, attribute, attributes = {}) {
125
+ this.attributes = {};
126
+ this.state = state;
127
+ this.attribute = attribute;
128
+ this.attributes = attributes;
129
+ this.attributes["data-attribute"] = attribute;
130
+ }
131
+ get render() {
132
+ const value = this.state[this.attribute] ? this.datetime_local_value(this.state[this.attribute]) : "";
133
+ return `<input type='datetime-local' ${htmlAttributes(this.attributes)} value='${value}'/>`;
134
+ }
135
+ add_action(event, klass, fn, options = {}) {
136
+ this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
137
+ return this;
138
+ }
139
+ datetime_local_value(value) {
140
+ if (!value) {
141
+ return "";
133
142
  }
134
- get render() {
135
- const value = this.state[this.attribute] ? this.datetime_local_value(this.state[this.attribute]) : "";
136
- return `<input type='datetime-local' ${htmlAttributes(this.attributes)} value='${value}'/>`;
143
+ const date = new Date(value);
144
+ date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
145
+ let month = date.getMonth() + 1;
146
+ let day = date.getDate();
147
+ let hours = date.getHours();
148
+ let minutes = date.getMinutes();
149
+ if (month < 10) {
150
+ month = `0${month}`;
137
151
  }
138
- add_action(event, klass, fn, options = {}) {
139
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
140
- return this;
152
+ if (day < 10) {
153
+ day = `0${day}`;
141
154
  }
142
- datetime_local_value(value) {
143
- if (!value) {
144
- return "";
145
- }
146
- const date = new Date(value);
147
- date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
148
- let month = date.getMonth() + 1;
149
- let day = date.getDate();
150
- let hours = date.getHours();
151
- let minutes = date.getMinutes();
152
- if (month < 10) {
153
- month = `0${month}`;
154
- }
155
- if (day < 10) {
156
- day = `0${day}`;
157
- }
158
- if (hours < 10) {
159
- hours = `0${hours}`;
160
- }
161
- if (minutes < 10) {
162
- minutes = `0${minutes}`;
163
- }
164
- return `${date.getFullYear()}-${month}-${day}T${hours}:${minutes}`;
155
+ if (hours < 10) {
156
+ hours = `0${hours}`;
165
157
  }
166
- }
167
-
168
- class Element {
169
- constructor(type, attributes = {}) {
170
- this.children = [];
171
- this.type = type;
172
- this.attributes = attributes;
173
- }
174
- get render() {
175
- return `<${this.type} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</${this.type}>`;
176
- }
177
- add(child) {
178
- this.children.push(child);
179
- return this;
158
+ if (minutes < 10) {
159
+ minutes = `0${minutes}`;
180
160
  }
161
+ return `${date.getFullYear()}-${month}-${day}T${hours}:${minutes}`;
181
162
  }
163
+ }
182
164
 
183
- class Embed {
184
- constructor(html) {
185
- this.html = html;
186
- }
187
- get render() {
188
- return this.html;
189
- }
165
+ class Element {
166
+ constructor(type, attributes = {}) {
167
+ this.children = [];
168
+ this.type = type;
169
+ this.attributes = attributes;
170
+ }
171
+ get render() {
172
+ return `<${this.type} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</${this.type}>`;
190
173
  }
174
+ add(child) {
175
+ this.children.push(child);
176
+ return this;
177
+ }
178
+ }
191
179
 
192
- class Emphasis {
193
- constructor(attributes = {}) {
194
- this.children = [];
195
- this.attributes = attributes;
196
- }
197
- get render() {
198
- return `<em ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</em>`;
199
- }
200
- add(child) {
201
- this.children.push(child);
202
- return this;
203
- }
180
+ class Embed {
181
+ constructor(html) {
182
+ this.html = html;
204
183
  }
184
+ get render() {
185
+ return this.html;
186
+ }
187
+ }
205
188
 
206
- class Form {
207
- constructor(attributes = {}) {
208
- this.children = [];
209
- this.attributes = attributes;
210
- }
211
- get render() {
212
- return `<form ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</form>`;
213
- }
214
- add(child) {
215
- this.children.push(child);
216
- return this;
217
- }
189
+ class Emphasis {
190
+ constructor(attributes = {}) {
191
+ this.children = [];
192
+ this.attributes = attributes;
193
+ }
194
+ get render() {
195
+ return `<em ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</em>`;
196
+ }
197
+ add(child) {
198
+ this.children.push(child);
199
+ return this;
218
200
  }
201
+ }
219
202
 
220
- class Heading {
221
- constructor(level, attributes = {}) {
222
- this.children = [];
223
- this.level = level;
224
- this.attributes = attributes;
225
- }
226
- get render() {
227
- return `<h${this.level} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</h${this.level}>`;
228
- }
229
- add(child) {
230
- this.children.push(child);
231
- return this;
232
- }
203
+ class Form {
204
+ constructor(attributes = {}) {
205
+ this.children = [];
206
+ this.attributes = attributes;
207
+ }
208
+ get render() {
209
+ return `<form ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</form>`;
210
+ }
211
+ add(child) {
212
+ this.children.push(child);
213
+ return this;
233
214
  }
215
+ }
234
216
 
235
- class Image {
236
- constructor(src, alt, attributes = {}) {
237
- this.children = [];
238
- this.attributes = attributes;
239
- this.src = src;
240
- this.alt = alt;
241
- }
242
- get render() {
243
- return `<img src='${this.src}' alt='${this.alt}' ${htmlAttributes(this.attributes)}/>`;
244
- }
217
+ class Heading {
218
+ constructor(level, attributes = {}) {
219
+ this.children = [];
220
+ this.level = level;
221
+ this.attributes = attributes;
222
+ }
223
+ get render() {
224
+ return `<h${this.level} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</h${this.level}>`;
225
+ }
226
+ add(child) {
227
+ this.children.push(child);
228
+ return this;
245
229
  }
230
+ }
246
231
 
247
- class Link {
248
- constructor(href, attributes = {}) {
249
- this.children = [];
250
- this.attributes = attributes;
251
- this.href = href;
252
- }
253
- get render() {
254
- return `<a href='${this.href}' ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</a>`;
255
- }
256
- add(child) {
257
- this.children.push(child);
258
- return this;
259
- }
232
+ class Image {
233
+ constructor(src, alt, attributes = {}) {
234
+ this.children = [];
235
+ this.attributes = attributes;
236
+ this.src = src;
237
+ this.alt = alt;
238
+ }
239
+ get render() {
240
+ return `<img src='${this.src}' alt='${this.alt}' ${htmlAttributes(this.attributes)}/>`;
260
241
  }
242
+ }
261
243
 
262
- class ListItem {
263
- constructor(attributes = {}) {
264
- this.children = [];
265
- this.attributes = attributes;
266
- }
267
- add(child) {
268
- this.children.push(child);
269
- return this;
270
- }
271
- get render() {
272
- return `<li ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</li>`;
273
- }
244
+ class Link {
245
+ constructor(href, attributes = {}) {
246
+ this.children = [];
247
+ this.attributes = attributes;
248
+ this.href = href;
249
+ }
250
+ get render() {
251
+ return `<a href='${this.href}' ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</a>`;
274
252
  }
253
+ add(child) {
254
+ this.children.push(child);
255
+ return this;
256
+ }
257
+ }
275
258
 
276
- class List {
277
- constructor(attributes = {}) {
278
- this.children = [];
279
- this.attributes = attributes;
280
- }
281
- add(child) {
282
- this.children.push(child);
283
- return this;
284
- }
285
- get render() {
286
- return `<ul ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</ul>`;
287
- }
259
+ class ListItem {
260
+ constructor(attributes = {}) {
261
+ this.children = [];
262
+ this.attributes = attributes;
288
263
  }
264
+ add(child) {
265
+ this.children.push(child);
266
+ return this;
267
+ }
268
+ get render() {
269
+ return `<li ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</li>`;
270
+ }
271
+ }
289
272
 
290
- class OrderedList {
291
- constructor(attributes = {}) {
292
- this.children = [];
293
- this.attributes = attributes;
294
- }
295
- add(child) {
296
- this.children.push(child);
297
- return this;
298
- }
299
- get render() {
300
- return `<ol ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</ol>`;
301
- }
273
+ class List {
274
+ constructor(attributes = {}) {
275
+ this.children = [];
276
+ this.attributes = attributes;
277
+ }
278
+ add(child) {
279
+ this.children.push(child);
280
+ return this;
302
281
  }
282
+ get render() {
283
+ return `<ul ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</ul>`;
284
+ }
285
+ }
303
286
 
304
- class Paragraph {
305
- constructor(attributes = {}) {
306
- this.children = [];
307
- this.attributes = attributes;
308
- }
309
- get render() {
310
- return `<p ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</p>`;
311
- }
312
- add(child) {
313
- this.children.push(child);
314
- return this;
315
- }
287
+ class OrderedList {
288
+ constructor(attributes = {}) {
289
+ this.children = [];
290
+ this.attributes = attributes;
291
+ }
292
+ add(child) {
293
+ this.children.push(child);
294
+ return this;
295
+ }
296
+ get render() {
297
+ return `<ol ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</ol>`;
316
298
  }
299
+ }
317
300
 
318
- class Quote {
319
- constructor(attributes = {}) {
320
- this.children = [];
321
- this.attributes = attributes;
322
- }
323
- get render() {
324
- return `<q ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</q>`;
325
- }
326
- add(child) {
327
- this.children.push(child);
328
- return this;
329
- }
301
+ class Paragraph {
302
+ constructor(attributes = {}) {
303
+ this.children = [];
304
+ this.attributes = attributes;
305
+ }
306
+ get render() {
307
+ return `<p ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</p>`;
330
308
  }
309
+ add(child) {
310
+ this.children.push(child);
311
+ return this;
312
+ }
313
+ }
331
314
 
332
- class RadioButton {
333
- constructor(state, attribute, attributes = {}) {
334
- this.state = state;
335
- this.attributes = attributes;
336
- this.attribute = attribute;
337
- this.attributes["data-attribute"] = attribute;
338
- }
339
- get render() {
340
- return `<input type='radio' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
341
- }
342
- add_action(event, klass, fn, options = {}) {
343
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
344
- return this;
345
- }
315
+ class Quote {
316
+ constructor(attributes = {}) {
317
+ this.children = [];
318
+ this.attributes = attributes;
346
319
  }
320
+ get render() {
321
+ return `<q ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</q>`;
322
+ }
323
+ add(child) {
324
+ this.children.push(child);
325
+ return this;
326
+ }
327
+ }
347
328
 
348
- class Select {
349
- constructor(options = [], state, attribute, attributes = {}) {
350
- this.children = [];
351
- this.options = options;
352
- this.state = state;
353
- this.attribute = attribute;
354
- this.attributes = attributes;
355
- }
356
- get render() {
357
- 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.render).join("")}</select>`;
358
- }
329
+ class RadioButton {
330
+ constructor(state, attribute, attributes = {}) {
331
+ this.state = state;
332
+ this.attributes = attributes;
333
+ this.attribute = attribute;
334
+ this.attributes["data-attribute"] = attribute;
359
335
  }
336
+ get render() {
337
+ return `<input type='radio' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
338
+ }
339
+ add_action(event, klass, fn, options = {}) {
340
+ this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
341
+ return this;
342
+ }
343
+ }
360
344
 
361
- class Span {
362
- constructor(attributes = {}) {
363
- this.children = [];
364
- this.attributes = attributes;
365
- }
366
- get render() {
367
- return `<span ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</span>`;
368
- }
369
- add(child) {
370
- this.children.push(child);
371
- return this;
372
- }
345
+ class Select {
346
+ constructor(options = [], state, attribute, attributes = {}) {
347
+ this.children = [];
348
+ this.options = options;
349
+ this.state = state;
350
+ this.attribute = attribute;
351
+ this.attributes = attributes;
352
+ }
353
+ get render() {
354
+ 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.render).join("")}</select>`;
373
355
  }
356
+ }
374
357
 
375
- class Component {
376
- constructor(state = {}, id = Math.random().toString(36).substring(2, 10), errors = []) {
377
- this._state = state;
378
- this.id = id;
379
- this._errors = errors;
380
- this._root = new Box({ data: { component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } });
381
- }
382
- get render() {
383
- return this._root.render;
384
- }
358
+ class Span {
359
+ constructor(attributes = {}) {
360
+ this.children = [];
361
+ this.attributes = attributes;
385
362
  }
363
+ get render() {
364
+ return `<span ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</span>`;
365
+ }
366
+ add(child) {
367
+ this.children.push(child);
368
+ return this;
369
+ }
370
+ }
386
371
 
387
- class TextField {
388
- constructor(state, attribute, attributes = {}) {
389
- this.state = state;
390
- this.attributes = attributes;
391
- this.attribute = attribute;
392
- this.attributes["data-attribute"] = attribute;
393
- }
394
- get render() {
395
- return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
396
- }
397
- add_action(event, klass, fn, options = {}) {
398
- this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
399
- return this;
400
- }
372
+ class Component {
373
+ constructor(state = {}, id = Math.random().toString(36).substring(2, 10), errors = []) {
374
+ this._state = state;
375
+ this.id = id;
376
+ this._errors = errors;
377
+ this._root = new Box({ data: { component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } });
378
+ }
379
+ get render() {
380
+ return this._root.render;
401
381
  }
382
+ }
402
383
 
403
- class Text {
404
- constructor(value) {
405
- this.value = value;
406
- }
407
- get render() {
408
- return this.value;
409
- }
384
+ class TextField {
385
+ constructor(state, attribute, attributes = {}) {
386
+ this.state = state;
387
+ this.attributes = attributes;
388
+ this.attribute = attribute;
389
+ this.attributes["data-attribute"] = attribute;
410
390
  }
391
+ get render() {
392
+ return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
393
+ }
394
+ add_action(event, klass, fn, options = {}) {
395
+ this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
396
+ return this;
397
+ }
398
+ }
411
399
 
412
- exports.BlockQuote = BlockQuote;
413
- exports.Box = Box;
414
- exports.Button = Button;
415
- exports.Checkbox = Checkbox;
416
- exports.Code = Code;
417
- exports.Component = Component;
418
- exports.DateTimeField = DateTimeField;
419
- exports.Element = Element;
420
- exports.Embed = Embed;
421
- exports.Emphasis = Emphasis;
422
- exports.Form = Form;
423
- exports.Heading = Heading;
424
- exports.Image = Image;
425
- exports.Link = Link;
426
- exports.List = List;
427
- exports.ListItem = ListItem;
428
- exports.OrderedList = OrderedList;
429
- exports.Paragraph = Paragraph;
430
- exports.Quote = Quote;
431
- exports.RadioButton = RadioButton;
432
- exports.Select = Select;
433
- exports.Span = Span;
434
- exports.Text = Text;
435
- exports.TextField = TextField;
400
+ class Text {
401
+ constructor(value) {
402
+ this.value = value;
403
+ }
404
+ get render() {
405
+ return this.value;
406
+ }
407
+ }
436
408
 
437
- return exports;
409
+ const Clapton = {
410
+ Box, Component, Text, TextField, Button, DateTimeField, BlockQuote, Checkbox, Code, Element, Emphasis, Form, Heading, Image, Link, List, ListItem, OrderedList, Paragraph, Quote, RadioButton, Select, Span, Embed
411
+ };
438
412
 
439
- })({});
413
+ export { Clapton };